Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
gzliudan
requested review from
AnilChinchawale,
anunay-xin,
benjamin202410,
liam-lai and
wanwiset25
November 11, 2026 03:58
wanwiset25
approved these changes
Nov 12, 2026
gzliudan
force-pushed
the
fix-yourturn-timing-flake
branch
2 times, most recently
from
November 12, 2026 12:03
5774f3b to
253e62a
Compare
The test assigns parent.Time before InsertBlock and Initial, while YourTurn compares waitedTime against a one-second mine period at second granularity. Any delay crossing a second boundary makes waitedTime >= minePeriod, so YourTurn reaches the round-leader check and returns true where the first assert expects false (CI run 42948682501, job 130287604486). Move the assignment after InsertBlock/Initial and align to a fresh wall-clock second, leaving a full second of slack before YourTurn.
gzliudan
force-pushed
the
fix-yourturn-timing-flake
branch
from
November 12, 2026 23:50
253e62a to
23f6833
Compare
This branch has not been deployed
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.
Summary
YourTurncomputeswaitedTime := time.Now().Unix() - int64(parent.Time)and returns false only whilewaitedTime < minePeriod. The package helpershortenV2Timingsshrinks round 0'sMinePeriodto 1 second. Becauseparent.Timewas stamped beforeInsertBlock/Initial, any I/O delay crossing a second boundary madewaitedTimecount as 1, soYourTurnskipped the mine-period guard and reached the round-leader check, returning true where the first assert expects false.The timestamp is now stamped after all I/O and aligned to a fresh wall-clock second, leaving a whole second of slack.
currentBlockHeaderis aCopyHeaderof the block; the block inserted into the chain keeps its original timestamp, so chain state andparent.Hash()are unchanged.leaderIndexdepends only on round, epoch and masternode count, so every later assertion keeps the same expectation.Evidence
42948682501, job130287604486(race (engine_v2 5/5)) —--- FAIL: TestIsYourTurnConsensusV2 (4.25s),authorised_masternode_test.go:55: Should be false. Its log shows[yourturn] Yes, it's my turn based on parent block round=1 ... ParentBlockNumber=901, i.e. the mine-period guard was skipped. That shard repeatedly loggedFailed to start filesystem watcher err="too many open files", which slows block insertion.go test -race -count=50 -run 'TestIsYourTurnConsensusV2$'(137.8s).go test -race -count=30 -run 'TestIsYourTurnConsensusV2$' ./consensus/tests/engine_v2_tests/→ok ... 91.360s. With a 500ms delay inserted after the assignment, the unaligned version failed 3 of 6 runs while the aligned version passed 6 of 6.make all,make generate,make tidy, clean-tree gate,make lint,go vet ./...,make test— all passed.Merge Danger
Door: two-way
Test-only change; reverting restores the previous timing behaviour.
Blast Radius: test-only
Only
TestIsYourTurnConsensusV2is touched. No production code, no config, no API. The test gets up to one second slower per run.Proposed changes
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) thatNot-checked items: this PR only reorders a timestamp assignment and adds a sub-second alignment inside an existing consensus unit test. It changes no node runtime, consensus rule, config, API or persisted data, so a private-network run from genesis, a devnet/testnet end-to-end plan, a backwards-compatibility test, mixed-version node coexistence and documentation updates are not applicable. Coverage is the corrected test itself, exercised 30 times under
-raceplus the fullmake testsuite.