pub struct BundleState {
pub state: AddressMap<BundleAccount>,
pub contracts: B256Map<Bytecode>,
pub reverts: Reverts,
pub state_size: usize,
pub reverts_size: usize,
}Expand description
Bundle state contain only values that got changed
For every account it contains both original and present state.
This is needed to decide if there were any changes to the account.
Changes are applied and reverts are created when TransitionState is applied to BundleState.
And can be used to revert BundleState to the state before transition.
Fields§
§state: AddressMap<BundleAccount>Account state
contracts: B256Map<Bytecode>All created contracts in this block.
reverts: RevertsChanges to revert
Note: Inside vector is not sorted by address.
But it is unique by address.
state_size: usizeThe size of the plain state in the bundle state
reverts_size: usizeThe size of reverts in the bundle state
Implementations§
Source§impl BundleState
impl BundleState
Sourcepub fn builder(revert_range: RangeInclusive<u64>) -> BundleBuilder
pub fn builder(revert_range: RangeInclusive<u64>) -> BundleBuilder
Returns builder instance for further manipulation.
Sourcepub fn new(
state: impl IntoIterator<Item = (Address, Option<AccountInfo>, Option<AccountInfo>, HashMap<U256, (U256, U256)>)>,
reverts: impl IntoIterator<Item = impl IntoIterator<Item = (Address, Option<Option<AccountInfo>>, impl IntoIterator<Item = (U256, U256)>)>>,
contracts: impl IntoIterator<Item = (B256, Bytecode)>,
) -> Self
pub fn new( state: impl IntoIterator<Item = (Address, Option<AccountInfo>, Option<AccountInfo>, HashMap<U256, (U256, U256)>)>, reverts: impl IntoIterator<Item = impl IntoIterator<Item = (Address, Option<Option<AccountInfo>>, impl IntoIterator<Item = (U256, U256)>)>>, contracts: impl IntoIterator<Item = (B256, Bytecode)>, ) -> Self
Creates it with new and old values of both Storage and AccountInfo.
Sourcepub fn size_hint(&self) -> usize
pub fn size_hint(&self) -> usize
Returns the approximate size of changes in the bundle state.
The estimation is not precise, because the information about the number of destroyed entries that need to be removed is not accessible to the bundle state.
Sourcepub const fn state(&self) -> &AddressMap<BundleAccount>
pub const fn state(&self) -> &AddressMap<BundleAccount>
Returns reference to the state.
Sourcepub fn account(&self, address: &Address) -> Option<&BundleAccount>
pub fn account(&self, address: &Address) -> Option<&BundleAccount>
Gets account from state.
Sourcepub fn storage(&self, address: &Address, storage_key: U256) -> Option<U256>
pub fn storage(&self, address: &Address, storage_key: U256) -> Option<U256>
Gets storage value from state.
Returns None if the account is not present in the bundle state or the slot is not known.
Sourcepub fn apply_transitions_and_create_reverts(
&mut self,
transitions: TransitionState,
retention: BundleRetention,
)
pub fn apply_transitions_and_create_reverts( &mut self, transitions: TransitionState, retention: BundleRetention, )
Consumes TransitionState by applying the changes and creating the
reverts.
If BundleRetention::includes_reverts is true, then the reverts will
be retained.
Sourcepub fn to_plain_state(
&self,
is_value_known: OriginalValuesKnown,
) -> StateChangeset
pub fn to_plain_state( &self, is_value_known: OriginalValuesKnown, ) -> StateChangeset
Generate a StateChangeset from the bundle state without consuming
it.
Sourcepub fn to_plain_state_and_reverts(
&self,
is_value_known: OriginalValuesKnown,
) -> (StateChangeset, PlainStateReverts)
pub fn to_plain_state_and_reverts( &self, is_value_known: OriginalValuesKnown, ) -> (StateChangeset, PlainStateReverts)
Generates a StateChangeset and PlainStateReverts from the bundle
state.
Sourcepub fn into_plain_state_and_reverts(
self,
is_value_known: OriginalValuesKnown,
) -> (StateChangeset, PlainStateReverts)
👎Deprecated: Use to_plain_state_and_reverts instead
pub fn into_plain_state_and_reverts( self, is_value_known: OriginalValuesKnown, ) -> (StateChangeset, PlainStateReverts)
Use to_plain_state_and_reverts instead
Consumes the bundle state and split it into a StateChangeset and a
PlainStateReverts.
Sourcepub fn extend_state(&mut self, other_state: AddressMap<BundleAccount>)
pub fn extend_state(&mut self, other_state: AddressMap<BundleAccount>)
Extends the bundle with other state.
Updates the other state only if other is not flagged as destroyed.
Sourcepub fn extend(&mut self, other: Self)
pub fn extend(&mut self, other: Self)
Extends the state with state that is build on top of it.
If storage was wiped in other state, copy this plain state
and put it inside other revert (if there is no duplicates of course).
If this and other accounts were both destroyed invalidate second
wipe flag (from other).
As wiping from database should be done only once
and we already transferred all potentially missing storages to the other revert.
Sourcepub fn take_n_reverts(&mut self, reverts_to_take: usize) -> Reverts
pub fn take_n_reverts(&mut self, reverts_to_take: usize) -> Reverts
Takes first N raw reverts from the BundleState.
Sourcepub fn take_all_reverts(&mut self) -> Reverts
pub fn take_all_reverts(&mut self) -> Reverts
Returns and clears all reverts from BundleState.
Sourcepub fn revert_latest(&mut self) -> bool
pub fn revert_latest(&mut self) -> bool
Reverts the state changes of the latest transition.
Note: This is the same as BundleState::revert(1)
Returns true if the state was reverted.
Sourcepub fn revert(&mut self, num_transitions: usize)
pub fn revert(&mut self, num_transitions: usize)
Reverts the state changes by N transitions back.
See also Self::revert_latest
Sourcepub fn prepend_state(&mut self, other: BundleState)
pub fn prepend_state(&mut self, other: BundleState)
Prepends present the state with the given BundleState.
It adds changes from the given state but does not override any existing changes.
Reverts are not updated.
Trait Implementations§
Source§impl Clone for BundleState
impl Clone for BundleState
Source§impl Debug for BundleState
impl Debug for BundleState
Source§impl Default for BundleState
impl Default for BundleState
Source§impl<'de> Deserialize<'de> for BundleState
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BundleState
serde only.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 BundleState
Source§impl PartialEq for BundleState
impl PartialEq for BundleState
Source§impl Serialize for BundleState
Available on crate feature serde only.
impl Serialize for BundleState
serde only.impl StructuralPartialEq for BundleState
Auto Trait Implementations§
impl Freeze for BundleState
impl RefUnwindSafe for BundleState
impl Send for BundleState
impl Sync for BundleState
impl Unpin for BundleState
impl UnsafeUnpin for BundleState
impl UnwindSafe for BundleState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>,
§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<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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreimpl<T> MaybeDebug for Twhere
T: Debug,
impl<T> MaybeSerde for Twhere
T: Serialize + for<'de> Deserialize<'de>,
§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
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: 120 bytes