From 384ba784c5e23b03050c2d179d462b186239d018 Mon Sep 17 00:00:00 2001 From: Bui Quang Minh Date: Wed, 25 Dec 2024 11:27:32 +0700 Subject: [PATCH] core/vm: nil check memorySize instead of dynamicGas We have the assumption that if an opcode has memorySize function then it has dynamicGas function. And we check that condition of every opcode in validate function. But in the interpreter, we actually assume that if an opcode has dynamicGas then it has memorySize function. However, it is still correct as every opcode currently have either these 2 functions or none. So this commit is trivial, to make the interpreter consistent with asssumption in validate function to avoid confusion. --- core/vm/interpreter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 996ed6e56a..911599041c 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -258,7 +258,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( contract.Gas -= cost } - if operation.dynamicGas != nil { + if operation.memorySize != nil { // All ops with a dynamic memory usage also has a dynamic gas cost. var memorySize uint64 // calculate the new memory size and expand the memory to fit