Skip to content

Fix: tenure downloader reward set error #6234 #6276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

kantai
Copy link
Contributor

@kantai kantai commented Jul 10, 2025

This PR refactors the reward cycle fetching logic in the tenure downloader and fixes the #6234 bug.

First -- I moved the downloader_block_height_to_reward_cycle method into a newly named (and commented) method thats a static method of the NakamotoDownloadStateMachine struct. The logic of that calculation is: given a block commit at burn height X, what is the latest possible reward cycle for a tenure the commit confirms?

I think that the only places we want to use this calculation are in WantedTenures request generation -- basically, given a sortition tip, what tenures could we download and confirm?

The bug in #6234 was caused by the fact that this calculation was also used for the reward set caching logic of the (unconfirmed) tenure downloader. This meant that for the first two tenures of a new reward cycle, the wrong reward sets would be used for download validation. The fix for this was to simply use the normal reward set calculation in those instances.

This PR adds an integration test for this behavior: basically, perform signer-set rollover with 2 active nodes. Importantly, in order for the test to actually cover the behavior, the nodes need to refuse block pushes (otherwise, they never need to use the TenureDownloader at all).

@kantai kantai requested review from a team as code owners July 10, 2025 15:36
obycode
obycode previously approved these changes Jul 10, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the clear comments!

obycode
obycode previously approved these changes Jul 10, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

👍

obycode
obycode previously approved these changes Jul 11, 2025
@kantai kantai added this to the 3.1.0.0.14 milestone Jul 11, 2025
@kantai kantai self-assigned this Jul 11, 2025
@kantai kantai moved this to Status: In Review in Stacks Core Eng Jul 11, 2025
@aldur aldur requested a review from Jiloc July 11, 2025 16:09
Jiloc
Jiloc previously approved these changes Jul 11, 2025
Copy link
Contributor

@Jiloc Jiloc left a comment

Choose a reason for hiding this comment

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

lgtm! The comment made it way clearer :) I just left a couple of comments that you can feel free to just close them and merge

Co-authored-by: Francesco <2530388+Jiloc@users.noreply.github.com>
@kantai kantai dismissed stale reviews from Jiloc and obycode via fde56b4 July 11, 2025 19:25
@kantai kantai requested a review from Jiloc July 11, 2025 20:49
Copy link
Contributor

@Jiloc Jiloc left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-project-automation github-project-automation bot moved this from Status: In Review to Status: 💻 In Progress in Stacks Core Eng Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: 💻 In Progress
Development

Successfully merging this pull request may close these issues.

Invalid tenure-start block: bad signer signature, tenure_id: 4630b863aedb9ea92b92abf7ddea09fae014a0c1
3 participants