Skip to content

Conversation

@pinebit
Copy link
Collaborator

@pinebit pinebit commented Dec 15, 2025

The idea for PrepareProposer duty.

category: feature
ticket: none
feature_flag: prepare_proposer

@pinebit pinebit force-pushed the pinebit/prepare-proposer branch from 60036af to 74de907 Compare December 15, 2025 10:56
Copy link

Copilot AI left a comment

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 introduces a new "prepare proposer" duty that runs one slot before block proposal duties to track peer participation and improve leader election. The feature aims to exclude offline or malicious nodes from being elected as leaders during proposer consensus by using participation data from the prior slot.

Key Changes:

  • Added DutyPrepareProposer duty type with associated data structures (PrepareProposerData and PrepareProposerDefinition)
  • Implemented participation tracking in QBFT consensus to record which peers are visible/connected during prepare_proposer duties
  • Modified leader election to use participation data when available, skipping offline peers for proposer duties
  • Added comprehensive unit tests covering participation storage, leader election, and data expiration

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
core/types.go Adds DutyPrepareProposer enum value (14) and string representation
core/unsigneddata.go Defines PrepareProposerData structure with TargetSlot and VisiblePeers fields, includes JSON marshaling
core/dutydefinition.go Defines PrepareProposerDefinition with TargetSlot field and JSON marshaling
core/scheduler/scheduler.go Schedules prepare_proposer duty at slot N-1 when proposer duty exists at slot N (feature-flagged)
core/fetcher/fetcher.go Handles PrepareProposer duty by creating PrepareProposerData from definitions
core/deadline.go Configures 2-slot deadline for PrepareProposer duties (same as attesters/aggregators)
core/consensus/qbft/qbft.go Implements participation tracking, stores visible peers from consensus, modifies leader election to use participation data
core/consensus/qbft/qbft_internal_test.go Adds comprehensive tests for participation tracking, leader election, and expiration behavior
core/consensus/qbft/sniffed_internal_test.go Updates test to accommodate new isLeader parameter in newDefinition signature
app/featureset/featureset.go Adds PrepareProposer feature flag with alpha status
core/scheduler/testdata/*.golden Updates golden test files to include prepare_proposer duties in expected output
core/scheduler/scheduler_test.go Updates test expectations to account for additional prepare_proposer duties (2 more duties in spread tests)
Comments suppressed due to low confidence (1)

core/consensus/qbft/qbft.go:917

  • The comment "cleans up entries older than 2 slots" could be more precise. The actual logic keeps data for the current slot and the previous slot (slot-1), deleting entries from slot-2 and earlier. Consider clarifying to "cleans up entries from 2 or more slots ago" or "keeps only current slot and previous slot data".
		resp[i] = "*"
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.20%. Comparing base (403a664) to head (59e451c).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
core/unsigneddata.go 3.44% 28 Missing ⚠️
core/consensus/qbft/qbft.go 71.15% 11 Missing and 4 partials ⚠️
core/dutydefinition.go 0.00% 14 Missing ⚠️
core/fetcher/fetcher.go 0.00% 8 Missing ⚠️
core/types.go 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4179      +/-   ##
==========================================
- Coverage   56.27%   56.20%   -0.08%     
==========================================
  Files         245      245              
  Lines       31288    31395     +107     
==========================================
+ Hits        17607    17645      +38     
- Misses      11364    11432      +68     
- Partials     2317     2318       +1     

☔ View full report in Codecov by Sentry.
📢 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.

@pinebit pinebit marked this pull request as ready for review December 15, 2025 12:52
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@pinebit pinebit added the do not merge Indicate to bulldozer bot that this PR should not be merged label Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicate to bulldozer bot that this PR should not be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants