Fabcoin Core
0.16.2
P2P Digital Currency
|
Message-call/contract-creation executor; useful for executing transactions. More...
#include <Executive.h>
Public Member Functions | |
Executive (State &_s, EnvInfo const &_envInfo, SealEngineFace const &_sealEngine, unsigned _level=0) | |
Simple constructor; executive will operate on given state, with the given environment info. More... | |
Executive (Block &_s, BlockChain const &_bc, unsigned _level=0) | |
Easiest constructor. More... | |
Executive (Block &_s, LastHashes const &_lh=LastHashes(), unsigned _level=0) | |
LastHashes-split constructor. More... | |
Executive (State &_s, Block const &_block, unsigned _txIndex, BlockChain const &_bc, unsigned _level=0) | |
Previous-state constructor. More... | |
Executive (Executive const &)=delete | |
void | operator= (Executive)=delete |
void | initialize (bytesConstRef _transaction) |
Initializes the executive for evaluating a transaction. You must call finalize() at some point following this. More... | |
void | initialize (Transaction const &_transaction) |
void | finalize () |
Finalise a transaction previously set up with initialize(). More... | |
bool | execute () |
Begins execution of a transaction. More... | |
Transaction const & | t () const |
LogEntries const & | logs () const |
u256 | gasUsed () const |
owning_bytes_ref | takeOutput () |
bool | create (Address _txSender, u256 _endowment, u256 _gasPrice, u256 _gas, bytesConstRef _code, Address _originAddress) |
Set up the executive for evaluating a bare CREATE (contract-creation) operation. More... | |
bool | call (Address _receiveAddress, Address _txSender, u256 _txValue, u256 _gasPrice, bytesConstRef _txData, u256 _gas) |
Set up the executive for evaluating a bare CALL (message call) operation. More... | |
bool | call (CallParameters const &_cp, u256 const &_gasPrice, Address const &_origin) |
void | accrueSubState (SubState &_parentContext) |
Finalise an operation through accruing the substate into the parent context. More... | |
bool | go (OnOpFunc const &_onOp=OnOpFunc()) |
Executes (or continues execution of) the VM. More... | |
u256 | gas () const |
Address | newAddress () const |
bool | excepted () const |
void | setResultRecipient (ExecutionResult &_res) |
Collect execution results in the result storage provided. More... | |
void | revert () |
Revert all changes made to the state by this execution. More... | |
Static Public Member Functions | |
static OnOpFunc | simpleTrace () |
Operation function for providing a simple trace of the VM execution. More... | |
static OnOpFunc | standardTrace (std::ostream &o_output) |
Operation function for providing a simple trace of the VM execution. More... | |
Private Attributes | |
State & | m_s |
The state to which this operation/transaction is applied. More... | |
EnvInfo | m_envInfo |
Information on the runtime environment. More... | |
std::shared_ptr< ExtVM > | m_ext |
The VM externality object for the VM execution or null if no VM is required. shared_ptr used only to allow ExtVM forward reference. This field does NOT survive this object. More... | |
owning_bytes_ref | m_output |
Execution output. More... | |
ExecutionResult * | m_res = nullptr |
Optional storage for execution results. More... | |
unsigned | m_depth = 0 |
The context's call-depth. More... | |
TransactionException | m_excepted = TransactionException::None |
Details if the VM's execution resulted in an exception. More... | |
int64_t | m_baseGasRequired |
The base amount of gas requried for executing this transaction. More... | |
u256 | m_gas = 0 |
The gas for EVM code execution. Initial amount before go() execution, final amount after go() execution. More... | |
u256 | m_refunded = 0 |
The amount of gas refunded. More... | |
Transaction | m_t |
The original transaction. Set by setup(). More... | |
LogEntries | m_logs |
The log entries created by this transaction. Set by finalize(). More... | |
u256 | m_gasCost |
SealEngineFace const & | m_sealEngine |
bool | m_isCreation = false |
Address | m_newAddress |
size_t | m_savepoint = 0 |
Message-call/contract-creation executor; useful for executing transactions.
Two ways of using this class - either as a transaction executive or a CALL/CREATE executive.
In the first use, after construction, begin with initialize(), then execute() and end with finalize(). Call go() after execute() only if it returns false.
In the second use, after construction, begin with call() or create() and end with accrueSubState(). Call go() after call()/create() only if it returns false.
Example:
Definition at line 106 of file Executive.h.
|
inline |
Simple constructor; executive will operate on given state, with the given environment info.
Definition at line 110 of file Executive.h.
Executive::Executive | ( | Block & | _s, |
BlockChain const & | _bc, | ||
unsigned | _level = 0 |
||
) |
Easiest constructor.
Creates executive to operate on the state of end of the given block, populating environment info from given Block and the LastHashes portion from the BlockChain.
Definition at line 159 of file Executive.cpp.
Executive::Executive | ( | Block & | _s, |
LastHashes const & | _lh = LastHashes() , |
||
unsigned | _level = 0 |
||
) |
LastHashes-split constructor.
Creates executive to operate on the state of end of the given block, populating environment info accordingly, with last hashes given explicitly.
Definition at line 167 of file Executive.cpp.
Executive::Executive | ( | State & | _s, |
Block const & | _block, | ||
unsigned | _txIndex, | ||
BlockChain const & | _bc, | ||
unsigned | _level = 0 |
||
) |
Previous-state constructor.
Creates executive to operate on the state of a particular transaction in the given block, populating environment info from the given Block and the LastHashes portion from the BlockChain. State is assigned the resultant value, but otherwise unused.
Definition at line 175 of file Executive.cpp.
|
delete |
void Executive::accrueSubState | ( | SubState & | _parentContext | ) |
Finalise an operation through accruing the substate into the parent context.
Definition at line 188 of file Executive.cpp.
bool Executive::call | ( | Address | _receiveAddress, |
Address | _txSender, | ||
u256 | _txValue, | ||
u256 | _gasPrice, | ||
bytesConstRef | _txData, | ||
u256 | _gas | ||
) |
Set up the executive for evaluating a bare CALL (message call) operation.
Definition at line 261 of file Executive.cpp.
bool Executive::call | ( | CallParameters const & | _cp, |
u256 const & | _gasPrice, | ||
Address const & | _origin | ||
) |
bool Executive::create | ( | Address | _txSender, |
u256 | _endowment, | ||
u256 | _gasPrice, | ||
u256 | _gas, | ||
bytesConstRef | _code, | ||
Address | _originAddress | ||
) |
Set up the executive for evaluating a bare CREATE (contract-creation) operation.
Definition at line 333 of file Executive.cpp.
|
inline |
Definition at line 181 of file Executive.h.
bool Executive::execute | ( | ) |
Begins execution of a transaction.
You must call finalize() following this.
Definition at line 247 of file Executive.cpp.
void Executive::finalize | ( | ) |
Finalise a transaction previously set up with initialize().
Definition at line 466 of file Executive.cpp.
|
inline |
Definition at line 176 of file Executive.h.
u256 Executive::gasUsed | ( | ) | const |
Definition at line 183 of file Executive.cpp.
Executes (or continues execution of) the VM.
Definition at line 386 of file Executive.cpp.
|
inline |
Initializes the executive for evaluating a transaction. You must call finalize() at some point following this.
Definition at line 135 of file Executive.h.
void Executive::initialize | ( | Transaction const & | _transaction | ) |
|
inline |
Definition at line 148 of file Executive.h.
|
inline |
Definition at line 179 of file Executive.h.
|
delete |
void Executive::revert | ( | ) |
Revert all changes made to the state by this execution.
Definition at line 503 of file Executive.cpp.
|
inline |
Collect execution results in the result storage provided.
Definition at line 184 of file Executive.h.
|
static |
Operation function for providing a simple trace of the VM execution.
Definition at line 366 of file Executive.cpp.
|
static |
Operation function for providing a simple trace of the VM execution.
|
inline |
Definition at line 145 of file Executive.h.
|
inline |
Definition at line 153 of file Executive.h.
|
private |
The base amount of gas requried for executing this transaction.
Definition at line 199 of file Executive.h.
|
private |
The context's call-depth.
Definition at line 197 of file Executive.h.
|
private |
Information on the runtime environment.
Definition at line 192 of file Executive.h.
|
private |
Details if the VM's execution resulted in an exception.
Definition at line 198 of file Executive.h.
|
private |
|
private |
The gas for EVM code execution. Initial amount before go() execution, final amount after go() execution.
Definition at line 200 of file Executive.h.
|
private |
Definition at line 206 of file Executive.h.
|
private |
Definition at line 209 of file Executive.h.
|
private |
The log entries created by this transaction. Set by finalize().
Definition at line 204 of file Executive.h.
|
private |
Definition at line 210 of file Executive.h.
|
private |
Execution output.
Definition at line 194 of file Executive.h.
|
private |
The amount of gas refunded.
Definition at line 201 of file Executive.h.
|
private |
Optional storage for execution results.
Definition at line 195 of file Executive.h.
|
private |
The state to which this operation/transaction is applied.
Definition at line 190 of file Executive.h.
|
private |
Definition at line 211 of file Executive.h.
|
private |
Definition at line 207 of file Executive.h.
|
private |
The original transaction. Set by setup().
Definition at line 203 of file Executive.h.