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

[Core] CheckColdStakeFreeOutput: skip SPORK checks if mnsync incomplete #1331

Merged
merged 1 commit into from
Feb 17, 2020

Conversation

random-zebra
Copy link

Currently CheckBlock skips the masternode (or budget) payment check in coinstakes when IsInitialBlockDownload() returns true (essentially when the current best block time is older than nMaxTipAge seconds).

Since, in order to verify the block payee, the masternode list needs to be up to date, IsBlockPayeeValidalso skips the checks when mnsync has not finished.
CheckColdStakeFreeOutput however, does not, so, when the spork list is not updated, SPORK_13 and SPORK_9 cannot be verified (in case of budget payment blocks) resulting in CheckBlock failures with

ERROR: CheckColdStakeFreeOutput: Wrong cold staking outputs:

(Unless the user doesn't manually set a lower nMaxTipAge to force IsInitialBlockDownload to true).

This fixes it.

@random-zebra random-zebra added this to the 4.1.0 milestone Feb 12, 2020
@random-zebra random-zebra self-assigned this Feb 12, 2020
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

good catch

utACK bd62481

Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

utACK bd62481

furszy added a commit that referenced this pull request Feb 17, 2020
…sync incomplete

bd62481 [Core] CheckColdStakeFreeOutput: skip SPORK checks if mnsync incomplete (random-zebra)

Pull request description:

  Currently `CheckBlock` skips the masternode (or budget) payment check in coinstakes when `IsInitialBlockDownload()` returns true (essentially when the current best block time is older than nMaxTipAge seconds).

  Since, in order to verify the block payee, the masternode list needs to be up to date, `IsBlockPayeeValid`also skips the checks when mnsync has not finished.
  `CheckColdStakeFreeOutput` however, does not, so, when the spork list is not updated, SPORK_13 and SPORK_9 cannot be verified (in case of budget payment blocks) resulting in CheckBlock failures with
  ```
  ERROR: CheckColdStakeFreeOutput: Wrong cold staking outputs:
  ```
  (Unless the user doesn't manually set a lower nMaxTipAge to force IsInitialBlockDownload to true).

  This fixes it.

ACKs for top commit:
  Fuzzbawls:
    utACK bd62481
  furszy:
    utACK bd62481

Tree-SHA512: aa52ac0c9bc597d7bceec88924fd6f264aa3588915eb1052dd28f32e133d16d2ab6527a67ef90004619c08fd613adf9f4c69bb1ee30dfd2fe2529862b39669c9
@furszy furszy merged commit bd62481 into PIVX-Project:master Feb 17, 2020
random-zebra added a commit that referenced this pull request Mar 25, 2020
…plete

aa5dc7b [Consensus] Strict check amounts in CCSFO for mnsync incomplete (random-zebra)
d6a1060 [Consensus] CheckColdStakeFreeOutput when mnsync not complete (random-zebra)

Pull request description:

  Follow up to #1331 for the same bug.

  **Problem:** if the finalized budgets and the masternode list are not synchronized, the output returned from `IsBudgetPaymentBlock` is unreliable.

  For the moment we fix it by checking that the sum of the stake input value and block reward is at least equal to the sum of the values of non-free outputs.

  A better approach, for the future, would be probably to outright prevent any call to `CheckBlock` when `IsInitialBlockDownload` is false but mnSync is not fully completed yet.

Top commit has no ACKs.

Tree-SHA512: cd2e765b865172a55bd8b05d132d356078b1956da6449c819ebdcedd1291d412fdf4249ac5e0d1e7db808c9c3543451df085791ed743e7441618368a07fad6c6
akshaynexus pushed a commit to ZENZO-Ecosystem/ZENZO-Core that referenced this pull request Mar 30, 2020
…sync not complete

aa5dc7b [Consensus] Strict check amounts in CCSFO for mnsync incomplete (random-zebra)
d6a1060 [Consensus] CheckColdStakeFreeOutput when mnsync not complete (random-zebra)

Pull request description:

  Follow up to PIVX-Project#1331 for the same bug.

  **Problem:** if the finalized budgets and the masternode list are not synchronized, the output returned from `IsBudgetPaymentBlock` is unreliable.

  For the moment we fix it by checking that the sum of the stake input value and block reward is at least equal to the sum of the values of non-free outputs.

  A better approach, for the future, would be probably to outright prevent any call to `CheckBlock` when `IsInitialBlockDownload` is false but mnSync is not fully completed yet.

Top commit has no ACKs.

Tree-SHA512: cd2e765b865172a55bd8b05d132d356078b1956da6449c819ebdcedd1291d412fdf4249ac5e0d1e7db808c9c3543451df085791ed743e7441618368a07fad6c6
@random-zebra random-zebra deleted the 2020_mnsync-checkmain branch September 24, 2020 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants