pipe num-validators through local-env cli - #2008
Conversation
Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
…idators Signed-off-by: Justin Frevert <justinfrevert@gmail.com> # Conflicts: # local-environment/README.md # local-environment/package.json # local-environment/src/index.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0aa824fe8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const selection = readMockValidatorSelection( | ||
| mockOverridePath(path.dirname(composeFile), network), | ||
| ); |
There was a problem hiding this comment.
Ignore stale mock overrides for finality checks
When a network was previously forked with a reduced validator count, this now reads the persisted <network>.mock.override.yaml and filters the probe list whenever that file exists. If the same checkout is later started with run <network> --from-genesis, that path only layers the generated genesis override and leaves the old mock override unused on disk, so verify-finality <network> can report success after checking only the stale subset while the other genesis validators are stalled. Gate this on the currently used fork-mode compose override, or ignore/remove stale mock metadata for from-genesis/base-compose runs.
Useful? React with 👍 / 👎.
Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
Assisted-by: Claude:claude-opus-4.8 Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba8a5ea247
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (persistedSelection?.disabledValidatorServices.length) { | ||
| await removeDockerComposeServices( | ||
| { | ||
| composeFile, | ||
| env, | ||
| profiles: runOptions.profiles, | ||
| }, |
There was a problem hiding this comment.
Stop active validators before replacing their data
When --num-validators is used to change an existing running fork, this only stops the newly disabled services, and it does so after restoreSnapshot has deleted and replaced every bind-mounted data directory and after mock-authorities has rewritten them. Validators retained in the new selection therefore remain alive with handles to the old database; because their service configuration is otherwise unchanged, the subsequent compose up need not recreate them, leaving retained nodes on the old state while newly enabled nodes use the regenerated snapshot. Stop or force-recreate all validator containers before restoring and converting the snapshot.
Useful? React with 👍 / 👎.
Overview
--num-validators <count>lets a well-known network fork come up with fewer mockvalidators than the network's Compose topology defines, instead of always
materializing the full set. Smaller forks start faster and fit on a laptop, which
is what most fork testing actually needs.
The flag is threaded through every local-env command that brings up or rolls a
forked network:
run,image-upgrade,full-upgrade, and the runtime-upgradepath, plus the
fork-networkCI workflow.mock-authorities convert(howmany validator keysets get synthesized) and a generated Compose override that
starts only the selected
node*services, parking the rest behind a profilethis tooling never activates.
(
x-midnight-mock), so later restarts can omit the flag and reuse it, andverify-finalityprobes the validators that are actually running rather thanthe full configured topology.
mock.validatorServices.Changing it requires
--from-snapshotso the authority set and seeds can beregenerated; it is rejected on reuse runs, in
--from-genesismode, and forthe standalone
local-envstack, whose topology and keys are fixed.Also fixes a GRANDPA finality stall found while testing this: the fork tooling
defaulted to
mock-authoritiesimages that predate the client-side aux-storagerewrite, which deadlocks the GRANDPA voter on a >=2.0.0 runtime. Details in
changes/node/changed/local-env-fork-grandpa-finality-fix.md. That stall was notcaused by the reduced validator set.
🗹 TODO before merging
📌 Submission Checklist
git commit -s) for the DCO🧪 Testing Evidence
Unit tests cover the selection resolver, the persisted-selection round trip, the
disabled-service profile, and the stale-override cleanup
(
local-environment/src/lib/mockValidatorSelection.test.ts).Manually verified by forking devnet (
2.0.0-rc.3) from a snapshot with--num-validators 3: all three validators author and finalize, and the clientand runtime GRANDPA set-ids match.
🔱 Fork Strategy
Links
Consumer of this tooling: midnightntwrk/midnight-indexer#1364