Expand description
Bytecode analysis module
Provides bytecode analysis capabilities using evmole and evm-disassembler:
- Function selector extraction
- Opcode disassembly
- Security pattern detection
§Single-Pass Analysis
For best performance when you need multiple types of analysis (security, stats,
disassembly), use analyze_bytecode which performs a single disassembly pass
and reuses the result. For individual operations, use the standalone functions.
§Example
ⓘ
use ethcli::bytecode::{analyze_bytecode, detect_security_issues};
// Full analysis (single-pass internally)
let analysis = analyze_bytecode("0x1234...", &bytecode, true, true, None);
// Or individual operations
let security = detect_security_issues(&bytecode);Modules§
- proxy_
slots - Well-known storage slots for proxy implementations
Structs§
- Bytecode
Analysis - Combined bytecode analysis results
- Disassembled
Op - A disassembled opcode
- Extracted
Function - A function extracted from bytecode
- Opcode
Stats - Opcode frequency statistics
- Proxy
Info - Result of proxy detection
- Security
Analysis - Security analysis results
- Security
Issue - A detected security issue in bytecode
Enums§
- Analysis
Error - Error type for bytecode analysis
- Disassembly
Error - Errors that can occur during disassembly
- Proxy
Type - Detected proxy type
- Risk
Level - Security risk level
- Security
Pattern - Security patterns to detect
- State
Mutability - State mutability of a function
Constants§
- MAX_
BYTECODE_ SIZE - Maximum bytecode size to analyze (256KB - well above EIP-170 24KB limit)
Functions§
- address_
from_ storage - Extract implementation address from storage slot value
- analyze_
bytecode - Perform a full bytecode analysis
- detect_
eip1167 - Detect if bytecode is an EIP-1167 minimal proxy
- detect_
proxy - Detect proxy patterns from bytecode alone
- detect_
security_ issues - Detect security issues in bytecode
- detect_
security_ issues_ from_ operations - Detect security issues from pre-disassembled operations
- disassemble_
bytecode - Disassemble bytecode into individual opcodes
- disassemble_
raw - Disassemble bytecode and return raw operations for further processing
- extract_
selectors - Extract function selectors from bytecode
- opcode_
stats - Calculate opcode frequency statistics
- opcode_
stats_ from_ operations - Calculate opcode frequency statistics from raw operations
- u256_
to_ b256 - Convert U256 to B256 for storage value