Skip to content

Commit

Permalink
re-add gasSLoad, used by SSTORE
Browse files Browse the repository at this point in the history
  • Loading branch information
jwasinger committed Feb 2, 2022
1 parent b81459a commit 49b3f85
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/vm/gas_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ func gasExtCodeCopy(evm *EVM, contract *Contract, stack *Stack, mem *Memory, mem
return usedGas + statelessGas, err
}

func gasSLoad(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
usedGas := uint64(0)

if evm.chainConfig.IsCancun(evm.Context.BlockNumber) {
where := stack.Back(0)
addr := contract.Address()
index := trieUtils.GetTreeKeyStorageSlot(addr[:], where)
usedGas += evm.Accesses.TouchAddressOnReadAndComputeGas(index)
}

return usedGas, nil
}

func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
// Apply the witness access costs, err is nil
accessGas, _ := gasSLoad(evm, contract, stack, mem, memorySize)
Expand Down

0 comments on commit 49b3f85

Please sign in to comment.