Skip to content

Commit

Permalink
core/vm: rm dynamic gas calculators for core reading ops
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Dec 16, 2024
1 parent f3a427e commit e4e381d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
3 changes: 0 additions & 3 deletions core/vm/eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,12 @@ func opExtCodeHashEIP7702(pc *uint64, interpreter *EVMInterpreter, scope *ScopeC
func enable7702(jt *JumpTable) {
jt[EXTCODECOPY].execute = opExtCodeCopyEIP7702
jt[EXTCODECOPY].constantGas = params.WarmStorageReadCostEIP2929
jt[EXTCODECOPY].dynamicGas = gasExtCodeCopyEIP7702

jt[EXTCODESIZE].execute = opExtCodeSizeEIP7702
jt[EXTCODESIZE].constantGas = params.WarmStorageReadCostEIP2929
jt[EXTCODESIZE].dynamicGas = gasEip7702CodeCheck

jt[EXTCODEHASH].execute = opExtCodeHashEIP7702
jt[EXTCODEHASH].constantGas = params.WarmStorageReadCostEIP2929
jt[EXTCODEHASH].dynamicGas = gasEip7702CodeCheck

jt[CALL].constantGas = params.WarmStorageReadCostEIP2929
jt[CALL].dynamicGas = gasCallEIP7702
Expand Down
38 changes: 0 additions & 38 deletions core/vm/operations_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,41 +310,3 @@ func makeCallVariantGasCallEIP7702(oldCalculator gasFunc) gasFunc {
return total, nil
}
}

func gasEip7702CodeCheck(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
cost, _ := gasEip2929AccountCheck(evm, contract, stack, mem, memorySize)
// Check if code is a delegation and if so, charge for resolution
addr := common.Address(stack.peek().Bytes20())
if addr, ok := types.ParseDelegation(evm.StateDB.GetCode(addr)); ok {
if evm.StateDB.AddressInAccessList(addr) {
cost += params.WarmStorageReadCostEIP2929
} else {
evm.StateDB.AddAddressToAccessList(addr)
cost += params.ColdAccountAccessCostEIP2929
}
}
return cost, nil
}

func gasExtCodeCopyEIP7702(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
gas, err := gasExtCodeCopyEIP2929(evm, contract, stack, mem, memorySize)
if err != nil {
return 0, err
}
// Check if code is a delegation and if so, charge for resolution
addr := common.Address(stack.peek().Bytes20())
if addr, ok := types.ParseDelegation(evm.StateDB.GetCode(addr)); ok {
var overflow bool
if evm.StateDB.AddressInAccessList(addr) {
if gas, overflow = math.SafeAdd(gas, params.WarmStorageReadCostEIP2929); overflow {
return 0, ErrGasUintOverflow
}
} else {
evm.StateDB.AddAddressToAccessList(addr)
if gas, overflow = math.SafeAdd(gas, params.ColdAccountAccessCostEIP2929); overflow {
return 0, ErrGasUintOverflow
}
}
}
return gas, nil
}

0 comments on commit e4e381d

Please sign in to comment.