From 122fb7175e1e00a1a3b3fa4067c83df7813b5cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 22 Nov 2021 19:07:31 +0100 Subject: [PATCH] core/vm: unconditionally pc++ in the loop --- core/vm/instructions.go | 6 ++---- core/vm/interpreter.go | 4 +--- core/vm/jump_table.go | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 8c68db848daf..bdd8ac3f9bda 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -526,7 +526,7 @@ func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt if !scope.Contract.validJumpdest(&pos) { return nil, ErrInvalidJump } - *pc = pos.Uint64() + *pc = pos.Uint64() - 1 // pc will be increased by the interpreter loop return nil, nil } @@ -536,9 +536,7 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by if !scope.Contract.validJumpdest(&pos) { return nil, ErrInvalidJump } - *pc = pos.Uint64() - } else { - *pc++ + *pc = pos.Uint64() - 1 // pc will be increased by the interpreter loop } return nil, nil } diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 7530ed693c28..7a30d60b3f3f 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -268,9 +268,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( if err != nil { break } - if !operation.jumps { - pc++ - } + pc++ } if err == errStopToken { diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 967f7632e06e..f6023b617073 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -526,14 +526,12 @@ func newFrontierInstructionSet() JumpTable { constantGas: GasMidStep, minStack: minStack(1, 0), maxStack: maxStack(1, 0), - jumps: true, }, JUMPI: { execute: opJumpi, constantGas: GasSlowStep, minStack: minStack(2, 0), maxStack: maxStack(2, 0), - jumps: true, }, PC: { execute: opPc,