pub trait JournalTr {
type Database: Database;
type FinalOutput;
Show 31 methods
// Required methods
fn new(database: Self::Database) -> Self;
fn db_ref(&self) -> &Self::Database;
fn db(&mut self) -> &mut Self::Database;
fn sload(
&mut self,
address: Address,
key: U256,
) -> Result<StateLoad<U256>, <Self::Database as Database>::Error>;
fn sstore(
&mut self,
address: Address,
key: U256,
value: U256,
) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error>;
fn tload(&mut self, address: Address, key: U256) -> U256;
fn tstore(&mut self, address: Address, key: U256, value: U256);
fn log(&mut self, log: Log);
fn selfdestruct(
&mut self,
address: Address,
target: Address,
) -> Result<StateLoad<SelfDestructResult>, <Self::Database as Database>::Error>;
fn warm_account_and_storage(
&mut self,
address: Address,
storage_keys: impl IntoIterator<Item = U256>,
) -> Result<(), <Self::Database as Database>::Error>;
fn warm_account(&mut self, address: Address);
fn warm_precompiles(&mut self, addresses: HashSet<Address>);
fn precompile_addresses(&self) -> &HashSet<Address>;
fn set_spec_id(&mut self, spec_id: SpecId);
fn touch_account(&mut self, address: Address);
fn transfer(
&mut self,
from: Address,
to: Address,
balance: U256,
) -> Result<Option<TransferError>, <Self::Database as Database>::Error>;
fn inc_account_nonce(
&mut self,
address: Address,
) -> Result<Option<u64>, <Self::Database as Database>::Error>;
fn load_account(
&mut self,
address: Address,
) -> Result<StateLoad<&mut Account>, <Self::Database as Database>::Error>;
fn load_account_code(
&mut self,
address: Address,
) -> Result<StateLoad<&mut Account>, <Self::Database as Database>::Error>;
fn load_account_delegated(
&mut self,
address: Address,
) -> Result<StateLoad<AccountLoad>, <Self::Database as Database>::Error>;
fn set_code_with_hash(
&mut self,
address: Address,
code: Bytecode,
hash: B256,
);
fn clear(&mut self);
fn checkpoint(&mut self) -> JournalCheckpoint;
fn checkpoint_commit(&mut self);
fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint);
fn create_account_checkpoint(
&mut self,
caller: Address,
address: Address,
balance: U256,
spec_id: SpecId,
) -> Result<JournalCheckpoint, TransferError>;
fn depth(&self) -> usize;
fn finalize(&mut self) -> Self::FinalOutput;
// Provided methods
fn set_code(&mut self, address: Address, code: Bytecode) { ... }
fn code(
&mut self,
address: Address,
) -> Result<StateLoad<Bytes>, <Self::Database as Database>::Error> { ... }
fn code_hash(
&mut self,
address: Address,
) -> Result<StateLoad<B256>, <Self::Database as Database>::Error> { ... }
}
Expand description
Trait that contains database and journal of all changes that were made to the state.
Required Associated Types§
type Database: Database
type FinalOutput
Required Methods§
Sourcefn new(database: Self::Database) -> Self
fn new(database: Self::Database) -> Self
Creates new Journaled state.
Dont forget to set spec_id.
Sourcefn sload(
&mut self,
address: Address,
key: U256,
) -> Result<StateLoad<U256>, <Self::Database as Database>::Error>
fn sload( &mut self, address: Address, key: U256, ) -> Result<StateLoad<U256>, <Self::Database as Database>::Error>
Returns the storage value from Journal state.
Loads the storage from database if not found in Journal state.
Sourcefn sstore(
&mut self,
address: Address,
key: U256,
value: U256,
) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error>
fn sstore( &mut self, address: Address, key: U256, value: U256, ) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error>
Stores the storage value in Journal state.
Sourcefn selfdestruct(
&mut self,
address: Address,
target: Address,
) -> Result<StateLoad<SelfDestructResult>, <Self::Database as Database>::Error>
fn selfdestruct( &mut self, address: Address, target: Address, ) -> Result<StateLoad<SelfDestructResult>, <Self::Database as Database>::Error>
Marks the account for selfdestruction and transfers all the balance to the target.
Sourcefn warm_account_and_storage(
&mut self,
address: Address,
storage_keys: impl IntoIterator<Item = U256>,
) -> Result<(), <Self::Database as Database>::Error>
fn warm_account_and_storage( &mut self, address: Address, storage_keys: impl IntoIterator<Item = U256>, ) -> Result<(), <Self::Database as Database>::Error>
Warms the account and storage.
Sourcefn warm_account(&mut self, address: Address)
fn warm_account(&mut self, address: Address)
Warms the account.
Sourcefn warm_precompiles(&mut self, addresses: HashSet<Address>)
fn warm_precompiles(&mut self, addresses: HashSet<Address>)
Warms the precompiles.
Sourcefn precompile_addresses(&self) -> &HashSet<Address>
fn precompile_addresses(&self) -> &HashSet<Address>
Returns the addresses of the precompiles.
Sourcefn set_spec_id(&mut self, spec_id: SpecId)
fn set_spec_id(&mut self, spec_id: SpecId)
Sets the spec id.
Sourcefn touch_account(&mut self, address: Address)
fn touch_account(&mut self, address: Address)
Touches the account.
Sourcefn transfer(
&mut self,
from: Address,
to: Address,
balance: U256,
) -> Result<Option<TransferError>, <Self::Database as Database>::Error>
fn transfer( &mut self, from: Address, to: Address, balance: U256, ) -> Result<Option<TransferError>, <Self::Database as Database>::Error>
Transfers the balance from one account to another.
Sourcefn inc_account_nonce(
&mut self,
address: Address,
) -> Result<Option<u64>, <Self::Database as Database>::Error>
fn inc_account_nonce( &mut self, address: Address, ) -> Result<Option<u64>, <Self::Database as Database>::Error>
Increments the nonce of the account.
Sourcefn load_account(
&mut self,
address: Address,
) -> Result<StateLoad<&mut Account>, <Self::Database as Database>::Error>
fn load_account( &mut self, address: Address, ) -> Result<StateLoad<&mut Account>, <Self::Database as Database>::Error>
Loads the account.
Sourcefn load_account_code(
&mut self,
address: Address,
) -> Result<StateLoad<&mut Account>, <Self::Database as Database>::Error>
fn load_account_code( &mut self, address: Address, ) -> Result<StateLoad<&mut Account>, <Self::Database as Database>::Error>
Loads the account code.
Sourcefn load_account_delegated(
&mut self,
address: Address,
) -> Result<StateLoad<AccountLoad>, <Self::Database as Database>::Error>
fn load_account_delegated( &mut self, address: Address, ) -> Result<StateLoad<AccountLoad>, <Self::Database as Database>::Error>
Loads the account delegated.
Sourcefn set_code_with_hash(&mut self, address: Address, code: Bytecode, hash: B256)
fn set_code_with_hash(&mut self, address: Address, code: Bytecode, hash: B256)
Sets bytecode with hash. Assume that account is warm.
Sourcefn clear(&mut self)
fn clear(&mut self)
Called at the end of the transaction to clean all residue data from journal.
Sourcefn checkpoint(&mut self) -> JournalCheckpoint
fn checkpoint(&mut self) -> JournalCheckpoint
Creates a checkpoint of the current state. State can be revert to this point if needed.
Sourcefn checkpoint_commit(&mut self)
fn checkpoint_commit(&mut self)
Commits the changes made since the last checkpoint.
Sourcefn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
Reverts the changes made since the last checkpoint.
Sourcefn create_account_checkpoint(
&mut self,
caller: Address,
address: Address,
balance: U256,
spec_id: SpecId,
) -> Result<JournalCheckpoint, TransferError>
fn create_account_checkpoint( &mut self, caller: Address, address: Address, balance: U256, spec_id: SpecId, ) -> Result<JournalCheckpoint, TransferError>
Creates a checkpoint of the account creation.
Sourcefn finalize(&mut self) -> Self::FinalOutput
fn finalize(&mut self) -> Self::FinalOutput
Does cleanup and returns modified state.
This resets the JournalTr to its initial state.
Provided Methods§
Sourcefn set_code(&mut self, address: Address, code: Bytecode)
fn set_code(&mut self, address: Address, code: Bytecode)
Sets bytecode and calculates hash.
Assume account is warm.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.