pub struct JournaledAccount<'a, DB, ENTRY: JournalEntryTr = JournalEntry> { /* private fields */ }Expand description
Journaled account contains both mutable account and journal entries.
Useful to encapsulate account and journal entries together. So when account gets changed, we can add a journal entry for it.
Implementations§
Source§impl<'a, DB: Database, ENTRY: JournalEntryTr> JournaledAccount<'a, DB, ENTRY>
impl<'a, DB: Database, ENTRY: JournalEntryTr> JournaledAccount<'a, DB, ENTRY>
Sourcepub fn new(
address: Address,
account: &'a mut Account,
journal_entries: &'a mut Vec<ENTRY>,
db: &'a mut DB,
access_list: &'a HashMap<Address, HashSet<StorageKey>>,
transaction_id: usize,
) -> Self
pub fn new( address: Address, account: &'a mut Account, journal_entries: &'a mut Vec<ENTRY>, db: &'a mut DB, access_list: &'a HashMap<Address, HashSet<StorageKey>>, transaction_id: usize, ) -> Self
Creates new JournaledAccount
Sourcepub fn sload_concrete_error(
&mut self,
key: StorageKey,
skip_cold_load: bool,
) -> Result<StateLoad<&mut EvmStorageSlot>, JournalLoadError<DB::Error>>
pub fn sload_concrete_error( &mut self, key: StorageKey, skip_cold_load: bool, ) -> Result<StateLoad<&mut EvmStorageSlot>, JournalLoadError<DB::Error>>
Loads the storage slot.
If storage is cold and skip_cold_load is true, it will return JournalLoadError::ColdLoadSkipped error.
Does not erase the db error.
Sourcepub fn sstore_concrete_error(
&mut self,
key: StorageKey,
new: StorageValue,
skip_cold_load: bool,
) -> Result<StateLoad<SStoreResult>, JournalLoadError<DB::Error>>
pub fn sstore_concrete_error( &mut self, key: StorageKey, new: StorageValue, skip_cold_load: bool, ) -> Result<StateLoad<SStoreResult>, JournalLoadError<DB::Error>>
Stores the storage slot.
If storage is cold and skip_cold_load is true, it will return JournalLoadError::ColdLoadSkipped error.
Does not erase the db error.
Sourcepub fn load_code_preserve_error(
&mut self,
) -> Result<&Bytecode, JournalLoadError<DB::Error>>
pub fn load_code_preserve_error( &mut self, ) -> Result<&Bytecode, JournalLoadError<DB::Error>>
Loads the code of the account. and returns it as reference.
Does not erase the db error.
Sourcepub fn into_account(self) -> &'a Account
pub fn into_account(self) -> &'a Account
Consumes the journaled account and returns the account.
Trait Implementations§
Source§impl<'a, DB: Debug, ENTRY: Debug + JournalEntryTr> Debug for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB: Debug, ENTRY: Debug + JournalEntryTr> Debug for JournaledAccount<'a, DB, ENTRY>
Source§impl<'a, DB: Database, ENTRY: JournalEntryTr> JournaledAccountTr for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB: Database, ENTRY: JournalEntryTr> JournaledAccountTr for JournaledAccount<'a, DB, ENTRY>
Source§fn unsafe_mark_cold(&mut self)
fn unsafe_mark_cold(&mut self)
Marks the account as cold without making a journal entry.
Changing account without journal entry can be a footgun as reverting of the state change
would not happen without entry. It is the reason why this function has an unsafe prefix.
If account is in access list, it would still be marked as warm if account get accessed again.
Source§fn set_balance(&mut self, balance: U256)
fn set_balance(&mut self, balance: U256)
Sets the balance of the account.
If balance is the same, we don’t add a journal entry.
Touches the account in all cases.
Source§fn incr_balance(&mut self, balance: U256) -> bool
fn incr_balance(&mut self, balance: U256) -> bool
Increments the balance of the account.
Touches the account in all cases.
Source§fn decr_balance(&mut self, balance: U256) -> bool
fn decr_balance(&mut self, balance: U256) -> bool
Decrements the balance of the account.
Touches the account in all cases.
Source§fn bump_nonce(&mut self) -> bool
fn bump_nonce(&mut self) -> bool
Bumps the nonce of the account.
Touches the account in all cases.
Returns true if nonce was bumped, false if nonce is at the max value.
Source§fn set_nonce(&mut self, nonce: u64)
fn set_nonce(&mut self, nonce: u64)
Set the nonce of the account and create a journal entry.
Touches the account in all cases.
Source§fn unsafe_set_nonce(&mut self, nonce: u64)
fn unsafe_set_nonce(&mut self, nonce: u64)
Set the nonce of the account without creating a journal entry.
Changing account without journal entry can be a footgun as reverting of the state change
would not happen without entry. It is the reason why this function has an unsafe prefix.
Source§fn set_code(&mut self, code_hash: B256, code: Bytecode)
fn set_code(&mut self, code_hash: B256, code: Bytecode)
Sets the code of the account.
Touches the account in all cases.
Source§fn set_code_and_hash_slow(&mut self, code: Bytecode)
fn set_code_and_hash_slow(&mut self, code: Bytecode)
Sets the code of the account. Calculates hash of the code.
Touches the account in all cases.
Source§fn delegate(&mut self, address: Address)
fn delegate(&mut self, address: Address)
Delegates the account to another address (EIP-7702).
This touches the account, sets the code to the delegation designation, and bumps the nonce.
Source§fn sload(
&mut self,
key: StorageKey,
skip_cold_load: bool,
) -> Result<StateLoad<&mut EvmStorageSlot>, JournalLoadErasedError>
fn sload( &mut self, key: StorageKey, skip_cold_load: bool, ) -> Result<StateLoad<&mut EvmStorageSlot>, JournalLoadErasedError>
Loads the storage slot.
Source§fn sstore(
&mut self,
key: StorageKey,
new: StorageValue,
skip_cold_load: bool,
) -> Result<StateLoad<SStoreResult>, JournalLoadErasedError>
fn sstore( &mut self, key: StorageKey, new: StorageValue, skip_cold_load: bool, ) -> Result<StateLoad<SStoreResult>, JournalLoadErasedError>
Stores the storage slot.
Source§fn load_code(&mut self) -> Result<&Bytecode, JournalLoadErasedError>
fn load_code(&mut self) -> Result<&Bytecode, JournalLoadErasedError>
Loads the code of the account. and returns it as reference.
Source§impl<'a, DB: PartialEq, ENTRY: PartialEq + JournalEntryTr> PartialEq for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB: PartialEq, ENTRY: PartialEq + JournalEntryTr> PartialEq for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB: Eq, ENTRY: Eq + JournalEntryTr> Eq for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB, ENTRY: JournalEntryTr> StructuralPartialEq for JournaledAccount<'a, DB, ENTRY>
Auto Trait Implementations§
impl<'a, DB, ENTRY> Freeze for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB, ENTRY> RefUnwindSafe for JournaledAccount<'a, DB, ENTRY>where
DB: RefUnwindSafe,
ENTRY: RefUnwindSafe,
impl<'a, DB, ENTRY> Send for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB, ENTRY> Sync for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB, ENTRY> Unpin for JournaledAccount<'a, DB, ENTRY>
impl<'a, DB, ENTRY = JournalEntry> !UnwindSafe for JournaledAccount<'a, DB, ENTRY>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
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 more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.