From e2fa55a48f352e8fdb3ec84aa80e6f49baeb7878 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Mon, 29 Nov 2021 13:18:27 +0100 Subject: [PATCH] core/vm: Define an operation for INVALID(0xfe) It is required to distinguish INVALID in the jump table from undefined opcodes. --- core/vm/instructions.go | 4 ++++ core/vm/jump_table.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index cb31970454d9..3de9d51dbc4f 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -819,6 +819,10 @@ func opStop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt return nil, errStopToken } +func opInvalid(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { + return nil, &ErrInvalidOpCode{opcode: INVALID} +} + func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { if interpreter.readOnly { return nil, ErrWriteProtection diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 25024c17aef9..5e55f18e2d0d 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -1028,6 +1028,12 @@ func newFrontierInstructionSet() JumpTable { maxStack: maxStack(2, 0), memorySize: memoryReturn, }, + INVALID: { + execute: opInvalid, + constantGas: 0, + minStack: minStack(0, 0), + maxStack: maxStack(0, 0), + }, SELFDESTRUCT: { execute: opSelfdestruct, dynamicGas: gasSelfdestruct,