Skip to content

Consensus subround dowork improvement - #7918

Merged
ssd04 merged 10 commits into
feat/testnet-fixesfrom
consensus-improvements-2
Jul 28, 2026
Merged

Consensus subround dowork improvement#7918
ssd04 merged 10 commits into
feat/testnet-fixesfrom
consensus-improvements-2

Conversation

@ssd04

@ssd04 ssd04 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@ssd04 ssd04 self-assigned this Jul 14, 2026
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.47%. Comparing base (af9046b) to head (c07b03f).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sstanculeanu
sstanculeanu previously approved these changes Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in Subround.DoWork() to abort work and mark the round as canceled.
  • Add a unit test ensuring DoWork returns false and sets the canceled flag when the context is closed.
  • In test helpers, return a cloned copy of Worker.receivedMessages, and simplify header access in consensusMessageValidator.

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 thread consensus/spos/export_test.go Outdated
Comment on lines +138 to +140
receivedMessages := maps.Clone(wrk.receivedMessages)

return receivedMessages
miiu96
miiu96 previously approved these changes Jul 27, 2026
@ssd04
ssd04 dismissed stale reviews from miiu96, BeniaminDrasovean, and sstanculeanu via c07b03f July 27, 2026 15:18
@ssd04
ssd04 merged commit fb49ffd into feat/testnet-fixes Jul 28, 2026
11 checks passed
@ssd04
ssd04 deleted the consensus-improvements-2 branch July 28, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants