Skip to main content

LocalContextTr

Trait LocalContextTr 

Source
pub trait LocalContextTr {
    // Required methods
    fn shared_memory_buffer(&self) -> &Rc<RefCell<Vec<u8>>>;
    fn clear(&mut self);
    fn set_precompile_error_context(&mut self, _output: String);
    fn take_precompile_error_context(&mut self) -> Option<String>;
    fn cpsb(&self) -> u64;
    fn set_cpsb(&mut self, cpsb: u64);

    // Provided method
    fn shared_memory_buffer_slice(
        &self,
        range: Range<usize>,
    ) -> Option<Ref<'_, [u8]>> { ... }
}
Expand description

Local context used for caching initcode from Initcode transactions.

Required Methods§

Source

fn shared_memory_buffer(&self) -> &Rc<RefCell<Vec<u8>>>

Interpreter shared memory buffer. A reused memory buffer for calls.

Source

fn clear(&mut self)

Clear the local context.

Source

fn set_precompile_error_context(&mut self, _output: String)

Set the error message for a precompile error, if any.

This is used to bubble up precompile error messages when the transaction directly targets a precompile (depth == 1).

Source

fn take_precompile_error_context(&mut self) -> Option<String>

Take and clear the precompile error context, if present.

Returns Some(String) if a precompile error message was recorded.

Source

fn cpsb(&self) -> u64

EIP-8037 cost_per_state_byte cached for the current transaction.

Populated by LocalContextTr::set_cpsb at transaction start so that the hot-path Host::cpsb is a single field read instead of recomputing cfg.cpsb().

Source

fn set_cpsb(&mut self, cpsb: u64)

Caches the EIP-8037 cost_per_state_byte for the current transaction.

Called at the start of every execution entry point (regular transaction, system call, and their inspector variants). The value must be derived via cfg.cpsb() so that cpsb_override is honored.

Provided Methods§

Source

fn shared_memory_buffer_slice( &self, range: Range<usize>, ) -> Option<Ref<'_, [u8]>>

Slice of the shared memory buffer returns None if range is not valid or buffer can’t be borrowed.

Implementors§