eth/tracers: fix accessList StorageKeys return null (#33976)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

This commit is contained in:
georgehao 2026-03-11 11:46:49 +08:00 committed by GitHub
parent 27c4ca9df0
commit f6068e3fb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -85,11 +85,14 @@ func (al accessList) equal(other accessList) bool {
func (al accessList) accessList() types.AccessList {
acl := make(types.AccessList, 0, len(al))
for addr, slots := range al {
tuple := types.AccessTuple{Address: addr, StorageKeys: []common.Hash{}}
for slot := range slots {
tuple.StorageKeys = append(tuple.StorageKeys, slot)
}
keys := slices.SortedFunc(maps.Keys(slots), common.Hash.Cmp)
// Ensure keys is never nil to avoid JSON serialization issues.
// When slots is empty, slices.SortedFunc returns nil, but JSON marshaling
// will serialize nil slice as null instead of [], which breaks clients
// that expect storageKeys to always be an array.
if keys == nil {
keys = []common.Hash{}
}
acl = append(acl, types.AccessTuple{Address: addr, StorageKeys: keys})
}
slices.SortFunc(acl, func(a, b types.AccessTuple) int { return a.Address.Cmp(b.Address) })