diff --git a/src/evm/interpreter.cpp b/src/evm/interpreter.cpp index 983cff5b3..a479b3afd 100644 --- a/src/evm/interpreter.cpp +++ b/src/evm/interpreter.cpp @@ -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(); @@ -349,6 +350,13 @@ void BaseInterpreter::interpret() { const uint8_t OpcodeU8 = static_cast(OpcodeByte); const evmc_opcode Op = static_cast(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;