stacks-network / stacks-core

The Stacks blockchain implementation
https://docs.stacks.co
GNU General Public License v3.0
3.01k stars 667 forks source link

Feat: PoX punish/reward via bitvec #4879

Closed kantai closed 3 months ago

kantai commented 3 months ago

This PR implements the punish/reward scheme for PoX block commits in Nakamoto by checking the produced block's bitvectors for compliance.

This works by allowing PoX reward addresses to be replaced with burn outputs in all cases. Any elected miner's block must contain a bitvector which conforms with the PoX address treatment in their winning block commit. This is enforced at the protocol's consensus level.

The bitvector itself is interpreted as a reward slot bitvec -- each slot is ordered as it is ordered by the reward set calculation (this is alphanumerically by burnchain_repr(), descending).

The checks are tested through a combination of unit and integration tests.

I think this PR could use a couple simple refactors (renaming block_commit.punish field to pox_treatment, renaming signer_bitvec to rewards_bitvec) and perhaps an additional assertion in the signer binary that asserts the bitvec is all 1s (for now: signers will eventually be responsible for choosing their own punishment scheme).

kantai commented 3 months ago

Ready for re-review