Skip to content
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

Merged
merged 2 commits into from
Aug 23, 2021
Merged

Conversation

itswisdomagain
Copy link
Member

@itswisdomagain itswisdomagain commented Sep 7, 2020

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 from node (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.

dex/testing/dcr/harness.sh Outdated Show resolved Hide resolved
dex/testing/dcr/harness.sh Outdated Show resolved Hide resolved
Copy link
Member

@JoeGruffins JoeGruffins left a 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?

@itswisdomagain
Copy link
Member Author

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.

@chappjc
Copy link
Member

chappjc commented Sep 16, 2020

Convert to draft?

@itswisdomagain itswisdomagain marked this pull request as draft September 16, 2020 18:43
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.
@itswisdomagain itswisdomagain marked this pull request as ready for review August 8, 2021 16:18
Copy link
Member

@JoeGruffins JoeGruffins left a 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.

Copy link
Member

@chappjc chappjc left a 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.

@chappjc chappjc merged commit 90b1d92 into decred:master Aug 23, 2021
@itswisdomagain itswisdomagain deleted the reorg-fixes branch August 23, 2021 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dex/testing/dcr: simnet harness: beta node hangs mining second block after disconnecting from alpha
4 participants