Repository navigation
MIP-0008: CAIP-2 Compliant Network IDs #195
Replies: 9 comments 16 replies
|
CAIP-2 Reference Format: Question: What should the reference portion of midnight:{reference} be? Options: Considerations: |
|
Namespace Registration: Question: How will midnight namespace be registered in the official CAIP-2 registry? Process: Considerations: |
|
Backward Compatibility Strategy: Question: How will solutions support both legacy and CAIP-2 formats during transition? Approaches: Considerations: |
|
Ledger State Impact: Question: Does network_id embedded in ledger state need to change? Context: Scenarios: Considerations: |
|
Address Encoding Interaction: Question: Should CAIP-2 NetworkId affect Bech32m address format? Current: Addresses use network-aware prefixes: mn_addr1... (mainnet), potential for mn_addr_testnet1... Options: Considerations: |
|
API Versioning: Question: How should public APIs (HTTP, RPC) handle NetworkId format changes? Endpoints affected: Strategies: Considerations: |
|
Type Safety and Validation: Question: How should CAIP-2 format be enforced at compile time? Current: NetworkId is type NetworkId = WellKnownNetworkId | string (weak typing) Improvements: Considerations: |
|
Thanks for opening the structured discussion around MIP-0008. Adding my downstream-builder / wallet-interoperability perspective. 1. CAIP-2 reference format For external CAIP-2 identifiers, I would prefer the network-name format:
Reason: this is the simplest shape for wallets, DApp connectors, policy/audit surfaces, OWS-style registries, docs, and user-facing tooling. It is also closest to the existing Midnight I agree genesis/hash references are stronger for cryptographic verification, but from a wallet/app integration perspective they may be better as resolver metadata or validation data rather than the primary human-facing CAIP-2 reference. 2. Namespace registration Development can proceed against a provisional The MIP can define the intended namespace and resolution method first, then the ChainAgnostic PR can follow as downstream standards work. 3. Backwards compatibility My preference is adapter-layer + dual support during transition. Midnight internals can continue using the existing lowercase network strings where needed, while external wallet/SDK/API boundaries expose or accept CAIP-2 identifiers. During the transition, tools can accept both formats and normalize at the boundary. That avoids breaking existing wallets, indexers, and DApps while still giving downstream ecosystems a globally unique identifier. 4. Ledger status impact I would avoid changing ledger/proof/consensus From the downstream builder perspective, the immediate need is external network identification for wallets, DApp connectors, registries, policy/audit surfaces, and interoperability tooling. I would keep consensus/proof serialization separate from this unless there is a core protocol reason to unify them. 5. Address encoding I would prefer decoupling CAIP-2 network identifiers from Bech32m address encoding. Address prefixes should remain stable unless Midnight core has a protocol/security reason to change them. CAIP-2 should identify the network at API, registry, connector, policy, and storage boundaries. So my preference is closest to hybrid:
That avoids breaking existing address validators and test vectors while still giving wallets and cross-chain tooling a globally unique network identifier. 6. API versioning For public APIs, I would prefer dual support with normalization at the boundary, plus deprecation warnings once the CAIP-2 path is stable. Concretely:
I would avoid forcing a hard 7. Type safety and validation My preference is “parse, don’t validate”, backed by branded/opaque types where possible. For example:
That keeps external input flexible while preventing unparsed strings from moving deeper into wallet/SDK/indexer logic. Runtime regex can be part of the parser, but I would not rely on regex alone as the public developer experience. I would also avoid enum-only validation as the only path, because future networks or test environments may need to be represented before every downstream library is updated. Suggested direction
|
|
Reference format: agreed @kapke, @NicolasDP and I worked through this over Slack. We’ve agreed on the following and I’m recording it here so the public record matches. The agreement
What the amendment will say:
Engineering impact This reuses existing plumbing, with no ledger, address or transaction-format changes. The wallet’s NodeClient already compares the node’s genesis hash with the indexer’s block 0 and reports WrongNetwork on a mismatch. The MIP adds a published value for that check to compare against. First application Preview relaunched as a new chain on 7 November 2026. The registry will list its new genesis hash as current and the previous one as superseded from that date, which is exactly the case rule 2 covers. Next steps
@kapke @NicolasDP, please correct anything I’ve misstated. |
Uh oh!
There was an error while loading. Please reload this page.
Midnight currently identifies networks using unqualified lowercase strings such as mainnet, preprod, and preview. These values appear in wallet SDKs, indexers, and DApp connector APIs. They are not globally unique: the string mainnet is shared by hundreds of blockchains and cannot be used safely in multi-chain wallet registries, CAIP chain-ID fields in wallet policy/audit surfaces, or cross-chain tooling without additional context.
This MIP proposes adopting CAIP-2 as the external network identification format for Midnight, using the proposed namespace midnight and a reference portion defined in this specification.
MIP-0008: CAIP-2 Network IDs
MPS-0003: CAIP Support
Contributors:
MIP: @alba-press
MPS: @bobblessinghartley
All reactions