Struct sputnikvm::Machine

source ·
pub struct Machine<M, P: Patch> { /* private fields */ }
Expand description

A VM state with PC.

Implementations

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.

Initialize a MessageCall transaction.

Panic

Requires caller of the transaction to be committed.

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

Panic

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

Initialize a ContractCreation transaction.

Panic

Requires caller of the transaction to be committed.

Initialize the runtime as a call from a CREATE opcode.

Panic

Requires caller of the CREATE opcode to be committed.

Deposit code for a ContractCreation transaction or a CREATE opcode.

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.

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.

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.

Create a new runtime.

Create a new runtime with the given states.

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.

Commit a new account into this runtime.

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

Peek the next instruction.

Peek the next opcode.

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.

Get the runtime state.

Get the runtime PC.

Get the current runtime status.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.