From 52685b4571ee7242952890d39de7f37d2cb7727e Mon Sep 17 00:00:00 2001 From: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:57:34 +0200 Subject: [PATCH] Update EIP-2935: Adjust gas-costs for 2935 (#12158) Cherry pick #10380 --- core/vm/eips.go | 18 +++--------------- core/vm/operations_acl.go | 19 ------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/core/vm/eips.go b/core/vm/eips.go index c05c41006fb..24e3f1b09e7 100644 --- a/core/vm/eips.go +++ b/core/vm/eips.go @@ -29,7 +29,6 @@ import ( ) var activators = map[int]func(*JumpTable){ - 2935: enable2935, 7516: enable7516, 6780: enable6780, 5656: enable5656, @@ -38,6 +37,7 @@ var activators = map[int]func(*JumpTable){ 3855: enable3855, 3529: enable3529, 3198: enable3198, + 2935: enable2935, 2929: enable2929, 2200: enable2200, 1884: enable1884, @@ -298,13 +298,7 @@ func opMcopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by // enable6780 applies EIP-6780 (deactivate SELFDESTRUCT) func enable6780(jt *JumpTable) { - jt[SELFDESTRUCT] = &operation{ - execute: opSelfdestruct6780, - dynamicGas: gasSelfdestructEIP3529, - constantGas: params.SelfdestructGasEIP150, - numPop: 1, - numPush: 0, - } + jt[SELFDESTRUCT].execute = opSelfdestruct6780 } // opBlobBaseFee implements the BLOBBASEFEE opcode @@ -331,11 +325,5 @@ func enable7516(jt *JumpTable) { // enable2935 applies EIP-2935 (Historical block hashes in state) func enable2935(jt *JumpTable) { - jt[BLOCKHASH] = &operation{ - execute: opBlockhash2935, - constantGas: GasExtStep, - dynamicGas: gasOpBlockhashEIP2935, - numPop: 1, - numPush: 1, - } + jt[BLOCKHASH].execute = opBlockhash2935 } diff --git a/core/vm/operations_acl.go b/core/vm/operations_acl.go index 1e1b68c6995..6256ae5740b 100644 --- a/core/vm/operations_acl.go +++ b/core/vm/operations_acl.go @@ -235,22 +235,3 @@ func makeSelfdestructGasFn(refundsEnabled bool) gasFunc { } return gasFunc } - -// gasOpBlockhashEIP2935 returns the gas for the new BLOCKHASH operation post EIP-2935 -// If arg is outside of the params.BlockHashHistoryServeWindow, zero dynamic gas is returned -// EIP-2929 Cold/Warm storage read cost is applicable here similar to SLOAD -func gasOpBlockhashEIP2935(evm *EVM, contract *Contract, stack *stack.Stack, mem *Memory, memorySize uint64) (uint64, error) { - arg := stack.Peek() - arg64, overflow := arg.Uint64WithOverflow() - if overflow { - return 0, nil - } - if arg64 >= evm.Context.BlockNumber || arg64+params.BlockHashHistoryServeWindow < evm.Context.BlockNumber { - return 0, nil - } - storageSlot := libcommon.BytesToHash(uint256.NewInt(arg64 % params.BlockHashHistoryServeWindow).Bytes()) - if _, slotMod := evm.IntraBlockState().AddSlotToAccessList(params.HistoryStorageAddress, storageSlot); slotMod { - return params.ColdSloadCostEIP2929, nil - } - return params.WarmStorageReadCostEIP2929, nil -}