fix(ccip/integration-tests): mine each tx in commitSqNrs to avoid nonce race#22017
Closed
fix(ccip/integration-tests): mine each tx in commitSqNrs to avoid nonce race#22017
Conversation
Contributor
|
✅ No conflicts with other open PRs targeting |
|
18a8767 to
67eb50c
Compare
…ce race TestCCIPReader_ExecutedMessages_MultiChainDisjoint flakes with "replacement transaction underpriced" because commitSqNrs loops EmitExecutionStateChanged without committing. Back-to-back sends race the simulated txpool's nonce accounting so bind.TransactOpts.Nonce==nil resolves to the same value twice, triggering the replacement-price rule. Mirror emitCommitReports (line 1635): Commit() after each tx so the next iteration's PendingNonceAt sees the bumped nonce. Single-element callers are unaffected (extra empty commit is harmless).
67eb50c to
3093a7f
Compare
|
Collaborator
Author
|
Superseded by #22031 (fresh branch off latest develop, identical diff). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Smoking gun
CI: #22016 run 24424913522 job 71356857697. Reproduces on base branch (not introduced by #22016).
Root cause
commitSqNrs(ccip_reader_test.go:1204) loopsEmitExecutionStateChangedwith noCommit()between iterations:Generated binding in
chainlink-ccip/.../ccip_reader_tester/ccip_reader_tester.go:357is a straight-throughcontract.Transact(opts, "emitExecutionStateChanged", ...)— it sends a tx to the simulated mempool and does not mine. Onlys.sb.Commit()mines.s.authis constructed bysetupSimulatedBackendAndAuthwithNonce==nil, soBoundContract.transactcallsPendingNonceAt(opts.From)for each tx. Onethclient/simulatedthe pending-pool nonce update is asynchronous withSendTransactionreturning, so two back-to-back sends can read the same pending nonce. The second tx then lands at an already-occupied mempool nonce with the same suggested gas price → go-ethereum returnsErrReplaceUnderpriced("replacement transaction underpriced").Why only
_MultiChainDisjointOnly that test passes multi-element
seqNums:seqNums[15, 17, 70][15, 16]Single-element callers never hit the race.
Fix
Mirror
emitCommitReports(line 1635), which already commits inside its loop. Adds.sb.Commit()at the end of each iteration ofcommitSqNrsso the next iteration'sPendingNonceAtsees the bumped state nonce. Single-element callers are unaffected — the extra commit is an empty block after the existing outerCommit();lp.Replay(ctx, 1)reads from block 1 regardless.Verification
go test -count=10 -run TestCCIPReader_ExecutedMessages_MultiChainDisjoint ./integration-tests/smoke/ccip/— 10/10 green.Full
TestCCIPReader_ExecutedMessages*— green.Scope
Single file, +1 line. No production code touched.