-
Notifications
You must be signed in to change notification settings - Fork 700
Add address-based transaction filtering for sequencer #4157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement infrastructure for filtering transactions based on addresses touched during execution. This supports compliance use cases on certain chains where transactions interacting with certain addresses must be rejected by the sequencer before inclusion. Addresses are collected during execution via TxProcessor.PushContract, which captures the contract address and caller for every CALL, STATICCALL, CREATE, and CREATE2 operation. The sequencer's postTxFilter then checks all collected addresses (plus tx.From and tx.To) against a configurable AddressFilter interface. DELEGATECALL and CALLCODE are intentionally not filtered as they only borrow code from the target address without any actual interaction. A StaticFilter implementation is provided for testing and as a demonstration for future integration.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4157 +/- ##
==========================================
- Coverage 33.41% 33.11% -0.31%
==========================================
Files 461 462 +1
Lines 55901 55932 +31
==========================================
- Hits 18681 18522 -159
- Misses 33921 34151 +230
+ Partials 3299 3259 -40 |
❌ 4 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
c874954 to
af1cd36
Compare
tsahee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see geth-side PR
All address filtering now goes through statedb.TouchAddress() and the arbTxFilter mechanism. preTxFilter uses TouchAddress for from/to addresses, while execution uses it for contract calls, creates, and selfdestruct. The filter now lives in ExecutionEngine to simplify setting up statedb with the filter.
af1cd36 to
2adc835
Compare
tsahee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also see geth side notes
| return nil, err | ||
| } | ||
| if s.addressFilter != nil { | ||
| statedb.SetAddressFilter(s.addressFilter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to apply the filter in sequenceDelayedMessageWithBlockMutex (and test it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will work on it, otherwise in the meantime maybe we can merge this PR if it looks good and do that in a separate PR?
txfilter/filter.go
Outdated
| return &StaticFilter{addresses: m} | ||
| } | ||
|
|
||
| func (f *StaticFilter) IsFiltered(addr common.Address) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments in geth about the interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
Address review feedback requesting async-capable address filtering: - TouchAddress submits addresses for checking (can start async checks) - IsFiltered blocks until all checks complete and returns result - Fresh state created per-tx in SetTxContext (replaces ClearAddresses) This design allows implementations to check addresses in parallel using separate goroutines while the main thread executes, enabling lookups in large databases without blocking execution.
tsahee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Implement infrastructure for filtering transactions based on addresses touched during execution. This supports compliance use cases on certain chains where transactions interacting with certain addresses must be rejected by the sequencer before inclusion.
Addresses are collected during execution via TxProcessor.PushContract, which captures the contract address and caller for every CALL, STATICCALL, CREATE, and CREATE2 operation. The sequencer's postTxFilter then checks all collected addresses (plus tx.From and tx.To) against a configurable AddressFilter interface.
SELFDESTRUCT is handled on the geth side by capturing the beneficiary address in opSelfdestruct and opSelfdestruct6780.
DELEGATECALL and CALLCODE are intentionally not filtered as they only borrow code from the target address without any actual interaction.
A StaticFilter implementation is provided for testing and as a demonstration for future integration.
pulls in OffchainLabs/go-ethereum#601
fixes: NIT-4221