Skip to content

Commit

Permalink
core/vm: unconditionally pc++ in the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Nov 22, 2021
1 parent 39407c6 commit 122fb71
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
6 changes: 2 additions & 4 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down
4 changes: 1 addition & 3 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 122fb71

Please sign in to comment.