Skip to content

feat: support dashmate regtest as a third network#1

Draft
QuantumExplorer wants to merge 1 commit intomainfrom
feat/local-regtest-support
Draft

feat: support dashmate regtest as a third network#1
QuantumExplorer wants to merge 1 commit intomainfrom
feat/local-regtest-support

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

Summary

Adds a third network — local — alongside testnet/mainnet, so the bridge runs end-to-end against a local dashmate setup local cluster without depending on any public infrastructure (insight, tRPC mirror, public DAPI evonodes).

Activate via the new Local network button or ?network=local.

What works on local

  • Insight UTXO/broadcast — Vite dev proxy forwards /local-insight → dashmate's insight container on 127.0.0.1:23001.
  • InstantSend lock retrieval — switched the DAPI client to call Dash Core's getislocks RPC directly. Same wire shape as the public tRPC mirrors; just filters Core's \"None\" sentinel for txids that don't yet have a lock. Auth is handled by the Vite proxy injecting the basic-auth header from `.env.local` so RPC creds never reach the client bundle.
  • Platform RPCs — `createPlatformSdk('local')` builds a `WasmSdk` directly via `WasmSdkBuilder.local() + WasmTrustedContext.prefetchLocalWithUrl('http://127.0.0.1:22444')\`, then wraps it with `EvoSDK.fromWasm(...)`. The dashmate quorum-list sidecar provides trusted quorum keys + masternode addresses.
  • Funding without a faucet — new Use Local Funds hero button (mirrors the testnet faucet UX) RPC-sendtoaddress 1 DASH from the seed node's wallet.

Refactor

The `EvoSDK.testnetTrusted/mainnetTrusted` ternary was inlined at 6+ sites across `identity.ts`, `dpns.ts`, `contract.ts`, and `main.ts`. Extracted into `src/platform/sdk.ts:createPlatformSdk(network)` so adding a third (and future) networks is a single-file change. `'testnet' | 'mainnet'` widened to `NetworkName` ('testnet' | 'mainnet' | 'local') throughout.

Cert UX heads-up

Each of the three local DAPI gateways (`https://127.0.0.1:{2443,2543,2643}\`) serves its own self-signed cert. The trusted-context sidecar discovers all three and the SDK round-robins between them, so the bridge would otherwise silently fail with `TypeError: Failed to fetch` until each cert is trusted in the browser.

Two mitigations:

  • Orange notice under the network selector with one-click links to each gateway (visit, accept, return).
  • For local: `banFailedAddress=false` and `retries=5` — failed (= cert-rejected) addresses aren't permanently banned, so the SDK fails over to a trusted one. Trusting any one of the three is sufficient.

Reviewer notes

  • Vite proxy with basic-auth injection: `vite.config.ts` uses the proxy's `configure` hook to set `Authorization: Basic ` on every `/local-rpc` request. Creds come from `.env.local` (gitignored) so they're only present at dev-server startup, never bundled.
  • Defaults match dashmate's `local_seed` config (insight 23001, RPC 20302, quorum sidecar 22444). Override via `LOCAL_*` env vars in `.env.local` if your setup differs.
  • Drive image / wasm-sdk version drift: during testing, the published `@dashevo/wasm-sdk@3.1.0-dev.1` (Feb 18) couldn't decode GroveDB proofs from a locally-built drive_abci (May 5) — `UnexpectedVariant { type_name: "GroveDBProof", allowed: 0..0, found: 1 }`. Fix is to publish a fresh `3.1.0-dev.X` from current `platform/` HEAD; in the meantime, `node_modules/@dashevo/{wasm-sdk,evo-sdk}` can be symlinked to `platform/packages/{wasm-sdk,js-evo-sdk}`.
  • Two `as any` casts at `src/platform/identity.ts:204` and `:392` for `IdentityPublicKey`/`IdentityPublicKeyInCreation` constructors — the upstream `PurposeLike`/`SecurityLevelLike`/`KeyTypeLike` types tightened to lowercase strings, but the bridge passes uppercase. Runtime accepts uppercase. Drop the casts when migrating to the new SDK release.
  • Cosmetic: local explorer URL falls through to mainnet's domain in `ui/components.ts` (no platform-explorer for local). Dead link, harmless.

Test plan

  • `npm run dev` then visit `http://localhost:5173/?network=local\` — Local network button highlights, cert notice renders.
  • Click each cert link, accept warnings.
  • Click Use Local Funds — seed node's RPC sendtoaddress fires, deposit detected automatically.
  • Asset-lock construction → broadcast → islock retrieval → identity registration completes against local cluster.
  • Testnet and mainnet flows still work (regression check).

🤖 Generated with Claude Code

Adds 'local' alongside testnet/mainnet so the bridge can target a local
dashmate cluster end-to-end without depending on public infrastructure.

What works on local:
- Insight UTXO/broadcast via Vite proxy to dashmate's insight container
- InstantSend lock retrieval via Dash Core's getislocks RPC (proxied
  through Vite, which injects basic-auth from .env.local so credentials
  never enter the client bundle)
- Platform RPCs via WasmSdkBuilder.local() + WasmTrustedContext from the
  dashmate quorum-list sidecar (port 22444)
- "Use Local Funds" hero button that RPC-sendtoaddress 1 DASH from the
  seed node so devs don't need a faucet

Refactors:
- Extracts createPlatformSdk() into src/platform/sdk.ts and routes every
  EvoSDK consumer (identity, dpns, contract, main) through it instead of
  the inline `network === 'mainnet' ? mainnetTrusted : testnetTrusted`
  ternaries, so adding networks doesn't require touching every call site
- Widens 'testnet' | 'mainnet' to NetworkName everywhere

UX:
- Visible cert-acceptance notice on local pointing at all three
  https://127.0.0.1:{2443,2543,2643} gateways (each has its own
  self-signed cert)
- For local, banFailedAddress=false and retries=5 so trusting any one of
  the three certs is sufficient — the SDK just fails over

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fecb50ed-3a07-49e6-a412-4e9ed7e89499

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/local-regtest-support

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 and usage tips.

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