Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-2935: Adjust gas-costs for 2935 #10380

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions core/vm/eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
)

var activators = map[int]func(*JumpTable){
2935: enable2935,
7516: enable7516,
6780: enable6780,
5656: enable5656,
Expand All @@ -38,6 +37,7 @@ var activators = map[int]func(*JumpTable){
3855: enable3855,
3529: enable3529,
3198: enable3198,
2935: enable2935,
2929: enable2929,
2200: enable2200,
1884: enable1884,
Expand Down Expand Up @@ -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
Expand All @@ -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
}
19 changes: 0 additions & 19 deletions core/vm/operations_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading