Skip to content

pipe num-validators through local-env cli - #2008

Merged
justinfrevert merged 10 commits into
mainfrom
local-env-cli-num-validators
Sep 11, 2026
Merged

pipe num-validators through local-env cli#2008
justinfrevert merged 10 commits into
mainfrom
local-env-cli-num-validators

Conversation

@justinfrevert

@justinfrevert justinfrevert commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Overview

--num-validators <count> lets a well-known network fork come up with fewer mock
validators 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-upgrade
path, plus the fork-network CI workflow.

  1. When forking from a snapshot the count drives mock-authorities convert (how
    many validator keysets get synthesized) and a generated Compose override that
    starts only the selected node* services, parking the rest behind a profile
    this tooling never activates.
  2. The active selection is persisted in the generated override
    (x-midnight-mock), so later restarts can omit the flag and reuse it, and
    verify-finality probes the validators that are actually running rather than
    the full configured topology.
  3. The count must be a positive integer no larger than mock.validatorServices.
    Changing it requires --from-snapshot so the authority set and seeds can be
    regenerated; it is rejected on reuse runs, in --from-genesis mode, and for
    the standalone local-env stack, whose topology and keys are fixed.

Also fixes a GRANDPA finality stall found while testing this: the fork tooling
defaulted to mock-authorities images that predate the client-side aux-storage
rewrite, 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 not
caused by the reduced validator set.

🗹 TODO before merging

  • Ready

📌 Submission Checklist

  • All commits are signed off (git commit -s) for the DCO
  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason:
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • Updated AGENTS.md if build commands, architecture, or workflows changed
  • No new todos introduced

🧪 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 client
and runtime GRANDPA set-ids match.

  • Additional tests are provided (if possible)

🔱 Fork Strategy

  • N/A

Links

Consumer of this tooling: midnightntwrk/midnight-indexer#1364

Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
@justinfrevert
justinfrevert marked this pull request as ready for review August 13, 2026 22:23
@justinfrevert
justinfrevert requested a review from a team as a code owner August 13, 2026 22:23
…idators

Signed-off-by: Justin Frevert <justinfrevert@gmail.com>

# Conflicts:
#	local-environment/README.md
#	local-environment/package.json
#	local-environment/src/index.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 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".

Comment thread local-environment/src/commands/verifyFinality.ts
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>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 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".

Comment thread local-environment/src/commands/run.ts
@justinfrevert justinfrevert added the bot:ai-assisted Authored or substantially edited by an AI agent label Aug 20, 2026
ozgb
ozgb previously approved these changes Aug 21, 2026
Resolves three collisions between the num-validators work and main:

- package.json: keep the branch's `src/commands/*.test.ts` glob, which
  covers main's `run.test.ts` plus any later command test.
- run.ts: both sides added to `runWellKnownNetwork`. Main's NODE_IMAGE
  guard runs first so it still fails before the snapshot restore, then
  the mock validator selection.
- imageUpgrade.ts: union of the two import groups; `discoverValidators`,
  `writeForkManifest` and `readMockValidatorSelection` are all used.

Assisted-by: AI <noreply@ai-assistant>
Signed-off-by: Justin Frevert <justinfrevert@gmail.com>
LGLO
LGLO previously approved these changes Sep 11, 2026
Comment thread changes/node/changed/local-env-fork-grandpa-finality-fix.md Outdated
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Justin Frevert <justinfrevert@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d808ab6aef

ℹ️ 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".

Comment thread .github/workflows/fork-network.yml
Comment thread local-environment/src/commands/run.ts
@justinfrevert
justinfrevert added this pull request to the merge queue Sep 11, 2026
Merged via the queue into main with commit 658a8c5 Sep 11, 2026
42 checks passed
@justinfrevert
justinfrevert deleted the local-env-cli-num-validators branch September 11, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:ai-assisted Authored or substantially edited by an AI agent skip-changes-check-issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants