Skip to content

[Peras 15] State-machine tests for PerasVoteDB#1809

Merged
agustinmista merged 1 commit intomainfrom
peras/vote-db-tests
Mar 5, 2026
Merged

[Peras 15] State-machine tests for PerasVoteDB#1809
agustinmista merged 1 commit intomainfrom
peras/vote-db-tests

Conversation

@agustinmista
Copy link
Copy Markdown
Contributor

@agustinmista agustinmista commented Dec 15, 2025

This PR implements state-machine tests for the PerasVoteDB using quickcheck-dynamic. Notably, we define rather constrained generators to increase the chances of (among others):

  • Voting for the same target more than once (normal behavior),
  • Voting more than once per round (PerasVoteAlreadyInDB),
  • Two voting targets becoming winners (MultipleWinnersInRound)

@agustinmista agustinmista self-assigned this Dec 15, 2025
@agustinmista agustinmista force-pushed the peras/vote-db-tests branch 3 times, most recently from 7dab848 to 6b35d34 Compare December 18, 2025 12:28
@agustinmista agustinmista force-pushed the peras/vote-db branch 4 times, most recently from 8127942 to 748f5a4 Compare December 24, 2025 13:26
@agustinmista agustinmista force-pushed the peras/vote-db-tests branch 3 times, most recently from d690be1 to 0c8ce7c Compare December 30, 2025 12:13
@agustinmista agustinmista changed the title [WIP] implementing state-machine tests for PerasVoteDB [Peras 15] State-machine tests for PerasVoteDB Dec 31, 2025
Copy link
Copy Markdown
Contributor

@tbagrel1 tbagrel1 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 to me! I've left a few questions about some non-crucial code choices :)

@agustinmista agustinmista force-pushed the peras/vote-db-tests branch 2 times, most recently from b434a16 to ba755b8 Compare January 26, 2026 15:41
@agustinmista agustinmista force-pushed the peras/vote-db branch 2 times, most recently from 9fa47c0 to 77d474b Compare January 28, 2026 10:58
@agustinmista agustinmista force-pushed the peras/vote-db-tests branch 2 times, most recently from 5be3ab8 to 14c6744 Compare January 28, 2026 12:18
@agustinmista agustinmista force-pushed the peras/vote-db-tests branch 3 times, most recently from 9e25257 to 70f7391 Compare February 3, 2026 15:44
@agustinmista agustinmista force-pushed the peras/vote-db branch 8 times, most recently from bc855a0 to 023456f Compare February 23, 2026 10:22
@agustinmista agustinmista force-pushed the peras/vote-db-tests branch 2 times, most recently from 30c6f5c to 0f9fd8e Compare February 23, 2026 13:33
github-merge-queue bot pushed a commit that referenced this pull request Feb 23, 2026
This PR introduces the API and implementation of an in-memory database
to store Peras votes received from other peers via ObjectDiffusion.

NOTES;

* To keep things compartmentalized, `O.C.Peras.Vote.Aggregation`
implements the tricky parts of the vote aggregation logic within a given
round, exposing only the interesting event of having _just_ reached
quorum via the `VoteGeneratedCert` and `VoteDidntGenerateCert` pattern
synonyms.

* Having multiple winners in the same round should, in principle, be
impossible under the right parameterization (i.e. quorum threshold >=
75%). Since this will be ultimately become a tunable parameter, we
resort to throw a `MultipleWinnersInRound` exception instead of a bare
call to `error`. In addition, selecting the committee via Local
Sortition in the future will add an extra level of statistical
uncertainty that needs to be accounted for. This is because the _actual_
size of voting committee might differ from the _expected_ one, so one
needs to end up asking for a stronger quorum to be reached before
declaring a round winner. This is now kept as a separate
`PerasQuorumStakeSafetyMargin` parameter.

* This PR is already rather large, so state-machine testing is
implemented separately in [Peras
15](#1809).
Base automatically changed from peras/vote-db to main February 23, 2026 20:46
Copy link
Copy Markdown
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

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

Changes look good, but remove the changelog fragment

This commit implements state-machine tests for the PerasVoteDB using
quickcheck-dynamic. Notably, we define rather constrained generators to
increase the chances of (among others):

* Voting for the same target more than once (normal behavior),
* Voting more than once per round (PerasVoteAlreadyInDB),
* Two voting targets becoming winners (MultipleWinnersInRound)

Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io>
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement PerasVoteDB

4 participants