Skip to content

change(consensus): Refactor block::check::subsidy_is_valid() #8719

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

Closed
wants to merge 16 commits into from

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Jul 24, 2024

Motivation

This is an optional refactor of the subsidy_is_valid() function and could include other cleanups following the NU6 consensus rule changes.

Depends-On: #8694.

Solution

  • Adds a num_halvings() fn
  • Calls num_halvings() instead of halving_divisor() in subsidy_is_valid()

Tests

Zebra has several vectors tests for this function.

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

arya2 added 10 commits July 22, 2024 19:27
…tructs, splits them into pre/post NU6 funding streams, and adds them as a field on `testnet::Parameters`
…onversion logic with constraints.

Minor refactors
…red Testnets, but that being okay since configured testnet parameters are checked when they're being built
…ams, updates the `miner_fees_are_valid()` and `subsidy_is_valid()` functions to check that the deferred pool contribution is valid and that there are no unclaimed block subsidies after NU6 activation, and adds some TODOs
@arya2 arya2 added C-cleanup Category: This is a cleanup P-Optional ✨ labels Jul 24, 2024
@arya2 arya2 self-assigned this Jul 24, 2024
@arya2 arya2 requested a review from a team as a code owner July 24, 2024 03:34
@arya2 arya2 requested review from upbqdn and removed request for a team July 24, 2024 03:34
…too, adds Mainnet/Testnet NU6 activation heights, fixes lints/compilation issue
@arya2 arya2 force-pushed the refactor-block-subsidy-check branch from 064d266 to cb039e3 Compare July 24, 2024 03:53
arya2 added 3 commits July 24, 2024 10:21
…est_funding_stream_values()` to use a configured testnet with the post-NU6 Mainnet funding streams height range
@arya2 arya2 force-pushed the refactor-block-subsidy-check branch from f407928 to fd76ec5 Compare July 24, 2024 22:25
Comment on lines -168 to -173
if height < slow_start_interval {
unreachable!(
"unsupported block height: callers should handle blocks below {:?}",
slow_start_interval
)
} else if halving_div.count_ones() != 1 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

height < slow_start_interval is checked in num_halvings() (and was checked in halving_divisor() before this change)

halving_div.count_ones() != 1 where halving_div is 1 << num_halvings should always be false if num_halvings <= 2 (and should have always been false before this change since it would return early if 1u64.checked_shl(num_halvings) == None).

@arya2 arya2 requested a review from a team as a code owner July 25, 2024 21:15
@arya2
Copy link
Contributor Author

arya2 commented Jul 25, 2024

Closing this for now, it's easier to recreate than to maintain

@arya2 arya2 closed this Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: This is a cleanup P-Optional ✨
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant