pub trait OpcodeTr {
// Required methods
fn modifies_evm_state(&self) -> bool;
fn modifies_transient_storage(&self) -> bool;
fn is_call(&self) -> bool;
}Expand description
Extended trait for EVM opcode analysis
Provides additional methods for determining what types of EVM state an opcode will modify when executed. This is useful for:
- Debugging tools that need to track state changes
- Optimization of state snapshots and memory sharing
- Security analysis of contract execution
Required Methods§
Sourcefn modifies_evm_state(&self) -> bool
fn modifies_evm_state(&self) -> bool
Check if this opcode modifies persistent EVM state
Returns true if the opcode will modify any persistent state including:
- Storage (via SSTORE)
- Account state (via CREATE, CREATE2, SELFDESTRUCT)
- Account balances (via CALL, CALLCODE with value transfer)
- Event logs (via LOG0-LOG4)
Note: This does NOT include temporary state like memory or stack, only state that persists beyond the current transaction execution.
§Example
use revm::bytecode::OpCode;
use edb_common::OpcodeTr;
assert!(OpCode::SSTORE.modifies_evm_state());
assert!(OpCode::CREATE.modifies_evm_state());
assert!(!OpCode::ADD.modifies_evm_state());
assert!(!OpCode::MSTORE.modifies_evm_state()); // Only modifies memorySourcefn modifies_transient_storage(&self) -> bool
fn modifies_transient_storage(&self) -> bool
Check if this opcode modifies transient storage (EIP-1153)
Transient storage is temporary storage that exists only for the duration of a transaction and is cleared when the transaction ends.
Returns true only for:
TSTORE(0x5C): Write to transient storage
Note: TLOAD (0x5D) only reads transient storage and doesn’t modify it.
§Example
use revm::bytecode::OpCode;
use edb_common::OpcodeTr;
assert!(OpCode::TSTORE.modifies_transient_storage());
assert!(!OpCode::TLOAD.modifies_transient_storage());
assert!(!OpCode::SSTORE.modifies_transient_storage());