-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MARF'ed Nakamoto chainstate #4930
Conversation
… actually higher than the memoized fork, and also, add get_nakamoto_tip_block_id() to SortitionHandle to facilitate querying the canonical Nakamoto tip
… chains coordinator requires querying it from the canonical fork memoized in the sortition DB. The reason I think this is safe here (and only here) is because forks can't happen arbitrarily. The memoized tip at the end of the prepare phase is practically guaranteed to point to the same reward set on all nodes, since the reward set is calculated at the start of the prepare phase.
…m elsewhere), and use malleablized blocks in the 10-sortitions-with-10-blocks-and-extensions test
…ecifically by a block ID must be carried out relative to a designated chain tip. Adds support for MARF'ing all the data for all affected methods, and rewrites all affected methods to use it.
… obtain method for blocks, and rewrite all methods to use the MARF for queries that are not specific to a block ID
… field and change its primary key. A tenure is recorded for a given block with a tenure change.
…t battery in TestPeer
… test, so we can simulate the presence of multiple (!!) nakamoto forks per Bitcoin fork and verify that the node still behaves correctly. Also, add torture tests for MARF'ed methods, to be performed for each processed block.
…rt block in the clarity VM
…hainstate within a particular fork, and deduce when we're ready to process unconfirmed tenures by the absence of confirmed tenure downloaders
So, the |
…hatever was stored first (doing anything else will break malleablized block tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple comments, otherwise looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
…state DBs since a node may be stopped and restarted during genesis sync (and failure to accept DB version 6 would lead to a panic)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR addresses #4810 and #4900 by computing the block hash of a Nakamoto block as its signer sighash. That is, Nakamoto blocks no longer commit to signer signatures. This change vastly simplifies the task of the signers to agree on whether or not a block is part of the canonical fork -- they do not need to agree on which of them signed and which did not, and they can compute a valid block signature by obtaining a threshold of any set of signatures independently of the miner.
In addition, this PR addresses block malleability by MARF'ing the Nakamoto chainstate. Now, queries on tenures, tenure-start blocks, and other chainstate data that is not directly keyed to a specific Nakamoto block are carried out relative to a Nakamoto chain tip. The chainstate DB now tracks per-fork data about tenures, instead of naively assuming that there will be one valid history of tenure-changes per Bitcoin fork.
This change makes the Stacks blockchain much more robust in the face of Nakamoto forks, which can arise for unavoidable but benign reasons, such as when a tenure-start block for a short-lived sortition is being processed concurrently with a new sortition (in which case, the orphaned tenure-start block would be accepted into the chainstate even though it conflicts with a Nakamoto block at the same height). Furthermore, should there ever arise multiple Nakamoto forks for any reason (due to a bug, a policy, or a benign cause), the node's chainstate will remain in a consistent and usable state.
In doing so, this change completely separates policy from mechanism regarding fork selection. It places the burden of deciding which Nakamoto forks can be built upon exclusively on the signers (a policy), and makes the Stacks node amenable to handling any such forks regardless of how they arise, without complaint (a mechanism for effecting a fork-choice policy).