pub struct TraceStep {
pub pc: u64,
pub op: Word,
pub gas: u64,
pub gas_cost: u64,
pub depth: u64,
pub stack: Vec<Word>,
pub memory: Option<Bytes>,
pub storage: Option<BTreeMap<String, String>>,
pub error: Option<String>,
pub snapshot: StepSnapshot,
}Expand description
One recorded EVM step, as a backend builds it.
A TransactionTrace holds its steps in a StepTable, which takes them with
StepTable::push and gives each back as a StepView or, when ownership is needed,
with StepView::to_trace_step.
The machine state lives in snapshot, once. The flat stack, memory, and
storage fields are the layout older trace files and web clients read: every
constructor in this workspace leaves them empty, serialization fills them from the
snapshot so the wire format is unchanged, and deserialization moves whatever they
hold into the snapshot. Read a step through TraceStep::snapshot_ref, which
handles both shapes; never through the flat fields.
Consecutive steps share their memory and storage when nothing changed between them
(see StepSnapshot), which is what keeps a trace of hundreds of thousands of steps
resident: memory changes on a handful of opcodes and storage on SSTORE alone.
Fields§
§pc: u64§op: WordThe mnemonic, shared with every other step running the same opcode: there are a couple of hundred of them and hundreds of thousands of steps.
gas: u64§gas_cost: u64The cost as the tracer reports it: for a call, its own cost plus the gas it forwards to the callee; for a creation, the same under REVM but without the forwarded gas under geth.
depth: u64§stack: Vec<Word>Legacy layout; empty unless a caller filled it by hand. See the type docs.
memory: Option<Bytes>Legacy layout; None unless a caller filled it by hand. See the type docs.
storage: Option<BTreeMap<String, String>>Legacy layout; None unless a caller filled it by hand. See the type docs.
error: Option<String>§snapshot: StepSnapshotImplementations§
Source§impl TraceStep
impl TraceStep
Sourcepub fn new(
pc: u64,
op: Word,
gas: u64,
gas_cost: u64,
depth: u64,
error: Option<String>,
snapshot: StepSnapshot,
) -> Self
pub fn new( pc: u64, op: Word, gas: u64, gas_cost: u64, depth: u64, error: Option<String>, snapshot: StepSnapshot, ) -> Self
A step whose state lives in snapshot, the way every backend builds one.
Sourcepub fn snapshot_ref(&self) -> StepSnapshotRef<'_>
pub fn snapshot_ref(&self) -> StepSnapshotRef<'_>
Borrows the machine state this step captured, without copying it.
Whichever shape the step is in, its snapshot or the legacy flat fields, this returns a view of it.
Prefer this over TraceStep::normalized_snapshot anywhere that walks a trace.
Traces routinely run to hundreds of thousands of steps and each one’s memory can
be tens of kilobytes, so copying per step — or, as variable decoding does, per
variable per step — dominates the cost of reading a trace.
Sourcepub fn normalized_snapshot(&self) -> StepSnapshot
pub fn normalized_snapshot(&self) -> StepSnapshot
Copies the machine state this step captured into an owned StepSnapshot.
Use this only when ownership is genuinely required; TraceStep::snapshot_ref is
the same view without the copy.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TraceStep
impl<'de> Deserialize<'de> for TraceStep
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for TraceStep
Source§impl Extend<TraceStep> for StepTable
impl Extend<TraceStep> for StepTable
Source§fn extend<I: IntoIterator<Item = TraceStep>>(&mut self, steps: I)
fn extend<I: IntoIterator<Item = TraceStep>>(&mut self, steps: I)
§Panics
As StepTable::push.
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<TraceStep> for StepTable
impl FromIterator<TraceStep> for StepTable
Source§fn from_iter<I: IntoIterator<Item = TraceStep>>(steps: I) -> Self
fn from_iter<I: IntoIterator<Item = TraceStep>>(steps: I) -> Self
§Panics
As StepTable::push.