Skip to content

Conversation

kwvg
Copy link
Collaborator

@kwvg kwvg commented Jul 23, 2023

@kwvg kwvg changed the title backports: merge bitcoin#19521, #22047, #21796, #21767, #24133, #24138, #24921, #27988, #24117, #27405 (assumeutxo: part 5) backport: merge bitcoin#19521, #22047, #21796, #21767, #24133, #24138, #24921, #27988, #24117, #27405 (assumeutxo: part 5) Jul 23, 2023
@github-actions
Copy link

This pull request has conflicts, please rebase.

@github-actions
Copy link

This pull request has conflicts, please rebase.

@github-actions
Copy link

This pull request has conflicts, please rebase.

@kwvg kwvg changed the title backport: merge bitcoin#19521, #22047, #21796, #21767, #24133, #24138, #24921, #27988, #24117, #27405 (assumeutxo: part 5) backport: merge bitcoin#19521, #22047, #21796, #21767, #24133, #24921, #27988, partial #24117, #24138, #27405 (assumeutxo: part 5) Jul 28, 2023
@kwvg kwvg marked this pull request as ready for review July 28, 2023 11:11
@kwvg kwvg requested review from knst, UdjinM6 and PastaPastaPasta July 28, 2023 11:11
@kwvg kwvg requested a review from UdjinM6 July 30, 2023 12:44
@UdjinM6 UdjinM6 added this to the 20 milestone Jul 30, 2023
UdjinM6
UdjinM6 previously approved these changes Jul 30, 2023
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

LGTM, utACK

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

Seems fine, one question

@kwvg kwvg requested a review from PastaPastaPasta August 1, 2023 06:52
Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

3 changes:

  • this: knst@1c71b08

  • this refactoring (optional, can be done as an extra PR): knst@0bfefaf

  • and document block_subsidy in feature_coinstatsindex.py

@kwvg kwvg dismissed stale reviews from PastaPastaPasta and knst via 0c2e3b9 August 1, 2023 17:18
@kwvg kwvg requested review from knst and PastaPastaPasta August 1, 2023 17:23
@kwvg
Copy link
Collaborator Author

kwvg commented Aug 1, 2023

A test failure occured because changes brought on by knst's review set the subsidy value for the genesis block to what was set in chainparams (which is correct behaviour, unlike earlier behaviour, which assumed that the genesis block's reward is defined by GetBlockSubsidy).

Remnants of earlier behaviour were still left over in feature_coinstatsindex.py (see here, where the hardcoded value was taken from running GetBlockSubsidy with zero-value args), which resulted in the test failing. The same has been fixed and changes pushed.

Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

utACK (still waiting CI)

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK for merging via merge commit

kwvg added 15 commits August 2, 2023 10:19
Dash uses the height and difficulty of the previous block to calculate
the subsidy for the current block... which in the case of the genesis
block is block -1, which doesn't exist.

Attempting in reading `pprev` which is will evaluate to a `nullptr`, so
for any blocks <=0, we fetch the subsidy expected from block 0 from
CChainParams.
It's highly unlikely the test will ever deal with chains with >4500
blocks, so only the subset of the subsidy logic that is needed to
validate `gettxoutsetinfo` output has been included
@PastaPastaPasta PastaPastaPasta merged commit 0b8e501 into dashpay:develop Aug 2, 2023
PastaPastaPasta pushed a commit that referenced this pull request Aug 27, 2023
#5524)

## Issue being fixed or feature implemented
Unlike bitcoin we are using PREVIOUS block in `GetBlockSubsidy()`.

That creates special case for genesis block, because it doesn't have
previous block. In this special case instead of calling
`GetBlockSubsidy` should be used pre-calculated value. To avoid
confusion for new code and simplify implementation, there's introduced a
new method `GetBlockSubsidyPrev` that has other interface: it takes
pointer `CBlockIndex* prev` in agruments instead pair of height + nbits.

These changes are follow-up for #5501 

## What was done?
Implemented new method `GetBlockSubsidyPrev()` and used instead of
`GetBlockSubsidy` when it is more convenient.

## How Has This Been Tested?
Run unit/functional tests.

## Breaking Changes
N/A


## Checklist:
- [x] I have performed a self-review of my own code
- [x] 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
- [x] I have assigned this pull request to a milestone

---------

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
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.

4 participants