Skip to main content

AccountChanges

Struct AccountChanges 

Source
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: Address

The 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

Source

pub const fn new(address: Address) -> AccountChanges

Creates a new AccountChanges instance for the given address with empty vectors.

Source

pub fn with_capacity(address: Address, capacity: usize) -> AccountChanges

Creates a new AccountChanges instance for the given address with specified capacity.

Source

pub const fn address(&self) -> Address

Returns the address of the account.

Source

pub fn storage_changes(&self) -> &[SlotChanges]

Returns the storage changes for this account.

Source

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.

Source

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.

Source

pub fn storage_reads(&self) -> &[Uint<256, 4>]

Returns the storage reads for this account.

Source

pub fn balance_changes(&self) -> &[BalanceChange]

Returns the balance changes for this account.

Source

pub fn nonce_changes(&self) -> &[NonceChange]

Returns the nonce changes for this account.

Source

pub fn code_changes(&self) -> &[CodeChange]

Returns the code changes for this account.

Source

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_changes are sorted lexicographically by storage key
  • each per-slot StorageChange list is sorted by block access index in ascending order
  • storage_reads are sorted lexicographically by storage key
  • balance_changes, nonce_changes, and code_changes are 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.

Source

pub const fn with_address(self, address: Address) -> AccountChanges

Set the address.

Source

pub fn with_storage_read(self, key: Uint<256, 4>) -> AccountChanges

Add a storage read slot.

Source

pub fn with_storage_change(self, change: SlotChanges) -> AccountChanges

Add a storage change (multiple writes to a slot grouped in SlotChanges).

Source

pub fn with_balance_change(self, change: BalanceChange) -> AccountChanges

Add a balance change.

Source

pub fn with_nonce_change(self, change: NonceChange) -> AccountChanges

Add a nonce change.

Source

pub fn with_code_change(self, change: CodeChange) -> AccountChanges

Add a code change.

Source

pub fn extend_storage_reads<I>(self, iter: I) -> AccountChanges
where I: IntoIterator<Item = Uint<256, 4>>,

Add multiple storage reads at once.

Source

pub fn extend_storage_changes<I>(self, iter: I) -> AccountChanges
where I: IntoIterator<Item = SlotChanges>,

Add multiple slot changes at once.

Trait Implementations§

Source§

impl<'arbitrary> Arbitrary<'arbitrary> for AccountChanges

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<AccountChanges, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<AccountChanges, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for AccountChanges

Source§

fn clone(&self) -> AccountChanges

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 AccountChanges

Source§

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

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

impl Decodable for AccountChanges

Source§

fn decode(b: &mut &[u8]) -> Result<AccountChanges, Error>

Decodes the blob into the appropriate type. buf must be advanced past the decoded object.
Source§

impl Default for AccountChanges

Source§

fn default() -> AccountChanges

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

impl<'de> Deserialize<'de> for AccountChanges

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<AccountChanges, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Encodable for AccountChanges

Source§

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes. Read more
Source§

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.
Source§

impl Eq for AccountChanges

Source§

impl FromIterator<AccountChanges> for Bal

Source§

fn from_iter<I>(iter: I) -> Bal
where I: IntoIterator<Item = AccountChanges>,

Creates a value from an iterator. Read more
Source§

impl Hash for AccountChanges

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for AccountChanges

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AccountChanges

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AccountChanges

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = 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.
Source§

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

Source§

fn vzip(self) -> V

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