Skip to content

Commit

Permalink
core/vm: Define an operation for INVALID(0xfe)
Browse files Browse the repository at this point in the history
It is required to distinguish INVALID in the jump table from undefined opcodes.
  • Loading branch information
gumb0 committed Sep 29, 2022
1 parent e01fae2 commit acd5ca1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit acd5ca1

Please sign in to comment.