Trait evmil::analysis::EvmState

source ·
pub trait EvmState: Debug {
    type Word: EvmWord;
    type Stack: EvmStack<Word = Self::Word>;
    type Memory: EvmMemory<Word = Self::Word>;
    type Storage: EvmStorage<Word = Self::Word>;

    // Required methods
    fn pc(&self) -> usize;
    fn stack(&self) -> &Self::Stack;
    fn stack_mut(&mut self) -> &mut Self::Stack;
    fn memory(&self) -> &Self::Memory;
    fn memory_mut(&mut self) -> &mut Self::Memory;
    fn storage(&self) -> &Self::Storage;
    fn storage_mut(&mut self) -> &mut Self::Storage;
    fn skip(&mut self, n: usize);
    fn goto(&mut self, pc: usize);
}
Expand description

Describes the state of an EVM at a given point (which could be running or terminated). In essence, this simply packages all the key components (e.g. stack, memory, storage) of the EVM state together.

An EvmState can be concrete or abstract. For example, a physically executing EVM operates over concrete states which are updated after each executed instruction. In contrast, a static analysis over a sequence of EVM bytecodes produces abstract states at each point which summarise the set of all possible states at that point.

Required Associated Types§

source

type Word: EvmWord

Defines what constitutes a word in this EVM. For example, a concrete evm will use a w256 here whilst an abstract evm will use something that can, for example, describe unknown values.

source

type Stack: EvmStack<Word = Self::Word>

Defines the stack implementation used in this EVM.

source

type Memory: EvmMemory<Word = Self::Word>

Defines the memory implementation used in this EVM.

source

type Storage: EvmStorage<Word = Self::Word>

Defines the memory implementation used in this EVM.

Required Methods§

source

fn pc(&self) -> usize

Get the program counter. Every EvmState has a statically known pc.

source

fn stack(&self) -> &Self::Stack

Get read access to the operand stack contained within this state.

source

fn stack_mut(&mut self) -> &mut Self::Stack

Get write access to the operand stack contained within this state.

source

fn memory(&self) -> &Self::Memory

Get read access to the scratch memory contained within this state.

source

fn memory_mut(&mut self) -> &mut Self::Memory

Get write access to the scratch memory contained within this state.

source

fn storage(&self) -> &Self::Storage

Get read access to the persistent storage contained within this state.

source

fn storage_mut(&mut self) -> &mut Self::Storage

Get write access to the persistent storage contained within this state.

source

fn skip(&mut self, n: usize)

Move program counter over n bytes in the next instruction.

source

fn goto(&mut self, pc: usize)

Move program counter to a given (byte) offset within the code section.

Implementors§

source§

impl<S, M, T> EvmState for ConcreteState<S, M, T>
where S: EvmStack, M: EvmMemory<Word = S::Word>, T: EvmStorage<Word = S::Word>,

§

type Word = <S as EvmStack>::Word

§

type Stack = S

§

type Memory = M

§

type Storage = T