Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4300 +/- ##
==========================================
- Coverage 34.84% 32.88% -1.96%
==========================================
Files 488 488
Lines 57870 57946 +76
==========================================
- Hits 20163 19056 -1107
- Misses 34134 35560 +1426
+ Partials 3573 3330 -243 |
❌ 13 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
9166e24 to
ceb7022
Compare
Tristan-Wilson
left a comment
There was a problem hiding this comment.
The change largely looks good, great tests, just some "policy" comments about the max gas and fail open.
Make TxPreCheckerMaxAllowedGas configurable instead of a hardcoded constant. Transactions exceeding the configured max gas are now rejected outright (fail closed) rather than partially executed (fail open), since we cannot guarantee full address coverage for transactions we can't fully simulate. The speculative execution is moved after the balance check so that underfunded transactions are rejected cheaply before spinning up EVM simulation. Wire TxPreChecker.SetAddressChecker in production alongside the existing ExecEngine.SetAddressChecker call now that PR #4235 has merged. - Add MaxAllowedGas field to TxPreCheckerConfig (default 50M, hot-reloadable) - Register max-allowed-gas flag and EventFilter flags in TxPreCheckerConfigAddOptions - Reject txs with gas > MaxAllowedGas before speculative execution - Move ApplyTransactionFilter block after balance check - Wire TxPreChecker.SetAddressChecker in ExecutionNode.Start - Replace deleted txfilter.NewStaticAsyncChecker with newHashedChecker in test - Add TestPreCheckerMaxAllowedGas test
|
Fixed my comments, over to @diegoximenes to review. |
diegoximenes
left a comment
There was a problem hiding this comment.
LGTM, with some nitpicks and doubts
| f.Int64(prefix+".required-state-age", DefaultTxPreCheckerConfig.RequiredStateAge, "how long ago should the storage conditions from eth_SendRawTransactionConditional be true, 0 = don't check old state") | ||
| f.Uint(prefix+".required-state-max-blocks", DefaultTxPreCheckerConfig.RequiredStateMaxBlocks, "maximum number of blocks to look back while looking for the <required-state-age> seconds old state, 0 = don't limit the search") | ||
| f.Bool(prefix+".apply-transaction-filter", DefaultTxPreCheckerConfig.ApplyTransactionFilter, "whether to apply the transaction filter while pre-checking") | ||
| f.Uint64(prefix+".max-allowed-gas", DefaultTxPreCheckerConfig.MaxAllowedGas, "max gas allowed for speculative execution during transaction filtering; txs exceeding this are rejected") |
There was a problem hiding this comment.
nitpick: Config name could mentioned that this is only to useful for filtering.
| } | ||
|
|
||
| if tx.Gas() > config.MaxAllowedGas { | ||
| log.Warn("rejecting transaction that exceeds prechecker max gas for filtering", |
There was a problem hiding this comment.
nitpick:
Why warn?
How about creating a metric for that, and lowering log level?
| deadlineCtx, cancel := context.WithTimeout(context.Background(), time.Second*5) | ||
| go func() { | ||
| <-deadlineCtx.Done() | ||
| if errors.Is(deadlineCtx.Err(), context.DeadlineExceeded) { | ||
| // Stop evm execution. Note cancellation is not necessarily immediate. | ||
| evm.Cancel() | ||
| } | ||
| }() | ||
| defer cancel() |
There was a problem hiding this comment.
Why this cancel logic is needed?
| _, err = core.ApplyMessage(evm, message, gasPool) | ||
| // Ignore execution errors, since we care only about touched addresses | ||
| _ = err |
There was a problem hiding this comment.
| _, err = core.ApplyMessage(evm, message, gasPool) | |
| // Ignore execution errors, since we care only about touched addresses | |
| _ = err | |
| // Ignore execution errors, since we care only about touched addresses | |
| _, _ = core.ApplyMessage(evm, message, gasPool) |
Tristan-Wilson
left a comment
There was a problem hiding this comment.
We likely need a different approach to handle retriable redemptions.
|
Closing this in favor of ProduceBlockAdvanced dryrun approach #4382 |
Fixes NIT-4344
Transaction address filtering on pre-checker, mirroring sequencer-side behaviour