Skip to content

Commit

Permalink
implement post-nyota verkle costs
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed Jun 27, 2024
1 parent 4133497 commit 1dfca6a
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 144 deletions.
2 changes: 1 addition & 1 deletion cmd/geth/verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func convertToVerkle(ctx *cli.Context) error {
return fmt.Errorf("could not find preimage for address %x %v %v", accIt.Hash(), acc, accIt.Error())
}
addrPoint := tutils.EvaluateAddressPoint(addr)
stem := tutils.GetTreeKeyVersionWithEvaluatedAddress(addrPoint)
stem := tutils.GetTreeKeyBasicDataEvaluatedAddress(addrPoint)

// Store the account code if present
if !bytes.Equal(acc.CodeHash, types.EmptyRootHash[:]) {
Expand Down
26 changes: 13 additions & 13 deletions core/overlay/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,29 @@ func (kvm *keyValueMigrator) addStorageSlot(addr []byte, slotNumber []byte, slot
func (kvm *keyValueMigrator) addAccount(addr []byte, acc *types.StateAccount) {
leafNodeData := kvm.getOrInitLeafNodeData(newBranchKey(addr, &zeroTreeIndex))

var version [verkle.LeafValueSize]byte
leafNodeData.Values[utils.VersionLeafKey] = version[:]
var basicData [verkle.LeafValueSize]byte
basicData[utils.BasicDataVersionOffset] = 0 // version

var balance [verkle.LeafValueSize]byte
for i, b := range acc.Balance.Bytes() {
balance[len(acc.Balance.Bytes())-1-i] = b
// get the lower 16 bytes of water and change its endianness
balanceBytes := acc.Balance.Bytes()
for i := 0; i < 16 && i < len(balanceBytes); i++ {
basicData[utils.BasicDataBalanceOffset+i] = balanceBytes[len(balanceBytes)-1-i]
}
leafNodeData.Values[utils.BalanceLeafKey] = balance[:]

var nonce [verkle.LeafValueSize]byte
binary.LittleEndian.PutUint64(nonce[:8], acc.Nonce)
leafNodeData.Values[utils.NonceLeafKey] = nonce[:]
binary.LittleEndian.PutUint64(basicData[utils.BasicDataNonceOffset:], acc.Nonce)

leafNodeData.Values[utils.BasicDataLeafKey] = basicData[:]
leafNodeData.Values[utils.CodeHashLeafKey] = acc.CodeHash[:]
}

// addAccountCode needs to be called AFTER addAccount, as it will reuse the leaf
// that was created in there.
func (kvm *keyValueMigrator) addAccountCode(addr []byte, codeSize uint64, chunks []byte) {
leafNodeData := kvm.getOrInitLeafNodeData(newBranchKey(addr, &zeroTreeIndex))

// Save the code size.
var codeSizeBytes [verkle.LeafValueSize]byte
binary.LittleEndian.PutUint64(codeSizeBytes[:8], codeSize)
leafNodeData.Values[utils.CodeSizeLeafKey] = codeSizeBytes[:]
var cs [8]byte
binary.LittleEndian.PutUint64(cs[:], codeSize)
copy(leafNodeData.Values[utils.BasicDataLeafKey][utils.BasicDataCodeSizeOffset:utils.BasicDataNonceOffset], cs[:3])

// The first 128 chunks are stored in the account header leaf.
for i := 0; i < 128 && i < len(chunks)/32; i++ {
Expand Down
43 changes: 11 additions & 32 deletions core/state/access_witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,41 +91,36 @@ func (aw *AccessWitness) Copy() *AccessWitness {

func (aw *AccessWitness) TouchFullAccount(addr []byte, isWrite bool) uint64 {
var gas uint64
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
for i := utils.BasicDataLeafKey; i <= utils.CodeHashLeafKey; i++ {
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, byte(i), isWrite)
}
return gas
}

func (aw *AccessWitness) TouchAndChargeMessageCall(addr []byte) uint64 {
var gas uint64
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, false)
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeSizeLeafKey, false)
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BasicDataLeafKey, false)
return gas
}

func (aw *AccessWitness) TouchAndChargeValueTransfer(callerAddr, targetAddr []byte) uint64 {
var gas uint64
gas += aw.touchAddressAndChargeGas(callerAddr, zeroTreeIndex, utils.BalanceLeafKey, true)
gas += aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BalanceLeafKey, true)
gas += aw.touchAddressAndChargeGas(callerAddr, zeroTreeIndex, utils.BasicDataLeafKey, true)
gas += aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BasicDataLeafKey, true)
return gas
}

// TouchAndChargeContractCreateInit charges access costs to initiate
// a contract creation
func (aw *AccessWitness) TouchAndChargeContractCreateInit(addr []byte, createSendsValue bool) uint64 {
var gas uint64
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, true)
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.NonceLeafKey, true)
if createSendsValue {
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BalanceLeafKey, true)
}
gas += aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BasicDataLeafKey, true)
return gas
}

func (aw *AccessWitness) TouchTxOriginAndComputeGas(originAddr []byte) uint64 {
for i := utils.VersionLeafKey; i <= utils.CodeSizeLeafKey; i++ {
aw.touchAddressAndChargeGas(originAddr, zeroTreeIndex, byte(i), i == utils.BalanceLeafKey || i == utils.NonceLeafKey)
for i := utils.BasicDataLeafKey; i <= utils.CodeHashLeafKey; i++ {
aw.touchAddressAndChargeGas(originAddr, zeroTreeIndex, byte(i), i == utils.BasicDataLeafKey)
}

// Kaustinen note: we're currently experimenting with stop chargin gas for the origin address
Expand All @@ -136,14 +131,10 @@ func (aw *AccessWitness) TouchTxOriginAndComputeGas(originAddr []byte) uint64 {
}

func (aw *AccessWitness) TouchTxExistingAndComputeGas(targetAddr []byte, sendsValue bool) uint64 {
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.VersionLeafKey, false)
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeSizeLeafKey, false)
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BasicDataLeafKey, false)
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeHashLeafKey, false)
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.NonceLeafKey, false)
if sendsValue {
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BalanceLeafKey, true)
} else {
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BalanceLeafKey, false)
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.BasicDataLeafKey, true)
}

// Kaustinen note: we're currently experimenting with stop chargin gas for the origin address
Expand Down Expand Up @@ -276,20 +267,8 @@ func (aw *AccessWitness) TouchCodeChunksRangeAndChargeGas(contractAddr []byte, s
return statelessGasCharged
}

func (aw *AccessWitness) TouchVersion(addr []byte, isWrite bool) uint64 {
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.VersionLeafKey, isWrite)
}

func (aw *AccessWitness) TouchBalance(addr []byte, isWrite bool) uint64 {
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BalanceLeafKey, isWrite)
}

func (aw *AccessWitness) TouchNonce(addr []byte, isWrite bool) uint64 {
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.NonceLeafKey, isWrite)
}

func (aw *AccessWitness) TouchCodeSize(addr []byte, isWrite bool) uint64 {
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.CodeSizeLeafKey, isWrite)
func (aw *AccessWitness) TouchBasicData(addr []byte, isWrite bool) uint64 {
return aw.touchAddressAndChargeGas(addr, zeroTreeIndex, utils.BasicDataLeafKey, isWrite)
}

func (aw *AccessWitness) TouchCodeHash(addr []byte, isWrite bool) uint64 {
Expand Down
2 changes: 1 addition & 1 deletion core/state/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (db *cachingDB) openMPTTrie(root common.Hash) (Trie, error) {
return tr, nil
}

func (db *cachingDB) openVKTrie(root common.Hash) (Trie, error) {
func (db *cachingDB) openVKTrie(_ common.Hash) (Trie, error) {
payload, err := db.DiskDB().Get(trie.FlatDBVerkleNodeKeyPrefix)
if err != nil {
return trie.NewVerkleTrie(verkle.New(), db.triedb, db.addrToPoint, db.CurrentTransitionState.Ended), nil
Expand Down
75 changes: 58 additions & 17 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,49 @@ func TestProcessVerkle(t *testing.T) {

txCost1 := params.TxGas
txCost2 := params.TxGas
contractCreationCost := intrinsicContractCreationGas + uint64(5600+700+700+700 /* creation with value */ +1439 /* execution costs */)
codeWithExtCodeCopyGas := intrinsicCodeWithExtCodeCopyGas + uint64(5600+700 /* creation */ +44044 /* execution costs */)
contractCreationCost := intrinsicContractCreationGas + uint64(

Check failure on line 501 in core/state_processor_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary conversion (unconvert)
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+params.WitnessBranchReadCost+params.WitnessBranchWriteCost+ /* creation */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* creation with value */
739 /* execution costs */)
codeWithExtCodeCopyGas := intrinsicCodeWithExtCodeCopyGas + uint64(

Check failure on line 505 in core/state_processor_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary conversion (unconvert)
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+params.WitnessBranchReadCost+params.WitnessBranchWriteCost+ /* creation (tx) */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+params.WitnessBranchReadCost+params.WitnessBranchWriteCost+ /* creation (CREATE at pc=0x20) */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* write code hash */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #0 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #1 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #2 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #3 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #4 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #5 */
params.WitnessChunkReadCost+ /* SLOAD in constructor */
params.WitnessChunkWriteCost+ /* SSTORE in constructor */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+params.WitnessBranchReadCost+params.WitnessBranchWriteCost+ /* creation (CREATE at PC=0x121) */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* write code hash */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #0 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #1 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #2 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #3 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #4 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #5 */
params.WitnessChunkReadCost+ /* SLOAD in constructor */
params.WitnessChunkWriteCost+ /* SSTORE in constructor */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* write code hash for tx creation */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #0 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #1 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #2 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #3 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #4 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #5 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #6 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #7 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #8 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #9 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #10 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #11 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #12 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #13 */
params.WitnessChunkReadCost+params.WitnessChunkWriteCost+ /* code chunk #14 */
4844 /* execution costs */)
blockGasUsagesExpected := []uint64{
txCost1*2 + txCost2,
txCost1*2 + txCost2 + contractCreationCost + codeWithExtCodeCopyGas,
Expand Down Expand Up @@ -939,7 +980,7 @@ func TestProcessVerklExtCodeHashOpcode(t *testing.T) {
}
})

contractKeccakTreeKey := utils.GetTreeKeyCodeKeccak(dummyContractAddr[:])
contractKeccakTreeKey := utils.GetTreeKeyCodeHash(dummyContractAddr[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[1] {
Expand Down Expand Up @@ -1034,7 +1075,7 @@ func TestProcessVerkleBalanceOpcode(t *testing.T) {
gen.AddTx(tx)
})

account2BalanceTreeKey := utils.GetTreeKeyBalance(account2[:])
account2BalanceTreeKey := utils.GetTreeKeyBasicData(account2[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[0] {
Expand All @@ -1049,7 +1090,7 @@ func TestProcessVerkleBalanceOpcode(t *testing.T) {

var zero [32]byte
balanceStateDiff := statediff[0][stateDiffIdx].SuffixDiffs[0]
if balanceStateDiff.Suffix != utils.BalanceLeafKey {
if balanceStateDiff.Suffix != utils.BasicDataLeafKey {
t.Fatalf("invalid suffix diff")
}
if balanceStateDiff.CurrentValue == nil {
Expand Down Expand Up @@ -1148,7 +1189,7 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) {

var zero [32]byte
{ // Check self-destructed contract in the witness
selfDestructContractTreeKey := utils.GetTreeKeyCodeKeccak(selfDestructContractAddr[:])
selfDestructContractTreeKey := utils.GetTreeKeyCodeHash(selfDestructContractAddr[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[1] {
Expand All @@ -1162,7 +1203,7 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) {
}

balanceStateDiff := statediff[1][stateDiffIdx].SuffixDiffs[1]
if balanceStateDiff.Suffix != utils.BalanceLeafKey {
if balanceStateDiff.Suffix != utils.BasicDataLeafKey {
t.Fatalf("balance invalid suffix")
}

Expand All @@ -1179,7 +1220,7 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) {
}
}
{ // Check self-destructed target in the witness.
selfDestructTargetTreeKey := utils.GetTreeKeyCodeKeccak(account2[:])
selfDestructTargetTreeKey := utils.GetTreeKeyCodeHash(account2[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[1] {
Expand All @@ -1193,7 +1234,7 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) {
}

balanceStateDiff := statediff[1][stateDiffIdx].SuffixDiffs[0]
if balanceStateDiff.Suffix != utils.BalanceLeafKey {
if balanceStateDiff.Suffix != utils.BasicDataLeafKey {
t.Fatalf("balance invalid suffix")
}
if balanceStateDiff.CurrentValue == nil {
Expand Down Expand Up @@ -1276,7 +1317,7 @@ func TestProcessVerkleSelfDestructInSameTx(t *testing.T) {
})

{ // Check self-destructed contract in the witness
selfDestructContractTreeKey := utils.GetTreeKeyCodeKeccak(selfDestructContractAddr[:])
selfDestructContractTreeKey := utils.GetTreeKeyCodeHash(selfDestructContractAddr[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[0] {
Expand All @@ -1290,7 +1331,7 @@ func TestProcessVerkleSelfDestructInSameTx(t *testing.T) {
}

balanceStateDiff := statediff[0][stateDiffIdx].SuffixDiffs[1]
if balanceStateDiff.Suffix != utils.BalanceLeafKey {
if balanceStateDiff.Suffix != utils.BasicDataLeafKey {
t.Fatalf("balance invalid suffix")
}

Expand All @@ -1303,7 +1344,7 @@ func TestProcessVerkleSelfDestructInSameTx(t *testing.T) {
}
}
{ // Check self-destructed target in the witness.
selfDestructTargetTreeKey := utils.GetTreeKeyCodeKeccak(account2[:])
selfDestructTargetTreeKey := utils.GetTreeKeyCodeHash(account2[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[0] {
Expand All @@ -1317,7 +1358,7 @@ func TestProcessVerkleSelfDestructInSameTx(t *testing.T) {
}

balanceStateDiff := statediff[0][stateDiffIdx].SuffixDiffs[0]
if balanceStateDiff.Suffix != utils.BalanceLeafKey {
if balanceStateDiff.Suffix != utils.BasicDataLeafKey {
t.Fatalf("balance invalid suffix")
}
if balanceStateDiff.CurrentValue == nil {
Expand Down Expand Up @@ -1422,7 +1463,7 @@ func TestProcessVerkleSelfDestructInSeparateTxWithSelfBeneficiary(t *testing.T)
// to the beneficiary. In this case both addresses are the same, thus this might be optimizable from a gas
// perspective. But until that happens, we need to honor this "balance reading" adding it to the witness.

selfDestructContractTreeKey := utils.GetTreeKeyCodeKeccak(selfDestructContractAddr[:])
selfDestructContractTreeKey := utils.GetTreeKeyCodeHash(selfDestructContractAddr[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[1] {
Expand All @@ -1436,7 +1477,7 @@ func TestProcessVerkleSelfDestructInSeparateTxWithSelfBeneficiary(t *testing.T)
}

balanceStateDiff := statediff[1][stateDiffIdx].SuffixDiffs[1]
if balanceStateDiff.Suffix != utils.BalanceLeafKey {
if balanceStateDiff.Suffix != utils.BasicDataLeafKey {
t.Fatalf("balance invalid suffix")
}

Expand Down Expand Up @@ -1521,7 +1562,7 @@ func TestProcessVerkleSelfDestructInSameTxWithSelfBeneficiary(t *testing.T) {
})

{ // Check self-destructed contract in the witness
selfDestructContractTreeKey := utils.GetTreeKeyCodeKeccak(selfDestructContractAddr[:])
selfDestructContractTreeKey := utils.GetTreeKeyCodeHash(selfDestructContractAddr[:])

var stateDiffIdx = -1
for i, stemStateDiff := range statediff[0] {
Expand All @@ -1535,7 +1576,7 @@ func TestProcessVerkleSelfDestructInSameTxWithSelfBeneficiary(t *testing.T) {
}

balanceStateDiff := statediff[0][stateDiffIdx].SuffixDiffs[1]
if balanceStateDiff.Suffix != utils.BalanceLeafKey {
if balanceStateDiff.Suffix != utils.BasicDataLeafKey {
t.Fatalf("balance invalid suffix")
}

Expand Down
25 changes: 7 additions & 18 deletions core/vm/operations_verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func gasSLoad4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memor

func gasBalance4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
address := stack.peek().Bytes20()
gas := evm.Accesses.TouchBalance(address[:], false)
gas := evm.Accesses.TouchBasicData(address[:], false)
if gas == 0 {
gas = params.WarmStorageReadCostEIP2929
}
Expand All @@ -52,8 +52,7 @@ func gasExtCodeSize4762(evm *EVM, contract *Contract, stack *Stack, mem *Memory,
if _, isPrecompile := evm.precompile(address); isPrecompile {
return 0, nil
}
wgas := evm.Accesses.TouchVersion(address[:], false)
wgas += evm.Accesses.TouchCodeSize(address[:], false)
wgas := evm.Accesses.TouchBasicData(address[:], false)
if wgas == 0 {
wgas = params.WarmStorageReadCostEIP2929
}
Expand Down Expand Up @@ -103,24 +102,15 @@ func gasSelfdestructEIP4762(evm *EVM, contract *Contract, stack *Stack, mem *Mem
}

contractAddr := contract.Address()
statelessGas := evm.Accesses.TouchVersion(contractAddr[:], false)
statelessGas += evm.Accesses.TouchCodeSize(contractAddr[:], false)
statelessGas += evm.Accesses.TouchBalance(contractAddr[:], false)
statelessGas := evm.Accesses.TouchBasicData(contractAddr[:], false)
if contractAddr != beneficiaryAddr {
statelessGas += evm.Accesses.TouchBalance(beneficiaryAddr[:], false)
statelessGas += evm.Accesses.TouchBasicData(beneficiaryAddr[:], false)
}
// Charge write costs if it transfers value
if evm.StateDB.GetBalance(contractAddr).Sign() != 0 {
statelessGas += evm.Accesses.TouchBalance(contractAddr[:], true)
statelessGas += evm.Accesses.TouchBasicData(contractAddr[:], true)
if contractAddr != beneficiaryAddr {
statelessGas += evm.Accesses.TouchBalance(beneficiaryAddr[:], true)
}

// Case when the beneficiary does not exist: touch the account
// but leave code hash and size alone.
if evm.StateDB.Empty(beneficiaryAddr) {
statelessGas += evm.Accesses.TouchVersion(beneficiaryAddr[:], true)
statelessGas += evm.Accesses.TouchNonce(beneficiaryAddr[:], true)
statelessGas += evm.Accesses.TouchBasicData(beneficiaryAddr[:], true)
}
}
return statelessGas, nil
Expand All @@ -133,8 +123,7 @@ func gasExtCodeCopyEIP4762(evm *EVM, contract *Contract, stack *Stack, mem *Memo
return 0, err
}
addr := common.Address(stack.peek().Bytes20())
wgas := evm.Accesses.TouchVersion(addr[:], false)
wgas += evm.Accesses.TouchCodeSize(addr[:], false)
wgas := evm.Accesses.TouchBasicData(addr[:], false)
if wgas == 0 {
wgas = params.WarmStorageReadCostEIP2929
}
Expand Down
Loading

0 comments on commit 1dfca6a

Please sign in to comment.