Skip to main content

StepTable

Struct StepTable 

Source
pub struct StepTable { /* private fields */ }
Expand description

The steps of a trace, in columns. See the module docs.

Implementations§

Source§

impl StepTable

Source

pub fn new() -> Self

Source

pub fn with_capacity(steps: usize) -> Self

An empty table that holds steps steps without allocating its columns again.

Source

pub fn try_from_steps( steps: impl IntoIterator<Item = TraceStep>, ) -> Result<Self, StepError>

A table of steps, in order.

§Errors

As StepTable::try_push.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, index: usize) -> Option<StepView<'_>>

Source

pub fn step(&self, index: usize) -> StepView<'_>

The step at index.

§Panics

When index is not below StepTable::len, as indexing a slice does.

Source

pub fn first(&self) -> Option<StepView<'_>>

Source

pub fn last(&self) -> Option<StepView<'_>>

Source

pub fn iter(&self) -> Steps<'_> ⓘ

Source

pub fn push(&mut self, step: TraceStep)

Appends a step built the way every backend builds one, sharing what did not change since the step before: its stack words, memory, storage and return data.

§Panics

When a stack word is not hex. A producer reading words from untrusted input, a node or a file, appends with StepTable::try_push instead.

Source

pub fn try_push(&mut self, step: TraceStep) -> Result<(), StepError>

StepTable::push for a step whose stack words may not be hex.

§Errors

Returns a StepError when a stack word is not hex. Nothing is appended then.

Source

pub fn append( &mut self, record: StepRecord, stack: impl IntoIterator<Item = EvmWord>, )

Appends a step whose whole stack is stack, bottom first. The words the previous step’s stack starts with are kept rather than stored again.

Source

pub fn append_kept( &mut self, record: StepRecord, kept: usize, words: impl IntoIterator<Item = EvmWord>, )

Appends a step whose stack is the bottom kept words of the previous step’s with words on top, for a producer that knows how much of the stack an instruction left alone and so never copies the rest.

§Panics

When kept is more than the previous step’s stack holds.

Source

pub fn start_memory_frame(&mut self)

Starts recording the memory of a new frame, empty, as a call or a creation starts one: the steps appended from now on have it, as written with StepTable::write_memory.

Source

pub fn end_memory_frame(&mut self)

Stops recording the innermost frame’s memory, as its call returns; the steps appended from now on have its caller’s again.

Source

pub fn write_memory( &mut self, offset: u64, data: &[u8], size: u64, ) -> Result<(), MemoryWriteError>

Records that the step appended last wrote data at offset of its frame’s memory, which is size bytes long afterwards; a write without data records memory growing. The steps appended after it see the write: a step’s memory is the memory it starts with.

§Errors

Returns a MemoryWriteError when the write ends past size or size is smaller than the memory was. Nothing is recorded then.

Source

pub fn storage_diffs( &self, ) -> impl DoubleEndedIterator<Item = (usize, &BTreeMap<String, StorageChange>)>

The steps that changed storage, with the slots they changed, in order.

Source

pub fn transient_storage( &self, ) -> impl DoubleEndedIterator<Item = (usize, &BTreeMap<String, String>)>

The steps that read or wrote transient storage, with the slots, in order.

Source

pub fn truncate(&mut self, len: usize)

Drops the steps from len on. What was recorded of their memory stays, unused.

Source

pub fn to_steps(&self) -> Vec<TraceStep>

Every step as a TraceStep of its own.

Trait Implementations§

Source§

impl Clone for StepTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StepTable

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StepTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for StepTable

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Reads steps as written by any version, appending each as it is read so that a file’s steps are never all resident as TraceSteps.

Source§

impl Eq for StepTable

Source§

impl Extend<TraceStep> for StepTable

Source§

fn extend<I: IntoIterator<Item = TraceStep>>(&mut self, steps: I)

§Panics

As StepTable::push.

Source§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<Vec<TraceStep>> for StepTable

Source§

fn from(steps: Vec<TraceStep>) -> Self

§Panics

As StepTable::push.

Source§

impl FromIterator<TraceStep> for StepTable

Source§

fn from_iter<I: IntoIterator<Item = TraceStep>>(steps: I) -> Self

§Panics

As StepTable::push.

Source§

impl<'a> IntoIterator for &'a StepTable

Source§

type Item = StepView<'a>

The type of the elements being iterated over.
Source§

type IntoIter = Steps<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for StepTable

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for StepTable

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.