Skip to content
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

Fix: manually calculate current reward cycle ID in /v2/pox_info #4468

Merged
merged 2 commits into from Mar 5, 2024

Conversation

kantai
Copy link
Member

@kantai kantai commented Mar 1, 2024

Description

/v2/pox invokes get-pox-info in the current PoX contract to obtain information about the current cycle. However, the burn view of this invocation is always one block behind the current chain tip: 2.x Stacks blocks are evaluated with a burnchain view equal to their parent (because the Stacks blocks must be assembled before the burn block in which they are committed).

This leads to an "off by one" situation at reward cycle boundaries. This isn't a huge problem for Stacks 2.x nodes, because the information returned from this endpoint isn't really critical during the reward cycle change-overs. For signers in Nakamoto, though, this is problematic: they must know that the reward cycle has changed because they are now responsible for signing any new blocks at the time of the change-over.

This PR addresses this problem by manually computing the current reward-cycle ID.

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 82.38%. Comparing base (4530f01) to head (d5af26e).
Report is 36 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #4468      +/-   ##
==========================================
- Coverage   83.45%   82.38%   -1.07%     
==========================================
  Files         448      453       +5     
  Lines      323993   325564    +1571     
  Branches        0      318     +318     
==========================================
- Hits       270387   268227    -2160     
- Misses      53606    57329    +3723     
- Partials        0        8       +8     
Files Coverage Δ
stackslib/src/net/api/getpoxinfo.rs 93.33% <83.33%> (-0.58%) ⬇️

... and 59 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4530f01...d5af26e. Read the comment docs.

jcnelson
jcnelson previously approved these changes Mar 1, 2024
obycode
obycode previously approved these changes Mar 1, 2024
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.

👍

@saralab saralab enabled auto-merge March 4, 2024 16:22
@kantai kantai dismissed stale reviews from obycode and jcnelson via d5af26e March 4, 2024 22:04
@kantai kantai requested review from jcnelson and obycode March 5, 2024 00:56
@saralab saralab added this pull request to the merge queue Mar 5, 2024
Merged via the queue into next with commit 11d7434 Mar 5, 2024
2 checks passed
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.

None yet

5 participants