Pre-checker tx filtering (using estimate gas call)#4583
Conversation
91af9cf to
2b91fd1
Compare
|
|
||
| type TransactionFilteringConfig struct { | ||
| DisableDelayedSequencingFilter bool `koanf:"disable-delayed-sequencing-filter"` | ||
| EnableRPCFilter bool `koanf:"enable-rpc-filter"` |
There was a problem hiding this comment.
EnableRPCFilter is too generic to me, since publishing a transaction also happens through RPC.
I am inclined on using EnableNonMutatingRPCFilter, but I think Tsahi doesn't like it.
I will let @tsahee decide that.
| EnableRPCFilter bool `koanf:"enable-rpc-filter"` | |
| EnableNonMutatingRPCFilter bool `koanf:"enable-non-mutating-rpc-filter"` |
There was a problem hiding this comment.
I indeed don't like non-mutating. enable-ethcall-filter? I know it's not exact but much more self-explanatory.
It should be identical to: https://github.com/OffchainLabs/nitro/pull/4591/changes
There was a problem hiding this comment.
Renamed to enable-ethcall-filter
| if err != nil { | ||
| return err | ||
| } | ||
| if err := c.checkFilteredAddresses(tx, block); err != nil { |
There was a problem hiding this comment.
checkFilteredAddresses could be done in the beginning of PreCheckTx to avoid that.
But fully running current PreCheckTx can avoid unnecessary gas estimation anyway.
| } | ||
|
|
||
| func (f *txFilterer) TouchAddresses(statedb *state.StateDB, tx *types.Transaction, sender common.Address) { | ||
| touchAddresses(statedb, nil, tx, sender) |
There was a problem hiding this comment.
These are retryables, so we need the full set: aliased sender and retryable-specific fields. The regular preTxFilter's from/to-only approach would miss those.
Current scenario:
- For delayed sequencing, the post tx filter calls touchRetryableAddresses, to handle ArbitrumSubmitRetryableTx in a special way. It also handles "TxTypeAlias" in a special way.
- For regular transaction sequencing, touchRetryableAddresses is not called, ArbitrumSubmitRetryableTx is not handled in a special way in any step of the filtering process.
- For pre-checker/eth_estimateGas we are enforcing to use the same policy as the delayed sequencing.
All those scenarios handle scheduled transactions.
At this point this is confusing to me.
I don't understand if regular transaction sequencing has an issue right now, and it should actually handle ArbitrumSubmitRetryableTx in a special way.
Or if we are enforcing this ArbitrumSubmitRetryableTx handling in eth_estimateGas unnecessarily, which doesn't seem create wrong results, but the whole inconsistency is causing me confusion.
I will let the way it is right now, but depending on the reason we should revisit it in another task to clean up this inconsistency.
@tsahee am I missing something?
| if n.AddressFilterService != nil { | ||
| n.AddressFilterService.Start(ctx) | ||
| checker := n.AddressFilterService.GetAddressChecker() | ||
| n.ExecEngine.SetAddressChecker(checker) |
There was a problem hiding this comment.
I think we need to move get/set address checker to (n *ExecutionNode) Initialize, and then ExecEngine, when started, will know it has an addresschecker (so it could do things like refuse transactions while the filter is not initialized)
There was a problem hiding this comment.
Now addressChecker is provided to ExecutionEngine through NewExecutionEngine.
n.ExecEngine.SetAddressChecker still exists, but only used by tests.
so it could do things like refuse transactions while the filter is not initialized
You mean the prechecker should refuse a transaction while the S3 file wasn't downloaded yet?
If so I think the load balancer should avoid sending a transaction to a prechecker that is not synced yet, and to decided if it is synced it should consider if it downloaded the S3 file already?
Same reasoning for nodes handling eth_call and eth_estimateGas.
| } | ||
|
|
||
| func (f *txFilterer) TouchAddresses(statedb *state.StateDB, tx *types.Transaction, sender common.Address) { | ||
| touchAddresses(statedb, nil, tx, sender) |
There was a problem hiding this comment.
So the event filter will be added in checkFiltered and de-facto will enforce the same policy as normal transactions. But it deserves more thought and possibly renaming
| if tx.Type() == types.ArbitrumInternalTxType { | ||
| return nil | ||
| } | ||
| func touchAddresses(db *state.StateDB, ef *eventfilter.EventFilter, tx *types.Transaction, sender common.Address) { |
There was a problem hiding this comment.
I think Diego's (justified) confusion comes from the fact that this function tries to do two things:
both "touch addresses" and apply event filter, while the function with the same name in core.TxFilterer only does one of those things, and eventFilter is applied later.
Either remove eventFilter from touchAddresses, or make the two funcs have different names.
There was a problem hiding this comment.
My confusion is a little bit more than that.
It is also the fact that both eth_estimateGas and delayed filtering handle ArbitrumSubmitRetryableTx in a different way than regular sequencing.
I can see a world where only delayed sequencing filters ArbitrumSubmitRetryableTx differently compared to eth_estimateGas and regular sequencing, or a world in which all of them handle ArbitrumSubmitRetryableTx in the same way.
I added a commit that make all kinds of filtering (delayed sequencing, eth_estimateGas, regular sequencing) handle ArbitrumSubmitRetryableTx.
There was a problem hiding this comment.
ArbitrumSubmitRetryableTx can only come from a L1, I don't think there is a way to create it with eth_call or eth_stimateGas
| if config.Sequencer.Enable { | ||
| seqConfigFetcher := func() *SequencerConfig { return &configFetcher.Get().Sequencer } | ||
| sequencer, err = NewSequencer(execEngine, parentChainReader, seqConfigFetcher, seqParentChain) | ||
| if config.TransactionFiltering.TransactionFiltererRPCClient.URL != "" { |
There was a problem hiding this comment.
not critical for this PR - but reporting will also move and will also cover (at least) prechecker
There was a problem hiding this comment.
As discussed out of GitHub, for reporting precheckers/sequencers will call cmd/filtering-report instead.
| if n.AddressFilterService != nil { | ||
| n.AddressFilterService.Start(ctx) | ||
| checker := n.AddressFilterService.GetAddressChecker() | ||
| n.ExecEngine.SetAddressChecker(checker) |
There was a problem hiding this comment.
I think we need to move get/set address checker to (n *ExecutionNode) Initialize, and then ExecEngine, when started, will know it has an addresschecker (so it could do things like refuse transactions while the filter is not initialized)
fixes NIT-4344
Pulls in OffchainLabs/go-ethereum#643
Add address filtering to TxPreChecker via gas estimation dry-run. Pre-checker now runs transactions through gasestimator.Run to detect filtered addresses before forwarding, catching sender/recipient, aliased, retryable, and event-based address matches including cascading redeems.