pub struct LevmAccount {
pub info: AccountInfo,
pub storage: FxHashMap<H256, U256>,
pub has_storage: bool,
pub status: AccountStatus,
pub exists: bool,
}Expand description
Similar to Account struct but suited for LEVM implementation.
Difference is this doesn’t have code and it contains an additional status field for decision-making.
The code is stored in the GeneralizedDatabase and can be accessed with its hash.
Some advantages:
- We’ll fetch the code only if we need to, this means less accesses to the database.
- If there’s duplicate code between accounts (which is pretty common) we’ll store it in memory only once.
- We’ll be able to make better decisions without relying on external structures, based on the current status of an Account. e.g. If it was untouched we skip processing it when calculating Account Updates, or if the account has been destroyed and re-created with same address we know that the storage on the Database is not valid and we shouldn’t access it, etc.
Fields§
§info: AccountInfo§storage: FxHashMap<H256, U256>§has_storage: boolIf true it means that attempting to create an account with this address it would at least collide because of storage. We just care about this kind of collision if the account doesn’t have code or nonce. Otherwise its value doesn’t matter. For more information see EIP-7610: https://eips.ethereum.org/EIPS/eip-7610 Warning: This attribute should only be used for handling create collisions as it’s not necessary appropriate for every scenario. Read the caveat below.
How this works:
- When getting an account from the DB this is set to true if the account has non-empty storage root.
- Upon destruction of an account this is set to false because storage is emptied for sure.
Important Caveat This only works for accounts of these characteristics that have been created in the past, we consider that accounts with storage but no nonce or code cannot be created anymore, otherwise the fix would need to be more complex because we should keep track of the storage root of an account during execution instead of just keeping track of it when fetching it from the Database or updating it when destroying it. The EIP that adds to the spec this check did it because there are 28 accounts with these characteristics already deployed in mainnet (back when they were deployed with nonce 0), but they cannot be created intentionally anymore.
status: AccountStatusCurrent status of the account.
exists: boolWhether this account exists in the state trie.
Used for EIP-7702 auth refund: account_exists (EELS) differs from !is_empty().
An account can exist but be empty (e.g., has non-empty storage root only).
Default is false (non-existent); set to true when loaded from DB with actual state.
Implementations§
Source§impl LevmAccount
impl LevmAccount
pub fn mark_destroyed(&mut self)
pub fn mark_modified(&mut self)
pub fn has_nonce(&self) -> bool
pub fn has_code(&self) -> bool
pub fn create_would_collide(&self) -> bool
pub fn is_empty(&self) -> bool
Sourcepub fn is_unmodified(&self) -> bool
pub fn is_unmodified(&self) -> bool
Checks if the account is unmodified.
Sourcepub fn clone_without_storage(&self) -> Self
pub fn clone_without_storage(&self) -> Self
Clones the account’s metadata (info + flags) but leaves storage empty.
Used on the streaming-executor read-fault path (load_account): when the streaming
merkleizer drains current_accounts_state, a hot account re-faulted on the next tx would
otherwise deep-copy its entire accumulated storage map (hundreds–thousands of slots) just
so the tx can read the ~3 it touches. Cloning info/flags only and faulting those slots in
lazily avoids that copy. Correctness relies on get_storage_value resolving a current
miss against initial_accounts_state (the committed in-block baseline) before the
pre-block store, which keeps the diff invariant “every key in current.storage is also in
initial.storage” intact.
Destructured (not ..) so adding a field to LevmAccount fails to compile here until it
is explicitly carried — a missing flag would silently corrupt the state-transition diff.
Trait Implementations§
Source§impl Clone for LevmAccount
impl Clone for LevmAccount
Source§fn clone(&self) -> LevmAccount
fn clone(&self) -> LevmAccount
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 LevmAccount
impl Debug for LevmAccount
Source§impl Default for LevmAccount
impl Default for LevmAccount
Source§fn default() -> LevmAccount
fn default() -> LevmAccount
Source§impl<'de> Deserialize<'de> for LevmAccount
impl<'de> Deserialize<'de> for LevmAccount
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for LevmAccount
Source§impl From<AccountState> for LevmAccount
impl From<AccountState> for LevmAccount
Source§fn from(state: AccountState) -> Self
fn from(state: AccountState) -> Self
Source§impl From<GenesisAccount> for LevmAccount
impl From<GenesisAccount> for LevmAccount
Source§fn from(genesis: GenesisAccount) -> Self
fn from(genesis: GenesisAccount) -> Self
Source§impl PartialEq for LevmAccount
impl PartialEq for LevmAccount
Source§fn eq(&self, other: &LevmAccount) -> bool
fn eq(&self, other: &LevmAccount) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for LevmAccount
impl Serialize for LevmAccount
impl StructuralPartialEq for LevmAccount
Auto Trait Implementations§
impl Freeze for LevmAccount
impl RefUnwindSafe for LevmAccount
impl Send for LevmAccount
impl Sync for LevmAccount
impl Unpin for LevmAccount
impl UnsafeUnpin for LevmAccount
impl UnwindSafe for LevmAccount
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.