Struct AccountInfo
pub struct AccountInfo {
pub balance: Uint<256, 4>,
pub nonce: u64,
pub code_hash: FixedBytes<32>,
pub code: Option<Bytecode>,
}Expand description
Account information that contains balance, nonce, code hash and code
Code is set as optional.
Fields§
§balance: Uint<256, 4>Account balance.
nonce: u64Account nonce.
code_hash: FixedBytes<32>Hash of the raw bytes in code, or KECCAK_EMPTY.
code: Option<Bytecode>Bytecode data associated with this account.
If None, code_hash will be used to fetch it from the database, if code needs to be
loaded from inside revm.
By default, this is Some(Bytecode::default()).
Implementations§
§impl AccountInfo
impl AccountInfo
pub fn new(
balance: Uint<256, 4>,
nonce: u64,
code_hash: FixedBytes<32>,
code: Bytecode,
) -> AccountInfo
pub fn new( balance: Uint<256, 4>, nonce: u64, code_hash: FixedBytes<32>, code: Bytecode, ) -> AccountInfo
Creates a new AccountInfo with the given fields.
pub fn with_code(self, code: Bytecode) -> AccountInfo
pub fn with_code(self, code: Bytecode) -> AccountInfo
Creates a new AccountInfo with the given code.
§Note
As code hash is calculated with Bytecode::hash_slow there will be performance penalty if used frequently.
pub fn with_code_hash(self, code_hash: FixedBytes<32>) -> AccountInfo
pub fn with_code_hash(self, code_hash: FixedBytes<32>) -> AccountInfo
Creates a new AccountInfo with the given code hash.
§Note
Resets code to None. Not guaranteed to maintain invariant code and code_hash. See
also Self::with_code_and_hash.
pub fn with_code_and_hash(
self,
code: Bytecode,
code_hash: FixedBytes<32>,
) -> AccountInfo
pub fn with_code_and_hash( self, code: Bytecode, code_hash: FixedBytes<32>, ) -> AccountInfo
Creates a new AccountInfo with the given code and code hash.
§Note
In debug mode panics if Bytecode::hash_slow called on code is not equivalent to
code_hash. See also Self::with_code.
pub fn with_balance(self, balance: Uint<256, 4>) -> AccountInfo
pub fn with_balance(self, balance: Uint<256, 4>) -> AccountInfo
Creates a new AccountInfo with the given balance.
pub fn with_nonce(self, nonce: u64) -> AccountInfo
pub fn with_nonce(self, nonce: u64) -> AccountInfo
Creates a new AccountInfo with the given nonce.
pub fn set_balance(&mut self, balance: Uint<256, 4>) -> &mut AccountInfo
pub fn set_balance(&mut self, balance: Uint<256, 4>) -> &mut AccountInfo
Sets the AccountInfo balance.
pub fn set_nonce(&mut self, nonce: u64) -> &mut AccountInfo
pub fn set_nonce(&mut self, nonce: u64) -> &mut AccountInfo
Sets the AccountInfo nonce.
pub fn set_code_hash(&mut self, code_hash: FixedBytes<32>) -> &mut AccountInfo
pub fn set_code_hash(&mut self, code_hash: FixedBytes<32>) -> &mut AccountInfo
Sets the AccountInfo code_hash and clears any cached bytecode.
§Note
Calling this after set_code(...) will remove the bytecode you just set.
If you intend to mutate the code, use only set_code.
pub fn set_code(&mut self, code: Bytecode) -> &mut AccountInfo
pub fn set_code(&mut self, code: Bytecode) -> &mut AccountInfo
Replaces the AccountInfo bytecode and recalculates code_hash.
§Note
As code hash is calculated with Bytecode::hash_slow there will be performance penalty if used frequently.
pub fn set_code_and_hash(&mut self, code: Bytecode, code_hash: FixedBytes<32>)
pub fn set_code_and_hash(&mut self, code: Bytecode, code_hash: FixedBytes<32>)
Sets the bytecode and its hash.
§Note
It is on the caller’s responsibility to ensure that the bytecode hash is correct.
pub fn copy_without_code(&self) -> AccountInfo
pub fn copy_without_code(&self) -> AccountInfo
Returns a copy of this account with the Bytecode removed.
This is useful when creating journals or snapshots of the state, where it is desirable to store the code blobs elsewhere.
§Note
This is distinct from without_code in that it returns
a new AccountInfo instance with the code removed.
without_code will modify and return the same instance.
pub fn without_code(self) -> AccountInfo
pub fn without_code(self) -> AccountInfo
Strips the Bytecode from this account and drop it.
This is useful when creating journals or snapshots of the state, where it is desirable to store the code blobs elsewhere.
§Note
This is distinct from copy_without_code in that it
modifies the account in place.
copy_without_code
will copy the non-code fields and return a new AccountInfo instance.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns if an account is empty.
An account is empty if the following conditions are met.
- code hash is zero or set to the Keccak256 hash of the empty string
"" - balance is zero
- nonce is zero
pub fn has_no_code_and_nonce(&self) -> bool
pub fn has_no_code_and_nonce(&self) -> bool
Returns true if account has no nonce and code.
pub fn code_hash(&self) -> FixedBytes<32>
pub fn code_hash(&self) -> FixedBytes<32>
Returns bytecode hash associated with this account.
If account does not have code, it returns KECCAK_EMPTY hash.
pub fn is_empty_code_hash(&self) -> bool
pub fn is_empty_code_hash(&self) -> bool
Returns true if the code hash is the Keccak256 hash of the empty string "".
pub fn take_bytecode(&mut self) -> Option<Bytecode>
pub fn take_bytecode(&mut self) -> Option<Bytecode>
Takes bytecode from account.
Code will be set to None.
pub fn from_balance(balance: Uint<256, 4>) -> AccountInfo
pub fn from_balance(balance: Uint<256, 4>) -> AccountInfo
Initializes an AccountInfo with the given balance, setting all other fields to their
default values.
pub fn from_bytecode(bytecode: Bytecode) -> AccountInfo
pub fn from_bytecode(bytecode: Bytecode) -> AccountInfo
Initializes an AccountInfo with the given bytecode, setting its balance to zero, its
nonce to 1, and calculating the code hash from the given bytecode.
Trait Implementations§
§impl Clone for AccountInfo
impl Clone for AccountInfo
§fn clone(&self) -> AccountInfo
fn clone(&self) -> AccountInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for AccountInfo
impl Debug for AccountInfo
§impl Default for AccountInfo
impl Default for AccountInfo
§fn default() -> AccountInfo
fn default() -> AccountInfo
§impl<'de> Deserialize<'de> for AccountInfo
impl<'de> Deserialize<'de> for AccountInfo
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AccountInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AccountInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl From<&AccountInfo> for Account
impl From<&AccountInfo> for Account
§fn from(revm_acc: &AccountInfo) -> Account
fn from(revm_acc: &AccountInfo) -> Account
§impl From<Account> for AccountInfo
impl From<Account> for AccountInfo
§fn from(reth_acc: Account) -> AccountInfo
fn from(reth_acc: Account) -> AccountInfo
§impl From<AccountInfo> for Account
impl From<AccountInfo> for Account
§fn from(info: AccountInfo) -> Account
fn from(info: AccountInfo) -> Account
§impl From<AccountInfo> for Account
impl From<AccountInfo> for Account
§fn from(revm_acc: AccountInfo) -> Account
fn from(revm_acc: AccountInfo) -> Account
§impl From<AccountInfo> for DbAccount
impl From<AccountInfo> for DbAccount
§fn from(info: AccountInfo) -> DbAccount
fn from(info: AccountInfo) -> DbAccount
§impl From<AccountInfo> for PlainAccount
impl From<AccountInfo> for PlainAccount
§fn from(info: AccountInfo) -> PlainAccount
fn from(info: AccountInfo) -> PlainAccount
§impl Hash for AccountInfo
impl Hash for AccountInfo
§impl Ord for AccountInfo
impl Ord for AccountInfo
§impl PartialEq for AccountInfo
impl PartialEq for AccountInfo
§impl PartialOrd for AccountInfo
impl PartialOrd for AccountInfo
§impl Serialize for AccountInfo
impl Serialize for AccountInfo
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for AccountInfo
Auto Trait Implementations§
impl !Freeze for AccountInfo
impl RefUnwindSafe for AccountInfo
impl Send for AccountInfo
impl Sync for AccountInfo
impl Unpin for AccountInfo
impl UnwindSafe for AccountInfo
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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<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> 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,
§impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
§fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
TxEnv from a transaction and a sender address.§impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
§fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
TxEnv from a transaction, its sender, and encoded transaction bytes.§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> 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 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> Pointable for T
impl<T> Pointable for T
§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.§impl<T> TryConv for T
impl<T> TryConv for T
§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> ⓘ
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§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>,
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
impl<'de, T> BorrowedRpcObject<'de> for Twhere
T: RpcBorrow<'de> + RpcSend,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeDebug for Twhere
T: Debug,
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSerde for Twhere
T: Serialize + for<'de> Deserialize<'de>,
impl<'de, T> RpcBorrow<'de> for T
impl<T> RpcObject for Twhere
T: RpcSend + RpcRecv,
impl<T> RpcRecv for T
impl<T> RpcSend for T
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: 136 bytes