Skip to content

core/priority: gate duties received from peers - #4643

Open
pinebit wants to merge 1 commit into
mainfrom
pinebit/priority-duty-gater
Open

core/priority: gate duties received from peers#4643
pinebit wants to merge 1 commit into
mainfrom
pinebit/priority-duty-gater

Conversation

@pinebit

@pinebit pinebit commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

The priority protocol handler uses the duty slot from the received message. A cluster peer can retain a deadliner entry and a request buffer per distinct slot, neither of which is released until the deadline it supplied expires.

Gate duties received from peers with core.DutyGaterFunc before allocating any per-duty state, matching what parsigex and the consensus components already do. The gater bounds duties to the current epoch plus two and rejects invalid duty types. Duties initiated locally stay ungated, they come from the scheduler.

Info sync duties are triggered for the last slot of the current epoch, so they sit well inside the gater's bound. TestDutyGaterInfoSync pins that, including for a peer lagging into the next epoch.

category: bug
ticket: none

The priority protocol handler used the duty slot straight off the wire.
A cluster peer could retain a deadliner entry and a request buffer per
distinct slot, neither of which is released until the (attacker chosen)
deadline expires.

Gate received duties with core.DutyGaterFunc before allocating any
per-duty state, as parsigex and the consensus components already do.
Duties initiated locally stay ungated, they come from the scheduler.

category: bug
ticket: none

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@pinebit
pinebit requested a lite review from Copilot August 12, 2026 08:42
@sonarqubecloud

Copy link
Copy Markdown

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 mitigates a potential peer-triggered resource retention issue in the priority protocol by gating peer-initiated duties (slot/type validation) before allocating any per-duty state, aligning priority with existing gating behavior in consensus and parsigex.

Changes:

  • Add core.DutyGaterFunc plumbing to the priority component/prioritiser constructors and wire it from app workflow setup.
  • Gate peer-received priority requests in handleRequest before touching the deadliner or allocating a per-duty request buffer.
  • Add targeted tests ensuring gated duties do not allocate per-duty state, and pin info-sync duties as allowed by the duty gater.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/priority/prioritiser.go Adds DutyGaterFunc to prioritiser and gates peer requests before deadliner/buffer allocation.
core/priority/prioritiser_test.go Updates constructor calls and adds an allow-all gater for tests.
core/priority/prioritiser_internal_test.go Adds tests asserting gated duties don’t create deadliner/buffer state and flood behavior doesn’t retain state.
core/priority/component.go Threads DutyGaterFunc into priority component construction.
core/gater_test.go Adds coverage ensuring info-sync duties remain allowed by the duty gater across epoch boundary reception.
app/app.go Wires the existing gaterFunc into priority protocol wiring.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.18%. Comparing base (64059d2) to head (ce740f8).

Files with missing lines Patch % Lines
app/app.go 0.00% 2 Missing ⚠️
core/priority/component.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4643      +/-   ##
==========================================
+ Coverage   58.15%   58.18%   +0.03%     
==========================================
  Files         247      247              
  Lines       34065    34068       +3     
==========================================
+ Hits        19811    19823      +12     
+ Misses      11780    11774       -6     
+ Partials     2474     2471       -3     

☔ 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.

@pinebit
pinebit requested a review from KaloyanTanev August 12, 2026 10:24
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.

3 participants