From 0f1ce92f94870647582ce88aab0a605c3dff6250 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 16 Oct 2018 05:00:05 +0300 Subject: [PATCH 1/9] Separate creation/movement of MN collateral and DMN registration process I propose to change DIP3 in a way that splits funds handling and DMN registration. Pros: 1. no need to move collaterals; 2. no need to update HW wallet firmware to support. Cons: 1. the logic is going to be slightly more complicated; 2. the process of MN registration is going to be split between using HW wallet and Core; 3. `ProRegTx` payload size is going to be slightly higher (+32 bytes). --- dip-0003.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/dip-0003.md b/dip-0003.md index 3e46f93..3ba7499 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -56,7 +56,7 @@ The previous system also made certain desirable features infeasible. The integra ## New On-Chain System -In the new system, the masternode list is derived entirely from information found on-chain. New masternodes are added by new special transactions called Provider Registration Transactions (abbreviated as ProRegTx). They are only removed by spending the collateral. A ProRegTx is a special transaction which consists of a 1000-Dash collateral payment, along with payload information (DIP2) described later in this document. +In the new system, the masternode list is derived entirely from information found on-chain. New masternodes are added by new special transactions called Provider Registration Transactions (abbreviated as ProRegTx). They are only removed by spending the collateral. A ProRegTx is a special transaction which refers to a 1000-Dash collateral payment, along with other payload information (DIP2) described later in this document. This DIP defines 2 masternode (sub)sets: @@ -67,7 +67,7 @@ Only the valid subset is used in calculations to determine the recipient of the ## Registering a Masternode (ProRegTx) -To join the masternode list, masternode owners must submit a special transaction (DIP2) to the network. This transaction is called a Provider Registration Transaction and is abbreviated to ProRegTx. The ProRegTx must contain one output with the 1000 Dash collateral. +To join the masternode list, masternode owners must submit a special transaction (DIP2) to the network. This transaction is called a Provider Registration Transaction and is abbreviated to ProRegTx. The ProRegTx must refer to an outpoint with the 1000 Dash collateral. The ProRegTx contains 3 public key IDs, which represent 3 different roles in the masternode and define update and voting rights. A "public key ID" refers to the hash160 of an ECDSA public key. These are: @@ -83,7 +83,7 @@ The ProRegTx also defines the masternode's type and mode. Default masternodes ar The ProRegTx also specifies the reward for the operator. The percentage of the masternode reward paid to the operator is calculated by dividing the operatorReward field by 100. When the field is set to zero, the owner will get the full reward for every block. If set to a non-zero value, the masternode operator may specify his operator reward payee script in a ProUpServTx. If he does not do so, the full reward goes to the masternode owner. -After a ProRegTx is mined into the chain, the corresponding masternode entry is added to the registered masternode set and therefore eligible for PoSe verification, masternode rewards and quorum participation. +After a ProRegTx is mined into the chain, the corresponding masternode entry is added to the registered masternode set and therefore eligible for PoSe verification, masternode rewards and quorum participation. If there is a masternode with the same collateral outpoint in the registered masternode set already, it's replaced with the newly registered one. The special transaction type used for Provider Transactions is 1. @@ -94,7 +94,7 @@ The transaction consists of the following data in the payload area: | version | uint_16 | 2 | Provider transaction version number. Currently set to 1. | | type | uint_16 | 2 | Masternode type. Default set to 0. | | mode | uint_16 | 2 | Masternode mode. Default set to 0. | -| collateralIndex | uint_32 | 4 | The collateral index. | +| collateralOutpoint | COutpoint | 36 | The collateral outpoint. | | ipAddress | byte[] | 16 | IPv6 address in network byte order. Only IPv4 mapped addresses are allowed (to be extended in the future) | | port | uint_16 | 2 | Port (network byte order) | | KeyIdOwner | CKeyID | 20 | The public key hash used for owner related signing (ProTx updates, governance voting) | @@ -105,7 +105,7 @@ The transaction consists of the following data in the payload area: | scriptPayout | Script | Variable | Payee script (p2pkh/p2sh) | | inputsHash | uint256 | 32 | Hash of all the outpoints of the transaction inputs | | payloadSigSize | compactSize uint | 1-9 | Size of the Signature | -| payloadSig | vector | Variable | Signature of the hash of the ProTx fields. Signed with KeyIdOwner | +| payloadSig | vector | Variable | Signature of the hash of the ProTx fields. Signed with the key corresponding to the collateral outpoint. | ## Updating Masternode Information @@ -211,17 +211,18 @@ Reorganisations of the chain must also correctly undo changes to the chain-tips A ProRegTx is invalid if any of these conditions are true: - 1. collateralIndex >= transaction output count - 2. Any KeyId* field is null (KeyIdOwner, KeyIdOperator or KeyIdVoting) - 3. KeyIdOwner or KeyIdOperator was already used by any entry in the registered masternodes set - 4. scriptPayout is not a P2PKH or P2SH script - 5. When scriptPayout is P2PKH script and the public key hash equals any of KeyIdOwner, KeyIdOperator or KeyIdVoting - 6. ipAddress is set and port is not set to the default mainnet port - 7. ipAddress is set and not routable or not an IPv4 mapped address - 8. ipAddress is set and already used in the registered masternodes set - 9. operatorReward > 10000 - 10. The inputsHash does not match the calculated hash - 11. payloadSig is invalid + 1. collateralOutpoint can't be found in UTXO + 2. collateralOutpoint amount isn't equal 1000 DASH + 3. Any KeyId* field is null (KeyIdOwner, KeyIdOperator or KeyIdVoting) + 4. KeyIdOwner or KeyIdOperator was already used by any entry in the registered masternodes set + 5. scriptPayout is not a P2PKH or P2SH script + 6. When scriptPayout is P2PKH script and the public key hash equals any of KeyIdOwner, KeyIdOperator or KeyIdVoting + 7. ipAddress is set and port is not set to the default mainnet port + 8. ipAddress is set and not routable or not an IPv4 mapped address + 9. ipAddress is set and already used in the registered masternodes set + 10. operatorReward > 10000 + 11. The inputsHash does not match the calculated hash + 12. payloadSig is invalid Please note that while deploying DIP3, additional and temporary validation rules will apply. The details of these temporary rules will be described in the deployment plan. From e17602f9f97e8f6f95f71eaa10ea574d7726586d Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 19 Oct 2018 14:47:24 +0300 Subject: [PATCH 2/9] integrated hybrid solution from codablock --- dip-0003.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dip-0003.md b/dip-0003.md index 3ba7499..07d7741 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -56,7 +56,7 @@ The previous system also made certain desirable features infeasible. The integra ## New On-Chain System -In the new system, the masternode list is derived entirely from information found on-chain. New masternodes are added by new special transactions called Provider Registration Transactions (abbreviated as ProRegTx). They are only removed by spending the collateral. A ProRegTx is a special transaction which refers to a 1000-Dash collateral payment, along with other payload information (DIP2) described later in this document. +In the new system, the masternode list is derived entirely from information found on-chain. New masternodes are added by new special transactions called Provider Registration Transactions (abbreviated as ProRegTx). They are only removed by spending the collateral. A ProRegTx is a special transaction which includes a 1000-Dash collateral payment or a reference to it, along with other payload information (DIP2) described later in this document. This DIP defines 2 masternode (sub)sets: @@ -67,7 +67,7 @@ Only the valid subset is used in calculations to determine the recipient of the ## Registering a Masternode (ProRegTx) -To join the masternode list, masternode owners must submit a special transaction (DIP2) to the network. This transaction is called a Provider Registration Transaction and is abbreviated to ProRegTx. The ProRegTx must refer to an outpoint with the 1000 Dash collateral. +To join the masternode list, masternode owners must submit a special transaction (DIP2) to the network. This transaction is called a Provider Registration Transaction and is abbreviated to ProRegTx. The ProRegTx must include an output with the 1000 DASH or refer to an already existing unspent output which holds 1000 DASH. The ProRegTx contains 3 public key IDs, which represent 3 different roles in the masternode and define update and voting rights. A "public key ID" refers to the hash160 of an ECDSA public key. These are: @@ -211,8 +211,8 @@ Reorganisations of the chain must also correctly undo changes to the chain-tips A ProRegTx is invalid if any of these conditions are true: - 1. collateralOutpoint can't be found in UTXO - 2. collateralOutpoint amount isn't equal 1000 DASH + 1. collateralOutpoint `hash` is empty but no output with 1000 DASH can be found on position `n` in outputs of ProRegTx + 2. collateralOutpoint `hash` is not empty but no output with 1000 DASH can't be found in UTXO with these `hash` and `n` 3. Any KeyId* field is null (KeyIdOwner, KeyIdOperator or KeyIdVoting) 4. KeyIdOwner or KeyIdOperator was already used by any entry in the registered masternodes set 5. scriptPayout is not a P2PKH or P2SH script From b8812fcacf028457e3f151b385739bb72cce58d9 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 19 Oct 2018 17:03:21 +0300 Subject: [PATCH 3/9] empty->null --- dip-0003.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dip-0003.md b/dip-0003.md index 07d7741..b9b4c00 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -211,8 +211,8 @@ Reorganisations of the chain must also correctly undo changes to the chain-tips A ProRegTx is invalid if any of these conditions are true: - 1. collateralOutpoint `hash` is empty but no output with 1000 DASH can be found on position `n` in outputs of ProRegTx - 2. collateralOutpoint `hash` is not empty but no output with 1000 DASH can't be found in UTXO with these `hash` and `n` + 1. collateralOutpoint `hash` is null but no output with 1000 DASH can be found on position `n` in outputs of ProRegTx + 2. collateralOutpoint `hash` is not null but no output with 1000 DASH can't be found in UTXO with these `hash` and `n` 3. Any KeyId* field is null (KeyIdOwner, KeyIdOperator or KeyIdVoting) 4. KeyIdOwner or KeyIdOperator was already used by any entry in the registered masternodes set 5. scriptPayout is not a P2PKH or P2SH script From 4b09024d20a8fba1a5653dedc081a0ac62f9b491 Mon Sep 17 00:00:00 2001 From: thephez Date: Fri, 19 Oct 2018 22:16:04 +0300 Subject: [PATCH 4/9] 1 Co-Authored-By: UdjinM6 --- dip-0003.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dip-0003.md b/dip-0003.md index b9b4c00..fc28de0 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -211,7 +211,7 @@ Reorganisations of the chain must also correctly undo changes to the chain-tips A ProRegTx is invalid if any of these conditions are true: - 1. collateralOutpoint `hash` is null but no output with 1000 DASH can be found on position `n` in outputs of ProRegTx + 1. collateralOutpoint `hash` is null but an output with 1000 DASH is present at position `n` of the ProRegTx outputs 2. collateralOutpoint `hash` is not null but no output with 1000 DASH can't be found in UTXO with these `hash` and `n` 3. Any KeyId* field is null (KeyIdOwner, KeyIdOperator or KeyIdVoting) 4. KeyIdOwner or KeyIdOperator was already used by any entry in the registered masternodes set From ce81f999b1bc25159e8095a305d53fe91329d3fa Mon Sep 17 00:00:00 2001 From: thephez Date: Fri, 19 Oct 2018 22:16:11 +0300 Subject: [PATCH 5/9] 2 Co-Authored-By: UdjinM6 --- dip-0003.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dip-0003.md b/dip-0003.md index fc28de0..a15e8d2 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -212,7 +212,7 @@ Reorganisations of the chain must also correctly undo changes to the chain-tips A ProRegTx is invalid if any of these conditions are true: 1. collateralOutpoint `hash` is null but an output with 1000 DASH is present at position `n` of the ProRegTx outputs - 2. collateralOutpoint `hash` is not null but no output with 1000 DASH can't be found in UTXO with these `hash` and `n` + 2. collateralOutpoint `hash` is not null but an output with 1000 DASH can't be found in the UTXO specified by the `hash` and `n` 3. Any KeyId* field is null (KeyIdOwner, KeyIdOperator or KeyIdVoting) 4. KeyIdOwner or KeyIdOperator was already used by any entry in the registered masternodes set 5. scriptPayout is not a P2PKH or P2SH script From c4288307d5d6002547b17a074cb9bf3ae9cebb07 Mon Sep 17 00:00:00 2001 From: thephez Date: Fri, 19 Oct 2018 22:16:29 +0300 Subject: [PATCH 6/9] new on-chain system Co-Authored-By: UdjinM6 --- dip-0003.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dip-0003.md b/dip-0003.md index a15e8d2..f5329d2 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -56,7 +56,7 @@ The previous system also made certain desirable features infeasible. The integra ## New On-Chain System -In the new system, the masternode list is derived entirely from information found on-chain. New masternodes are added by new special transactions called Provider Registration Transactions (abbreviated as ProRegTx). They are only removed by spending the collateral. A ProRegTx is a special transaction which includes a 1000-Dash collateral payment or a reference to it, along with other payload information (DIP2) described later in this document. +In the new system, the masternode list is derived entirely from information found on-chain. New masternodes are added by new special transactions called Provider Registration Transactions (abbreviated as ProRegTx). They are only removed by spending the collateral. A ProRegTx is a special transaction which includes either a 1000-Dash collateral payment or a reference to it, along with other payload information (DIP2) described later in this document. This DIP defines 2 masternode (sub)sets: From 6b1942914b71bcd086730bb8f18d48e752d61927 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Tue, 23 Oct 2018 12:39:14 +0300 Subject: [PATCH 7/9] Update dip-0003.md Co-Authored-By: UdjinM6 --- dip-0003.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dip-0003.md b/dip-0003.md index f5329d2..6339342 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -105,7 +105,7 @@ The transaction consists of the following data in the payload area: | scriptPayout | Script | Variable | Payee script (p2pkh/p2sh) | | inputsHash | uint256 | 32 | Hash of all the outpoints of the transaction inputs | | payloadSigSize | compactSize uint | 1-9 | Size of the Signature | -| payloadSig | vector | Variable | Signature of the hash of the ProTx fields. Signed with the key corresponding to the collateral outpoint. | +| payloadSig | vector | Variable | Signature of the hash of the ProTx fields. Signed with the key corresponding to the collateral outpoint in case the collateral is not part of the ProRegTx itself, empty otherwise. | ## Updating Masternode Information From 827c5a09eca449c60921cf92bfb4ab1f814bfc55 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Tue, 23 Oct 2018 12:41:53 +0300 Subject: [PATCH 8/9] Update dip-0003.md Co-Authored-By: UdjinM6 --- dip-0003.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dip-0003.md b/dip-0003.md index 6339342..5fe751b 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -222,7 +222,9 @@ A ProRegTx is invalid if any of these conditions are true: 9. ipAddress is set and already used in the registered masternodes set 10. operatorReward > 10000 11. The inputsHash does not match the calculated hash - 12. payloadSig is invalid + 12. collateralOutpoint `hash` is null and payloadSig is not empty (zero size) + 13. collateralOutpoint `hash` is not null and payloadSig is not a valid signature signed with the collateral key + 14. collateralOutpoint `hash` is not null and the referenced collateral is not a P2PKH output Please note that while deploying DIP3, additional and temporary validation rules will apply. The details of these temporary rules will be described in the deployment plan. From fff7f42acba7fdd47cab21b897246f5d241724f2 Mon Sep 17 00:00:00 2001 From: InhumanPerfection <39734219+InhumanPerfection@users.noreply.github.com> Date: Tue, 23 Oct 2018 16:05:07 +0300 Subject: [PATCH 9/9] hash is null but no 1000 at `n` Co-Authored-By: UdjinM6 --- dip-0003.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dip-0003.md b/dip-0003.md index 5fe751b..fa8df62 100644 --- a/dip-0003.md +++ b/dip-0003.md @@ -211,7 +211,7 @@ Reorganisations of the chain must also correctly undo changes to the chain-tips A ProRegTx is invalid if any of these conditions are true: - 1. collateralOutpoint `hash` is null but an output with 1000 DASH is present at position `n` of the ProRegTx outputs + 1. collateralOutpoint `hash` is null but an output with 1000 DASH is not present at position `n` of the ProRegTx outputs 2. collateralOutpoint `hash` is not null but an output with 1000 DASH can't be found in the UTXO specified by the `hash` and `n` 3. Any KeyId* field is null (KeyIdOwner, KeyIdOperator or KeyIdVoting) 4. KeyIdOwner or KeyIdOperator was already used by any entry in the registered masternodes set