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

[Doc] Introducing Deterministic Masternodes #2267

Merged
merged 1 commit into from Jul 18, 2021

Conversation

random-zebra
Copy link

This is the current state of my DMN branch.
Deterministic masternodes fully working on regtest (except for proof of service, which will come later), with a good number of tests covering registration, update, revocation, revival, collaterals auto-locking, consistency after reorgs, compatibility with the old system, payments, and governance voting. ☕

There are several differences with Dash code, mostly in the RPC, mempool, block assembler, compatibility code, wallet, deployment logic, and unit/functional testing (which led to the discovery of a few bugs, including a non-trivial one, reported upstream).
But, overall, this remains respectful of the specification given here (at least for now... we'll have to modify the spec a bit when introducing shield rewards later):

Huge props and thanks to Codablock and the Dash Core developers for the design of this awesome protocol.

In order to follow the specification, implementing it in our PoS system, while still allowing the cold-stake script, a critical consensus change was needed: the masternode/budget payment is no longer included in the coinstake transaction. It is, instead, an output of the coinbase transaction, which, in turn, is no longer required to be empty.
As a side effect, this enables the definition and use of a new P2CS script, with no "free" outputs.
The block version is bumped to 10, with the new rules.

This PR serves as general container for tracking, and will now be divided in more manageable sub-PRs, for better review.

Introduction

Deterministic Masternode lists are lists of masternodes, built at every block, relying only on on-chain data (previous list, and transactions included in the current block).
All nodes derive (and verify) their masternode lists independently, from the same on-chain transactions, thus they immediately reach consensus on the tier-two state (number of masternodes, properties and status of each one).
As clearly explained in the "motivation" part of the DIP document, this is crucially different from the previous system:

The previous system was maintained with consensus mechanisms that predated Satoshi Nakamoto’s solution to the Byzantine Generals Problem. This meant that each node needed to maintain their own individual masternode list with P2P messages and not a blockchain based solution. Due to the nature of the P2P system, there was no guarantee that nodes would come to the same conclusion on what the masternode list ought to look like. Discrepancies might, for example, occur due to a different order of message reception or if messages had not been received at all. This posed some risks in regard to consensus and limited the possible uses of quorums by the system.

As a concrete example, the previous system required implementing workarounds such as "masternode reward voting" which was performed multiple blocks in advance for each block to make sure that consensus would be found and agreed on. Enforcing this consensus however still posed a risk which could have resulted in network wide forking, so a spork to turn off masternode payment enforcement was added to prevent this issue from occurring. The spork was used sporadically after major network updates.

This is a major overhaul, which brings also a good number of improvements in the user experience, while removing the shortcomings of the previous system.
All reviewers are encouraged to take a deep dive in the DIP3 document, which describes perfectly the advantages of the new system.

New Roles

For each masternode, three different "roles" are defined. Each role is represented by a private/public keypair.

  1. Owner: Must be unique on the network. Can update the other two roles, and the masternode payout address.
  2. Operator: Must be unique on the network. The operator key is saved in the pivx.conf of the remote node, and it is used to sign masternode-related P2P messages (e.g. budget finalisations, or masternode winners in the compatibility code). It can also be used to update the masternode IP-address, or the operator payout address (if the masternode is configured to allow a percentage of the reward to be paid to operator).
  3. Voting: Doesn't have to be unique (multiple masternodes can share the same voting key). It is used to cast budget votes.

The same keypair can be used for all three roles (at least for now, the operator key will be changed to a BLS key soon), but they must be different from the key of the collateral address.

New Transaction Types

Special transactions (DIP2) were introduced in #1966, but no new transaction type has been defined in PIVX yet.
Here we introduce four new types, each identifying a particular transaction payload, with its own validation rules:

  • PROREG (provider-register): this is the main special transaction. Used for the registration of a new masternode, setting all of its properties (such as the keys for each role). It creates the masternode collateral, as one of its outputs, or it references a 10000 PIV unspent output on chain (in which case, it must include a signature with its keys, as proof of ownership).
  • PROUPSERV (provider-update-service): sent by the mn operator to update the properties related to the service (IP address, operator payout address)
  • PROUPREG (provider-update-registrar): sent by the mn owner to update the operator key, the voting key, or the payout address.
  • PROUPREV (provider-update-revoke): sent by the mn operator to revoke the service, and put the mn in PoSe-banned state (e.g. in case of compromised keys). The masternode can be "revived" later, by sending a ProUpReg tx, which sets a new operator key, and then a ProUpServ tx (signed with the new key), which sets the new IP address for the masternode.

Code Architecture

Deterministic masternodes are represented as objects of the class CDeterministicMN.
This class includes a member variable that stores a shared pointer to a constant CDeterministicMNState object, which encapsulates the dmn state (updated properties and status).

A list of masternodes is represented by the class CDeterministicMNList, which uses immutable functional maps (https://github.com/arximboldi/immer) to hold the actual information about each entry.
A new list is built at every block and mantained by CDeterministicMNManager.

The use of immutable functional maps is, in my opinion, an elegant solution, devised by Codablock, to reduce the memory overhead required for the masternode list update at every block, by adopting a copy-on-write approach.
Immutable data structures are provided by default on functional-programming oriented languages, such as Clojure or Scala, but for C++ we unfortunately need to rely on third party libraries.
We could switch to an implementation based on std::maps, but that would severly impact the performance and require hundreds of MB in the ram, just for MN list housekeeping.

The code still contains a lot of ugly parts, which we need to keep for compatibility with the old system. Most of them are properly commented. My first task, after the full deployment on mainnet, will be to do a general cleanup and refactoring, removing all the legacy system code.

Deployment

This an hard-forking update, slated for PIVX v6.0.
It will be deployed with a combination of nuparams activation height, and a spork message.
For this purpose, a new height-based (rather than time-based) spork, SPORK_21_LEGACY_MNS_MAX_HEIGHT, is introduced.
It will be used only during the transition to the new system, and can be removed afterwards.

As in the previous mandatory upgrades, there will be a protocol bump, shortly before the enforcement block.
All nodes must be updated before the protobump.
Masternodes, as usual, will need to send a new MNB start message, after upgrading, with the new protocol number.

After the enforcement, new consensus rules apply (such as block v10), and new special transactions are accepted on the network (with the exception of PROUPREG).
Deterministic masternodes can be registered, but have a few limitations, in order to be compatible with the legacy system (which is still active): for example, they cannot pay a portion of the reward to the operator, yet.
The system still uses the old logic for masternode payments (mnw signed messages), with new compatibility code, in order to take into account also nodes from the deterministic list.

After the activation of SPORK_21_LEGACY_MNS_MAX_HEIGHT, the legacy system is disabled, and the transition to deterministic masternode lists is complete.
At this point, mno can also send PROUPREG transactions, and use all the features of DMNs. The new payment logic applies.

The reasons for using a spork, instead of pre-set number of blocks after enforcement, are multiple:

  • It allows for easier testing on testnet, with the possibility of disabling and re-enabling legacy masternodes multiple times, in order to test different scenarios
  • It allows for safer deployment on mainnet: we might want to wait until the network has a good percentage of dmn, before disabling the legacy system. Or, conversely, there could be an unforseen bug in the compatibility code, which would require a transition faster than expected.

TODO

These are the next milestones:

  • Proof of service for masternodes (with DIP6 and DIP7)
  • kickass GUI
  • Budget system overhaul
  • Chain-locks (DIP8)
  • SHIELD masternode rewards

random-zebra added a commit that referenced this pull request Apr 6, 2021
…ring reorg

2ae953a Store disconnected block transactions outside mempool during reorg (random-zebra)

Pull request description:

  Extracted from #2267.
  This backports bitcoin#9208.
  As highlighted by zcash/zcash#2951, this "performance improvement" actually includes a fix for the following bug:

  > Currently, AcceptToMemoryPool is called inside DisconnectTip after the block has been disconnected, but before chainActive has been updated. This means that height-dependent consensus rules are checked assuming the height is one greater than it actually is, which is a problem when disconnecting the last block before a network upgrade (e.g. during a reorg across the upgrade boundary).

  This has additional consequences with special transactions (that's why it was discovered in #2267), as, during a reorg, `ProUp*` transactions, included in the block, might not be resurrected in the mempool, due to the inconsistent state of chainActive.

ACKs for top commit:
  furszy:
    re-ACK 2ae953a.
  Fuzzbawls:
    ACK 2ae953a

Tree-SHA512: d97d00594acab4db239a162f37a744e7cb6dbf45aef9a8fe6e51db440a26efb93086bc2b7de4c0b4b4adbcce55f5e066f1e8698cac094c3c6d1ba5e94c6f317d
random-zebra added a commit that referenced this pull request Apr 6, 2021
92c3c8d [Build] Use C++14 standard (random-zebra)
4db411f [Consensus] Add SPORK_21 to disable old masternodes at specific height (random-zebra)
a6519e1 [Consensus] Introduce V6 hardfork params (random-zebra)

Pull request description:

  Extracted from #2267.
  This includes the network upgrade parameter for `UPGRADE_V6_0` (currently disabled on all three networks), and defines `SPORK_21_LEGACY_MNS_MAX_HEIGHT`, which will be used for the transition to DMN lists (as described, under "deployment", in #2267).
  This also sets the C++ standard to `14`, which will be required by the immer library, and other parts of the code.

ACKs for top commit:
  furszy:
    ACK 92c3c8d
  Fuzzbawls:
    ACK 92c3c8d

Tree-SHA512: a4669d7e4d32e72af18bcd6783f91449c0d51aab27521234480291844b89d1c1cd53d9ab1e62f2d5a462e8efc4178e8efc941312e8d56d8263e166cae7f24523
random-zebra added a commit that referenced this pull request Apr 11, 2021
b408de3 [Refactoring] non-contextual checks for special txes in CheckBlock (random-zebra)
50a55b7 [Cleanup] Remove unused boolean arguments in CheckZerocoinSpend (random-zebra)
34882e6 [Refactoring][Consensus] Connect SpecialTx processing to validation code (random-zebra)
eba2377 [Refactoring] Move CheckSpecialTx out of CheckTransaction (random-zebra)
63a87f9 [Refactoring] move zerocoin contextual checks out of CheckTransaction (random-zebra)
bfd3fe4 [Refactoring] unify contextual checks for txes (random-zebra)
11d2025 [Refactoring] move sapling contextual checks out of CheckTransaction (random-zebra)
dab3830 [Tests][Trivial] Remove annoying warning for unintended optimization (random-zebra)
e1eb3f5 [Cleanup] Remove fSaplingActive from CheckSpecialTx (random-zebra)
9ef8031 [Wallet] Account for extra payload sizes in Fund/CreateTransaction (random-zebra)
517fe0c [Trivial][Cleanup] Remove unused variable in ScanForWalletTransactions (random-zebra)
286a35e [Refactoring] Make CWallet::FundTransaction atomic (random-zebra)
e288fd6 [RPC] Return full debug message for ATMP failures in sendrawtransaction (random-zebra)
69662f8 [Core] Add GetSerializeSizeNetwork for generic (non-array) Optionals (random-zebra)
211b36d [Tests] Fix proper sapling tx version in unit tests (random-zebra)
a0a5170 [Refactor] Introduce GetUTXO* functions relying on pcoinsTip (random-zebra)
6267534 [MOVE] rename files specialtx_validation.* --> specialtx.* (random-zebra)

Pull request description:

  Extracted from #2267.
  This is a collection of small refactorings around the validation code, which will make future additions easier to review.
  See individual commit's description.

ACKs for top commit:
  furszy:
    ACK b408de3 .
  Fuzzbawls:
    Code ACK b408de3

Tree-SHA512: 4265869adba892baa144fc87d56c301fe79939a7e0937967789a73fc1df8a6674d80bba528d88c61227ddbfa92914ef351c6e9f07d1ebee0cf43ebb21f24e6d5
furszy added a commit that referenced this pull request Apr 13, 2021
c27bbed [Cleanup] functions impl: branch on new line (random-zebra)
8850b3e [Refactoring] Make CEvoDB mutex public (random-zebra)
304fc46 Take memory used by CEvoDB/CDBTransaction into account when flushing (random-zebra)
ed0d4f9 Track memory usage in CDBTransaction and CEvoDB (random-zebra)
f259774 Implement CDBTransactionIterator (Alexander Block)
51920cb Change CDBTransaction to compare keys by their serialized form (Alexander Block)
7094a60 Support passing CDataStream as key into CDBWrapper/CDBBatch/CDBIterator (Alexander Block)
cdd44d4 [Cleanup] Drop unneeded casts (random-zebra)
65b8ddc [DB] Specialize CScopedDBTransaction for evo database (random-zebra)
34a7541 [Refactoring] Properly add explicit specifier where appropriate (random-zebra)
6a36968 Implement 2-stage commit for CEvoDB to avoid inconsistencies (Alexander Block)
e6c7efe [Refactoring] Let Commit() return void (random-zebra)
fec56b0 [DB] Ensure evoDB consistency by storing best block hash (random-zebra)
be85c9a [Refactoring] migrate evoDb to unique pointer (random-zebra)
cab50d3 [Tests] Fix functional test suite with new directory 'evodb' (random-zebra)
ad7f5d7 [DB][BUG] Add virtual destructor for KeyValueHolder (random-zebra)
d6c56d1 Introduce CEvoDB for all evo related things, e.g. DIP3 (Alexander Block)
2496933 Implement CDBTransaction and CScopedDBTransaction (Alexander Block)
da6a2c1 [Build] CMake: Introduce evo headers (random-zebra)
f3a7cfb [Trivial] Remove unused variable in ProcessNewBlock (random-zebra)

Pull request description:

  Extracted from #2267.
  This introduces the new database, used for all DMN-related things, and updates the dbWrapper.

  Builds on top of:
  - [x] #2269
  - [x] #2270

ACKs for top commit:
  Fuzzbawls:
    Code ACK c27bbed
  furszy:
    Code ACK c27bbed.

Tree-SHA512: a93b0c96759b9493659d2e5c69d2fa9d7dbcb260b7f7ec4d2e7db2d1f2a4561f9548bbe4db07272792b5d6dbf33fd8e7c84f04d958781e6d9bb3fb1fdcbf2ea1
furszy added a commit that referenced this pull request Apr 27, 2021
6dbdf37 [Consensus] Serialize also shield inputs for ProReg inputshash (random-zebra)
e0ff60f [Consensus] Serialize the whole scriptPayout for ProReg sign string (random-zebra)
e659d7e [Trivial] Fix styling/logging nits (random-zebra)
170ab92 [Tests] Check for protx inputs hash in evo_specialtx_tests (random-zebra)
a1cb227 [BUG] Add proper virtual dtor for CActiveDeterministicMasternodeManager (random-zebra)
0520ea9 [Init] Add -mnoperatorprivatekey to flag the active mn as deterministic (random-zebra)
dcb5df9 [Refactoring] CADMM: GetLocalAddress static (random-zebra)
6cd5b0c [Refactoring] encapsulate activeMNINfo inside activeMNManager (random-zebra)
ca9d10c Implement CActiveDeterministicMasternodeManager (Alexander Block)
66302c3 [Tests] Check deterministic masternodes unique properties (random-zebra)
ddad010 [Validation] Check duplicate unique-properties for masternodes (random-zebra)
41869ec [Refactoring] Add IsDIP3Enforced/LegacyMNObsolete funcs to DMNManager (random-zebra)
c013bf1 [Refactoring] Add evo Notification Interface (random-zebra)
180a311 [Validation] Connect deterministic manager to block processing (random-zebra)
7f2d2b5 [MOVE-ONLY] move special_tx_validation_test inside evo_* test file (random-zebra)
9ac0f37 [Tests] Introduce evo_deterministicmns_tests.cpp (random-zebra)
48c66dc Conflict handling for ProRegTx in mempool (Alexander Block)
ae33972 [Core] Deterministic Masternode List implementation (random-zebra)
50c277b Implement std::unordered_map/set compatible hasher classes for salted hashes (Alexander Block)
0c064f8 [Tests] Add tests for SetTxPayload/GetTxPayload and CheckStringSig (random-zebra)
693772a [Core] Introduce ProRegTx payload (random-zebra)
6fb2496 Define hash function for uint256 to be used in STL-like containers (random-zebra)
3f74c88 [Build] CMake: add immer headers (random-zebra)
e067443 [Build] Add "immer" functional/immutable containers library (random-zebra)
b92de4d [Consensus] Reject special txes before V6 enforcement (random-zebra)

Pull request description:

  Extracted from #2267.
  This is the first fundamental PR.
  Here we introduce the `PROREG` transaction type, the DMN manager (and active-masternode manager), and all the required classes (`CDeterministicMN`, `CDeterministicMNState`, `CDeterministicMNStateDiff`, `CDeterministicMNList` and `CDeterministicMNListDiff`).

  This contains also the headers-only immer library for persistent immutable data structures. Reasons for the inclusion are explained in #2267 (under "code architecture").
  The headers are copied over, at the same commit used by Dash (`0a718d2d76bab6ebdcf43de943bd6c7d2dbfe2f9`). Later on, we might want to properly include this as a git subtree.

  Built on top of:
  - [x] #2271

ACKs for top commit:
  furszy:
    Code review ACK 6dbdf37.
  Fuzzbawls:
    Code ACK 6dbdf37

Tree-SHA512: 3b175eef5cd03c73ee4d125063a4a5f5a5eff6064fb6ff3f54c01b6f2d48562c6181cbfa2687025a2fc9a65a80b17d799581cba1f2937333dfee4c3212b5cfac
furszy added a commit that referenced this pull request May 5, 2021
… the coinbase transaction

c2060ef [Tests] Add IsCoinbaseValueValid_test unit test case in budget_tests (random-zebra)
5994ac9 [Refactoring] Spork: decouple AddSporkMessage from UpdateSpork (random-zebra)
c5ff712 [Refactoring] Update active state inside IsCoinbaseValueValid (random-zebra)
bfa628e [Refactoring] Cleanup in preparation for compatibility code (random-zebra)
82e186c [Refactoring] Refactor FillBlockPayee in preparation for DMN payments (random-zebra)
b9eacdc [Refactoring] No need to check mint-outputs to define coinbase txes (random-zebra)
c14870b [Consensus] Stricter checks for coinbase for v10+ (random-zebra)
e8c35ee [Consensus] Bump block version to 10: non empty coinbase transaction (random-zebra)
a891d5b [RPC] Don't skip coinbases in ListReceived (random-zebra)
8afc832 [Cleanup] Remove IsZerocoinMint check in FillBlockPayee (random-zebra)
e567f7f [Refactoring] Pass both coinbase and coinstake to FillBlockPayee (random-zebra)
944e793 [Cleanup] LoadStakeInput: no need for the previous block (random-zebra)
c6f71b2 [Refactoring] Decouple coinstake creation/signing (random-zebra)
5f3d3ba [Cleanup] Refactor CPivStake::CreateTxIn into GetTxIn (random-zebra)
1f71993 [Cleanup][Trivial] Remove unused param nMasternodeCountDrift (random-zebra)
58ee29f [Refactoring] Directly return empty DMN list before enforcement (random-zebra)

Pull request description:

  Extracted from #2267.
  This PR introduces an important consensus change. As per title, mn/budget payments are now outputs of the coinbase transaction, rather than the coinstake (which, now, contains only outputs belonging to the staker).
  The block version is bumped to 10.
  Also refactor the budget-payment functions, in preparation for the compatibility code and the new payment logic.

  Built on top of:
  - [x] #2273

ACKs for top commit:
  furszy:
    No code changes after rebase, ACK c2060ef
  Fuzzbawls:
    Code ACK c2060ef

Tree-SHA512: 29d6f729772f88ff908b9a83af8d378ddf6aa2d80e9f684df53d66b04ee44f9eac30d7cae9b911954f1a3bd321bfc0791d2944ebb87610a79f23d426c3702ca6
random-zebra added a commit that referenced this pull request May 6, 2021
e754732 [RPC][Tests] Include proTx data in json formatted transactions (random-zebra)
431693f Missing lock for Masternode::SetSpent() method. (furszy)
fb60da4 [Refactoring][RPC] protx send: avoid extra serializing/unserializing (random-zebra)
4c50f7a [Refactoring][RPC] Decouple atmp/relay functions in sendrawtransaction (random-zebra)
86dcf69 [Consensus] Make masternode collateral amount a consensus param (random-zebra)
503e7da [Consensus] Prevent usage of same collateral for MN and DMN instance (random-zebra)
f218357 [RPC] Add DMN support to listmasternodes (random-zebra)
716e7ed [RPC] Deprecate startmasternode when SPORK_21 is active (random-zebra)
70fe350 [MN] Stop processing legacy masternodes after SPORK_21 is active (random-zebra)
a718654 [RPC] Block EVO rpcs before V6 enforcement (random-zebra)
214dc7f [RPC] Implement protx_list (random-zebra)
cad0f0e [RPC] Implement protx_register RPC functions (random-zebra)

Pull request description:

  Extracted from #2267. Based on top of
  - [x] #2273

  Implement `protx_register` and `protx_list` RPC commands.
  Add DMN support to `listmasternodes`.
  Deprecate `startmasternode` after SPORK_21 activation.

ACKs for top commit:
  furszy:
    code ACK e754732 after cherry-pick.
  Fuzzbawls:
    Code ACK e754732

Tree-SHA512: 92fdb8e9056bcba0dad04db39048147e2650d306c85319a9825fb3d2b50a81bb58686412a3a406bf43809186eb97fa97b449e877757ba2ac5fec7926d198116e
furszy added a commit that referenced this pull request May 11, 2021
4a5baf3 [Doc] Add cold-staking changes to release notes (random-zebra)
c19416f [GUI] Use new opcode for P2CS after v6 enforcement (random-zebra)
45ebfee [RPC] Use new opcode for P2CS after v6 enforcement (random-zebra)
8eefab5 [Tests] Add script test for new opcode (random-zebra)
df11631 [Script] Introduce new OP_CHECKCOLDSTAKEVERIFY opcode (random-zebra)
b194386 [Refactor] Rename CCSV opcode to OP_CHECKCOLDSTAKEVERIFY_LOF (random-zebra)

Pull request description:

  Extracted from #2267, and rebased on top of #2258.
  Given the consensus change, introduced in #2274, we can define a more secure `OP_CHECKCOLDSTAKEVERIFY` opcode, which doesn't leave the last output of the coinstake "free" (as we no longer pay masternode/budgets in the coinstake tx).

  Built on top of:
  - [x] #2258
  - [x] #2274

ACKs for top commit:
  Fuzzbawls:
    re-Code ACK 4a5baf3 after rebase, no code changes.
  furszy:
    ACK 4a5baf3.

Tree-SHA512: ee78b76137e40df05b854f8959755f1b99e7c7328fb13708ba7e3e6dae6357450210ce19ed7a99dc54aa0d6051d0dbd745af70f4b6e9927de5d3cbb2e04fffb6
random-zebra added a commit that referenced this pull request May 23, 2021
6b7b9df [BUG][Test] Return directly block template without mempool txes (random-zebra)
f593706 [test] add mnsync and spork8 activation in deterministicmns_tests (furszy)
753986a [test] Add unit test coverage for invalid block payee (furszy)
a81abb4 [Trivial] Fix typo utoxs --> utxos (random-zebra)
f6aefd8 [Tests] Check masternode payments in evo_deterministicmns_tests (random-zebra)
4c731a9 [Consensus] New DMN payment logic (random-zebra)

Pull request description:

  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:
  - [x] #2275
  - [x] #2296

ACKs for top commit:
  furszy:
    ACK 6b7b9df

Tree-SHA512: 9328e2e2d820510845ede63e4db557ceb49df9cfb27f1ac1b36a20878c99728bc60b8f5c4cbfa00f161be5a3c5b7d72cba8ba4dc476383718f66a6d8cdddd70c
random-zebra added a commit that referenced this pull request May 25, 2021
…voting

04cd17e [QA][BUG] Fix test and rework setupDMN to return only proTx hash (random-zebra)
9aeeb76 [Test] Add test coverage for MN and DMN votes expiration removal. (furszy)
3f16936 [Test] Update tiertwo_mn_compatibility and check winners (random-zebra)
ad2cc30 [Consensus] Check against current hash when no payee is found (random-zebra)
ede4519 [Cleanup] Remove unused parameter in GetCurrentMasternode (random-zebra)
dd3bce9 [Tests] Raise regtest ping timeouts to 1/10th of mainnet value (random-zebra)
d616239 [Cleanup] Remove redundant checks in CMasternodePaymentWinner::IsValid (random-zebra)
0db3f57 [Consensus] Compatibility: sign/verify mnw with deterministic nodes (random-zebra)
dbc19ff [Refactor] Decouple getting active mn keys from VoteOnFinalizedBudgets (random-zebra)
971f1da [Consensus] DMN payment compatibility code (random-zebra)
acfa24b [Tests] Introduce tiertwo_dmn_compatibility functional test (random-zebra)
6ad7ea6 [BUG] Fix locking order between CDeterministicMNManager/CMasternodeman (random-zebra)
aa867d5 [RPC] Add DMN support to listmasternodes (random-zebra)
064f774 [RPC] getmasternodestatus for DMN (random-zebra)
8b10fc2 [P2P] Stop processing mnw messages when Legacy MN system is obsolete (random-zebra)
baf60c7 [Tests] governance_sync_basic sign final budget with DMN too (random-zebra)
474e0b2 [RPC][Refactoring] Use ProcessProposal(FinalBudget)Vote directly (random-zebra)
72c2a70 [RPC] Get all required keys before signing budgets (random-zebra)
0591957 [RPC][Refactoring] Mn final budget / proposal voting code de-duplication (random-zebra)
a7557f7 [Validation] Sign/Verify final budgets with DMNs (random-zebra)
6fcd53d [MN] Active MN manager: return key and dmn after validation (random-zebra)
5df5067 [Tests] tiertwo_governance_basic: add deterministic masternodes (random-zebra)
972d236 [RPC] Init Deterministic masternode on-demand (random-zebra)
f93bc0f [Budget] Validate proposal votes from deterministic masternodes (random-zebra)
c5b9e6f [RPC][Budget] Deterministic MNs: vote for proposals (random-zebra)
366bfd0 [RPC] Remove redundant checks for wallet existing/unlocked (random-zebra)

Pull request description:

  Extrated from #2267.
  This enables proposals and budget voting for DMNs.
  It also implements the compatibility code for masternode payments, to be used between v6 enforcement and SPORK_21 activation (when both systems coexist).

  Based on top of:
  - [x] #2275
  - [x] #2296

ACKs for top commit:
  furszy:
    ACK 04cd17e ☕.
  Fuzzbawls:
    ACK 04cd17e

Tree-SHA512: d9504fdd87a7cd05c385e08d51cde0566738bd8992b493ca77592f9b1d1254374d0c5d49d9278edb4525c5559f7e26496fc6b0dd846bbb3acb2164e330ccc92e
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
furszy added a commit that referenced this pull request Jun 17, 2021
aacada8 [BUG] Fix mempool conflicts due to disconnected blocks (random-zebra)
91ad6eb [Tests] Functional testing for ProUpServ txes (random-zebra)
e2c83dd [RPC] Implement "protx_update_service" call (random-zebra)
fb2557f [Mempool] Conflict handling for ProUpServ txes (random-zebra)
281d460 [Tests] Add provider-update-service to dip3_protx unit-test (random-zebra)
e83e454 [TierTwo] Connect ProUpServ payload management in dmn manager (random-zebra)
a197fce [Tests] Add Get/Set payload unit-test for ProUpServ txes (random-zebra)
1f5f509 [Refactoring] Prepare mempool code for multiple payload types (random-zebra)
a83d87e [Core] Introduce ProUpServ payload and transaction type (random-zebra)

Pull request description:

  Exctracted from #2267
  This PR:
  - introduces the `PROUPSERV` payload and transaction type.
  This special transaction is submitted by the operator (the payload must be signed with the operator key) to update the IP/port fields.
  If the original ProReg transaction set a non-zero operatorReward, this payload can also be used to update the operator's payout address.

  - adds the new RPC `protx_update_service` to create ProUpServ transactions

  - adds unit and functional testing

  Builds on top of:
  - [x] #2345

ACKs for top commit:
  furszy:
    utACK aacada8 after rebase.
  Fuzzbawls:
    Code ACK aacada8

Tree-SHA512: 6a642dfa5c7d239de23adaacd2cba56621f4392b2d34a436e023df6452cf9d39c55fb58c62ade2705db4f55f47674fc936644d731e9f8eb526d6679815faa864
furszy added a commit that referenced this pull request Jul 7, 2021
27d9f4e [QA] exercise generic calls to CheckSpecialTx and fix random bug (random-zebra)
2552e53 [Trivial][Cleanup] Remove unused vZC_DENOMS from the test framework (random-zebra)
9e42dfb [Tests] Fix random failure and add MN revival test in deterministicmns (random-zebra)
e2081a7 [Consensus] Don't Allow ProUpReg txes while in transition to DMN (random-zebra)
336e18c [RPC][Trivial] Add missing RPC help examples (random-zebra)
b02d147 [Tests] Functional testing for ProUpRev txes (random-zebra)
2c16960 [RPC] Implement "protx_revoke" call (random-zebra)
86fd9db [Mempool] Conflict handling for ProUpRev txes (random-zebra)
a822a03 [Tests] Add provider-update-revoke to dip3_protx unit-test (random-zebra)
a4a0afb [TierTwo] Connect ProUpRev payload management in dmn manager (random-zebra)
9699143 [Tests] Add Get/Set payload unit-test for ProUpRev txes (random-zebra)
055f5d3 [Core] Introduce ProUpRev payload and transaction type (random-zebra)
1f01a5f [Tests] Functional testing for ProUpReg txes (random-zebra)
48e8862 [RPC] Implement "protx_update_registrar" call (random-zebra)
cb4ce9e [Mempool] Conflict handling for ProUpReg txes (random-zebra)
864c0f5 [BUG] Check for duplicate operator key when processing ProUpReg txes (random-zebra)
553cd56 [Tests] Add provider-update-registrar to dip3_protx unit-test (random-zebra)
060729a [TierTwo] Connect ProUpReg payload management in dmn manager (random-zebra)
ceeaf31 [Tests] Add Get/Set payload unit-test for ProUpReg txes (random-zebra)
1f9e61c [Core] Introduce ProUpReg payload and transaction type (random-zebra)

Pull request description:

  Built on top of:
  - [x] #2349

  This concludes the first DMN-milestone list #2267 (comment).

  Here we introduce the last two payloads and transaction types, adding relative RPC commands, and updating the tests:

  - `PROUPREG` (provider-update-registrar) submitted by the owner (the payload must be signed with the owner key) to update the operator key and/or the voting key and/or the payout address.

  - `PROUPREV` (provider-update-revoke) submitted by the operator, to revoke the service, and put the mn in PoSe-banned state (e.g. in case of compromised keys). The masternode can be "revived" later, by sending a ProUpReg tx, which sets a new operator key, and then a ProUpServ tx (signed with the new operator key), which sets the new IP address for the masternode.

ACKs for top commit:
  furszy:
    No changes after rebase, only serialization code update. ACK 27d9f4e.
  furszy:
     have run all the tests locally one more time, ACK 27d9f4e. Merging..

Tree-SHA512: 756688cf2da66703a70ac668f6d7747041f0c28c102fe253d17ff85b71d05670088e71ca4ac0d1739d101986602ea69abb1e5a54f283aad8e8ad8f58f0f5dc96
@furszy
Copy link

furszy commented Jul 7, 2021

As far as what we have here, this PR is over :) . Are you going to leave only the release-notes commit here?

@random-zebra
Copy link
Author

Yes, only release-notes left here 🎉

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 9f43405

doc/release-notes.md Show resolved Hide resolved
@Fuzzbawls Fuzzbawls changed the title [Tiertwo] Introducing Deterministic Masternodes [Doc] Introducing Deterministic Masternodes Jul 18, 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.

utACK 9f43405

I did change the PR's prefix to Doc since this is now only a documentation PR and all other code work was done in sub-PRs

@random-zebra random-zebra added Docs and Output and removed Budget/Proposal System Consensus Needs Release Notes Placeholder tag for anything needing mention in the "Notable Changes" section of release notes Protocol-Update Upstream Dash Validation labels Jul 18, 2021
@random-zebra random-zebra merged commit 152d244 into PIVX-Project:master Jul 18, 2021
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