From e57dee4c65104396f2d43470b7d08f1ca701b0ac Mon Sep 17 00:00:00 2001 From: Francesco4203 Date: Mon, 8 Jul 2024 18:02:41 +0700 Subject: [PATCH] core/vm: merge opJumpdest to opJump/opJumpi --- core/vm/instructions.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 0ead197a10..e618132785 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -526,6 +526,13 @@ func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt return nil, ErrInvalidJump } *pc = pos.Uint64() + + // Next instruction is definitely opJumpDest, which does nothing, so execute it immediately by consuming the gas required and skipping it + interpreter.evm.Context.Counter++ + if !scope.Contract.UseGas(params.JumpdestGas) { + return nil, ErrOutOfGas + } + *pc++ return nil, nil } @@ -536,6 +543,13 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by return nil, ErrInvalidJump } *pc = pos.Uint64() + + // Next instruction is definitely opJumpDest, which does nothing, so execute it immediately by consuming the gas required and skipping it + interpreter.evm.Context.Counter++ + if !scope.Contract.UseGas(params.JumpdestGas) { + return nil, ErrOutOfGas + } + *pc++ } else { *pc++ }