-
Notifications
You must be signed in to change notification settings - Fork 719
Expand file tree
/
Copy pathtx_filterer.go
More file actions
37 lines (30 loc) · 1.23 KB
/
tx_filterer.go
File metadata and controls
37 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2021-2026, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md
package gethexec
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/offchainlabs/nitro/execution/gethexec/eventfilter"
)
// txFilterer implements core.TxFilterer for address-based transaction filtering
// for node API calls such as eth_estimateGas and eth_call. It wraps ExecutionEngine to resolve the address
// checker lazily, so tests can inject checkers via ExecEngine.SetAddressChecker.
type txFilterer struct {
execEngine *ExecutionEngine
eventFilter *eventfilter.EventFilter
}
func (f *txFilterer) Setup(statedb *state.StateDB) {
statedb.SetAddressChecker(f.execEngine.addressChecker)
statedb.SetTxContext(common.Hash{}, 0)
}
func (f *txFilterer) TouchAddresses(statedb *state.StateDB, tx *types.Transaction, sender common.Address) {
touchAddresses(statedb, tx, sender)
}
func (f *txFilterer) ApplyEventsAndCheckFiltered(statedb *state.StateDB) error {
applyEventFilter(f.eventFilter, statedb)
if filtered, _ := statedb.IsAddressFiltered(); filtered {
return state.ErrArbTxFilter
}
return nil
}