eth/tracers/logger: fix exclude address list (#34887)

Fixes the exclusion list of the accessListTracer.

---------

Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
This commit is contained in:
cui 2026-05-07 20:03:32 +08:00 committed by GitHub
parent c5598fe958
commit f7b7d4c7e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 2 deletions

View file

@ -112,9 +112,10 @@ type AccessListTracer struct {
func NewAccessListTracer(acl types.AccessList, addressesToExclude map[common.Address]struct{}) *AccessListTracer {
list := newAccessList()
for _, al := range acl {
if _, ok := addressesToExclude[al.Address]; !ok {
list.addAddress(al.Address)
if _, ok := addressesToExclude[al.Address]; ok {
continue
}
list.addAddress(al.Address)
for _, slot := range al.StorageKeys {
list.addSlot(al.Address, slot)
}

View file

@ -0,0 +1,39 @@
// Copyright 2026 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package logger
import (
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
func TestNewAccessListTracerExcludedAddress(t *testing.T) {
excluded := common.HexToAddress("0x2222222222222222222222222222222222222222")
slot := common.HexToHash("0x01")
prelude := types.AccessList{{
Address: excluded,
StorageKeys: []common.Hash{slot},
}}
excl := map[common.Address]struct{}{excluded: {}}
tracer := NewAccessListTracer(prelude, excl)
got := tracer.AccessList()
if len(got) != 0 {
t.Fatalf("excluded prelude address must not contribute tuples, got %+v", got)
}
}