core/state: moved event sorting into GetRemovedAccountsWithBalance

This commit is contained in:
zsfelfoldi 2026-03-20 12:08:09 +01:00 committed by Gary Rong
parent d74e319ad6
commit b8939107a2
2 changed files with 7 additions and 9 deletions

View file

@ -762,6 +762,11 @@ func (s *StateDB) GetRemovedAccountsWithBalance() (list []RemovedAccountWithBala
list = append(list, RemovedAccountWithBalance{Address: obj.address, Balance: obj.Balance()})
}
}
if list != nil {
sort.Slice(list, func(i, j int) bool {
return list[i].Address.Cmp(list[j].Address) < 0
})
}
return list
}

View file

@ -20,7 +20,6 @@ import (
"context"
"fmt"
"math/big"
"sort"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/misc"
@ -176,14 +175,8 @@ func ApplyTransactionWithEVM(msg *Message, gp *GasPool, statedb *state.StateDB,
}
if evm.ChainConfig().IsAmsterdam(blockNumber, blockTime) {
// Emit burn logs where accounts with non-empty balances have been deleted
removedWithBalance := statedb.GetRemovedAccountsWithBalance()
if removedWithBalance != nil {
sort.Slice(removedWithBalance, func(i, j int) bool {
return removedWithBalance[i].Address.Cmp(removedWithBalance[j].Address) < 0
})
for _, sd := range removedWithBalance {
statedb.AddLog(types.EthBurnLog(blockNumber, sd.Address, sd.Balance))
}
for _, sd := range statedb.GetRemovedAccountsWithBalance() {
statedb.AddLog(types.EthBurnLog(blockNumber, sd.Address, sd.Balance))
}
}
// Update the state with pending changes.