Skip to content
Open
8 changes: 7 additions & 1 deletion arbitrum/filter/filter_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ type FilterReason struct {
}

// lint:require-exhaustive-initialization
type FilteredAddressRecord struct {
type FilteredAddressWithReason struct {
Address common.Address `json:"address"`
FilterReason
}

// lint:require-exhaustive-initialization
type FilteredAddressRecord struct {
FilterSetID string `json:"filterSetId"`
FilteredAddressWithReason
}
4 changes: 2 additions & 2 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ func (s *StateDB) SetAddressChecker(checker AddressChecker) {
s.arbExtraData.addressChecker = checker
}

func (s *StateDB) TouchAddress(record *filter.FilteredAddressRecord) {
func (s *StateDB) TouchAddress(touched *filter.FilteredAddressWithReason) {
if s.arbExtraData.addressCheckerState != nil {
s.arbExtraData.addressCheckerState.TouchAddress(record)
s.arbExtraData.addressCheckerState.TouchAddress(touched)
}
}

Expand Down
4 changes: 3 additions & 1 deletion core/state/statedb_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ var ErrArbTxFilter error = errors.New("internal error")
// Implementations manage their own synchronization (sync, WaitGroup, channels, etc).
type AddressCheckerState interface {
// TouchAddress records an address access and checks if it should be filtered.
TouchAddress(record *filter.FilteredAddressRecord)
// The checker is responsible for attaching the filter set ID to produce the
// final FilteredAddressRecord.
TouchAddress(*filter.FilteredAddressWithReason)

// IsFiltered returns whether any touched address was filtered and the
// list of filtered address records collected during the transaction.
Expand Down
4 changes: 2 additions & 2 deletions core/state/statedb_hooked.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ func (s *hookedStateDB) SetAddressChecker(checker AddressChecker) {
s.inner.SetAddressChecker(checker)
}

func (s *hookedStateDB) TouchAddress(record *filter.FilteredAddressRecord) {
s.inner.TouchAddress(record)
func (s *hookedStateDB) TouchAddress(touched *filter.FilteredAddressWithReason) {
s.inner.TouchAddress(touched)
}

func (s *hookedStateDB) IsAddressFiltered() (bool, []filter.FilteredAddressRecord) {
Expand Down
10 changes: 2 additions & 8 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,7 @@ func opSelfdestruct(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
return nil, ErrWriteProtection
}
beneficiary := scope.Stack.pop()
evm.StateDB.TouchAddress(&filter.FilteredAddressRecord{
Address: beneficiary.Bytes20(),
FilterReason: filter.FilterReason{Reason: filter.ReasonSelfdestructBeneficiary, EventRuleMatch: nil},
})
evm.StateDB.TouchAddress(&filter.FilteredAddressWithReason{Address: beneficiary.Bytes20(), FilterReason: filter.FilterReason{Reason: filter.ReasonSelfdestructBeneficiary, EventRuleMatch: nil}})
balance := evm.StateDB.GetBalance(scope.Contract.Address())
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
evm.StateDB.SelfDestruct(scope.Contract.Address())
Expand Down Expand Up @@ -958,10 +955,7 @@ func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, erro
}

beneficiary := scope.Stack.pop()
evm.StateDB.TouchAddress(&filter.FilteredAddressRecord{
Address: beneficiary.Bytes20(),
FilterReason: filter.FilterReason{Reason: filter.ReasonSelfdestructBeneficiary, EventRuleMatch: nil},
})
evm.StateDB.TouchAddress(&filter.FilteredAddressWithReason{Address: beneficiary.Bytes20(), FilterReason: filter.FilterReason{Reason: filter.ReasonSelfdestructBeneficiary, EventRuleMatch: nil}})
balance := evm.StateDB.GetBalance(scope.Contract.Address())
evm.StateDB.SubBalance(scope.Contract.Address(), balance, tracing.BalanceDecreaseSelfdestruct)
evm.StateDB.AddBalance(beneficiary.Bytes20(), balance, tracing.BalanceIncreaseSelfdestruct)
Expand Down
2 changes: 1 addition & 1 deletion core/vm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type StateDB interface {
ClearTxFilter()
IsTxFiltered() bool
SetAddressChecker(checker state.AddressChecker)
TouchAddress(record *filter.FilteredAddressRecord)
TouchAddress(*filter.FilteredAddressWithReason)
IsAddressFiltered() (bool, []filter.FilteredAddressRecord)

Recording() bool
Expand Down
4 changes: 2 additions & 2 deletions eth/gasestimator/gasestimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ func run(ctx context.Context, call *core.Message, opts *Options) (*core.Executio
if txFilterer != nil {
txFilterer.Setup(dirtyState)

dirtyState.TouchAddress(&filter.FilteredAddressRecord{Address: call.From, FilterReason: filter.FilterReason{Reason: filter.ReasonFrom, EventRuleMatch: nil}})
dirtyState.TouchAddress(&filter.FilteredAddressWithReason{Address: call.From, FilterReason: filter.FilterReason{Reason: filter.ReasonFrom, EventRuleMatch: nil}})
if call.To != nil {
dirtyState.TouchAddress(&filter.FilteredAddressRecord{Address: *call.To, FilterReason: filter.FilterReason{Reason: filter.ReasonTo, EventRuleMatch: nil}})
dirtyState.TouchAddress(&filter.FilteredAddressWithReason{Address: *call.To, FilterReason: filter.FilterReason{Reason: filter.ReasonTo, EventRuleMatch: nil}})
}
}

Expand Down
Loading