[−][src]Struct ethereumvm::Machine
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]
&mut self,
preclaimed_value: U256
) -> Result<(), RequireError>
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]
&mut self,
preclaimed_value: U256
) -> Result<(), RequireError>
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]
&mut self,
beneficiary: Address,
real_used_gas: Gas,
preclaimed_value: U256,
fresh_account_state: &AccountState<'a, P::Account>
) -> Result<(), RequireError>
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]
&mut self,
fresh_account_state: &AccountState<'a, P::Account>
)
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]
patch: &'a P,
context: Context,
depth: usize,
account_state: AccountState<'a, P::Account>
) -> Self
Create a new runtime with the given states.
pub fn commit_account(
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
[src]
&mut self,
commitment: AccountCommitment
) -> Result<(), CommitError>
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> !Sync for Machine<'a, M, P>
impl<'a, M, P> !Send for Machine<'a, M, P>
impl<'a, M, P> Unpin for Machine<'a, M, P> where
M: Unpin,
M: Unpin,
impl<'a, M, P> !RefUnwindSafe for Machine<'a, M, P>
impl<'a, M, P> !UnwindSafe for Machine<'a, M, P>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self