13 EVM::EVM(evmc_instance* _instance) noexcept : m_instance(_instance)
15 assert(m_instance !=
nullptr);
16 assert(evmc_is_abi_compatible(m_instance));
21 auto result = evmc_set_option(m_instance, pair.first.c_str(), pair.second.c_str());
24 case EVMC_SET_OPTION_SUCCESS:
26 case EVMC_SET_OPTION_INVALID_NAME:
27 cwarn <<
"Unknown EVMC option '" << pair.first <<
"'";
29 case EVMC_SET_OPTION_INVALID_VALUE:
30 cwarn <<
"Invalid value '" << pair.second <<
"' for EVMC option '" << pair.first <<
"'";
33 cwarn <<
"Unknown error when setting EVMC option '" << pair.first <<
"'";
42 evmc_call_kind
kind = _ext.
isCreate ? EVMC_CREATE : EVMC_CALL;
43 uint32_t flags = _ext.
staticCall ? EVMC_STATIC : 0;
44 assert(flags != EVMC_STATIC ||
kind == EVMC_CALL);
49 evmc_execute(m_instance, &_ext, mode, &msg, _ext.
code.data(), _ext.
code.size())};
57 constexpr int64_t int64max = std::numeric_limits<int64_t>::max();
62 assert(io_gas <= int64max);
64 assert(_ext.
depth <= static_cast<size_t>(std::numeric_limits<int32_t>::max()));
66 auto gas =
static_cast<int64_t
>(io_gas);
85 case EVMC_INVALID_INSTRUCTION:
86 case EVMC_UNDEFINED_INSTRUCTION:
89 case EVMC_BAD_JUMP_DESTINATION:
92 case EVMC_STACK_OVERFLOW:
95 case EVMC_STACK_UNDERFLOW:
98 case EVMC_INVALID_MEMORY_ACCESS:
99 BOOST_THROW_EXCEPTION(BufferOverrun());
101 case EVMC_STATIC_MODE_VIOLATION:
102 BOOST_THROW_EXCEPTION(DisallowedStateChange());
105 cwarn <<
"Execution rejected by EVMC, executing with default VM implementation";
108 case EVMC_INTERNAL_ERROR:
110 if (r.
status() <= EVMC_INTERNAL_ERROR)
122 return EVMC_CONSTANTINOPLE;
124 return EVMC_BYZANTIUM;
126 return EVMC_SPURIOUS_DRAGON;
128 return EVMC_TANGERINE_WHISTLE;
130 return EVMC_HOMESTEAD;
131 return EVMC_FRONTIER;
owning_bytes_ref exec(u256 &io_gas, ExtVMFace &_ext, OnOpFunc const &_onOp) final
VM implementation.
std::vector< std::pair< std::string, std::string > > & evmcOptions() noexcept
Returns the EVMC options parsed from command line.
static VMPtr create()
Creates a VM instance of the global kind (controlled by the –vm command line option).
std::function< void(uint64_t, uint64_t, Instruction, bigint, bigint, bigint, VMFace const *, ExtVMFace const *)> OnOpFunc
u256 value
Value (in Wei) that was passed to this address.
evmc_status_code status() const
virtual EVMSchedule const & evmSchedule() const
Return the EVM gas-price schedule for this execution context.
evmc_address toEvmC(Address const &_addr)
static evmc_revision toRevision(EVMSchedule const &_schedule)
Translate the EVMSchedule to EVMC revision.
Ran out of stack executing code of the transaction.
bytesConstRef output() const
EVM(evmc_instance *_instance) noexcept
bool staticCall
Throw on state changing.
Ran out of gas executing code of the transaction.
Address caller
Address which sent the message (either equal to origin or a contract).
Result execute(ExtVMFace &_ext, int64_t gas)
Handy wrapper for evmc_execute().
unsigned depth
Depth of the present call.
u256 const & gasLimit() const
Interface and null implementation of the class for specifying VM externalities.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
bytes code
Current code that is executing.
Address myAddress
Address associated with executing code (a contract, or contract-to-be).
bool isCreate
Is this a CREATE call?
std::vector< mutable_value_type > toVector() const
boost::error_info< struct tag_evmcStatusCode, evmc_status_code > errinfo_evmcStatusCode
Error info for EVMC status code.
EnvInfo const & envInfo() const
Get the execution environment information.
bytesConstRef data
Current input data.
int64_t timestamp() const