Consensus subround dowork improvement - #7918
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/testnet-fixes #7918 +/- ##
======================================================
+ Coverage 77.45% 77.47% +0.01%
======================================================
Files 887 887
Lines 126472 126476 +4
======================================================
+ Hits 97964 97985 +21
+ Misses 22057 22042 -15
+ Partials 6451 6449 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sstanculeanu
previously approved these changes
Jul 21, 2026
BeniaminDrasovean
previously approved these changes
Jul 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves SPoS consensus subround execution by making DoWork responsive to context cancellation, adds a regression test for this behavior, and introduces a safer test-only accessor for received messages while also doing a small cleanup in message validation.
Changes:
- Add
ctx.Done()handling inSubround.DoWork()to abort work and mark the round as canceled. - Add a unit test ensuring
DoWorkreturnsfalseand sets the canceled flag when the context is closed. - In test helpers, return a cloned copy of
Worker.receivedMessages, and simplify header access inconsensusMessageValidator.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
consensus/spos/subround.go |
Adds context-cancellation handling to stop subround work early. |
consensus/spos/subround_test.go |
Adds coverage for the new context-cancellation behavior in DoWork. |
consensus/spos/export_test.go |
Adjusts test-only ReceivedMessages() accessor to avoid returning the internal map directly. |
consensus/spos/consensusMessageValidator.go |
Minor refactor: cache header lookup and remove an obsolete comment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
168
to
172
| select { | ||
| case <-ctx.Done(): | ||
| sr.SetRoundCanceled(true) | ||
| return false | ||
| case <-sr.consensusStateChangedChannel: |
Comment on lines
+138
to
+140
| receivedMessages := maps.Clone(wrk.receivedMessages) | ||
|
|
||
| return receivedMessages |
miiu96
previously approved these changes
Jul 27, 2026
ssd04
dismissed stale reviews from miiu96, BeniaminDrasovean, and sstanculeanu
via
July 27, 2026 15:18
c07b03f
BeniaminDrasovean
approved these changes
Jul 28, 2026
sstanculeanu
approved these changes
Jul 28, 2026
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.
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?