pub struct AccountChanges {
pub address: Address,
pub storage_changes: Vec<SlotChanges>,
pub storage_reads: Vec<Uint<256, 4>>,
pub balance_changes: Vec<BalanceChange>,
pub nonce_changes: Vec<NonceChange>,
pub code_changes: Vec<CodeChange>,
}Expand description
This struct is used to track the changes across accounts in a block.
Fields§
§address: AddressThe address of the account whose changes are stored.
storage_changes: Vec<SlotChanges>List of slot changes for this account.
storage_reads: Vec<Uint<256, 4>>List of storage reads for this account.
balance_changes: Vec<BalanceChange>List of balance changes for this account.
nonce_changes: Vec<NonceChange>List of nonce changes for this account.
code_changes: Vec<CodeChange>List of code changes for this account.
Implementations§
Source§impl AccountChanges
impl AccountChanges
Sourcepub const fn new(address: Address) -> AccountChanges
pub const fn new(address: Address) -> AccountChanges
Creates a new AccountChanges instance for the given address with empty vectors.
Sourcepub fn with_capacity(address: Address, capacity: usize) -> AccountChanges
pub fn with_capacity(address: Address, capacity: usize) -> AccountChanges
Creates a new AccountChanges instance for the given address with specified capacity.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this account change set contains no changes or reads.
A SlotChanges entry with an empty change list does not count as data, so an entry
that only carries the address (or empty slot entries) is considered empty.
Sourcepub fn storage_changes(&self) -> &[SlotChanges]
pub fn storage_changes(&self) -> &[SlotChanges]
Returns the storage changes for this account.
Sourcepub fn storage_slots(&self) -> impl Iterator<Item = Uint<256, 4>>
pub fn storage_slots(&self) -> impl Iterator<Item = Uint<256, 4>>
Returns an iterator over storage slots present in this account’s changes and reads.
Changed slots are yielded first, followed by read slots.
Sourcepub fn storage_post_states(
&self,
) -> impl Iterator<Item = (Uint<256, 4>, Uint<256, 4>)>
pub fn storage_post_states( &self, ) -> impl Iterator<Item = (Uint<256, 4>, Uint<256, 4>)>
Returns an iterator over the post-state value for each changed storage slot.
The post-state value is taken from the last recorded change for each slot.
Sourcepub fn balance_post_state(&self) -> Option<Uint<256, 4>>
pub fn balance_post_state(&self) -> Option<Uint<256, 4>>
Returns the balance from the last recorded change, or None if unchanged.
Sourcepub fn nonce_post_state(&self) -> Option<u64>
pub fn nonce_post_state(&self) -> Option<u64>
Returns the nonce from the last recorded change, or None if unchanged.
Sourcepub fn code_post_state(&self) -> Option<&Bytes>
pub fn code_post_state(&self) -> Option<&Bytes>
Returns the code from the last recorded change, or None if unchanged.
Sourcepub fn code_hash_post_state(&self) -> Option<FixedBytes<32>>
pub fn code_hash_post_state(&self) -> Option<FixedBytes<32>>
Returns the hash of the code from the last recorded change, or None if unchanged.
KECCAK256_EMPTY is returned when the code was set to empty.
Sourcepub fn code_post_state_with_hash(&self) -> Option<(FixedBytes<32>, &Bytes)>
pub fn code_post_state_with_hash(&self) -> Option<(FixedBytes<32>, &Bytes)>
Returns the code from the last recorded change together with its hash, or None if
unchanged.
Use this over hashing Self::code_post_state separately when both the code and its hash
are needed, for example when storing the deployed bytecode by hash.
Sourcepub fn account_info(&self) -> BalAccountInfo
pub fn account_info(&self) -> BalAccountInfo
Returns the account-level fields this entry changed, see BalAccountInfo.
Sourcepub fn has_storage_changes(&self) -> bool
pub fn has_storage_changes(&self) -> bool
Returns true if this entry writes at least one storage slot.
SlotChanges entries without changes are ignored, mirroring Self::is_empty.
Sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Returns true if this entry records at least one state change.
Entries that only record reads leave the account untouched and do not contribute to the block’s post-state.
Sourcepub fn merge(&mut self, incoming: AccountChanges)
pub fn merge(&mut self, incoming: AccountChanges)
Merges another account change set into this one.
Storage changes for matching slots are grouped together. Storage reads are normalized after
merging so that written slots are represented by storage_changes, while storage_reads
only contains unique read-only slots in first-seen order. This preserves the EIP-7928
invariant that a storage slot appears in either reads or changes, but not both, after
independently valid account change sets are combined.
This preserves relative ordering by appending incoming changes to existing changes. Call
Self::sort after merging if canonical EIP-7928 ordering is required.
§Panics
Panics if the two account change sets have different addresses.
Sourcepub fn storage_reads(&self) -> &[Uint<256, 4>]
pub fn storage_reads(&self) -> &[Uint<256, 4>]
Returns the storage reads for this account.
Sourcepub fn balance_changes(&self) -> &[BalanceChange]
pub fn balance_changes(&self) -> &[BalanceChange]
Returns the balance changes for this account.
Sourcepub fn nonce_changes(&self) -> &[NonceChange]
pub fn nonce_changes(&self) -> &[NonceChange]
Returns the nonce changes for this account.
Sourcepub fn code_changes(&self) -> &[CodeChange]
pub fn code_changes(&self) -> &[CodeChange]
Returns the code changes for this account.
Sourcepub fn sort(&mut self)
pub fn sort(&mut self)
Sorts this account’s changes in-place according to the account-local EIP-7928 ordering rules.
This applies the account-local ordering required by the “Ordering, Uniqueness and Determinism” section of EIP-7928:
storage_changesare sorted lexicographically by storage key- each per-slot
StorageChangelist is sorted by block access index in ascending order storage_readsare sorted lexicographically by storage keybalance_changes,nonce_changes, andcode_changesare sorted by block access index in ascending order
Per-slot storage change ordering is delegated to SlotChanges::sort.
This method only canonicalizes ordering for a single account. It does not enforce the EIP-7928 uniqueness constraints for storage keys or block access indexes.
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Renormalizes this account change set in place.
Empty SlotChanges entries are dropped, duplicate slot entries are folded together
(preserving the relative order of their changes), and storage reads are deduplicated and
pruned against written slots, restoring the EIP-7928 invariant that a slot appears in
either reads or changes but not both.
Sourcepub fn collapse_changes_at(&mut self, at: BlockAccessIndex)
pub fn collapse_changes_at(&mut self, at: BlockAccessIndex)
Collapses each change list to its last entry and assigns that entry to at.
The last entry of each list is treated as the effective value (“last write wins”),
matching Self::storage_post_states. Storage reads carry no block access index and are
left untouched.
Sourcepub fn shift_indices_from(&mut self, from: BlockAccessIndex)
pub fn shift_indices_from(&mut self, from: BlockAccessIndex)
Shifts every recorded block access index at or after from forward by one.
Indices saturate at u64::MAX instead of overflowing.
Sourcepub const fn with_address(self, address: Address) -> AccountChanges
pub const fn with_address(self, address: Address) -> AccountChanges
Set the address.
Sourcepub fn with_storage_read(self, key: Uint<256, 4>) -> AccountChanges
pub fn with_storage_read(self, key: Uint<256, 4>) -> AccountChanges
Add a storage read slot.
Sourcepub fn with_storage_change(self, change: SlotChanges) -> AccountChanges
pub fn with_storage_change(self, change: SlotChanges) -> AccountChanges
Add a storage change (multiple writes to a slot grouped in SlotChanges).
Sourcepub fn with_balance_change(self, change: BalanceChange) -> AccountChanges
pub fn with_balance_change(self, change: BalanceChange) -> AccountChanges
Add a balance change.
Sourcepub fn with_nonce_change(self, change: NonceChange) -> AccountChanges
pub fn with_nonce_change(self, change: NonceChange) -> AccountChanges
Add a nonce change.
Sourcepub fn with_code_change(self, change: CodeChange) -> AccountChanges
pub fn with_code_change(self, change: CodeChange) -> AccountChanges
Add a code change.
Sourcepub fn extend_storage_reads<I>(self, iter: I) -> AccountChangeswhere
I: IntoIterator<Item = Uint<256, 4>>,
pub fn extend_storage_reads<I>(self, iter: I) -> AccountChangeswhere
I: IntoIterator<Item = Uint<256, 4>>,
Add multiple storage reads at once.
Sourcepub fn extend_storage_changes<I>(self, iter: I) -> AccountChangeswhere
I: IntoIterator<Item = SlotChanges>,
pub fn extend_storage_changes<I>(self, iter: I) -> AccountChangeswhere
I: IntoIterator<Item = SlotChanges>,
Add multiple slot changes at once.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for AccountChanges
impl<'arbitrary> Arbitrary<'arbitrary> for AccountChanges
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<AccountChanges, Error>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<AccountChanges, Error>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(
u: Unstructured<'arbitrary>,
) -> Result<AccountChanges, Error>
fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<AccountChanges, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl BorshDeserialize for AccountChanges
impl BorshDeserialize for AccountChanges
fn deserialize_reader<__R>(reader: &mut __R) -> Result<AccountChanges, Error>where
__R: Read,
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for AccountChanges
impl BorshSerialize for AccountChanges
Source§impl Clone for AccountChanges
impl Clone for AccountChanges
Source§fn clone(&self) -> AccountChanges
fn clone(&self) -> AccountChanges
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AccountChanges
impl Debug for AccountChanges
Source§impl Decodable for AccountChanges
impl Decodable for AccountChanges
Source§impl Default for AccountChanges
impl Default for AccountChanges
Source§fn default() -> AccountChanges
fn default() -> AccountChanges
Source§impl<'de> Deserialize<'de> for AccountChanges
impl<'de> Deserialize<'de> for AccountChanges
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AccountChanges, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AccountChanges, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Encodable for AccountChanges
impl Encodable for AccountChanges
impl Eq for AccountChanges
Source§impl From<&AccountChanges> for BalAccountInfo
impl From<&AccountChanges> for BalAccountInfo
Source§fn from(changes: &AccountChanges) -> BalAccountInfo
fn from(changes: &AccountChanges) -> BalAccountInfo
Source§impl FromIterator<AccountChanges> for Bal
impl FromIterator<AccountChanges> for Bal
Source§fn from_iter<I>(iter: I) -> Balwhere
I: IntoIterator<Item = AccountChanges>,
fn from_iter<I>(iter: I) -> Balwhere
I: IntoIterator<Item = AccountChanges>,
Source§impl Hash for AccountChanges
impl Hash for AccountChanges
Source§impl PartialEq for AccountChanges
impl PartialEq for AccountChanges
Source§impl Serialize for AccountChanges
impl Serialize for AccountChanges
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for AccountChanges
Auto Trait Implementations§
impl Freeze for AccountChanges
impl RefUnwindSafe for AccountChanges
impl Send for AccountChanges
impl Sync for AccountChanges
impl Unpin for AccountChanges
impl UnsafeUnpin for AccountChanges
impl UnwindSafe for AccountChanges
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 144 bytes