Skip to content

Fix flaky ProposeNewConstitution test#6601

Open
carbolymer wants to merge 1 commit into
masterfrom
mgalazyn/test/fix-flaky-propose-new-constitution
Open

Fix flaky ProposeNewConstitution test#6601
carbolymer wants to merge 1 commit into
masterfrom
mgalazyn/test/fix-flaky-propose-new-constitution

Conversation

@carbolymer

@carbolymer carbolymer commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Raise dvtUpdateToConstitution to 51% (from the default 0%) via Conway genesis override, so a minority of yes-votes cannot trigger instant ratification.
  • Split voting into two rounds: round 1 (3 yes = 33%, below threshold) keeps the proposal alive for deterministic ledger and CLI assertions; round 2 (+1 yes, +3 no, +2 abstain = 4/7 = 57.1%) crosses the threshold and triggers ratification.
  • Replace waitForGovActionVotes + immediate assertions with retryUntilJustM polling that exits only when the exact expected vote count appears in both ledger state and CLI output.
  • Extend govActionLifetime to 4 epochs and ratification timeout to epoch 20 so the proposal survives the pulsing snapshot refresh cycle.
  • Move query proposals assertion before voting so the proposal structure is verified while it has zero votes (deterministic).

Root cause

The default dvtUpdateToConstitution = 0% means any single DRep yes-vote immediately satisfies the ratification threshold.
Combined with the pulsing snapshot lag (the snapshot only picks up new votes at epoch boundaries), the window where the proposal exists with votes but is not yet ratified is extremely narrow.
The old test submitted all 9 votes at once and then asserted on the transient "proposal with votes" state, which was a race condition.

Approach

Structure the test so that the states we are interested in are longer-lived (addressing review feedback):

  1. Override Conway genesis to set a meaningful ratification threshold
  2. Vote in rounds so the below-threshold state is stable for assertions
  3. Use exact-count polling guards so assertions never fire on stale data

Test plan

  • Test passes consistently with DISABLE_RETRIES=1 (4/4 runs, ~75-96s each)
  • CI green

@carbolymer carbolymer changed the title Fix flaky propose new constitution Fix flaky propose new constitution test Jun 17, 2026
@carbolymer carbolymer self-assigned this Jun 17, 2026
@carbolymer carbolymer changed the base branch from master to mgalazyn/feature/update-cardano-rpc-11.0 June 17, 2026 08:17
@carbolymer carbolymer force-pushed the mgalazyn/feature/update-cardano-rpc-11.0 branch from 2064644 to 0e48d61 Compare June 18, 2026 10:40
Base automatically changed from mgalazyn/feature/update-cardano-rpc-11.0 to master June 19, 2026 12:45
@carbolymer carbolymer force-pushed the mgalazyn/test/fix-flaky-propose-new-constitution branch 4 times, most recently from d9fddec to 0020a36 Compare June 29, 2026 10:40
@carbolymer carbolymer changed the title Fix flaky propose new constitution test Fix flaky ProposeNewConstitution test Jun 29, 2026
@carbolymer carbolymer force-pushed the mgalazyn/test/fix-flaky-propose-new-constitution branch from 0020a36 to 29c0245 Compare June 29, 2026 10:48
@carbolymer carbolymer marked this pull request as ready for review June 29, 2026 10:51
@carbolymer carbolymer requested a review from a team as a code owner June 29, 2026 10:51
@carbolymer carbolymer requested a review from Copilot June 29, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make the ProposeNewConstitution governance integration test deterministic by avoiding a transient “proposal-with-votes-but-not-yet-ratified” window caused by low (0%) voting thresholds and pulsing snapshot lag.

Changes:

  • Overrides Conway genesis in the test to raise dvtUpdateToConstitution (to 51%) and extend govActionLifetime, and updates the configuration.yaml genesis hash accordingly.
  • Splits DRep voting into two rounds and replaces “wait then assert” logic with retryUntilJustM polling guards that wait for exact expected vote counts in ledger state and CLI output.
  • Updates several golden query outputs (notably PlutusV3 cost model parameter values) and adds .serena/ to .gitignore.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs Reworks the test setup (genesis override + rehash), voting flow (two rounds), and assertion strategy (exact-count polling) to eliminate flakiness.
cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersOut.txt Updates expected protocol parameter output (PlutusV3 cost model values).
cardano-testnet/test/cardano-testnet-test/files/golden/queries/protocolParametersFileOut.json Updates expected protocol parameter JSON output (PlutusV3 cost model values).
cardano-testnet/test/cardano-testnet-test/files/golden/queries/govStateOut.json Updates expected governance state JSON output (PlutusV3 cost model values).
cardano-testnet/changelog.d/20260629_103800_mgalazyn_fix_flaky_propose_new_constitution.md Documents the test flake fix and new strategy.
.gitignore Ignores .serena/ directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +73 to +75
-- Generate model for votes in two rounds.
-- Round 1: 3 yes votes = 33.3% of active DRep stake, below 51% threshold - proposal stays alive.
-- Round 2: +1 yes, +3 no, +2 abstain. New ratio is 4/7 participating = 57.1%, triggers ratification.
Comment on lines +329 to +330
-- Round 1: submit 3 yes votes (33.3% of active DRep stake, below 51% threshold).
-- The proposal cannot be ratified, so it persists across epoch boundaries.
stakePoolVotes <- H.evalMaybe $ cliProposal ^? Aeson.key "stakePoolVotes" . Aeson._Object
stakePoolVotes === mempty

-- Round 2: submit +1 yes, +3 no, +2 abstain. New ratio is 4/7 = 57.1% > 51%, triggers ratification.

- Fixed flaky `ProposeNewConstitution` test by raising `dvtUpdateToConstitution` to 51% and splitting voting into two rounds.
The old test submitted all votes at once with the default threshold of 0%, so any single yes-vote could trigger instant ratification; combined with pulsing snapshot lag, the "proposal with votes" state was transient and assertions failed non-deterministically.
The new test uses `createTestnetEnv` + genesis override to set a meaningful threshold, then votes in two rounds: round 1 (3 yes, below threshold) keeps the proposal alive for deterministic assertions, round 2 (+1 yes, +3 no, +2 abstain = 57.1%) triggers ratification.
Comment on lines 403 to 407
7305,
-900,
1716,
960,
549,
57,
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.

Fix flaky ProposeNewConstitution test with per-test genesis override and two-round voting

2 participants