stacks-core
stacks-core copied to clipboard
Mining Pool Proposal
Is your feature request related to a problem? Please describe. Mining Pool aims to solve the following problems of current mining pool and individual miner https://github.com/stacks-network/stacks-blockchain/issues/1969:
- Users do not need to trust the Mining Pool. If the user subsidizes the Mining Pool to participate in the mining of block N, the income will be automatically distributed in the stacks network without the permission of the Mining Pool.
- Users can go online or offline at will
- More flexible mining pool logic can be implemented through the clarity smart contract
This issue will discuss in detail the process of subsequent bitcoin transactions and the specific implementation of the contract
Describe the solution you'd like From the previous conversation with @jcnelson in monthly mining conference. The implementation of the mining pool scheme is through:
- Use bitcoin multi-signature script to fund block commit
- stacks 2.1 upgrade will support taproot / segwit PoX outputs, and support stacks coinbase payments to smart contracts.
The above two points can confirm the sponsor of the block commit in the contract, so the mining pool rewards can be issued without permission.
The inputs to the block commit would be as follows:
- The mining pool operator's spent TXO
- The scriptsig that actually funds the block commit
The outputs would be as follows:
- The OP_RETURN encoding the block commit
- The first PoX output
- The second PoX output
- The pool operator's dust UTXO
- The pool's new taproot UTXO
From this bitcoin script transaction, there are the following questions:
- What is the role of dust UTXO?
- Why do mining pool operators need to sign their spent UTXO?
- If I am a new user who wants to participate in the mining pool, how will I participate in the funding process of scriptsig?
- As far as I know, at this stage, bitocin multi-signature m-of-n supports up to 15 users' multi-signature. Is it possible to exceed this number? Or will there be other supports that allow more users to participate? @jcnelson
Hi @tyGavinZJU, thanks for opening this issue!
What is the role of dust UTXO?
Stacks uses a block-commit windowing scheme to determine the probability that a given block-commit will win sortition -- specifically, the (non-normalized) sortition weight is min(last-commit-btc, median-window-commit-btc)
. This window makes discount-mining through PoX prohibitively expensive, since a discount-miner will need to spend lots of BTC in order to raise their median window sufficiently to have a non-trivial chance of winning the target block (and because they don't know in advance whether or not their reward addresses are up for payment in PoX, they must continuously spend lots of BTC or gain control over most PoX address slots).
In order to implement this window, the node requires that each block-commit from a miner consume the UTXO from the miner's last block-commit. This way, the node can determine which Bitcoin blocks in the block-commit window the miner has mined in, and calculate the median BTC spend in the window.
The UTXO does not need to hold much value. It just needs to exist.
Why do mining pool operators need to sign their spent UTXO?
A mining pool needs to generate a block-commit that consumes the UTXO produced in the pool's last block-commit in order to prove that they have mined continuously. As of right now, the UTXO must be a p2pkh or p2sh script (which includes p2wpkh-p2sh and p2wsh-p2sh scripts). As you point out, it is not necessary that this UTXO represents the mining pool participants (but it can), but it is encouraged since it would make the transaction smaller. The only requirements are that the UTXO has the same script across block-commits, and forms a chain of linked block-commit transactions.
If I am a new user who wants to participate in the mining pool, how will I participate in the funding process of scriptsig?
If we use the sponsored block-commit model, where the miner UTXO and funding addresses are separate, then the user would send their BTC to the funding address. Once they have done so, they can prove to the pool's smart contract that they committed their BTC by (a) posting a Merkle proof to the contract that proves that their transaction was included in the Bitcoin chain, and (b) have the contract parse the Bitcoin transaction to determine the amount of BTC sent and determine which Stacks principal sent it.
As far as I know, at this stage, bitocin multi-signature m-of-n supports up to 15 users' multi-signature. Is it possible to exceed this number? Or will there be other supports that allow more users to participate?
According to https://bitcoincore.org/en/segwit_wallet_dev/, with p2wsh-p2sh multisig, you have 3600 bytes of script space, with up to 100 witness stack items of up to 80 bytes each. I think that means you can get up to 99 signatures, but you'll want to test it (I've never tried it).
Closing due to inactivity. There is an ongoing grant for a decentralized mining pool here: https://github.com/stacksgov/Stacks-Grant-Launchpad/issues/790