Skip to main content

WorldDiff

Struct WorldDiff 

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

Pending modifications to the global state that are executed at the end of a block. In other words, side effects.

Implementations§

Source§

impl WorldDiff

Source

pub fn set_record_storage_logs(&mut self, record: bool)

Controls whether the per-access storage log trace (storage_logs / rollback_storage_logs) is accumulated.

Recording is on by default — it is required by consumers that build an in-circuit storage argument from storage_log_queries() (e.g. Boojum witness generation via sort_storage_access_queries). A re-execution verifier with no in-circuit storage argument (e.g. Airbender), which derives the deduplicated storage set from the SLOT_PROTECTIVE_READ flag + storage_writes instead, can pass false to avoid the trace’s memory cost (~270 MiB on large batches).

§Panics

Panics if any storage slot has already been read or written — toggling mid-execution would leave a partial trace or partial dedup state.

Source

pub fn reserve_auxiliary_log_capacity( &mut self, events: usize, pubdata_costs: usize, storage_refunds: usize, )

Reserve capacity for the auxiliary log Vecs (events, pubdata_costs, storage_refunds). Each of these doubles during execution and the transient peak is non-trivial inside the verifier guest.

Source

pub fn storage_refunds(&self) -> &[u32]

Returns recorded refunds for all storage operations.

Source

pub fn pubdata_costs(&self) -> &[i32]

Returns recorded pubdata costs for all storage operations.

Source

pub fn protective_reads_iter(&self) -> impl Iterator<Item = (H160, U256)> + '_

Iterates over slots that need a protective read — read at rollback-depth zero (the dedup’s did_read_at_depth_zero set). Combined with storage_writes this is the set of slots that appear in the deduplicated storage logs. Sorted by (address, key) via the slot_flags map’s BTreeMap backing.

Source

pub fn initial_storage_value( &self, contract: H160, key: U256, ) -> Option<StorageSlot>

Returns the initial (pre-batch) value of a slot if it has been touched by a read or write during execution. Used by per-slot summary derivation in place of walking the storage_logs trace.

The set of slots returning Some depends on the recording mode (see Self::set_record_storage_logs): with the trace disabled, read-only slots are cached and reported here; in the default mode only written slots are.

Source

pub fn storage_log_queries(&self) -> &[LogQuery]

Returns all recorded storage log queries.

These logs are sufficient for vm2 state-transition checks and diagnostics.

Source

pub fn storage_log_queries_after(&self, snapshot: &Snapshot) -> &[LogQuery]

Returns storage log queries recorded after the specified snapshot was created.

Source

pub fn get_storage_changes( &self, ) -> impl Iterator<Item = ((H160, U256), StorageChange)> + '_

Gets changes for all touched storage slots.

Source

pub fn get_storage_changes_after( &self, snapshot: &Snapshot, ) -> impl Iterator<Item = ((H160, U256), StorageChange)> + '_

Gets changes for storage slots touched after the specified snapshot was created.

Source

pub fn events_after(&self, snapshot: &Snapshot) -> &[Event]

Returns events emitted after the specified snapshot was created.

Source

pub fn l2_to_l1_logs_after(&self, snapshot: &Snapshot) -> &[L2ToL1Log]

Returns L2-to-L1 logs emitted after the specified snapshot was created.

Source

pub fn decommitted_hashes(&self) -> impl Iterator<Item = U256> + '_

Returns hashes of contract bytecodes that were observed by decommit bookkeeping in no particular order.

This includes successful decommits and far-call out-of-gas attempts recorded as [DecommitState::Unsuccessful] for legacy used_contract_hashes compatibility.

Source

pub fn snapshot(&self) -> Snapshot

Get a snapshot for selecting which logs & co. to output using Self::events_after() and other methods.

Trait Implementations§

Source§

impl Debug for WorldDiff

Source§

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

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

impl Default for WorldDiff

Source§

fn default() -> WorldDiff

Returns the “default value” for a type. 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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V