pub struct GeneralizedDatabase {
pub store: Arc<dyn Database>,
pub current_accounts_state: CacheDB,
pub initial_accounts_state: CacheDB,
pub shared_base: Option<Arc<CacheDB>>,
pub codes: FxHashMap<H256, Code>,
pub code_metadata: FxHashMap<H256, CodeMetadata>,
pub tx_backup: Option<CallFrameBackup>,
pub bal_recorder: Option<BlockAccessListRecorder>,
pub accessed_accounts: Option<FxHashSet<Address>>,
pub lazy_bal: Option<LazyBalCursor>,
/* private fields */
}Fields§
§store: Arc<dyn Database>§current_accounts_state: CacheDB§initial_accounts_state: CacheDBShared read-only base state (pre-block snapshot of system-touched addresses for
parallel groups, captured from initial_accounts_state after prepare_block).
Checked on load_account AFTER the lazy_bal hook so the BAL overlay (which
includes system-call effects at idx 0) takes precedence for any address the BAL
covers. Accounts are cloned into initial_accounts_state on first access.
codes: FxHashMap<H256, Code>§code_metadata: FxHashMap<H256, CodeMetadata>§tx_backup: Option<CallFrameBackup>§bal_recorder: Option<BlockAccessListRecorder>Optional BAL recorder for EIP-7928 Block Access List recording.
accessed_accounts: Option<FxHashSet<Address>>Optional tracker for BAL validation: records addresses accessed via load_account. Enabled only during parallel execution to detect extraneous BAL pure-access entries.
lazy_bal: Option<LazyBalCursor>Optional BAL cursor for lazy per-read prefix materialization. When set, account loads and storage reads consult the BAL before hitting the store.
Implementations§
Source§impl GeneralizedDatabase
impl GeneralizedDatabase
pub fn new(store: Arc<dyn Database>) -> Self
Creates a new GeneralizedDatabase with a shared read-only base state. Used for parallel execution groups that share post-system-call state. Skips initial_accounts_state tracking since parallel per-tx DBs never call get_state_transitions_tx (state comes from BAL instead).
Like new_with_shared_base but pre-allocates account/code maps to
capacity entries, avoiding rehashing during BAL seeding.
Sourcepub fn enable_bal_recording(&mut self)
pub fn enable_bal_recording(&mut self)
Enables BAL recording for EIP-7928. After enabling, state changes will be recorded during execution.
Sourcepub fn disable_bal_recording(&mut self)
pub fn disable_bal_recording(&mut self)
Disables BAL recording.
Sourcepub fn set_bal_index(&mut self, index: u32)
pub fn set_bal_index(&mut self, index: u32)
Sets the current block access index for BAL recording per EIP-7928 spec (uint32). Call this before each transaction or phase.
Sourcepub fn take_bal(&mut self) -> Option<BlockAccessList>
pub fn take_bal(&mut self) -> Option<BlockAccessList>
Takes the BAL recorder and builds the final BlockAccessList. Returns None if recording was not enabled.
Sourcepub fn bal_recorder_mut(&mut self) -> Option<&mut BlockAccessListRecorder>
pub fn bal_recorder_mut(&mut self) -> Option<&mut BlockAccessListRecorder>
Returns a mutable reference to the BAL recorder if enabled.
Sourcepub fn new_with_account_state(
store: Arc<dyn Database>,
current_accounts_state: FxHashMap<Address, Account>,
) -> Self
pub fn new_with_account_state( store: Arc<dyn Database>, current_accounts_state: FxHashMap<Address, Account>, ) -> Self
Only used within Levm Runner, where the accounts already have all the storage pre-loaded, not used in real case scenarios.
Sourcepub fn get_account(
&mut self,
address: Address,
) -> Result<&LevmAccount, InternalError>
pub fn get_account( &mut self, address: Address, ) -> Result<&LevmAccount, InternalError>
Gets reference of an account
Sourcepub fn get_account_mut(
&mut self,
address: Address,
) -> Result<&mut LevmAccount, InternalError>
pub fn get_account_mut( &mut self, address: Address, ) -> Result<&mut LevmAccount, InternalError>
Gets mutable reference of an account
Warning: Use directly only if outside of the EVM, otherwise use vm.get_account_mut because it contemplates call frame backups.
Sourcepub fn get_code(&mut self, code_hash: H256) -> Result<&Code, InternalError>
pub fn get_code(&mut self, code_hash: H256) -> Result<&Code, InternalError>
Gets code immutably given the code hash.
Use this only inside of the VM, when we don’t surely know if the code is in the cache or not
But e.g. in get_state_transitions just do db.codes.get(code_hash) because we know for sure code is there.
Sourcepub fn get_account_code(
&mut self,
address: Address,
) -> Result<&Code, InternalError>
pub fn get_account_code( &mut self, address: Address, ) -> Result<&Code, InternalError>
Shortcut for getting the code when we only have the address of an account and we don’t need anything else.
Sourcepub fn get_code_metadata(
&mut self,
code_hash: H256,
) -> Result<&CodeMetadata, InternalError>
pub fn get_code_metadata( &mut self, code_hash: H256, ) -> Result<&CodeMetadata, InternalError>
Gets code metadata immutably given the code hash.
Sourcepub fn get_code_length(
&mut self,
address: Address,
) -> Result<usize, InternalError>
pub fn get_code_length( &mut self, address: Address, ) -> Result<usize, InternalError>
Convenience method to get code length by address (optimized for EXTCODESIZE).
Sourcepub fn get_tx_backup(&self) -> Result<CallFrameBackup, InternalError>
pub fn get_tx_backup(&self) -> Result<CallFrameBackup, InternalError>
Gets the transaction backup, if it exists.
It only works if the BackupHook was enabled during the transaction execution.
Sourcepub fn undo_last_transaction(&mut self) -> Result<(), VMError>
pub fn undo_last_transaction(&mut self) -> Result<(), VMError>
Undoes the last transaction by restoring the cache state to the state before the transaction.
pub fn get_state_transitions(&mut self) -> Result<Vec<AccountUpdate>, VMError>
pub fn get_state_transitions_tx( &mut self, ) -> Result<Vec<AccountUpdate>, VMError>
Trait Implementations§
Source§impl Clone for GeneralizedDatabase
impl Clone for GeneralizedDatabase
Source§fn clone(&self) -> GeneralizedDatabase
fn clone(&self) -> GeneralizedDatabase
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for GeneralizedDatabase
impl !UnwindSafe for GeneralizedDatabase
impl Freeze for GeneralizedDatabase
impl Send for GeneralizedDatabase
impl Sync for GeneralizedDatabase
impl Unpin for GeneralizedDatabase
impl UnsafeUnpin for GeneralizedDatabase
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,
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.