Skip to content

feat(networks): per-network services, teratest fixes, scaletest wiring (draft) - #36

Draft
galt-tr wants to merge 1 commit into
masterfrom
feat/scaletest-network
Draft

galt-tr wants to merge 1 commit into
masterfrom
feat/scaletest-network

Conversation

@galt-tr

@galt-tr galt-tr commented Oct 8, 2026

Copy link
Copy Markdown

Draft. This shows where teratestnet and scaling teratestnet (scaletest) support stands. Teratest works end to end. Scaletest is fully wired but hidden from the network picker until the wallet library ships the regtest chain (bsv-blockchain/ts-stack#819, in flight).

Why

Every network now has its own go-messagebox server (bsva-infra-flux PR #395): messagebox, messagebox-testnet, messagebox-ttn and messagebox-tstn .bsvblockchain.tech. The wallet sent every network to mainnet's box and mainnet's overlay. Reviewing teratest support turned up several more gaps, and adding a fourth network meant replacing the per-network ternaries that sent any unnamed network to teratest's endpoints.

What changed

One per-network table: core/networks.ts holds NETWORKS. Every former ternary reads it, and Record<AppChain, …> makes a missing network a type error. Each network records its Arcade, MessageBox, WhatsOnChain/explorer, TAAL/GorillaPool/Bitails fallbacks, overlay preset, push support and availability.

Teratest fixes (live now):

  • Home screen showed the previous network's wallet: storage records the toolbox chain ('ttn'), but storageMatchesNetwork expected 'test', so a teratest wallet always looked like the previous network's.
  • Per-network MessageBox: each network defaults to its own server. A saved preference equal to any network's default (or the retired one) follows the open network; a server the user chose is kept. Settings resolve and save the same way the payment code does.
  • Overlay routing: bindMessageBoxNetwork points every MessageBox/PeerPay client at the open network's overlay. PeerPayClient 2.5.3 never passes networkPreset through, so every network was asking mainnet's overlay. On a network with no overlay, the client routes to its configured host.
  • Identity lookups use the open network's overlay (teratest had been using testnet's).
  • Push registers only for profiles on a network whose MessageBox sends push (mainnet's). Each profile's host follows that profile's own network.
  • Fallbacks: teratest no longer gets Bitails or a TAAL key (the TAAL key had been aliased to the WhatsOnChain key in app/_layout.tsx). ARC presets in Settings are per network.
  • Verified on a device build.

Scaletest (wired, not available):

  • App id scaletest, label "Scaling Teratest", with its own database file (*-scaletestnet-*.db) and backup account. Arcade is arcade-tstn-us-1, MessageBox is messagebox-tstn, and hosts can override either via EXPO_PUBLIC_SCALETEST_*.
  • Toolbox chain is 'regtest', not 'tstn'. The deployed scale cluster runs Teranode regtest parameters: regtest genesis 0f9188f1…, bits 0x207fffff, and its ChainTracks reports regtest. The toolbox's tstn is go-chaincfg's real-proof-of-work TeraScalingTestNetParams, so the toolbox is right and the wallet maps to regtest. feat(wallet-toolbox): add regtest chain with its proof-of-work limit ts-stack#819 adds that chain, with regtest's proof-of-work limit applied only when the chain is named regtest.
  • Header window is anchored at the regtest genesis, which every chain reset keeps.
  • No WhatsOnChain, explorer or overlay: the address rail, sweep, BEEF repair, spendability check and explorer links are off. Pay shows the address option as unavailable. Identity search finds nothing.
  • NETWORKS.scaletest.available = false keeps it out of the picker.

Bridging until ts-stack#819 is released

@bsv/wallet-toolbox-mobile is still 2.14.x, which has no regtest chain. Two typed casts, both documented to be removed when the dependency is bumped:

  • toWalletChain returns the toolbox's Chain, with one cast for 'regtest'.
  • headerStore passes the chain to validateHeaderProofOfWork. 2.14.x ignores the extra argument, and 2.15.0 uses it to pick the proof-of-work limit.

A canary test (networks.test.ts: "cannot build its services on the installed toolbox yet") fails as soon as the dependency supports regtest. That is the cue to:

  1. bump @bsv/wallet-toolbox-mobile to ≥ 2.15.0;
  2. set NETWORKS.scaletest.available = true;
  3. drop the two casts and turn the canary into a test that builds the scaletest services.

Remaining before merge

  • feat(wallet-toolbox): add regtest chain with its proof-of-work limit ts-stack#819 merged and published (its CI is currently blocked on a repo-wide pnpm audit failure: new proxy-addr and source-map-js advisories, unrelated to it).
  • Bump the toolbox dependency, enable scaletest, remove the bridge (see above).
  • Device check on scaletest: fund from faucet-tstn, send and receive between two profiles over messagebox-tstn, mine a block, and confirm the proof arrives through Arcade SSE.
  • Native-speaker review of the new pay_address_unavailable_network string (11 locales were machine-written).

Upgrade notes

  • Old MessageBox messages: testnet and teratest profiles on the default server move to their own network's box. Messages still unread for them on mainnet's box are no longer read; queued outbox retries keep the host recorded per entry. Their existing push registrations on mainnet's box are left in place, not withdrawn.
  • Breaking toolbox API changes, listed in packages/expo-wallet-toolbox/CHANGELOG.md under Unreleased: makePeerPayClient, useMessageBoxConfig, useOfflineNoticeActions, wocConfigFor, createWocBroadcastService, KNOWN_ARC_URLS, and the AppChain / WalletChain unions.

Verification

  • npx tsc --noEmit: clean.
  • npx jest: 6053 passed, 3 failed. All three are in __tests__/mandala/createRuntime.test.ts, which also fails on master.
  • Lint on changed files: no new errors or warnings compared with master.
  • New tests: networks.test.ts, pay/messageBoxNetwork.test.ts (resolution, host override, binding pinned to MessageBoxClient's routing fields, the no-overlay fallback), the rewritten net/chainMatch.test.ts, and per-network cases in the service-config, broadcast, address, database-registry, translation and MessageBox settings tests.

One per-network table (core/networks.ts) replaces the ternaries that sent
any unnamed network to teratest's endpoints.

Teratest fixes:
- storageMatchesNetwork compared teratest storage ('ttn') with 'test', so
  the home screen always treated a teratest wallet as the previous
  network's.
- Each network uses its own MessageBox server (messagebox-testnet, -ttn,
  -tstn). MessageBox and PeerPay clients look recipients up in the open
  network's overlay; PeerPayClient never passed networkPreset through.
- Identity lookups use the open network's overlay.
- Push registration only for profiles on a network whose MessageBox
  sends push.
- No Bitails or TAAL key on teratest; ARC presets are per network.

Scaling teratestnet (scaletest) is wired but not available. The deployed
chain runs Teranode regtest parameters, so it maps to the toolbox chain
'regtest', which lands in @bsv/wallet-toolbox 2.15.0
(bsv-blockchain/ts-stack#819). Until the dependency is bumped,
toWalletChain and the header store bridge the type, and a canary test
fails once the toolbox supports regtest. With no WhatsOnChain, the address
rail, sweep, BEEF repair and explorer links are off there.
* override" rather than crash.
*/
export function getMessageBoxUrlOverride(chain: AppChain): string | undefined {
const url = current?.services[chain]?.messageBoxUrl?.trim().replace(/\/+$/, '') ?? ''

This branch has not been deployed

No deployments
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.

2 participants