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

blockchain: Add fullblock tests for voting. #562

Merged
merged 1 commit into from Feb 13, 2017

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Feb 13, 2017

This requires PR #542

This adds a series of full block tests which exercise the new voting functionality exposed via PoS votebits and a threshold state machine. As with other full block tests, these involve generating a completely
valid chain starting with genesis block and methodically reaching various thresholds.

To achieve this, the tests creates two stake version 4 test dummy deployments that are carried out at the same time to also ensure voting on multiple agendas concurrently works as intended. The first agenda is voted in via a majority yes vote while the second is rejected via a majority no vote.

The following is an overview of the progression of the tests:

  • Generate enough block to reach one block before the first stake version interval using v3 blocks and v3 votes in order to trigger stake version enforcement
  • Generate enough blocks to reach one block before the next rule change interval using v3 blocks and v3 votes
    • Ensure that voting on the agendas does not start due to lack of majority proof-of-work upgrade, lack of majority proof-of-stake upgrade, and not being on a rule change interval
  • Generate enough blocks to reach one block before the next stake version interval using v3 blocks and v4 votes in order to achieve stake version 4 enforcement
    • Ensure that voting on the agendas does not start due to lack of majority proof-of-work upgrade and not being on a rule change interval
  • Generate enough blocks to reach the next rule change interval while still using a majority of v3 blocks and v4 votes, but set the last two blocks to v4
    • Ensure that voting on the agendas does not start due to lack of majority proof-of-work upgrade and not being on a rule change interval
  • Generate enough blocks to achieve proof-of-work block version lockin using v4 blocks and v4 votes
    • Ensure that voting on the agendas does not start even though all upgrade conditions have been met due to not having reached a rule change interval
  • Generate enough blocks to reach the next rule change interval using v4 blocks and v4 votes such that the majority votes vote yes to the first agenda and no to the second agenda
    • Ensure that the voting on agendas begins, but that the yes and no votes do not count yet since the voting had not started yet until this rule change interval was reached
  • Generate enough blocks to reach the next rule change interval using v4 blocks and v4 votes such that the majority votes vote yes to the first agenda and no to the second agenda
    • Ensure the first agenda becomes locked in since it was voted in with a majority yes and the second agenda fails since it was rejected with a majority no
  • Generate enough blocks to reach the next rule change interval using v4 blocks and v4 votes such that the majority votes vote the opposite way they previously did (no to first agenda and yes to second agenda)
    • Ensure the first agenda becomes active and the second agenda remains failed since a rule change can't be undone once it has achieved lockedin status or has failed

@davecgh davecgh changed the title blockchain: Add fullblcok tests for voting. blockchain: Add fullblock tests for voting. Feb 13, 2017
@davecgh davecgh force-pushed the thresholdstate_fullblock_tests branch from 8c1ed35 to 1269bc3 Compare February 13, 2017 19:26
This adds a series of full block tests which exercise the new voting
functionality exposed via PoS votebits and a threshold state machine.
As with other full block tests, these involve generating a completely
valid chain starting with genesis block and methodically reaching
various thresholds.

To achieve this, the tests creates two stake version 4 test dummy
deployments that are carried out at the same time to also ensure voting
on multiple agendas concurrently works as intended.  The first agenda is
voted in via a majority yes vote while the second is rejected via a
majority no vote.

The following is an overview of the progression of the tests:

- Generate enough block to reach one block before the first stake
  version interval using v3 blocks and v3 votes in order to trigger
  stake version enforcement
- Generate enough blocks to reach one block before the next rule change
  interval using v3 blocks and v3 votes
  - Ensure that voting on the agendas does not start due to lack of
    majority proof-of-work upgrade, lack of majority proof-of-stake
    upgrade, and not being on a rule change interval
- Generate enough blocks to reach one block before the next stake
  version interval using v3 blocks and v4 votes in order to achieve
  stake version 4 enforcement
  - Ensure that voting on the agendas does not start due to lack of
    majority proof-of-work upgrade and not being on a rule change
    interval
- Generate enough blocks to reach the next rule change interval while
  still using a majority of v3 blocks and v4 votes, but set the last two
  blocks to v4
  - Ensure that voting on the agendas does not start due to lack of
    majority proof-of-work upgrade and not being on a rule change
    interval
- Generate enough blocks to achieve proof-of-work block version lockin
  using v4 blocks and v4 votes
  - Ensure that voting on the agendas does not start even though all
    upgrade conditions have been met due to not having reached a rule
    change interval
- Generate enough blocks to reach the next rule change interval using v4
  blocks and v4 votes such that the majority votes vote yes to the first
  agenda and no to the second agenda
  - Ensure that the voting on agendas begins, but that the yes and no
    votes do not count yet since the voting had not started yet until
    this rule change interval was reached
- Generate enough blocks to reach the next rule change interval using v4
  blocks and v4 votes such that the majority votes vote yes to the first
  agenda and no to the second agenda
  - Ensure the first agenda becomes locked in since it was voted in
    with a majority yes and the second agenda fails since it was
    rejected with a majority no
- Generate enough blocks to reach the next rule change interval using v4
  blocks and v4 votes such that the majority votes vote the opposite way
  they previously did (no to first agenda and yes to second agenda)
  - Ensure the first agenda becomes active and the second agenda remains
    failed since a rule change can't be undone once it has achieved
    lockedin status or has failed
Copy link
Member

@alexlyp alexlyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@jcvernaleo
Copy link
Member

Assuming travis passes this one looks good to me. Do you want a @marcopeereboom OK as well since he was working on this stuff with you?

@marcopeereboom marcopeereboom added this to the v0.8.0 milestone Feb 13, 2017
@davecgh
Copy link
Member Author

davecgh commented Feb 13, 2017

I assigned @marcopeereboom for a review as well.

Copy link
Member

@marcopeereboom marcopeereboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went over this albeit not with a fine toothed comb. I replicated these test in the synthetic test package and arrived at the same result though.

@alexlyp alexlyp merged commit 1269bc3 into decred:master Feb 13, 2017
@davecgh davecgh deleted the thresholdstate_fullblock_tests branch February 13, 2017 19:51
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.

None yet

4 participants