Skip to main content

Module bytecode

Module bytecode 

Source
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§

BytecodeAnalysis
Combined bytecode analysis results
DisassembledOp
A disassembled opcode
ExtractedFunction
A function extracted from bytecode
OpcodeStats
Opcode frequency statistics
ProxyInfo
Result of proxy detection
SecurityAnalysis
Security analysis results
SecurityIssue
A detected security issue in bytecode

Enums§

AnalysisError
Error type for bytecode analysis
DisassemblyError
Errors that can occur during disassembly
ProxyType
Detected proxy type
RiskLevel
Security risk level
SecurityPattern
Security patterns to detect
StateMutability
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