Skip to content

fix: bound DKG pending message queues across NodeId reconnects - #7524

Draft
PastaPastaPasta wants to merge 1 commit into
dashpay:developfrom
PastaPastaPasta:sec/v017
Draft

fix: bound DKG pending message queues across NodeId reconnects#7524
PastaPastaPasta wants to merge 1 commit into
dashpay:developfrom
PastaPastaPasta:sec/v017

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Aug 2, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

v23.1.8 added param-derived limits for individual DKG messages, but aggregate pending-queue retention was still bounded only by messagesPerNode[from] >= maxMessagesPerNode. NodeId is an ephemeral per-connection identifier, and disconnecting a peer did not release its counter, queued payloads, or queued seenMessages hashes.

A peer could therefore reconnect under fresh NodeId values and repeatedly obtain a new quota while prior payloads remained resident. Observer-mode handlers are especially exposed because they enqueue DKG traffic but do not advance rounds and clear the queues.

What was done?

  • Rebase the fix onto current develop, preserving the v23.1.8 per-message structural and size checks.
  • Retain the per-connection message-count quota and add a queue-wide limit based on actual serialized payload bytes. Each message-type budget is derived from the quorum size and that type's maximum well-formed serialized size.
  • Reject duplicate hashes and empty or individually over-budget remote payloads before quota accounting or eviction, so replay traffic cannot evict another queued message.
  • On byte pressure, evict the oldest payload belonging to the peer currently retaining the most bytes.
  • Add a protocol-handler finalization hook and remove a disconnecting peer's unprocessed payloads, quota, and corresponding queued hashes.
  • Keep locally generated DKG contributions exempt from peer-driven limits.

How Has This Been Tested?

  • make -C src -j8 test/test_dash
  • ./src/test/test_dash --run_test=llmq_dkg_pending_tests (8 test cases)
  • git diff upstream/develop...HEAD --check

The focused tests cover per-node quotas, byte bounds across fresh NodeId values, oversized and empty payload rejection, duplicate replay behavior, byte-based eviction, local-message retention, and disconnect cleanup/accounting.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

@PastaPastaPasta
PastaPastaPasta force-pushed the sec/v017 branch 2 times, most recently from ee9c5e9 to b988249 Compare August 3, 2026 15:01
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

CDKGPendingMessages limited intake per NodeId, but NodeId is an ephemeral per-connection identifier. Reconnecting peers could therefore obtain a fresh quota while previously queued payloads remained resident; observer-mode handlers could retain that state indefinitely.

Bound each message-type queue by actual serialized payload bytes derived from its quorum parameters while retaining the per-connection count limit. Reject duplicates and invalid sizes before applying capacity pressure, evict the oldest payload from the peer with the largest occupancy when necessary, and keep locally generated DKG messages exempt.

Add a protocol-handler finalization hook that releases a disconnecting peer's unprocessed payloads, quota, and corresponding seen hashes. Cover byte accounting, reconnect bounds, duplicate replay, eviction, local messages, and disconnect cleanup with focused unit tests.
@PastaPastaPasta PastaPastaPasta changed the title fix: bound DKG pending message queue across NodeId reconnects fix: bound DKG pending message queues across NodeId reconnects Aug 4, 2026
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.

1 participant