-
Notifications
You must be signed in to change notification settings - Fork 92
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
dex/testing/dcr: fix reorg script #669
Conversation
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.
Looks ok to me. But we want the three block reorg on alpha? Adding a new wallet?
Yeah... Add a second wallet to beta that can vote on tickets purchased by the alpha wallet i.e. shares the same seed with the alpha wallet. Gave that a rough trial but didn't work as expected. Will get back to it once I have some time. |
Convert to draft? |
The dcr beta node is only able to add 1 block to the mainchain after disconnecting from the alpha node, because the beta node has no way to receive votes while disconnected from alpha. This prevents reorgs on either nodes since the reorg script ends with both nodes reconnected but having just 1 divergent mainchain block each. This is fixed by mining an "extra" block on either node (after reconnection) to trigger a reorg on the other node. Additionally, the dcr reorg script is modified to accept 2 optional arguments: `./reorg (node depth), where - `node` is the node that should experience a reorg, either "alpha" or "beta" - `depth` is the number of blocks that should be purged from `node`. Currently, due to the beta mining limitation mentioned above, only 1 block can be purged from either nodes during reorg, but the reorged node will always see `depth` new blocks after the reorg.
During reorg, a clone of the alpha wallet is connected to the beta node after the beta node is disconnected from the alpha node. The added wallet uses the same seed as the alpha wallet and is thus able to vote on tickets purchased by the alpha wallet when the alpha node was connected to the beta node. Without a voting wallet connected to the beta node, it can only mine 1 block after it is disconnected from the alpha node. Moreover, connecting just any voting wallet to the beta node does not suffice as the added wallet may not have enough tickets called to vote on a previous block because the tickets called to vote are selected from a pool of tickets purchased by both the new and the alpha voting wallets and the alpha voting wallet may have more tickets called to vote on the previous block than the other voting wallet connected to the beta node.
12bf8be
to
fe438e9
Compare
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.
Really awesome. Working perfectly.
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.
Looks good. I also like the alpha/beta port changes to make them more orderly.
The dcr reorg script is modified to accept 2 optional arguments:
`./reorg (node depth), where
node
is the node that should undergo a reorg, either "alpha" or "beta" (default: alpha)depth
is the number of blocks that should be purged fromnode
(default: 2).At the end of the reorg, both nodes will have
depth+1
new blocks.During reorg, a clone of the alpha wallet is connected to the beta node after the beta node
is disconnected from the alpha node. This is done to enable mining multiple blocks on the
beta node.
The alpha wallet clone uses the same seed as the alpha wallet and is thus able to vote on
tickets purchased by the alpha wallet when the alpha node was connected to the beta node,
supplying enough votes to the beta node to validate previous blocks and allow the creation
of new blocks.
Resolves #646.