PPLNS Share Accounting
Each share has enough data to reconstruct the bitcoin block’s coinbase transaction. Given the payout distribution in the bitcoin coinbase p2poolv2 nodes compare it to the payout distribution derived from the local view of the sharechain. If these match, the share is valid, else it is rejected with a PPLNS mismatch error.
Coinbase Maturity, PPLNS Window and Trading Window
The N in the pay-per-last-N-shares in P2Poolv2 is 120,960 which maps to the number of target block interval periods of 10s in a two week window.
A coinbase can only be spent once it is 6048 deep from the chain tip. This is chosen to be the same time period as 100 bitcoin blocks. So the PPLNS window starts after the first 6048 blocks on the chain, that is the maturity window shares are excluded from the PPLNS accounting.
The window shares between coinbase maturity and the PPLNS expiry height is called the trading window. The diagram below shows these concepts.
Uncle Blocks and Rewards
Each shareblock header can refer to maximum of three uncle blocks, and each uncle referenced from a shareblock should not be more than three blocks deep from itself. A shareblock referenced as an uncle by a shareblock cannot be referenced as an uncle shareblock from another shareblock.
In the diagram, Uncle A and Uncle B are valid shares that lost the race to join the main chain. Uncle A and uncle B are both uncles of Shareblock 4.
PPLNS accounting counts an uncle’s work in full but splits it between two miners:
-
The uncle’s miner earns 90% of the uncle’s difficulty.
-
The nephew’s miner earns the nephew’s own difficulty plus 10% of each uncle’s difficulty.
Suppose every share in the diagram has difficulty d. The miners of Uncle A and Uncle B each earn 0.9d, and the miner of Shareblock 4 earns 1.2d: its own d plus 0.1d for each uncle. Together they earn 3d, the same as three shares on the main chain, so no work goes uncounted. The bonus gives miners a reason to include uncles, and the discount keeps a share on the main chain worth more than an uncle.