Trait JournalTr
pub trait JournalTr {
type Database: Database;
type State;
type JournalEntry: JournalEntryTr;
Show 44 methods
// Required methods
fn new(database: Self::Database) -> Self;
fn db_mut(&mut self) -> &mut Self::Database;
fn db(&self) -> &Self::Database;
fn sload_skip_cold_load(
&mut self,
_address: Address,
_key: Uint<256, 4>,
_skip_cold_load: bool,
) -> Result<StateLoad<Uint<256, 4>>, JournalLoadError<<Self::Database as Database>::Error>>;
fn sstore_skip_cold_load(
&mut self,
_address: Address,
_key: Uint<256, 4>,
_value: Uint<256, 4>,
_skip_cold_load: bool,
) -> Result<StateLoad<SStoreResult>, JournalLoadError<<Self::Database as Database>::Error>>;
fn tload(&mut self, address: Address, key: Uint<256, 4>) -> Uint<256, 4>;
fn tstore(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
);
fn log(&mut self, log: Log);
fn selfdestruct(
&mut self,
address: Address,
target: Address,
) -> Result<StateLoad<SelfDestructResult>, <Self::Database as Database>::Error>;
fn warm_access_list(
&mut self,
access_list: HashMap<Address, HashSet<Uint<256, 4>>>,
);
fn warm_coinbase_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: Uint<256, 4>,
) -> Result<Option<TransferError>, <Self::Database as Database>::Error>;
fn transfer_loaded(
&mut self,
from: Address,
to: Address,
balance: Uint<256, 4>,
) -> Option<TransferError>;
fn caller_accounting_journal_entry(
&mut self,
address: Address,
old_balance: Uint<256, 4>,
bump_nonce: bool,
);
fn balance_incr(
&mut self,
address: Address,
balance: Uint<256, 4>,
) -> Result<(), <Self::Database as Database>::Error>;
fn nonce_bump_journal_entry(&mut self, address: Address);
fn load_account(
&mut self,
address: Address,
) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>;
fn load_account_with_code(
&mut self,
address: Address,
) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>;
fn load_account_delegated(
&mut self,
address: Address,
) -> Result<StateLoad<AccountLoad>, <Self::Database as Database>::Error>;
fn load_account_mut_optional_code(
&mut self,
address: Address,
load_code: bool,
) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error>;
fn set_code_with_hash(
&mut self,
address: Address,
code: Bytecode,
hash: FixedBytes<32>,
);
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: Uint<256, 4>,
spec_id: SpecId,
) -> Result<JournalCheckpoint, TransferError>;
fn depth(&self) -> usize;
fn take_logs(&mut self) -> Vec<Log>;
fn commit_tx(&mut self);
fn discard_tx(&mut self);
fn finalize(&mut self) -> Self::State;
fn load_account_info_skip_cold_load(
&mut self,
_address: Address,
_load_code: bool,
_skip_cold_load: bool,
) -> Result<AccountInfoLoad<'_>, JournalLoadError<<Self::Database as Database>::Error>>;
// Provided methods
fn sload(
&mut self,
address: Address,
key: Uint<256, 4>,
) -> Result<StateLoad<Uint<256, 4>>, <Self::Database as Database>::Error> { ... }
fn sstore(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error> { ... }
fn load_account_code(
&mut self,
address: Address,
) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error> { ... }
fn load_account_mut(
&mut self,
address: Address,
) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error> { ... }
fn load_account_with_code_mut(
&mut self,
address: Address,
) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error> { ... }
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<FixedBytes<32>>, <Self::Database as Database>::Error> { ... }
fn clear(&mut self) { ... }
}Expand description
Trait that contains database and journal of all changes that were made to the state.
Required Associated Types§
type State
type State
State type that is returned by the journal after finalization.
type JournalEntry: JournalEntryTr
type JournalEntry: JournalEntryTr
Journal Entry type that is used in the journal.
Required Methods§
fn sload_skip_cold_load(
&mut self,
_address: Address,
_key: Uint<256, 4>,
_skip_cold_load: bool,
) -> Result<StateLoad<Uint<256, 4>>, JournalLoadError<<Self::Database as Database>::Error>>
fn sload_skip_cold_load( &mut self, _address: Address, _key: Uint<256, 4>, _skip_cold_load: bool, ) -> Result<StateLoad<Uint<256, 4>>, JournalLoadError<<Self::Database as Database>::Error>>
Loads the storage value from Journal state.
fn sstore_skip_cold_load(
&mut self,
_address: Address,
_key: Uint<256, 4>,
_value: Uint<256, 4>,
_skip_cold_load: bool,
) -> Result<StateLoad<SStoreResult>, JournalLoadError<<Self::Database as Database>::Error>>
fn sstore_skip_cold_load( &mut self, _address: Address, _key: Uint<256, 4>, _value: Uint<256, 4>, _skip_cold_load: bool, ) -> Result<StateLoad<SStoreResult>, JournalLoadError<<Self::Database as Database>::Error>>
Stores the storage value in Journal state.
fn tload(&mut self, address: Address, key: Uint<256, 4>) -> Uint<256, 4>
fn tload(&mut self, address: Address, key: Uint<256, 4>) -> Uint<256, 4>
Loads transient storage value.
fn tstore(&mut self, address: Address, key: Uint<256, 4>, value: Uint<256, 4>)
fn tstore(&mut self, address: Address, key: Uint<256, 4>, value: Uint<256, 4>)
Stores transient storage value.
fn log(&mut self, log: Log)
fn log(&mut self, log: Log)
Logs the log in Journal state.
fn 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.
fn warm_access_list(
&mut self,
access_list: HashMap<Address, HashSet<Uint<256, 4>>>,
)
fn warm_access_list( &mut self, access_list: HashMap<Address, HashSet<Uint<256, 4>>>, )
Sets access list inside journal.
fn warm_coinbase_account(&mut self, address: Address)
fn warm_coinbase_account(&mut self, address: Address)
Warms the coinbase account.
fn warm_precompiles(&mut self, addresses: HashSet<Address>)
fn warm_precompiles(&mut self, addresses: HashSet<Address>)
Warms the precompiles.
fn precompile_addresses(&self) -> &HashSet<Address>
fn precompile_addresses(&self) -> &HashSet<Address>
Returns the addresses of the precompiles.
fn set_spec_id(&mut self, spec_id: SpecId)
fn set_spec_id(&mut self, spec_id: SpecId)
Sets the spec id.
fn touch_account(&mut self, address: Address)
fn touch_account(&mut self, address: Address)
Touches the account.
fn transfer(
&mut self,
from: Address,
to: Address,
balance: Uint<256, 4>,
) -> Result<Option<TransferError>, <Self::Database as Database>::Error>
fn transfer( &mut self, from: Address, to: Address, balance: Uint<256, 4>, ) -> Result<Option<TransferError>, <Self::Database as Database>::Error>
Transfers the balance from one account to another.
fn transfer_loaded(
&mut self,
from: Address,
to: Address,
balance: Uint<256, 4>,
) -> Option<TransferError>
fn transfer_loaded( &mut self, from: Address, to: Address, balance: Uint<256, 4>, ) -> Option<TransferError>
Transfers the balance from one account to another. Assume form and to are loaded.
fn caller_accounting_journal_entry(
&mut self,
address: Address,
old_balance: Uint<256, 4>,
bump_nonce: bool,
)
fn caller_accounting_journal_entry( &mut self, address: Address, old_balance: Uint<256, 4>, bump_nonce: bool, )
Increments the balance of the account.
fn balance_incr(
&mut self,
address: Address,
balance: Uint<256, 4>,
) -> Result<(), <Self::Database as Database>::Error>
fn balance_incr( &mut self, address: Address, balance: Uint<256, 4>, ) -> Result<(), <Self::Database as Database>::Error>
Increments the balance of the account.
fn nonce_bump_journal_entry(&mut self, address: Address)
fn nonce_bump_journal_entry(&mut self, address: Address)
Increments the nonce of the account.
fn load_account(
&mut self,
address: Address,
) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>
fn load_account( &mut self, address: Address, ) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>
Loads the account.
fn load_account_with_code(
&mut self,
address: Address,
) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>
fn load_account_with_code( &mut self, address: Address, ) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>
Loads the account with code.
fn 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.
fn load_account_mut_optional_code(
&mut self,
address: Address,
load_code: bool,
) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error>
fn load_account_mut_optional_code( &mut self, address: Address, load_code: bool, ) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error>
Loads the journaled account.
fn set_code_with_hash(
&mut self,
address: Address,
code: Bytecode,
hash: FixedBytes<32>,
)
fn set_code_with_hash( &mut self, address: Address, code: Bytecode, hash: FixedBytes<32>, )
Sets bytecode with hash. Assume that account is warm.
fn 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.
fn checkpoint_commit(&mut self)
fn checkpoint_commit(&mut self)
Commits the changes made since the last checkpoint.
fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
fn checkpoint_revert(&mut self, checkpoint: JournalCheckpoint)
Reverts the changes made since the last checkpoint.
fn create_account_checkpoint(
&mut self,
caller: Address,
address: Address,
balance: Uint<256, 4>,
spec_id: SpecId,
) -> Result<JournalCheckpoint, TransferError>
fn create_account_checkpoint( &mut self, caller: Address, address: Address, balance: Uint<256, 4>, spec_id: SpecId, ) -> Result<JournalCheckpoint, TransferError>
Creates a checkpoint of the account creation.
fn commit_tx(&mut self)
fn commit_tx(&mut self)
Commit current transaction journal and returns transaction logs.
fn discard_tx(&mut self)
fn discard_tx(&mut self)
Discard current transaction journal by removing journal entries and logs and incrementing the transaction id.
This function is useful to discard intermediate state that is interrupted by error and it will not revert any already committed changes and it is safe to call it multiple times.
fn finalize(&mut self) -> Self::State
fn finalize(&mut self) -> Self::State
Clear current journal resetting it to initial state and return changes state.
fn load_account_info_skip_cold_load(
&mut self,
_address: Address,
_load_code: bool,
_skip_cold_load: bool,
) -> Result<AccountInfoLoad<'_>, JournalLoadError<<Self::Database as Database>::Error>>
fn load_account_info_skip_cold_load( &mut self, _address: Address, _load_code: bool, _skip_cold_load: bool, ) -> Result<AccountInfoLoad<'_>, JournalLoadError<<Self::Database as Database>::Error>>
Loads the account info from Journal state.
Provided Methods§
fn sload(
&mut self,
address: Address,
key: Uint<256, 4>,
) -> Result<StateLoad<Uint<256, 4>>, <Self::Database as Database>::Error>
fn sload( &mut self, address: Address, key: Uint<256, 4>, ) -> Result<StateLoad<Uint<256, 4>>, <Self::Database as Database>::Error>
Returns the storage value from Journal state.
Loads the storage from database if not found in Journal state.
fn sstore(
&mut self,
address: Address,
key: Uint<256, 4>,
value: Uint<256, 4>,
) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error>
fn sstore( &mut self, address: Address, key: Uint<256, 4>, value: Uint<256, 4>, ) -> Result<StateLoad<SStoreResult>, <Self::Database as Database>::Error>
Stores the storage value in Journal state.
fn load_account_code(
&mut self,
address: Address,
) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>
👎Deprecated: Use load_account_with_code instead
fn load_account_code( &mut self, address: Address, ) -> Result<StateLoad<&Account>, <Self::Database as Database>::Error>
load_account_with_code insteadLoads the account code, use load_account_with_code instead.
fn load_account_mut(
&mut self,
address: Address,
) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error>
fn load_account_mut( &mut self, address: Address, ) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error>
Loads the journaled account.
fn load_account_with_code_mut(
&mut self,
address: Address,
) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error>
fn load_account_with_code_mut( &mut self, address: Address, ) -> Result<StateLoad<JournaledAccount<'_, Self::JournalEntry>>, <Self::Database as Database>::Error>
Loads the journaled account.
fn 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.
fn code(
&mut self,
address: Address,
) -> Result<StateLoad<Bytes>, <Self::Database as Database>::Error>
fn code( &mut self, address: Address, ) -> Result<StateLoad<Bytes>, <Self::Database as Database>::Error>
Returns account code bytes and if address is cold loaded.
fn code_hash(
&mut self,
address: Address,
) -> Result<StateLoad<FixedBytes<32>>, <Self::Database as Database>::Error>
fn code_hash( &mut self, address: Address, ) -> Result<StateLoad<FixedBytes<32>>, <Self::Database as Database>::Error>
Gets code hash of account.
fn clear(&mut self)
fn clear(&mut self)
Called at the end of the transaction to clean all residue data from journal.
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.