core/vm: mark the correct address as touched

This commit is contained in:
Marius van der Wijden 2024-06-28 10:18:39 +02:00
parent dc4d53b83c
commit e0c3db0de4
2 changed files with 9 additions and 9 deletions

View file

@ -725,14 +725,14 @@ func enableEOF(jt *JumpTable) {
jt[EXTCALL] = &operation{ jt[EXTCALL] = &operation{
execute: opExtCall, execute: opExtCall,
constantGas: params.WarmStorageReadCostEIP2929, constantGas: params.WarmStorageReadCostEIP2929,
dynamicGas: makeCallVariantGasCallEIP2929(gasExtCall), dynamicGas: makeCallVariantGasCallEIP2929(gasExtCall, 0),
minStack: minStack(4, 1), minStack: minStack(4, 1),
maxStack: maxStack(4, 1), maxStack: maxStack(4, 1),
memorySize: memoryExtCall, memorySize: memoryExtCall,
} }
jt[EXTDELEGATECALL] = &operation{ jt[EXTDELEGATECALL] = &operation{
execute: opExtDelegateCall, execute: opExtDelegateCall,
dynamicGas: makeCallVariantGasCallEIP2929(gasExtDelegateCall), dynamicGas: makeCallVariantGasCallEIP2929(gasExtDelegateCall, 0),
constantGas: params.WarmStorageReadCostEIP2929, constantGas: params.WarmStorageReadCostEIP2929,
minStack: minStack(3, 1), minStack: minStack(3, 1),
maxStack: maxStack(3, 1), maxStack: maxStack(3, 1),
@ -741,7 +741,7 @@ func enableEOF(jt *JumpTable) {
jt[EXTSTATICCALL] = &operation{ jt[EXTSTATICCALL] = &operation{
execute: opExtStaticCall, execute: opExtStaticCall,
constantGas: params.WarmStorageReadCostEIP2929, constantGas: params.WarmStorageReadCostEIP2929,
dynamicGas: makeCallVariantGasCallEIP2929(gasExtStaticCall), dynamicGas: makeCallVariantGasCallEIP2929(gasExtStaticCall, 0),
minStack: minStack(3, 1), minStack: minStack(3, 1),
maxStack: maxStack(3, 1), maxStack: maxStack(3, 1),
memorySize: memoryExtStaticCall, memorySize: memoryExtStaticCall,

View file

@ -159,9 +159,9 @@ func gasEip2929AccountCheck(evm *EVM, contract *Contract, stack *Stack, mem *Mem
return 0, nil return 0, nil
} }
func makeCallVariantGasCallEIP2929(oldCalculator gasFunc) gasFunc { func makeCallVariantGasCallEIP2929(oldCalculator gasFunc, addrPosition int) gasFunc {
return func(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { return func(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
addr := common.Address(stack.Back(1).Bytes20()) addr := common.Address(stack.Back(addrPosition).Bytes20())
// Check slot presence in the access list // Check slot presence in the access list
warmAccess := evm.StateDB.AddressInAccessList(addr) warmAccess := evm.StateDB.AddressInAccessList(addr)
// The WarmStorageReadCostEIP2929 (100) is already deducted in the form of a constant cost, so // The WarmStorageReadCostEIP2929 (100) is already deducted in the form of a constant cost, so
@ -199,10 +199,10 @@ func makeCallVariantGasCallEIP2929(oldCalculator gasFunc) gasFunc {
} }
var ( var (
gasCallEIP2929 = makeCallVariantGasCallEIP2929(gasCall) gasCallEIP2929 = makeCallVariantGasCallEIP2929(gasCall, 1)
gasDelegateCallEIP2929 = makeCallVariantGasCallEIP2929(gasDelegateCall) gasDelegateCallEIP2929 = makeCallVariantGasCallEIP2929(gasDelegateCall, 1)
gasStaticCallEIP2929 = makeCallVariantGasCallEIP2929(gasStaticCall) gasStaticCallEIP2929 = makeCallVariantGasCallEIP2929(gasStaticCall, 1)
gasCallCodeEIP2929 = makeCallVariantGasCallEIP2929(gasCallCode) gasCallCodeEIP2929 = makeCallVariantGasCallEIP2929(gasCallCode, 1)
gasSelfdestructEIP2929 = makeSelfdestructGasFn(true) gasSelfdestructEIP2929 = makeSelfdestructGasFn(true)
// gasSelfdestructEIP3529 implements the changes in EIP-3529 (no refunds) // gasSelfdestructEIP3529 implements the changes in EIP-3529 (no refunds)
gasSelfdestructEIP3529 = makeSelfdestructGasFn(false) gasSelfdestructEIP3529 = makeSelfdestructGasFn(false)