Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
dev::eth::Executive Class Reference

Message-call/contract-creation executor; useful for executing transactions. More...

#include <Executive.h>

Collaboration diagram for dev::eth::Executive:
[legend]

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

Statem_s
 The state to which this operation/transaction is applied. More...
 
EnvInfo m_envInfo
 Information on the runtime environment. More...
 
std::shared_ptr< ExtVMm_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...
 
ExecutionResultm_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
 

Detailed Description

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:

Executive e(state, blockchain, 0);
e.initialize(transaction);
if (!e.execute())
e.go();
e.finalize();

Definition at line 106 of file Executive.h.

Constructor & Destructor Documentation

dev::eth::Executive::Executive ( State _s,
EnvInfo const &  _envInfo,
SealEngineFace const &  _sealEngine,
unsigned  _level = 0 
)
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.

dev::eth::Executive::Executive ( Executive const &  )
delete

Member Function Documentation

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.

Returns
false iff go() must be called (and thus a VM execution in required).

Definition at line 261 of file Executive.cpp.

Here is the caller graph for this function:

bool Executive::call ( CallParameters const &  _cp,
u256 const &  _gasPrice,
Address const &  _origin 
)

Definition at line 267 of file Executive.cpp.

Here is the call graph for this function:

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.

Returns
false iff go() must be called (and thus a VM execution in required).

Definition at line 333 of file Executive.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool dev::eth::Executive::excepted ( ) const
inline
Returns
true iff the operation ended with a VM exception.

Definition at line 181 of file Executive.h.

bool Executive::execute ( )

Begins execution of a transaction.

You must call finalize() following this.

Returns
true if the transaction is done, false if go() must be called.

Definition at line 247 of file Executive.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Executive::finalize ( )

Finalise a transaction previously set up with initialize().

Warning
Only valid after initialize() and execute(), and possibly go().

Definition at line 466 of file Executive.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

u256 dev::eth::Executive::gas ( ) const
inline
Returns
gas remaining after the transaction/operation. Valid after the transaction has been executed.

Definition at line 176 of file Executive.h.

Here is the caller graph for this function:

u256 Executive::gasUsed ( ) const
Returns
total gas used in the transaction/operation.
Warning
Only valid after finalise().

Definition at line 183 of file Executive.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Executive::go ( OnOpFunc const &  _onOp = OnOpFunc())

Executes (or continues execution of) the VM.

Returns
false iff go() must be called again to finish the transaction.

Definition at line 386 of file Executive.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::Executive::initialize ( bytesConstRef  _transaction)
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.

Here is the call graph for this function:

Here is the caller graph for this function:

void Executive::initialize ( Transaction const &  _transaction)

Definition at line 194 of file Executive.cpp.

Here is the call graph for this function:

LogEntries const& dev::eth::Executive::logs ( ) const
inline
Returns
the log entries created by this operation.
Warning
Only valid after finalise().

Definition at line 148 of file Executive.h.

Here is the caller graph for this function:

Address dev::eth::Executive::newAddress ( ) const
inline
Returns
the new address for the created contract in the CREATE operation.

Definition at line 179 of file Executive.h.

void dev::eth::Executive::operator= ( Executive  )
delete
void Executive::revert ( )

Revert all changes made to the state by this execution.

Definition at line 503 of file Executive.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::eth::Executive::setResultRecipient ( ExecutionResult _res)
inline

Collect execution results in the result storage provided.

Definition at line 184 of file Executive.h.

Here is the caller graph for this function:

OnOpFunc Executive::simpleTrace ( )
static

Operation function for providing a simple trace of the VM execution.

Definition at line 366 of file Executive.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static OnOpFunc dev::eth::Executive::standardTrace ( std::ostream &  o_output)
static

Operation function for providing a simple trace of the VM execution.

Transaction const& dev::eth::Executive::t ( ) const
inline
Returns
the transaction from initialize().
Warning
Only valid after initialize().

Definition at line 145 of file Executive.h.

Here is the caller graph for this function:

owning_bytes_ref dev::eth::Executive::takeOutput ( )
inline

Definition at line 153 of file Executive.h.

Member Data Documentation

int64_t dev::eth::Executive::m_baseGasRequired
private

The base amount of gas requried for executing this transaction.

Definition at line 199 of file Executive.h.

unsigned dev::eth::Executive::m_depth = 0
private

The context's call-depth.

Definition at line 197 of file Executive.h.

EnvInfo dev::eth::Executive::m_envInfo
private

Information on the runtime environment.

Definition at line 192 of file Executive.h.

TransactionException dev::eth::Executive::m_excepted = TransactionException::None
private

Details if the VM's execution resulted in an exception.

Definition at line 198 of file Executive.h.

std::shared_ptr<ExtVM> dev::eth::Executive::m_ext
private

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.

Definition at line 193 of file Executive.h.

u256 dev::eth::Executive::m_gas = 0
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.

u256 dev::eth::Executive::m_gasCost
private

Definition at line 206 of file Executive.h.

bool dev::eth::Executive::m_isCreation = false
private

Definition at line 209 of file Executive.h.

LogEntries dev::eth::Executive::m_logs
private

The log entries created by this transaction. Set by finalize().

Definition at line 204 of file Executive.h.

Address dev::eth::Executive::m_newAddress
private

Definition at line 210 of file Executive.h.

owning_bytes_ref dev::eth::Executive::m_output
private

Execution output.

Definition at line 194 of file Executive.h.

u256 dev::eth::Executive::m_refunded = 0
private

The amount of gas refunded.

Definition at line 201 of file Executive.h.

ExecutionResult* dev::eth::Executive::m_res = nullptr
private

Optional storage for execution results.

Definition at line 195 of file Executive.h.

State& dev::eth::Executive::m_s
private

The state to which this operation/transaction is applied.

Definition at line 190 of file Executive.h.

size_t dev::eth::Executive::m_savepoint = 0
private

Definition at line 211 of file Executive.h.

SealEngineFace const& dev::eth::Executive::m_sealEngine
private

Definition at line 207 of file Executive.h.

Transaction dev::eth::Executive::m_t
private

The original transaction. Set by setup().

Definition at line 203 of file Executive.h.


The documentation for this class was generated from the following files: