Repository navigation
fix: deflake //rs/consensus:cup_explorer_test - #10515
Merged
Merged
Conversation
eichhorl
approved these changes
Jun 19, 2026
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Oct 18, 2026
`//rs/tests/consensus:cup_explorer_test` flaked 4 times in 182 runs since dfinity#11786 (2026-10-09), across `_farm`, `_local` and `_head_nns_farm`, and always the same way. The `test` task fails with `assertion left == right failed, left: 5, right: 4` because the `RecoverSubnet` proposal ends `Failed` instead of `Executed`. Its failure reason: the registry canister traps at `do_recover_subnet.rs:124`, because the system subnet answered the recovery's `setup_initial_dkg` request with `Attempts to run this DKG repeatedly failed`. ### Root cause The system subnet rejects the request because it uses up its attempts while it still cannot use the request's registry version: 1. `do_recover_subnet` sends `SetupInitialDKG` with the registry canister's latest version (`pre_call_registry_version`). The test created that version 3.5-4.2 s earlier with its "Update DKG length" proposal, the one that puts a registry version between halting and recovery. 2. Blocks only include dealings and transcripts for a remote DKG request once the block's registry version has reached the request's version (`build_callback_id_config_map`, `remote.rs:185`). The block maker only uses a version that has been in the replica's registry client for at least `POLLING_PERIOD + poll_delay_duration_ms` = 10 s (`get_stable_registry_version`). Before that, the orchestrator's registry replicator has to store the version (it polls every 5 s), and the replica's registry client has to pick it up from the local store (also every 5 s). So the request cannot be served until 10-20 s after the version is created. Each failed replicator poll adds up to ~10 s. 3. Meanwhile, every DKG summary increments the request's attempt counter, whether or not the request could be served (`get_updated_remote_dkg_attempts`). The request is rejected at the 5th summary after it arrives (`MAX_REMOTE_DKG_ATTEMPTS`), i.e. after 4 to 5 DKG intervals. 4. dfinity#11786 set the system subnet's DKG interval to 14 so that the subnet generates its vetKD key quickly. On this fast single-node subnet a 15-block interval lasts 3.5-4 s, so the request was rejected only 15-17 s after it arrived. 5. Measured from the creation of the version, that budget is ~20-21 s, minus the ~3 blocks the DKG needs once it can use the version. That is about the worst case of point 2, so the request is rejected whenever both pollers pick the version up late. That is what happened in the 4 failures: - The replicator stored the new version 4.5-5.3 s after its creation, the top of its range. - The version became usable at most ~1.2 s too late for the DKG to finish before the 5th summary. - In the 4 passing retries, the remote transcripts were created 10.9-15.6 s after the version was stored, as point 2 predicts. - Apart from the two errors that carry the rejection itself, no system-node log shows any DKG dealing or transcript error. ### Fix Give the system subnet its own DKG interval of 49 instead of 14. The app subnet keeps 14, so it still halts quickly. - **Not shorter.** The subnet makes at most 5 blocks/s, because a single node notarizes after `initial_notary_delay` = 200 ms. At that rate, 4 intervals of 50 blocks give the request at least ~40 s. That is about twice the 10-20 s of point 2, with room left for one failed replicator poll. - **Not much longer.** The system subnet's first signed CUP has to exist before `test_extract_master_public_keys` downloads its first CUP, 40-50 s after genesis. While no CUP verifies, `explore()` writes nothing, and `extract_master_public_keys` then panics on the empty file instead of retrying. - With 49, that first CUP is at height 50. It exists 12-19 s after genesis and already holds all keys, the vetKD key included. - With 99, the first CUP would be at height 100. In the slowest attempts it would come only a few seconds before the download. ### History This test has hit the same failure before: - dfinity#10055 (2026-05-12) started counting every interval as an attempt. Before it, a request was only counted in intervals in which its DKG configs were created. - Back then the system subnet used interval 14, and the test flaked with the same error in June. dfinity#10515 fixed that by returning the system subnet to the default interval of 499. - dfinity#11786 set the interval back to 14 to get the vetKD key quickly. The new comment above the constant explains why the interval must not be shortened again. ### Verification On a devenv, `bazel test --runs_per_test=3` of the 4 non-manual variants passed 12 out of 12 runs: `_farm`, `_head_nns_farm`, `_local` and `_head_nns_local`. - **The recovery's remote DKG.** In the 6 `_local` runs, the test log includes the system node's journal. There the remote DKG transcripts were created 8.6-12.6 s after the request, before or during the first DKG interval that counted it. The 5th summary would only have come 65-90 s after the request; the devenv makes fewer blocks per second than CI. - One run hit the failures' unlucky phase: the version was stored 0.3 s after the request arrived. It still finished after 12.6 s. - **The key extraction.** In all 12 runs, `test_extract_master_public_keys` got a CUP holding all keys (height 100) on its first attempt. ### Possible follow-ups (not in this PR) - **Consensus:** `get_updated_remote_dkg_attempts` could stop counting a request while the summary's registry version hasn't reached the request's version, as before dfinity#10055. Requests would then no longer be rejected as "repeatedly failed" without being attempted. This matters little for subnets with long DKG intervals, such as the 499-block default, where 4 intervals last far longer than the ~20 s registry delay. - **CUP explorer:** `explore()` could report whether it wrote a CUP, and `read_and_verify_cup` could return errors instead of panicking. `test_extract_master_public_keys` could then retry while no CUP verifies yet, which would lift the upper bound on the system subnet's DKG interval in this test. This PR was created following the steps in `.claude/skills/fix-flaky-tests/SKILL.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Leo Eichhorn <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
:cup_explorer_testrecently flaked withAttempts to run this DKG repeatedly failed. This happened to two runs already (on June 18th and on June 11th). Since this could be related to the recent DKG changes, I spent quite a bit of time to understand if there was a real regression, but it looks like the subnet genuinely does not have time to create the transcripts in one interval when CI is under load. The following is Claude's opinion, but @eichhorl you might want to take a closer look, here's the BuildBuddy link.Why the DKG timed out — a timing/load race:
The NNS is
Subnet::fast_single_node(...)withDKG_INTERVAL = 14. It produces a new DKG summary every ~3.5s (failed run: heights 300→315→330→345→360 at 15:01:36→…→15:01:50).The recovery context appears at ~15:01:34.8, so it gets only ~5 fast intervals (~14–17s of wall-clock) to complete, while each interval already spends ~1.95s just loading the low‑threshold transcript on the single overloaded node.
Failed run: never completed in those 5 attempts. Passed run: the same DKG finished in ~1 interval (transcripts found at height 296, ~12s after the recover call). Purely a wall-clock-per-attempt race.