mvs-org / metaverse

The Metaverse individual chain service ETP coin and immutable data space for Hyperspace.
https://mvs.org
GNU Affero General Public License v3.0
307 stars 115 forks source link

PoS mining delegated staking without supernodes deign to help users voting. #402

Open betachen opened 4 years ago

canguruhh commented 4 years ago

There are 2 signatures involved in PoS block creation. One is the spending of the vote utxo in the coinstake transaction and the other one is the block signature that signs the whole block.

1) Quick way: For the spending of the utxos the staking user can already create a chain of valid coinstake transactions for every vote and send all to the delegate. The delegate can then just use those already signed transactions when the vote has its turn. Clean way: Add a new opcode that allows a script that lets the delegate spend the vote utxo only if the outputs of the transactions have the same script as the previous output of the vote utxo. The staking user could of course still spend it without restrictions. This way all vote utxos with the new script can be used by the delegate only to send it back to use staking user.

2) Currently the consensus rule for the block signature takes the pubic key for the signature check from the first input of the coinstake transaction. It just reads the last item which is the top item on the stack. We could completely change this rule so that it would take the public key from some additional output of that transaction or we create a new script that is the same as a P2PKH script but starts with an additional OP_DROP. This way we can put an additional public key to the input script so this one would be used for the block signature validation. The OP_DROP will remove the additional pubkey directly so it would stay spendable with the stakers signature. There could even be an OP_IF to check for the height of the stack so that the OP_DROP is only executed if the height is 3. This way the user can spend the utxo with an normal P2PKH input script

Currently: Output: OP_DUP OP_HASH160 [ staker_pub ] OP_EQUALVERIFY OP_CHECKSIG Input: [staker_sig] [staker_pub] The the staker_pub is the top of the stack so it will use this one for the block signature

Alternative Script 1: Output: OP_DROP OP_DUP OP_HASH160 [ staker_pub ] OP_EQUALVERIFY OP_CHECKSIG Input: [staker_sig] [staker_pub] [delegate_pub]

Alternative Script 2: Output: OP_DEPTH [3] OP_EQUAL OP_IF OP_DROP OP_ENDIF OP_DUP OP_HASH160 [ staker_pub ] OP_EQUALVERIFY OP_CHECKSIG Input: [staker_sig] [staker_pub] [delegate_pub]

canguruhh commented 4 years ago

Maybe it would be easier to activate dPoS