pub struct JournaledAccount<'a, ENTRY: JournalEntryTr> { /* 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, ENTRY: JournalEntryTr> JournaledAccount<'a, ENTRY>
impl<'a, ENTRY: JournalEntryTr> JournaledAccount<'a, ENTRY>
Sourcepub fn into_account_ref(self) -> &'a Account
pub fn into_account_ref(self) -> &'a Account
Consumes the journaled account and returns the mutable account.
Sourcepub fn new(
address: Address,
account: &'a mut Account,
journal_entries: &'a mut Vec<ENTRY>,
) -> Self
pub fn new( address: Address, account: &'a mut Account, journal_entries: &'a mut Vec<ENTRY>, ) -> Self
Creates a new journaled account.
Sourcepub fn unsafe_mark_cold(&mut self)
pub 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.
Sourcepub fn set_balance(&mut self, balance: U256)
pub 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.
Sourcepub fn incr_balance(&mut self, balance: U256) -> bool
pub fn incr_balance(&mut self, balance: U256) -> bool
Increments the balance of the account.
Touches the account in all cases.
Sourcepub fn decr_balance(&mut self, balance: U256) -> bool
pub fn decr_balance(&mut self, balance: U256) -> bool
Decrements the balance of the account.
Touches the account in all cases.
Sourcepub fn bump_nonce(&mut self) -> bool
pub 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.
Sourcepub fn set_nonce(&mut self, nonce: u64)
pub fn set_nonce(&mut self, nonce: u64)
Set the nonce of the account and create a journal entry.
Touches the account in all cases.
Sourcepub fn unsafe_set_nonce(&mut self, nonce: u64)
pub 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.
Sourcepub fn set_code(&mut self, code_hash: B256, code: Bytecode)
pub fn set_code(&mut self, code_hash: B256, code: Bytecode)
Sets the code of the account.
Touches the account in all cases.
Sourcepub fn set_code_and_hash_slow(&mut self, code: Bytecode)
pub 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.
Methods from Deref<Target = Account>§
Sourcepub fn state_clear_aware_is_empty(&self, spec: SpecId) -> bool
pub fn state_clear_aware_is_empty(&self, spec: SpecId) -> bool
Checks if account is empty and check if empty state before spurious dragon hardfork.
Sourcepub fn is_selfdestructed(&self) -> bool
pub fn is_selfdestructed(&self) -> bool
Is account marked for self destruct.
Sourcepub fn is_touched(&self) -> bool
pub fn is_touched(&self) -> bool
If account status is marked as touched.
Sourcepub fn is_cold_transaction_id(&self, transaction_id: usize) -> bool
pub fn is_cold_transaction_id(&self, transaction_id: usize) -> bool
Is account warm for given transaction id.
Sourcepub fn is_created_locally(&self) -> bool
pub fn is_created_locally(&self) -> bool
Is account locally created
Sourcepub fn is_selfdestructed_locally(&self) -> bool
pub fn is_selfdestructed_locally(&self) -> bool
Is account locally selfdestructed
Sourcepub fn is_loaded_as_not_existing(&self) -> bool
pub fn is_loaded_as_not_existing(&self) -> bool
Is account loaded as not existing from database.
This is needed for pre spurious dragon hardforks where existing and empty were two separate states.
Sourcepub fn is_loaded_as_not_existing_not_touched(&self) -> bool
pub fn is_loaded_as_not_existing_not_touched(&self) -> bool
Is account loaded as not existing from database and not touched.
Sourcepub fn is_created(&self) -> bool
pub fn is_created(&self) -> bool
Is account newly created in this transaction.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Is account empty, check if nonce and balance are zero and code is empty.
Sourcepub fn changed_storage_slots(
&self,
) -> impl Iterator<Item = (&Uint<256, 4>, &EvmStorageSlot)>
pub fn changed_storage_slots( &self, ) -> impl Iterator<Item = (&Uint<256, 4>, &EvmStorageSlot)>
Returns an iterator over the storage slots that have been changed.
See also EvmStorageSlot::is_changed.
Trait Implementations§
Source§impl<'a, ENTRY: Debug + JournalEntryTr> Debug for JournaledAccount<'a, ENTRY>
impl<'a, ENTRY: Debug + JournalEntryTr> Debug for JournaledAccount<'a, ENTRY>
Source§impl<'a, ENTRY: JournalEntryTr> Deref for JournaledAccount<'a, ENTRY>
impl<'a, ENTRY: JournalEntryTr> Deref for JournaledAccount<'a, ENTRY>
Source§impl<'a, ENTRY: PartialEq + JournalEntryTr> PartialEq for JournaledAccount<'a, ENTRY>
impl<'a, ENTRY: PartialEq + JournalEntryTr> PartialEq for JournaledAccount<'a, ENTRY>
impl<'a, ENTRY: Eq + JournalEntryTr> Eq for JournaledAccount<'a, ENTRY>
impl<'a, ENTRY: JournalEntryTr> StructuralPartialEq for JournaledAccount<'a, ENTRY>
Auto Trait Implementations§
impl<'a, ENTRY> Freeze for JournaledAccount<'a, ENTRY>
impl<'a, ENTRY> RefUnwindSafe for JournaledAccount<'a, ENTRY>where
ENTRY: RefUnwindSafe,
impl<'a, ENTRY> Send for JournaledAccount<'a, ENTRY>where
ENTRY: Send,
impl<'a, ENTRY> Sync for JournaledAccount<'a, ENTRY>where
ENTRY: Sync,
impl<'a, ENTRY> Unpin for JournaledAccount<'a, ENTRY>
impl<'a, ENTRY> !UnwindSafe for JournaledAccount<'a, ENTRY>
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.