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

[Consensus] New masternode payment logic #2309

Merged
merged 6 commits into from
May 23, 2021

Conversation

random-zebra
Copy link

@random-zebra random-zebra commented Apr 11, 2021

Estracted from #2267
This implements the new payment logic for deterministic masternodes, to be used after the deactivation of the legacy system with SPORK_21.

Based on top of:

@random-zebra
Copy link
Author

Rebased on master. Next in line for the DIP3 list.

Fuzzbawls
Fuzzbawls previously approved these changes May 13, 2021
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.

Code ACK c3c3202

few non-blocking whitespace nits, but otherwise looks good

src/masternode-payments.cpp Outdated Show resolved Hide resolved
src/masternode-payments.cpp Outdated Show resolved Hide resolved
src/test/evo_deterministicmns_tests.cpp Outdated Show resolved Hide resolved
@random-zebra
Copy link
Author

Fixed whitespaces.

Fuzzbawls
Fuzzbawls previously approved these changes May 13, 2021
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.

re-Code ACK 69e6ab5

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.

Code review completed

Spent some time here, have expanded the test coverage to verify that an invalid block paying to a DMN that shouldn't be paying is being rejected. Plus, found out that the new DMN payments validation flow is not being tested, it is just skipped due the not finished masternode sync process and the disabled MN payments spork in the test (the IsBlockPayeeValid function is just returning true without performing any validation at line 245).

The work is here https://github.com/furszy/PIVX/commits/202103-dmn-payments, all yours ☕.

src/masternode-payments.cpp Outdated Show resolved Hide resolved
src/masternode-payments.cpp Outdated Show resolved Hide resolved
@random-zebra
Copy link
Author

Thanks for the review @furszy .
Functional testing for invalid mn payees will be added in b28fc43, but good idea to have unit test coverage too.
Picked. Spork8/mnsyc shouldn't be needed in the future (SPORK_8 can be deprecated after the switch, and the mnsync will be required exclusively for budgets) but better to keep it for now, yah 👍 .

Added a commit at the end, as, rebasing on master, I noticed that I broke this test in #2360.

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.

All good👌 , nice work 🍺.
ACK 6b7b9df

@random-zebra random-zebra merged commit d95f524 into PIVX-Project:master May 23, 2021
furszy added a commit that referenced this pull request May 31, 2021
4fd564c [Tests] Add EvoNotificationInterface in the TestingSetup fixture (random-zebra)
f6aa6ad [BUG] Check masternode/budget payments during block connection (random-zebra)
57fa99f [Tests] Introduce tiertwo_reorg_mempool test (random-zebra)
9a1bf27 [BUG] Add special tx processing to RollforwardBlock (random-zebra)
5d6bcef [RPC][Tests] Include proTx data in json formatted transactions (random-zebra)
93e8453 [Tests] Update deterministicmns test checking collateral locking (random-zebra)
cc132a8 [Wallet] Implement auto-locking of masternode collaterals (random-zebra)
c857636 [Tests] Introduce new functional test tiertwo_deterministicmns.py (random-zebra)

Pull request description:

  Another one coming from #2267
  This PR introduces a "auto-locking" feature for masternode collaterals:

  - at startup, the wallet is scanned, and any masternode collateral coin found gets locked. Can be disabled setting `-mnconflock=0` (although, there is no need for a `masternode.conf` anymore, so we might want to consider defining and using a new flag here, and removing `mnconflock` after 6.0).

  - during runtime, when a ProRegTx is processed by `CWallet::AddToWalletIfInvolvingMe`, the wallet checks for ownership of the collateral, and automatically locks it in case.

  Here, we also add two more functional tests (`tiertwo_deterministicmns.py`, `tiertwo_reorg_mempool.py`), update the other tests, checking the auto-locking feature, and fix a couple bugs:

  - Missing special tx processing in RollforwardBlock

  - Validity of tiertwo payments can (and must) be verified only during block connection, as we keep the deterministic state only for the active chain, not for all possible chaintips.

  Builds on top of:
  - [x] #2308
  - [x] #2309

ACKs for top commit:
  furszy:
    re-ACK 4fd564c after the tiny fix and merging..

Tree-SHA512: b0f05d9265c02fe90baf48e5dcf66b34f078b90ffd0eef1488606013f84996b2ebaa7d70725c59db2f7456105a6eff2ba08da966858f81c4f19d014a72cd7692
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.

3 participants