core/priority: gate duties received from peers - #4643
Conversation
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>
|
There was a problem hiding this comment.
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.DutyGaterFuncplumbing to the priority component/prioritiser constructors and wire it fromappworkflow setup. - Gate peer-received priority requests in
handleRequestbefore 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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|



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.DutyGaterFuncbefore 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.
TestDutyGaterInfoSyncpins that, including for a peer lagging into the next epoch.category: bug
ticket: none