Skip to content

feat: per-network configuration with named devnets and no hard-coded contract ids - #11

Merged
PastaPastaPasta merged 4 commits into
masterfrom
feat/per-network-config
Sep 25, 2026
Merged

PastaPastaPasta merged 4 commits into
masterfrom
feat/per-network-config

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Problem

Every client assumed testnet. Contract ids were written by hand in forge-web/lib/constants.ts and in forge-core, so pointing a build at mainnet or a devnet did not fail cleanly. Mainnet had null placeholders that surfaced as generic errors. A devnet could not be selected at all. A network with no registry could quietly fall back to testnet ids. Now that the forge-v2 contracts are registered on devnet moutai, the clients need a single, per-network place to read those ids from before the forge-v2 client migration can start.

What changed

One source of truth for contract ids: forge-contracts/deployments/<key>.json (testnet, mainnet, devnet-<name>).

  • forge-core's build.rs globs the directory and embeds every file, so committing a new deployment file needs no code change. forge-web imports each file in lib/deployments.ts, and a test fails if a file on disk is missing from that map.
  • A network with no deployment resolves to Error::NotDeployed / NotDeployedError, never to another network's ids. create_repo refuses before paying for a contract whose listing could never be published.
  • Overrides: FORGE_REGISTRY_CONTRACT_ID, config registry_contract_id, and git config dash.registryContractId (Rust); NEXT_PUBLIC_REGISTRY_CONTRACT_ID (web). dg doctor reports which source won.

Named devnets. Network is testnet, mainnet or Devnet { name, dapi_addresses, quorum_base_url }.

  • dg, forge-relay and forge-import take --network devnet --devnet-name <name> [--dapi-addresses ...], with config keys and DASH_FORGE_* env vars. git-remote-dash reads dash.network, dash.devnetName and dash.dapiAddresses. Settings layer field-wise, and each layer falls back to the deployment file. For dg the order is flags > config file > env. For git-remote-dash it is env (set by dg for its child) > git config. For forge-relay it is flags > config file > env.
  • A devnet's DAPI addresses and quorum URL fall back to devnet-<name>.json. When the file has no top-level dapiAddresses, the addresses fall back again to the v2.devnet.addresses that deploy-v2.mjs recorded (Rust and TS). The quorum URL defaults to quorums.<name>.networks.dash.org. forge-web can override it with NEXT_PUBLIC_QUORUM_URL, matching DASH_FORGE_QUORUM_URL.
  • forge-web builds for a devnet with NEXT_PUBLIC_NETWORK=devnet NEXT_PUBLIC_DEVNET_NAME=moutai and connects with a trusted evo-sdk devnet context. Every non-mainnet build shows a network badge in the header. When no registry is deployed, the web renders a not-deployed state instead of querying.

forge-v2 ids are exposed for the upcoming client migration:

  • Rust: Deployment::v2 and NetworkTarget::v2 are Option<ForgeIds { core, collab, group }>.
  • TS: NETWORKS[n].v2 is ForgeIds | null, via forgeV2Ids() in lib/deployments.ts.
  • Ids count only when both forgeCore and forgeCollab have status: "registered" and contractGroupId is recorded. A deploy still broadcasting is not a deployment. Rust and TS apply the same rule and test it.
  • No client operation reads v2 yet. That is the next PR.

devnet-moutai.json now carries both the top-level client fields (network, devnetName, dapiAddresses, registry: null) and master's v2 record verbatim: forgeCore GdZY…, forgeCollab CbsaT6…, forgeCollabSuperseded, schemaHash. deploy-v2.mjs read-modify-writes the whole object, so it keeps the client fields.

Rebase onto master (forge-v2 contracts, FORGE_RULES_V2, #6, #8, #10, #12). Conflicts resolved:

Verification

Check Result
cargo fmt --all -- --check pass
cargo clippy --locked --workspace --all-targets -- -D warnings pass
cargo test --locked --workspace 350 passed, 0 failed, 4 ignored (live)
pnpm typecheck / pnpm lint pass
pnpm test 439 passed, 3 skipped (live)
pnpm build (default testnet) pass
NEXT_PUBLIC_NETWORK=devnet NEXT_PUBLIC_DEVNET_NAME=moutai pnpm build pass
devnet-moutai.json parses in Rust with the expected v2 ids (read from the file on disk) moutai_exposes_its_forge_v2_ids_from_the_deployment_file
devnet-moutai.json parses in TS with the expected v2 ids constants.test.ts › exposes the forge-v2 ids devnet-moutai.json records
Partial or in-flight v2 records yield no ids (Rust and TS) a_partial_v2_record_is_not_a_deployment, forgeV2Ids suite
DAPI address fallback to v2.devnet.addresses (Rust and TS) dapi_addresses_fall_back_to_the_v2_devnet_record, recordedDapiAddresses suite
Devnet quorum endpoint, and the NEXT_PUBLIC_QUORUM_URL override quorumEndpoint suite
git range-diff of the replayed commits against the originals only the conflict hunks listed above differ

Not verified live

  • No dg, git-remote-dash or forge-relay command was run against devnet moutai, and none was run against testnet from this branch. Resolution is covered by unit tests only.
  • The moutai web build was not opened in a browser, so the devnet evo-sdk trusted connection and the quorum-key fetch from quorums.moutai.networks.dash.org were not checked live.
  • Mainnet still has no deployment file. Its not-deployed path is tested, but the runbook deploy has not been run.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for mainnet and named devnets across the CLI, relay, Git integration, and web app, with network selection through command-line options, environment variables, or Git configuration.
    • Added network-specific contract and endpoint settings, plus visible network badges and guidance when a network has no registry deployment.
    • Web builds can now include deployment data for supported networks.
  • Bug Fixes

    • Missing deployments now produce a clear error instead of silently using contract IDs from another network.
    • Improved network matching for identity files and signing keys.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 2894c5bd-b11a-4e5a-bf8d-1c8de760e5cf

📥 Commits

Reviewing files that changed from the base of the PR and between 3d450b9 and 1cd356c.

📒 Files selected for processing (64)
  • .github/workflows/pages.yml
  • .github/workflows/rust.yml
  • README.md
  • crates/dg/src/auth.rs
  • crates/dg/src/config.rs
  • crates/dg/src/context.rs
  • crates/dg/src/doctor.rs
  • crates/dg/src/main.rs
  • crates/dg/src/pr.rs
  • crates/dg/src/repo.rs
  • crates/forge-core/build.rs
  • crates/forge-core/src/backends/live_tests.rs
  • crates/forge-core/src/collab.rs
  • crates/forge-core/src/error.rs
  • crates/forge-core/src/lib.rs
  • crates/forge-core/src/network.rs
  • crates/forge-core/src/platform.rs
  • crates/forge-core/src/repo.rs
  • crates/forge-core/src/tokens.rs
  • crates/forge-core/tests/collab_tokens.rs
  • crates/forge-core/tests/live_roundtrip.rs
  • crates/forge-core/tests/repo_lifecycle.rs
  • crates/forge-import/src/importer.rs
  • crates/forge-import/src/main.rs
  • crates/forge-relay/examples/ci_consumer.rs
  • crates/forge-relay/src/config.rs
  • crates/forge-relay/src/daemon.rs
  • crates/forge-relay/src/ingest.rs
  • crates/forge-relay/src/main.rs
  • crates/git-remote-dash/src/admin.rs
  • crates/git-remote-dash/src/git.rs
  • crates/git-remote-dash/src/helper.rs
  • crates/git-remote-dash/src/main.rs
  • docs/BUILDING.md
  • docs/mainnet-runbook.md
  • forge-contracts/deployments/devnet-moutai.json
  • forge-web/app/new/page.tsx
  • forge-web/app/page.tsx
  • forge-web/app/settings/page.tsx
  • forge-web/components/app-header.tsx
  • forge-web/components/login-modal.tsx
  • forge-web/components/profile-content.tsx
  • forge-web/components/repo/repo-scaffold.tsx
  • forge-web/components/repo/settings-content.tsx
  • forge-web/components/ui/network-badge.tsx
  • forge-web/components/ui/trust-panel.tsx
  • forge-web/lib/auth/controller.ts
  • forge-web/lib/auth/identity-file.ts
  • forge-web/lib/auth/wif.ts
  • forge-web/lib/constants.test.ts
  • forge-web/lib/constants.ts
  • forge-web/lib/deployments.ts
  • forge-web/lib/repo/collab.ts
  • forge-web/lib/repo/resolveRepo.ts
  • forge-web/lib/repo/token-history.live.test.ts
  • forge-web/lib/repo/tokens.test.ts
  • forge-web/lib/repo/tokens.ts
  • forge-web/lib/repo/writes.ts
  • forge-web/lib/sdk/service.ts
  • forge-web/lib/view/discovery.ts
  • forge-web/lib/view/dpns.ts
  • forge-web/lib/view/repo-view.ts
  • forge-web/lib/view/trust.test.ts
  • forge-web/lib/view/trust.ts
 _________________________________________________
< My whiskers twitch when I detect a memory leak. >
 -------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PastaPastaPasta and others added 4 commits September 25, 2026 06:16
…contract ids

forge-core gains a network module: Network is testnet, mainnet or Devnet { name, dapi_addresses, quorum_base_url }. Contract ids come only from forge-contracts/deployments/<key>.json, embedded by a build script that globs the directory, with a FORGE_REGISTRY_CONTRACT_ID / config / git-config override. A network with no deployment fails with Error::NotDeployed instead of using testnet ids, and create_repo refuses before paying for a contract.

dg gets --network devnet, --devnet-name and --dapi-addresses (plus config.toml keys); git-remote-dash reads dash.network / dash.devnetName / dash.dapiAddresses; forge-relay and forge-import take the same flags. dg doctor reports the network, the registry id and its source.

forge-web resolves the network from NEXT_PUBLIC_NETWORK / NEXT_PUBLIC_DEVNET_NAME / NEXT_PUBLIC_DAPI_ADDRESSES and the bundled deployment files, shows a network badge in the header on every non-mainnet build, and renders a not-deployed state rather than querying another network. Adds the devnet-moutai deployment skeleton.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…WORK constant

Drop the unused registry owner id, parse each deployment file once, add Deployment::registry(), and replace repeated NETWORKS[DEFAULT_NETWORK] lookups in forge-web with ACTIVE_NETWORK.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ution

Parse the v2 record deploy-v2.mjs writes into devnet-moutai.json and expose it as v2: Option<ForgeIds{core, collab, group}> on Deployment and NetworkTarget (Rust) and NETWORKS[n].v2 (TS). Ids count only when both contracts are registered and the group is recorded, so an in-flight deploy is not a deployment. Tests read the expected ids from the file on disk.

Also restore the two fixes the dropped merge commit carried: parse_id's doc comment, and the BUILDING.md note on what devnet-moutai.json records.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Trust copy names the network by its key (devnet-moutai). QUORUM_KEY_ENDPOINT is built from a pure quorumEndpoint(config) helper, tested for devnet. forge-web honors NEXT_PUBLIC_QUORUM_URL (parity with DASH_FORGE_QUORUM_URL). A deployment file without top-level dapiAddresses falls back to v2.devnet.addresses in both Rust and TS. Drop stale 'skeleton' wording.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

1 participant