[][src]Struct evm::Machine

pub struct Machine<'a, M, P: Patch> { /* fields omitted */ }

A VM state with PC.

Methods

impl<'a, M: Memory, P: Patch> Machine<'a, M, P>[src]

Lifecycle of a Machine

When a new non-invoked transaction is created, initialize_call or initialize_create should be called. After this, the machine can be stepped as normal. When the machine meets a CALL/CALLCODE or CREATE instruction, a sub-machine will be created. This submachine should first call invoke_call or invoke_create. After the submachine is finished, it should call apply_sub. When the non-invoked transaction is finished, it should first call code_deposit if it is a contract creation transaction. After that, it should call finalize.

pub fn initialize_call(
    &mut self,
    preclaimed_value: U256
) -> Result<(), RequireError>
[src]

Initialize a MessageCall transaction.

Panic

Requires caller of the transaction to be committed.

pub fn invoke_call(&mut self) -> Result<(), RequireError>[src]

Initialize the runtime as a call from a CALL or CALLCODE opcode.

Panic

Requires caller of the CALL/CALLCODE opcode to be committed.

pub fn initialize_create(
    &mut self,
    preclaimed_value: U256
) -> Result<(), RequireError>
[src]

Initialize a ContractCreation transaction.

Panic

Requires caller of the transaction to be committed.

pub fn invoke_create(&mut self) -> Result<(), RequireError>[src]

Initialize the runtime as a call from a CREATE opcode.

Panic

Requires caller of the CREATE opcode to be committed.

pub fn code_deposit(&mut self)[src]

Deposit code for a ContractCreation transaction or a CREATE opcode.

pub fn finalize_transaction(
    &mut self,
    beneficiary: Address,
    real_used_gas: Gas,
    preclaimed_value: U256,
    fresh_account_state: &AccountState<'a, P::Account>
) -> Result<(), RequireError>
[src]

Finalize a transaction. This should not be used when invoked by an opcode and should only be used in the top level.

Panic

Requires caller of the transaction to be committed.

pub fn finalize_context(
    &mut self,
    fresh_account_state: &AccountState<'a, P::Account>
)
[src]

Finalize a context execution. This should not be used when invoked by an opcode and should only be used in the top level.

Panic

Requires caller of the transaction to be committed.

pub fn apply_sub(&mut self, sub: Machine<'a, M, P>)[src]

Apply a sub runtime into the current runtime. This sub runtime should have been created by the current runtime's derive function. Depending whether the current runtime is invoking a ContractCreation or MessageCall instruction, it will apply various states back.

impl<'a, M: Memory, P: Patch> Machine<'a, M, P>[src]

pub fn derive(&self, context: Context) -> Self[src]

Derive this runtime to create a sub runtime. This will not modify the current runtime, and it will have a chance to review whether it wants to accept the result of this sub runtime afterwards.

pub fn new(patch: &'a P, context: Context, depth: usize) -> Self[src]

Create a new runtime.

pub fn with_states(
    patch: &'a P,
    context: Context,
    depth: usize,
    account_state: AccountState<'a, P::Account>
) -> Self
[src]

Create a new runtime with the given states.

pub fn commit_account(
    &mut self,
    commitment: AccountCommitment
) -> Result<(), CommitError>
[src]

Commit a new account into this runtime.

pub fn step_precompiled(&mut self) -> bool[src]

Step a precompiled runtime. This function returns true if the runtime is indeed a precompiled address. Otherwise return false with state unchanged.

pub fn peek(&self) -> Option<Instruction>[src]

Peek the next instruction.

pub fn peek_opcode(&self) -> Option<Opcode>[src]

Peek the next opcode.

pub fn step(&mut self, runtime: &Runtime) -> Result<(), RequireError>[src]

Step an instruction in the PC. The eval result is refected by the runtime status, and it will only return an error if there're accounts or blockhashes to be committed to this runtime for it to run. In that case, the state of the current runtime will not be affected.

pub fn state(&self) -> &State<M, P>[src]

Get the runtime state.

pub fn take_state(self) -> State<'a, M, P>[src]

Take the runtime state

pub fn pc(&self) -> PC<P>[src]

Get the runtime PC.

pub fn status(&self) -> MachineStatus[src]

Get the current runtime status.

Auto Trait Implementations

impl<'a, M, P> !Send for Machine<'a, M, P>

impl<'a, M, P> !Sync for Machine<'a, M, P>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self