pub trait VM {
Show 15 methods
fn commit_account(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>;
fn commit_blockhash(
&mut self,
number: U256,
hash: H256
) -> Result<(), CommitError>;
fn status(&self) -> VMStatus;
fn peek(&self) -> Option<Instruction>;
fn peek_opcode(&self) -> Option<Opcode>;
fn step(&mut self) -> Result<(), RequireError>;
fn accounts(&self) -> Values<'_, Address, AccountChange>;
fn used_addresses(&self) -> Set<Address>;
fn out(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
;
fn available_gas(&self) -> Gas;
fn refunded_gas(&self) -> Gas;
fn logs(&self) -> &[Log];
fn removed(&self) -> &[Address];
fn used_gas(&self) -> Gas;
fn fire(&mut self) -> Result<(), RequireError> { ... }
}
Expand description
Represents an EVM. This is usually the main interface for clients to interact with.
Required Methods
sourcefn commit_account(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
fn commit_account(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
Commit an account information to this VM. This should only
be used when receiving RequireError
.
sourcefn commit_blockhash(
&mut self,
number: U256,
hash: H256
) -> Result<(), CommitError>
fn commit_blockhash(
&mut self,
number: U256,
hash: H256
) -> Result<(), CommitError>
Commit a block hash to this VM. This should only be used when
receiving RequireError
.
sourcefn peek(&self) -> Option<Instruction>
fn peek(&self) -> Option<Instruction>
Read the next instruction to be executed.
sourcefn peek_opcode(&self) -> Option<Opcode>
fn peek_opcode(&self) -> Option<Opcode>
Read the next opcode to be executed.
sourcefn step(&mut self) -> Result<(), RequireError>
fn step(&mut self) -> Result<(), RequireError>
Run one instruction and return. If it succeeds, VM status can
still be Running
. If the call stack has more than one items,
this will only executes the last items’ one single
instruction.
sourcefn accounts(&self) -> Values<'_, Address, AccountChange>
fn accounts(&self) -> Values<'_, Address, AccountChange>
Returns the changed or committed accounts information up to current execution status.
sourcefn used_addresses(&self) -> Set<Address>
fn used_addresses(&self) -> Set<Address>
Returns all fetched or modified addresses.
sourcefn out(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
fn out(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Returns the out value, if any.
sourcefn available_gas(&self) -> Gas
fn available_gas(&self) -> Gas
Returns the available gas of this VM.
sourcefn refunded_gas(&self) -> Gas
fn refunded_gas(&self) -> Gas
Returns the refunded gas of this VM.
sourcefn logs(&self) -> &[Log]
fn logs(&self) -> &[Log]
Returns logs to be appended to the current block if the user decided to accept the running status of this VM.
Provided Methods
sourcefn fire(&mut self) -> Result<(), RequireError>
fn fire(&mut self) -> Result<(), RequireError>
Run instructions until it reaches a RequireError
or
exits. If this function succeeds, the VM status can only be
either ExitedOk
or ExitedErr
.