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
impl WorldDiff
Sourcepub fn set_record_storage_logs(&mut self, record: bool)
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.
Sourcepub fn reserve_auxiliary_log_capacity(
&mut self,
events: usize,
pubdata_costs: usize,
storage_refunds: usize,
)
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.
Sourcepub fn storage_refunds(&self) -> &[u32]
pub fn storage_refunds(&self) -> &[u32]
Returns recorded refunds for all storage operations.
Sourcepub fn pubdata_costs(&self) -> &[i32]
pub fn pubdata_costs(&self) -> &[i32]
Returns recorded pubdata costs for all storage operations.
Sourcepub fn protective_reads_iter(&self) -> impl Iterator<Item = (H160, U256)> + '_
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.
Sourcepub fn initial_storage_value(
&self,
contract: H160,
key: U256,
) -> Option<StorageSlot>
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.
Sourcepub fn storage_log_queries(&self) -> &[LogQuery]
pub fn storage_log_queries(&self) -> &[LogQuery]
Returns all recorded storage log queries.
These logs are sufficient for vm2 state-transition checks and diagnostics.
Sourcepub fn storage_log_queries_after(&self, snapshot: &Snapshot) -> &[LogQuery]
pub fn storage_log_queries_after(&self, snapshot: &Snapshot) -> &[LogQuery]
Returns storage log queries recorded after the specified snapshot was created.
Sourcepub fn get_storage_changes(
&self,
) -> impl Iterator<Item = ((H160, U256), StorageChange)> + '_
pub fn get_storage_changes( &self, ) -> impl Iterator<Item = ((H160, U256), StorageChange)> + '_
Gets changes for all touched storage slots.
Sourcepub fn get_storage_changes_after(
&self,
snapshot: &Snapshot,
) -> impl Iterator<Item = ((H160, U256), StorageChange)> + '_
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.
Sourcepub fn events_after(&self, snapshot: &Snapshot) -> &[Event]
pub fn events_after(&self, snapshot: &Snapshot) -> &[Event]
Returns events emitted after the specified snapshot was created.
Sourcepub fn l2_to_l1_logs_after(&self, snapshot: &Snapshot) -> &[L2ToL1Log]
pub fn l2_to_l1_logs_after(&self, snapshot: &Snapshot) -> &[L2ToL1Log]
Returns L2-to-L1 logs emitted after the specified snapshot was created.
Sourcepub fn decommitted_hashes(&self) -> impl Iterator<Item = U256> + '_
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.
Sourcepub fn snapshot(&self) -> Snapshot
pub fn snapshot(&self) -> Snapshot
Get a snapshot for selecting which logs & co. to output using Self::events_after() and other methods.