Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/evm/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ void BaseInterpreter::interpret() {

size_t CodeSize = Mod->CodeSize;
Byte *Code = Mod->Code;
static const auto *MetricsTable =
evmc_get_instruction_metrics_table(DEFAULT_REVISION);
evmc_revision Revision = Context.getInstance()->getRevision();
const auto *MetricsTable = evmc_get_instruction_metrics_table(Revision);
const auto *NamesTable = evmc_get_instruction_names_table(Revision);
const auto &Cache = Mod->getBytecodeCache();
const uint8_t *__restrict JumpDestMap = Cache.JumpDestMap.data();
const intx::uint256 *__restrict PushValueMap = Cache.PushValueMap.data();
Expand All @@ -349,6 +350,13 @@ void BaseInterpreter::interpret() {
const uint8_t OpcodeU8 = static_cast<uint8_t>(OpcodeByte);
const evmc_opcode Op = static_cast<evmc_opcode>(OpcodeByte);

// EVMC does not have opcodes like MCOPY... in CANCUN
if (Revision < EVMC_CANCUN && NamesTable[Op] == NULL) {
// Undefined instruction
Context.setStatus(EVMC_UNDEFINED_INSTRUCTION);
break;
}

switch (Op) {
case evmc_opcode::OP_STOP: {
const uint64_t RemainingGas = Frame->Msg.gas;
Expand Down