Skip to content

fix: respect stop= in nakamoto unconfirmed tenure downloads - #7917

Open
cylewitruk-stacks wants to merge 1 commit into
stacks-network:mainfrom
cylewitruk-stacks:fix/nakamoto-tenure-download-stop-query
Open

cylewitruk-stacks wants to merge 1 commit into
stacks-network:mainfrom
cylewitruk-stacks:fix/nakamoto-tenure-download-stop-query

Conversation

@cylewitruk-stacks

Copy link
Copy Markdown
Contributor

Description

Fixes two issues preventing stop= from working in Nakamoto unconfirmed tenure downloads:

  1. Preserve the stop= query parameter on /v3/tenures/{block_id} requests (stackslib/src/net/api/gettenure.rs): StacksHttpRequest::new_get_nakamoto_tenure previously embedded ?stop=<block_id> directly in the path string, which StacksHttpRequest::new_for_peer stripped and replaced with HttpRequestContents query args. Pass stop via HttpRequestContents::query_arg instead so peers actually receive it.
  2. Finish unconfirmed tenure downloads at the child of highest_processed_block_id (stackslib/src/net/download/nakamoto/tenure_downloader_unconfirmed.rs): a peer honouring stop=<id> stops before sending <id>, so the downloader now marks the download complete when block.header.parent_block_id == highest_processed_block_id rather than waiting for highest_processed_block_id itself.

Adds a request round-trip test for stop= parsing (test_try_parse_request_with_stop), updates unconfirmed tenure downloader tests, and adds a changelog fragment (changelog.d/nakamoto-tenure-request-stop-query.fixed).

Additional info (benefits, drawbacks, caveats)

  • Benefit: Avoids re-downloading already-processed blocks all the way back to the tenure start when syncing an unconfirmed Nakamoto tenure.
  • Compatibility: Older peers that ignore stop= continue to work; the downloader still stops once it reaches the child of highest_processed_block_id and truncates any trailing blocks.

Checklist

  • Test coverage for new or modified code paths
  • For new Clarity features or consensus changes, add property tests (N/A)
  • Changelog fragment(s) or "no changelog" label added
  • Required documentation changes (N/A)
  • New clarity functions have corresponding PR in clarity-benchmarking repo (N/A)

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.

🟢 Approval recommended

No active review issues block approval of the unconfirmed tenure synchronization fix.

No open issues 🎉

What changed in this PR

Fixes stop= handling in Nakamoto unconfirmed tenure synchronization, avoiding unnecessary downloads of already-processed blocks.

Changes:

  • Preserves the stop query parameter when constructing tenure requests.
  • Completes downloads at the child of the highest processed block, matching the server’s exclusive stop boundary.
  • Adds request round-trip coverage, updates downloader assertions, and documents the fix.
File Description
stackslib/​src/​net/​tests/​download/​nakamoto.rs Updates completion and returned-block expectations.
stackslib/​src/​net/​download/​nakamoto/​tenure_downloader_unconfirmed.rs Detects completion using the block’s parent ID.
stackslib/​src/​net/​api/​tests/​gettenure.rs Tests serialization and parsing of stop.
stackslib/​src/​net/​api/​gettenure.rs Passes stop through request query arguments.
changelog.d/​nakamoto-tenure-request-stop-query.fixed Documents the corrected download behavior.

Review effort: Balanced

@cylewitruk-stacks cylewitruk-stacks changed the title fix(net): respect stop= in nakamoto unconfirmed tenure downloads fix: respect stop= in nakamoto unconfirmed tenure downloads Nov 27, 2026

This branch has not been deployed

No deployments
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