core: only initialize the state access list post Amsterdam

This commit is contained in:
Gary Rong 2026-04-21 15:27:10 +08:00
parent f088bff4ec
commit 41dfa7dd57
2 changed files with 13 additions and 1 deletions

View file

@ -1430,7 +1430,10 @@ func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, d
} }
// Reset transient storage at the beginning of transaction execution // Reset transient storage at the beginning of transaction execution
s.transientStorage = newTransientStorage() s.transientStorage = newTransientStorage()
s.stateReadList = bal.NewStateAccessList()
if rules.IsAmsterdam {
s.stateReadList = bal.NewStateAccessList()
}
} }
// AddAddressToAccessList adds the given address to the access list // AddAddressToAccessList adds the given address to the access list

View file

@ -42,6 +42,9 @@ func NewStateAccessList() *StateAccessList {
// AddAccount records an access to the given account. It is a no-op if the // AddAccount records an access to the given account. It is a no-op if the
// account is already present. // account is already present.
func (s *StateAccessList) AddAccount(addr common.Address) { func (s *StateAccessList) AddAccount(addr common.Address) {
if s == nil {
return
}
if _, exists := s.list[addr]; !exists { if _, exists := s.list[addr]; !exists {
s.list[addr] = make(StorageAccessList) s.list[addr] = make(StorageAccessList)
} }
@ -50,6 +53,9 @@ func (s *StateAccessList) AddAccount(addr common.Address) {
// AddState records an access to the given storage slot. The owning account is // AddState records an access to the given storage slot. The owning account is
// implicitly recorded as well. // implicitly recorded as well.
func (s *StateAccessList) AddState(addr common.Address, slot common.Hash) { func (s *StateAccessList) AddState(addr common.Address, slot common.Hash) {
if s == nil {
return
}
slots, exists := s.list[addr] slots, exists := s.list[addr]
if !exists { if !exists {
slots = make(StorageAccessList) slots = make(StorageAccessList)
@ -60,6 +66,9 @@ func (s *StateAccessList) AddState(addr common.Address, slot common.Hash) {
// Merge merges the entries from other into the receiver. // Merge merges the entries from other into the receiver.
func (s *StateAccessList) Merge(other *StateAccessList) { func (s *StateAccessList) Merge(other *StateAccessList) {
if s == nil || other == nil {
return
}
for addr, otherSlots := range other.list { for addr, otherSlots := range other.list {
slots, exists := s.list[addr] slots, exists := s.list[addr]
if !exists { if !exists {