mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-09 09:36:40 +00:00
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:
parent
c5598fe958
commit
f7b7d4c7e5
2 changed files with 42 additions and 2 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
39
eth/tracers/logger/access_list_tracer_test.go
Normal file
39
eth/tracers/logger/access_list_tracer_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue