From 10967b8e5eaadc33f43d6774fa8a06d22fcd16e2 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 6 Aug 2024 09:12:10 -0300 Subject: [PATCH] vm: fix gas underflow Signed-off-by: Ignacio Hagopian --- core/vm/interpreter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index f355bb68a030..30c3ec0c3126 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -183,7 +183,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // if the PC ends up in a new "chunk" of verkleized code, charge the // associated costs. contractAddr := contract.Address() - contract.Gas -= in.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(contractAddr[:], pc, 1, uint64(len(contract.Code)), false) + if !contract.UseGas(in.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(contractAddr[:], pc, 1, uint64(len(contract.Code)), false)) { + return nil, ErrOutOfGas + } } // Get the operation from the jump table and validate the stack to ensure there are