 |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
Go to the documentation of this file.
24 #include <boost/thread.hpp>
33 static unsigned const c_depthLimit = 1024;
36 static size_t const c_singleExecutionStackSize = 100 * 1024;
39 static size_t const c_defaultStackSize =
49 static size_t const c_entryOverhead = 128 * 1024;
52 static unsigned const c_offloadPoint = (c_defaultStackSize - c_entryOverhead) / c_singleExecutionStackSize;
57 boost::thread::attributes attrs;
58 attrs.set_stack_size((c_depthLimit - c_offloadPoint) * c_singleExecutionStackSize);
62 boost::exception_ptr exception;
63 boost::thread{attrs, [&]{
70 exception = boost::current_exception();
74 boost::rethrow_exception(exception);
84 if (_depth == c_offloadPoint)
86 cnote <<
"Stack offloading (depth: " << c_offloadPoint <<
")";
87 goOnOffloadedStack(_e, _onOp);
104 return EVMC_OUT_OF_GAS;
107 return EVMC_UNDEFINED_INSTRUCTION;
110 return EVMC_STACK_OVERFLOW;
113 return EVMC_STACK_UNDERFLOW;
115 case TransactionException ::BadJumpDestination:
116 return EVMC_BAD_JUMP_DESTINATION;
132 e.accrueSubState(
sub);
136 return {transactionExceptionToEvmcStatusCode(e.getException()), e.takeOutput()};
169 e.accrueSubState(
sub);
172 return {transactionExceptionToEvmcStatusCode(e.getException()), e.takeOutput(), e.newAddress()};
190 if (_number >= currentNumber || _number < (std::max<u256>(256, currentNumber) - 256))
198 assert(lastHashes.size() > (
unsigned)(currentNumber - 1 - _number));
199 return lastHashes[(unsigned)(currentNumber - 1 - _number)];
203 u256 const gas = 1000000;
std::function< void(uint64_t, uint64_t, Instruction, bigint, bigint, bigint, VMFace const *, ExtVMFace const *)> OnOpFunc
bool go(OnOpFunc const &_onOp=OnOpFunc())
@ OutOfStack
Ran out of stack executing code of the transaction.
virtual void suicide(Address)
Suicide the associated contract and give proceeds to the given address.
Encodes a transaction, ready to be exported to or freshly imported from RLP.
void toBigEndian(T _val, Out &o_out)
SubState sub
Sub-band VM state (suicides, refund counter, logs).
BlockHeader const & header() const
void setStore(u256 _n, u256 _v) final
Write a value in storage.
@ CREATE
create a new account with associated code
u256 experimentalForkBlock
void suicide(Address _a) final
Suicide the associated contract to the given address.
u256 getNonce(Address const &_addr) const
ChainOperationParams const & chainParams() const
size_t codeSize(Address const &_contract) const
void setBalance(Address const &_addr, u256 const &_value)
void addBalance(Address const &_id, u256 const &_amount)
Address myAddress
Address associated with executing code (a contract, or contract-to-be).
u256 gasPrice
Price of gas (that we already paid).
bool exists(Address _a) final
Does the account exist?
std::vector< h256 > h256s
unsigned depth
Depth of the present call.
LastBlockHashesFace const & lastHashes() const
Message-call/contract-creation executor; useful for executing transactions.
const Address c_blockhashContractAddress(0xf0)
Address of the special contract for block hash storage defined in EIP96.
size_t codeSizeAt(Address _a) final
Instruction
Virtual machine bytecode instruction.
Address caller
Address which sent the message (either equal to origin or a contract).
void setStorage(Address const &_contract, u256 const &_location, u256 const &_value)
Set the value of a storage position of an account.
CallResult call(CallParameters &_params) final
Create a new message call.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
h256 codeHashAt(Address _a) final
h256 blockHash(u256 _number) final
Hash of a block if within the last 256 blocks, or h256() otherwise.
CreateResult create(u256 _endowment, u256 &io_gas, bytesConstRef _code, Instruction _op, u256 _salt, OnOpFunc const &_onOp={}) final
Create a new contract.
virtual h256s precedingHashes(h256 const &_mostRecentHash) const =0
u256 balance(Address const &_id) const
h256 codeHash(Address const &_contract) const
Description of the result of executing a transaction.
EnvInfo const & envInfo() const
Get the execution environment information.
@ OutOfGas
Ran out of gas executing code of the transaction.
std::pair< ExecutionResult, TransactionReceipt > execute(EnvInfo const &_envInfo, SealEngineFace const &_sealEngine, Transaction const &_t, Permanence _p=Permanence::Committed, OnOpFunc const &_onOp=OnOpFunc())
void forceSender(Address const &_a)
Force the sender to a particular value. This will result in an invalid transaction RLP.
@ CREATE2
create a new account with associated code. sha3((sender + salt + code)
Address origin
Original transactor.