Skip to content

feat(cli)!: run every network from its stack descriptor - #1944

Merged
mordamax merged 23 commits into
mainfrom
refactor/host-cli-owned-network-config
Nov 6, 2026
Merged

mordamax merged 23 commits into
mainfrom
refactor/host-cli-owned-network-config

Conversation

@mordamax

@mordamax mordamax commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

A fork or a local network now runs from its stack descriptor alone, for example truapi-host --stack ./local-stack.json signing-host

  • HOST_CLI_PEOPLE_WS, HOST_CLI_ASSET_HUB_WS, HOST_CLI_BULLETIN_WS, HOST_CLI_IDENTITY_BACKEND_BASE, HOST_CLI_DOTNS_POP_CONTROLLER and HOST_CLI_LOCAL_NETWORK_CONFIG are removed
  • The hidden local-network-check command is removed
  • A local stack file may point at loopback ws:// and http:// URLs
  • An endpoint of a local stack that does not answer within 3 seconds is now logged and left to fail on first use, as for any stack
  • A stack without a dub service or dotns.popController is refused for every command
  • Username reads now use the stack's dotns.popController instead of looking the controller up on chain
  • A published built-in descriptor that changes its id or TLD, or that the CLI cannot run, is rejected with a warning, and the bundled copy is used
  • stack bundle now also refuses a copy that changes the id, and a built-in network's copy the CLI cannot run on
  • --network pcf-devnet runs on PCF's devnet from its signed descriptor, as a test network like paseo-next-v2 and previewnet
  • --network polkadot is removed
  • A --stack chain with one of Polkadot's genesis hashes now runs when it is a fork of Polkadot
  • The command stops when such a chain serves Polkadot itself or does not answer
  • A --stack may now use the dot TLD, so a Polkadot fork with the id polkadot-fork runs under its own namespace
  • trinity-stack's Chain::genesis, Descriptor::service and Descriptor::dotns_address return a validated descriptor's values as bytes
  • E2E_LIVE_CHAIN is removed

Unlike RFC 2, where only a host build may introduce a stack on Polkadot's genesis hashes or dot, this CLI runs any fork and refuses only chains that are Polkadot itself, since its accounts are throwaway test accounts and a fork's own blocks keep its signatures off mainnet.

Part of #1312

@mordamax
mordamax requested review from a team as code owners November 6, 2026 00:02
@github-actions github-actions Bot added size:XXL 1000 lines or more; split it, or say in the description why it cannot be status:waiting-on-review Ready for a reviewer labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Bundle size report

Compared with main at 566bccd.

Raw Gzip Brotli
truapi-host 8.50 MiB (+1.0 KiB) 5.86 MiB (+401 B) 5.53 MiB (-437 B)
truapi-provider 4.04 MiB 1.27 MiB 961.3 KiB
truapi 7.90 MiB 1.10 MiB 917.4 KiB
trinity-stack 634.3 KiB (+56 B) 247.5 KiB (-10 B) 204.6 KiB (-109 B, -0.1%)
Total 21.05 MiB (+1.1 KiB) 8.48 MiB (+391 B) 7.56 MiB (-546 B)

WebAssembly modules

Raw Gzip Brotli
truapi-host/wasm/web/truapi_server_bg.wasm 3.38 MiB (+678 B) 1.17 MiB (+320 B) 890.6 KiB (-515 B, -0.1%)
truapi-host/wasm/web/truapi_verifiable_bg.wasm 4.89 MiB 4.64 MiB 4.61 MiB
truapi-provider/truapi_provider_bg.wasm 3.99 MiB 1.26 MiB 953.5 KiB
trinity-stack/wasm/trinity_stack_bg.wasm 564.5 KiB (+56 B) 230.5 KiB (-10 B) 189.9 KiB (-109 B, -0.1%)
Changed files (3)
Raw Gzip Brotli
truapi-host/wasm/web/truapi_server_bg.wasm 3.38 MiB (+678 B) 1.17 MiB (+320 B) 890.6 KiB (-515 B, -0.1%)
truapi-host/generated/host-callbacks.js 13.7 KiB (+385 B, +2.8%) 4.2 KiB (+85 B, +2.0%) 3.6 KiB (+76 B, +2.1%)
trinity-stack/wasm/trinity_stack_bg.wasm 564.5 KiB (+56 B) 230.5 KiB (-10 B) 189.9 KiB (-109 B, -0.1%)

Commit: 4f00b09

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

CI Status: 24 required jobs green, 21 passed and 3 skipped by path filter.

All job results
job result
android-app success
android-bindings skipped
bundle-size success
changes success
changeset-guard success
cli-package success
codegen success
e2e skipped
explorer success
headless-install success
host-wasm success
ios-app success
ios-bindings success
licenses success
playground success
provider-android-bindings skipped
release-guard success
rust success
ts-client success
ts-debugger success
ts-host success
ts-trinity-stack success
wasm-provider success
workflow-lint success

Signing credentials: valid as of 2026-11-06

Commit 4f00b096 · run log

@mordamax mordamax changed the title refactor(cli): own the network config instead of leaking it feat(cli)!: own the network config and replace polkadot with pcf-devnet Nov 6, 2026

@pgherveou pgherveou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestion, here or in a follow-up: make the stack descriptor the CLI's only network source. The same fields now live in four shapes (Descriptor, StackProjection, NetworkConfig, LocalNetwork), the CLI decodes descriptor hex that trinity-stack already decoded while validating, and Network::id() repeats each bundled descriptor's id.

Rough shape:

  • trinity-stack gets parsed accessors: Chain::genesis(), Descriptor::service(kind), Descriptor::dotns_address(key).
  • NetworkConfig and StackProjection become one Stack newtype that owns the descriptor, is built once the host checks pass (including dub and dotns.popController), and exposes infallible accessors.
  • Drop HOST_CLI_*_WS, HOST_CLI_IDENTITY_BACKEND_BASE and HOST_CLI_DOTNS_POP_CONTROLLER: since #1885 --stack covers forks and local networks, and polkadot-pop-e2e can pass the stack it already reads as HOST_CLI_STACK. HOST_CLI_LOCAL_NETWORK_CONFIG stays for now, applied as an edit to the descriptor.

Details, risks and a commit plan: https://gist.github.com/pgherveou/de670d60ac70da6d1d4c177b52eb7d17

@mordamax mordamax changed the title feat(cli)!: own the network config and replace polkadot with pcf-devnet feat(cli)!: run every network from its stack descriptor Nov 6, 2026
@mordamax

mordamax commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Suggestion, here or in a follow-up: make the stack descriptor the CLI's only network source. The same fields now live in four shapes (Descriptor, StackProjection, NetworkConfig, LocalNetwork), the CLI decodes descriptor hex that trinity-stack already decoded while validating, and Network::id() repeats each bundled descriptor's id.

Rough shape:

  • trinity-stack gets parsed accessors: Chain::genesis(), Descriptor::service(kind), Descriptor::dotns_address(key).
  • NetworkConfig and StackProjection become one Stack newtype that owns the descriptor, is built once the host checks pass (including dub and dotns.popController), and exposes infallible accessors.
  • Drop HOST_CLI_*_WS, HOST_CLI_IDENTITY_BACKEND_BASE and HOST_CLI_DOTNS_POP_CONTROLLER: since feat(cli)!: take every test network from its Trinity stack descriptor #1885 --stack covers forks and local networks, and polkadot-pop-e2e can pass the stack it already reads as HOST_CLI_STACK. HOST_CLI_LOCAL_NETWORK_CONFIG stays for now, applied as an edit to the descriptor.

Details, risks and a commit plan: https://gist.github.com/pgherveou/de670d60ac70da6d1d4c177b52eb7d17

Did it all in this PR, except two things. HOST_CLI_LOCAL_NETWORK_CONFIG is gone too instead of becoming a descriptor edit, since the CLI needs a DUB and the rest of a stack anyway, so a local network is just a --stack file now. And built_in.rs stays on accept rather than StackReader: StackReader has no TLD or id pin, so the CLI would have to override its choice from outside. Probably worth adding that pin to trinity-stack separately

Check the flag combinations once at startup in NetworkSource::new, so a
source with both cannot exist. Covers --network and --stack given on
opposite sides of the subcommand, which clap's conflicts_with misses for
global args.
@mordamax
mordamax enabled auto-merge November 6, 2026 17:13
@mordamax
mordamax added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit c38ac5b Nov 6, 2026
48 checks passed
@mordamax
mordamax deleted the refactor/host-cli-owned-network-config branch November 6, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1000 lines or more; split it, or say in the description why it cannot be status:waiting-on-review Ready for a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants