Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::eth::Executive Class Reference

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)
 
 Executive (Block &_s, LastBlockHashesFace const &_lh, unsigned _level=0)
 
 Executive (State &io_s, Block const &_block, unsigned _txIndex, BlockChain const &_bc, unsigned _level=0)
 
 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)
 
bool finalize ()
 
bool execute ()
 
Transaction const & t () const
 
LogEntries const & logs () const
 
u256 gasUsed () const
 
owning_bytes_ref takeOutput ()
 
bool create (Address const &_txSender, u256 const &_endowment, u256 const &_gasPrice, u256 const &_gas, bytesConstRef _code, Address const &_originAddress)
 
bool createOpcode (Address const &_sender, u256 const &_endowment, u256 const &_gasPrice, u256 const &_gas, bytesConstRef _code, Address const &_originAddress)
 
bool create2Opcode (Address const &_sender, u256 const &_endowment, u256 const &_gasPrice, u256 const &_gas, bytesConstRef _code, Address const &_originAddress, u256 const &_salt)
 
bool call (Address const &_receiveAddress, Address const &_txSender, u256 const &_txValue, u256 const &_gasPrice, bytesConstRef _txData, u256 const &_gas)
 
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())
 
OnOpFunc simpleTrace ()
 Operation function for providing a simple trace of the VM execution. More...
 
u256 gas () const
 
Address newAddress () const
 
TransactionException getException () const noexcept
 
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...
 

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 103 of file Executive.h.

Constructor & Destructor Documentation

◆ Executive() [1/5]

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 107 of file Executive.h.

◆ Executive() [2/5]

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 182 of file Executive.cpp.

◆ Executive() [3/5]

Executive::Executive ( Block _s,
LastBlockHashesFace const &  _lh,
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 190 of file Executive.cpp.

◆ Executive() [4/5]

Executive::Executive ( State io_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 198 of file Executive.cpp.

◆ Executive() [5/5]

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

Member Function Documentation

◆ accrueSubState()

void Executive::accrueSubState ( SubState _parentContext)

Finalise an operation through accruing the substate into the parent context.

Definition at line 211 of file Executive.cpp.

◆ call() [1/2]

bool Executive::call ( Address const &  _receiveAddress,
Address const &  _txSender,
u256 const &  _txValue,
u256 const &  _gasPrice,
bytesConstRef  _txData,
u256 const &  _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 285 of file Executive.cpp.

◆ call() [2/2]

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

Definition at line 291 of file Executive.cpp.

◆ create()

bool Executive::create ( Address const &  _txSender,
u256 const &  _endowment,
u256 const &  _gasPrice,
u256 const &  _gas,
bytesConstRef  _code,
Address const &  _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 357 of file Executive.cpp.

◆ create2Opcode()

bool Executive::create2Opcode ( Address const &  _sender,
u256 const &  _endowment,
u256 const &  _gasPrice,
u256 const &  _gas,
bytesConstRef  _code,
Address const &  _originAddress,
u256 const &  _salt 
)
Returns
false iff go() must be called (and thus a VM execution in required).

Definition at line 370 of file Executive.cpp.

◆ createOpcode()

bool Executive::createOpcode ( Address const &  _sender,
u256 const &  _endowment,
u256 const &  _gasPrice,
u256 const &  _gas,
bytesConstRef  _code,
Address const &  _originAddress 
)
Returns
false iff go() must be called (and thus a VM execution in required).

Definition at line 363 of file Executive.cpp.

◆ execute()

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 269 of file Executive.cpp.

◆ finalize()

bool Executive::finalize ( )

Finalise a transaction previously set up with initialize().

Warning
Only valid after initialize() and execute(), and possibly go().
Returns
true if the outermost execution halted normally, false if exceptionally halted.

Definition at line 535 of file Executive.cpp.

◆ gas()

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

Definition at line 175 of file Executive.h.

◆ gasUsed()

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

Definition at line 206 of file Executive.cpp.

◆ getException()

TransactionException dev::eth::Executive::getException ( ) const
inlinenoexcept
Returns
The exception that has happened during the execution if any.

Definition at line 181 of file Executive.h.

◆ go()

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 441 of file Executive.cpp.

◆ initialize() [1/2]

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 132 of file Executive.h.

◆ initialize() [2/2]

void Executive::initialize ( Transaction const &  _transaction)

Definition at line 217 of file Executive.cpp.

◆ logs()

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

Definition at line 146 of file Executive.h.

◆ newAddress()

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

Definition at line 178 of file Executive.h.

◆ operator=()

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

◆ revert()

void Executive::revert ( )

Revert all changes made to the state by this execution.

Definition at line 575 of file Executive.cpp.

◆ setResultRecipient()

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

Collect execution results in the result storage provided.

Definition at line 184 of file Executive.h.

◆ simpleTrace()

OnOpFunc Executive::simpleTrace ( )

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

Definition at line 420 of file Executive.cpp.

◆ t()

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

Definition at line 143 of file Executive.h.

◆ takeOutput()

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

Definition at line 151 of file Executive.h.


The documentation for this class was generated from the following files:
dev::eth::Executive::Executive
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.
Definition: Executive.h:107