Trait JournalTr

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: 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 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_account_and_storage( &mut self, address: Address, storage_keys: impl IntoIterator<Item = Uint<256, 4>>, ) -> Result<(), <Self::Database as Database>::Error>; fn warm_account(&mut self, address: Address); fn warm_precompiles(&mut self, addresses: HashSet<Address, RandomState>); fn precompile_addresses(&self) -> &HashSet<Address, RandomState>; 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 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: FixedBytes<32>, ); 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: Uint<256, 4>, 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<FixedBytes<32>>, <Self::Database as Database>::Error> { ... }
}

Required Associated Types§

Required Methods§

fn new(database: Self::Database) -> Self

Creates new Journaled state.

Dont forget to set spec_id.

fn db_ref(&self) -> &Self::Database

Returns the database.

fn db(&mut self) -> &mut Self::Database

Returns the mutable database.

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>

Stores the storage value in Journal state.

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>)

Stores transient storage value.

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>

Marks the account for selfdestruction and transfers all the balance to the target.

fn warm_account_and_storage( &mut self, address: Address, storage_keys: impl IntoIterator<Item = Uint<256, 4>>, ) -> Result<(), <Self::Database as Database>::Error>

fn warm_account(&mut self, address: Address)

fn warm_precompiles(&mut self, addresses: HashSet<Address, RandomState>)

fn precompile_addresses(&self) -> &HashSet<Address, RandomState>

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 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: FixedBytes<32>, )

Sets bytecode with hash. Assume that account is warm.

fn clear(&mut self)

Called at the end of the transaction to clean all residue data from journal.

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 finalize(&mut self) -> Self::FinalOutput

Does cleanup and returns modified state.

This resets the JournalTr to its initial state.

Provided Methods§

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>

Returns account code bytes and if address is cold loaded.

In case of EOF account it will return EOF_MAGIC (0xEF00) as code.

fn code_hash( &mut self, address: Address, ) -> Result<StateLoad<FixedBytes<32>>, <Self::Database as Database>::Error>

Gets code hash of account.

In case of EOF account it will return EOF_MAGIC_HASH (the hash of 0xEF00).

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.

Implementors§

§

impl<DB, ENTRY> JournalTr for Journal<DB, ENTRY>
where DB: Database, ENTRY: JournalEntryTr,