Sharechain
A sharechain is a blockchain of shareblocks, and each shareblock embeds a bitcoin header. The sharechain difficulty is much lower than the bitcoin difficulty, so the sharechain is a blockchain of "weak" bitcoin blocks.
Shareblock Header and Bitcoin Header
The diagram below shows how the shareblock header relates to the
bitcoin header. The two bits fields hold one difficulty target each:
the bitcoin header’s bits for the bitcoin block, and the
shareblock header’s bits for the sharechain.
The diagram shows the previous block hashes, the bits fields, the
time fields, and the full bitcoin header. It leaves out the other
header fields; Shareblock Format lists them all.
Shareblock Format
A shareblock has a header and a body. The shareblock hash covers every header field and none of the body. Each header field is fixed by the proof of work, so one proof of work can stand behind only one shareblock hash. The table below lists the header fields and how the proof of work fixes each one.
| Field | Contents | Fixed by |
|---|---|---|
Previous shareblock hash |
Hash of the parent shareblock |
Share commitment |
Uncles |
Hashes of up to three uncle shareblocks |
Share commitment |
Miner bitcoin address |
Address that receives the miner’s bitcoin payouts, with its network class |
Share commitment |
Miner sharechain address |
Witness program that the share coinbase pays |
Share commitment |
Bitcoin header |
The weak bitcoin block header the miner hashed |
The proof of work itself |
|
Sharechain target in compact form |
Share commitment |
Time |
Share timestamp set by the miner |
Share commitment |
Donation and fee |
Developer donation and pool fee, each an address and basis points |
Share commitment |
Bitcoin height |
Height of the bitcoin block being mined |
Bitcoin coinbase locktime |
Coinbase proof |
SHA256 midstate of the bitcoin coinbase prefix, the prefix length, and the share witness root |
Bitcoin header’s merkle root |
The share commitment and the coinbase proof are described on the Share Commitments page.
The body holds the data that the proof of work fixes but the header cannot check by itself:
- Share transactions
-
The share coinbase followed by the share’s other transactions. The share witness root in the coinbase proof commits to the other transactions.
- Coinbase merkle branch
-
The path from the bitcoin coinbase to the bitcoin header’s merkle root. Shares mined on one block template share a branch.
- Bitcoin coinbase
-
The coinbase transaction the miner hashed. Its scriptSig carries the aux flags, extranonce, and nanosecond timestamp, and its outputs carry the payouts, the BIP141 witness commitment, and the share commitment.
A node checks the body against the header before storing it; see Body Matches the Header.
Sharechain and Bitcoin Blockchain
The sharechain is a chain of shareblocks. Each shareblock embeds a
bitcoin header that carries the proof of work. A node hashes the
bitcoin header and compares the resulting block hash with the
shareblock header’s bits field to check that the share meets the sharechain
difficulty. It also compares the block hash with the bitcoin header’s
bits field to check whether the share is a bitcoin block that it can
broadcast to the bitcoin network.
Several shareblocks can build on the same previous bitcoin block, as the dashed arrows in the diagram below show. The orange arrow from Shareblock 3 to Block 101 shows that Shareblock 3’s proof of work meets the bitcoin difficulty, so Block 101 can be submitted to the bitcoin network.
Sharechain Provides Consensus on Payout Distribution
A sharechain gives all nodes Nakamoto consensus on the weak shares. All nodes eventually converge on the same view of the sharechain, so they all determine the same payout distribution when building shares. Every node can therefore check that every share on the sharechain pays out honestly. When a peer sends a share whose payouts do not match the receiving node’s local view, the receiving node rejects it. See PPLNS Share Accounting for how a decentralized network handles share accounting.
Without the consensus the sharechain provides, a node cannot validate that a share’s payout distribution matches its own view. See Share Validation for how shares are validated.
Shares Have a Valuation
When the pool finds a block, every share within a certain depth of the sharechain tip earns a payout from the bitcoin coinbase. The length of the PPLNS (pay-per-last-N-shares) window sets this depth. A share therefore holds an intrinsic value: it earns bitcoin if the pool finds a bitcoin block before the share expires. This makes a share behave like an option with a known expiry.
Apart from the share’s position in the PPLNS window, other fields in the shareblock help assign a value to a share:
-
The pool difficulty the share was mined at: the shareblock header’s
bits -
The bitcoin difficulty when the share was mined: the bitcoin header’s
bits -
The share’s height in the sharechain
Miners can sell this value to others. Miners want an immediate payout, and buyers want the bitcoin the share will earn when the pool finds a bitcoin block.
Sharechain Provides UTXO & Script-Based Transaction Support
The sharechain supports UTXO and Script-based transactions. Each shareblock has a coinbase that pays the share’s miner one share unit. This output captures the intrinsic value of the share, and transaction support lets the miner trade it.
With UTXO and Script support, a miner can trade a share for bitcoin through atomic swaps, on-chain or off-chain. See Sell Shares for Payouts for how such swaps give miners a payout mechanism on P2Poolv2.