Skip to content

fix(testnet): discover evonodes with the published dapi-client instead of a stale built-in list - #55

Merged
PastaPastaPasta merged 4 commits into
mainfrom
feat/dapi-discovery-5.0.2
Nov 2, 2026
Merged

PastaPastaPasta merged 4 commits into
mainfrom
feat/dapi-discovery-5.0.2

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why

Testnet gets its InstantSend lock from DAPI streams on evonodes (#53), but the bridge can't use @dashevo/dapi-client's own node discovery. It is pinned to 3.1.0-dev.7, whose nested dashcore-lib 0.22 can't parse V24 masternode list diffs (CbTx v4). The node list therefore comes from the quorum service, with a hard-coded snapshot of 20 evonode IPs as fallback. Evonodes and their certificates rotate within days, so that snapshot goes stale.

Published @dashevo/dapi-client 5.0.2 (dash-spv 6.0.2, dashcore-lib 0.26.1) parses V24 again. Simply dropping TESTNET.dapiAddresses isn't enough, though, for three reasons:

  • It falls through to the single-client path and loses the 3-stream resilience from fix(testnet): get InstantSend locks from the DAPI stream instead of trpc.digitalcash.dev #53.
  • 5.0.2's default testnet discovery filters the live list through a snapshot whitelist of 41 addresses bundled in the library: another stale list.
  • Its long-lived masternode-list stream is unsafe in browsers. grpc-web reports a stream error through end, so the provider drops its stream without settling the pending read. Meanwhile ReconnectableStream keeps reconnecting forever with nobody listening. One of the six bundled testnet seeds (seed-1.pshenmic.dev) doesn't resolve, so this would be hit often.

What changed

  • Dependencies. @dashevo/dapi-client 5.0.2 and @dashevo/dashcore-lib 0.26.1 (exact). The tree now has a single dashcore-lib (0.26.1); the old nested parser is gone.
  • Discovery (src/api/evonode-discovery.ts):
    • Source. A one-shot read of the simplified masternode list from dapi-client's testnet seeds: subscribeToMasternodeList with retries 0. It starts on one seed and adds the next when a seed fails or stays silent for 3 s. The first full list is parsed with dashcore-lib, and every stream and client is closed afterwards. The read has a 10 s deadline and can be aborted.
    • Filtering. Every valid evonode in the list is considered, so the library's whitelist is not applied. Endpoints come from getPlatformHTTPSEndpoint(), which also handles extended-address evonodes.
    • Health hint. The quorum service's health-checked list is read alongside. When at least 3 nodes are in both lists, only those are used. If no seed serves the list, the quorum list is the fallback.
    • Caching. Results are kept for 10 minutes and then read again. A refresh that finds nothing keeps the previous list. If no list was ever found, the subscription rejects before broadcast.
  • IS lock subscription. Testnet runs the existing multi-node path on the discovered nodes: 3 distinct streams, the bounded height race, replacements, the readiness cap and cleanup. Discovery runs inside the same abortable section before broadcast. The lock-status diagnostic uses a client over the discovered nodes.
  • When discovery runs. It is warmed in the funding gate next to the SDK connect, so it finishes before the key-backup download (fix(bridge): stop the key backup download from breaking the SDK load on iPhone #54 ordering) and is re-warmed with it. Idle visitors start no discovery. TESTNET.dapiAddresses is removed.
  • Unchanged. Devnets keep their configured addresses. Mainnet keeps JSON-RPC and its config.
  • Devnet status. dapi-client 5 returns null for status sections a node omits, where 3.x threw. A devnet status without a chain section still counts as a failed read, not a healthy one.

Testing

  • Checks: tsc, vitest (792), the build with its artifact check, and deterministic Playwright all pass. One username-transfer e2e test flakes under local parallel load; it also flakes on main and passes 5/5 alone.
  • Browser harness (production Vite config, headless Chromium and WebKit, main thread and Web Worker):
    • Discovery: 1.6–4.3 s, 41 evonodes, 3 distinct streams, ready in about 1.1 s. Disconnect leaves no open requests.
    • Seeds blocked: the quorum fallback is used.
    • Seeds and quorum blocked: the subscription rejects before any stream opens.
    • Dead seed: seed-1.pshenmic.dev is skipped.
    • Blackholed nodes: with 31 of the 41 nodes blackholed, picks that include a live node still work. When all three picks are dead, the subscription fails at 8 s before broadcast, as on main.
  • Funded testnet runs (faucet tDASH) on the production build:
    • Creates: three completed, in Chromium and WebKit, with the IS lock over the stream in 1.5–3.5 s. Two of them dropped the first EvoSDK chunk download on purpose, and fix(bridge): stop the key backup download from breaking the SDK load on iPhone #54's ?retry= reload recovered it; the SDK and discovery both finished before the key-backup download.
    • Top-up: one completed, in WebKit.
    • ChainLock fallback: with every IS lock stream blackholed, the flow timed out, offered the fallback and registered with a chain-lock proof.
    • Failure: one create failed at registration with the EvoSDK's own transport error (UNIMPLEMENTED from a node). That path is outside this change, and the run before it and the one after it passed.
    • No run made a digitalcash.dev request.
  • Mainnet: mainnet looks the same as production. Separately, rpc.digitalcash.dev currently resets connections (production shows "Chain-lock RPC unreachable" too). In Node, dapi-client mainnet getStatus (the ChainLock fallback's last resort) now succeeds where 3.1.0-dev.7 threw getTotalSyncedTime.

Not verified / follow-ups

  • Real iPhones (WebKit headless only), and Firefox.
  • Bundle size. The lazy IS-lock chunk grows by about 1.2 MB gzipped (4.63 → 5.82 MB), almost all from wasm-dpp 5.0.2, which dapi-client requires. Idle visitors download that chunk during warm-up.
  • Mainnet. The mainnet dapi-client fallback still uses the library's long-lived masternode-list stream, a pre-existing issue left out of scope here.
  • Stalled height requests. getBestBlockHeight requests to blackholed nodes stay open after the 8 s race deadline (pre-existing).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Testnet connections now discover evonodes dynamically from the network’s masternode list, with the quorum-service list available as a fallback.
    • Discovery starts when a funding flow begins, rather than on page load, helping keep idle visits free of discovery requests.
  • Bug Fixes
    • Funding subscriptions stop before broadcast if no usable evonodes can be found, instead of proceeding without a valid node list.

PastaPastaPasta and others added 3 commits November 2, 2026 12:00
Testnet IS lock streams ran on a list from the quorum service, falling
back to a hard-coded snapshot of 20 evonodes, because dapi-client
3.1.0-dev.7's nested dashcore-lib 0.22 could not parse V24 masternode
list diffs (CbTx v4).

- Upgrade @dashevo/dapi-client to 5.0.2 and @dashevo/dashcore-lib to
  0.26.1 (the version dash-spv 6.0.2 uses), leaving one dashcore-lib in
  the tree.
- EvonodeDiscovery reads the valid evonodes from the client's synced
  simplified masternode list on every subscription. It skips the
  address provider, which on testnet filters by a snapshot bundled with
  the library. It replaces the client when dapi-client drops the list
  stream (which it never resyncs) or a sync misses its 10 s deadline,
  and falls back to the quorum service list. If both fail, the
  subscription rejects before broadcast.
- The multi-node path (3 distinct streams, bounded height race,
  replacements, readiness cap, cleanup) now runs on the discovered
  nodes. Devnets keep their configured addresses; mainnet keeps
  JSON-RPC.
- Discovery is warmed in the funding gate alongside the SDK connect,
  before the key backup download; idle visitors start none.
- Drop TESTNET.dapiAddresses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…streaming it

Review found that dapi-client's long-lived masternode list stream is
unsafe in browsers: grpc-web reports a stream error through 'end', so
the provider nulls its stream without settling the pending read, while
ReconnectableStream keeps reconnecting (maxRetriesOnError -1) with no
listener. A dead seed (seed-1.pshenmic.dev doesn't resolve) or an iOS
download prompt would hang every read for the full deadline and leak a
stream for the life of the page.

- fetchEvonodesFromSeeds opens subscribeToMasternodeList (retries 0) on
  one seed from dapi-client's testnet config, adds the next seed on
  failure or after 3 s of silence, parses the first (full) list with
  dashcore-lib, and cancels every stream and client. 10 s deadline,
  abortable.
- EvonodeDiscovery keeps the list for 10 minutes, then reads it again;
  concurrent readers share one read; disconnect() aborts it.
- Endpoints come from SimplifiedMNListEntry.getPlatformHTTPSEndpoint(),
  so evonodes registered with extended addresses are dialled on their
  platform_https host.
- The shared client (lock-status diagnostic) now covers the discovered
  nodes instead of dapi-client's whitelist-filtered seed provider.
- dapi-client 5 returns null for missing status sections where 3.x
  threw; a devnet status without a chain section still counts as a
  failed read, not a healthy one.
- Simplifier cleanups: docs, unused export, redundant guard, stale test
  options; the e2e idle check also covers seed-1.pshenmic.dev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n failure

Second review round on the discovery rewrite.

- The masternode list says a node is registered and not PoSe-banned,
  not that its DAPI answers browsers. The quorum service's health-checked
  list is now read alongside it: when at least 3 nodes are in both, only
  those are used (the old primary source was health-filtered too). The
  quorum list is still the fallback when no seed serves the list.
- Every result is kept for 10 minutes, including the fallback, so a dead
  seed set doesn't cost each subscription the full deadline. A refresh
  that finds nothing keeps the previous list instead of failing.
- A throw in the stream-opened callback now fails the seed instead of
  escaping as an unhandled rejection; a read aborted by disconnect() can
  no longer clear a newer pending read.
- Simplifier cleanups: one release() path for streams and clients, one
  pending-read field, createClient shared with the class, no unused
  exports or types.
- Tests: late stream after settle, no hedge after success, pre-aborted
  signal, empty seeds, end without data, health narrowing, stale-list
  reuse; "opens nothing" checks now count every non-seed client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d71a312-f94a-4ccd-ae77-53e34b08af15
Commits

Reviewing files that changed from the base of the PR and between 5fff91d and aca9fa3.

Files selected for processing: 6
  • src/api/dapi-subscription-multi.test.ts
  • src/api/dapi-subscription.ts
  • src/api/evonode-discovery.test.ts
  • src/api/evonode-discovery.ts
  • src/api/evonodes.test.ts
  • src/api/evonodes.ts
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8ec55ee8-91ba-4148-81b2-2e6e089987c6
Commits

Reviewing files that changed from the base of the PR and between 05baedb and 5fff91d.

Files ignored due to path filters: 1
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing: 18
  • CLAUDE.md
  • e2e/deterministic.spec.ts
  • package.json
  • src/api/dapi-subscription-multi.test.ts
  • src/api/dapi-subscription.ts
  • src/api/dapi.ts
  • src/api/evonode-discovery-sml.test.ts
  • src/api/evonode-discovery.test.ts
  • src/api/evonode-discovery.ts
  • src/api/evonodes.test.ts
  • src/api/evonodes.ts
  • src/api/islock.test.ts
  • src/api/islock.ts
  • src/api/platform-status-routing.test.ts
  • src/config.ts
  • src/main.ts
  • src/types/external.d.ts
  • vite.config.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Testnet evonodes are now discovered from DAPI-client masternode lists, with quorum-service endpoints used as fallback. Discovery is connected to DAPI subscriptions and funding initialization. The static testnet address list and its resolver functions are removed.

Changes: Testnet evonode discovery

Layer / File(s) Summary
Discovery sources and endpoint selection
src/api/evonode-discovery.ts, src/api/evonode-discovery.test.ts, src/api/evonode-discovery-sml.test.ts, src/api/evonodes.ts, src/api/evonodes.test.ts, src/config.ts, src/types/external.d.ts, vite.config.ts, package.json
The discovery code extracts usable endpoints from seed-served masternode lists and checks quorum-service health. It caches results and uses healthy endpoints as fallback when the seed list is unavailable. Testnet no longer sets static dapiAddresses; dependency and build configuration changes support the discovery implementation.
Discovery-backed DAPI subscriptions
src/api/dapi-subscription.ts, src/api/dapi-subscription-multi.test.ts, src/api/dapi.ts, src/api/platform-status-routing.test.ts
The subscription client uses discovered testnet endpoints for node selection, height probing, and subscriptions. Tests cover endpoint selection, fallback, stream replacement, cancellation, warm-up, and configured devnet addresses.
Funding initialization and discovery warm-up
src/main.ts, src/api/islock.ts, src/api/islock.test.ts, e2e/deterministic.spec.ts, CLAUDE.md
Funding initialization warms evonode discovery alongside the Platform SDK. The IS-lock service exposes a discovery warm-up method. Documentation describes discovery when a funding flow starts, and the idle-page E2E test checks that discovery requests do not occur on page load.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant DAPISubscriptionClient
  participant EvonodeDiscovery
  participant DapiClient
  participant QuorumService
  DAPISubscriptionClient->>EvonodeDiscovery: getNodes()
  EvonodeDiscovery->>DapiClient: Read masternode list from seeds
  EvonodeDiscovery->>QuorumService: Fetch healthy endpoints
  EvonodeDiscovery-->>DAPISubscriptionClient: Return selected endpoints
  DAPISubscriptionClient->>DapiClient: Probe and subscribe to discovered nodes
Loading

Possibly related PRs

  • dashpay/dash-bridge#53: Adds the static testnet address list and resolver functions that this pull request removes, and adds multi-node subscription logic that this pull request updates.
Merge Risk: Moderate · previous review 5fff9

Testnet funding can fail before broadcast even when other discovered nodes are available. Improve seed and height-probe retries before merging; health filtering also misses extended-address nodes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: testnet evonode discovery now uses the published @dashevo/dapi-client instead of a stale built-in node list. The raw summary confirms this: TESTNET.dapiAddresses is re…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: testnet evonode discovery now uses the published @dashevo/dapi-client instead of a stale built-in node list. The raw summary confirms this: TESTNET.dapiAddresses is removed, discovery runs from the masternode list with the quorum-service list as fallback, and dapi-client moves from 3.1.0-dev.7 to 5.0.2. The title is specific and does not use vague terms. It does not mention the caching, hedging, or health-check details, which is expected for a short title.

Full details: Docstring Coverage

Explanation

Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 16 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread src/api/dapi-subscription.ts Resolved
Comment thread src/api/evonode-discovery.ts Resolved
Comment thread src/api/evonode-discovery.ts Resolved
…lists

Review follow-ups on #55.

- When no node in the first batch of 3 answers the block-height probe,
  the next batch is asked, up to the stream budget of 9 nodes, before
  failing (still before broadcast). The streams then start from the
  batch that answered. With 31 of 41 testnet evonodes blackholed in a
  browser, 3 of 3 subscriptions now succeed (2 of 3 failed at 8 s).
- A seed whose masternode list has no valid evonodes counts as a failed
  seed, so the next seed is asked.
- The quorum service's health list is built from each node's
  platform_https endpoint (falling back to the Core host), so it matches
  the masternode list for evonodes registered with extended addresses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PastaPastaPasta
PastaPastaPasta merged commit 4e7eedc into main Nov 2, 2026
4 checks passed
PastaPastaPasta added a commit that referenced this pull request Nov 2, 2026
…ev onto DAPI (#56)

* fix(mainnet): get IS locks and chain-lock heights from DAPI, drop digitalcash.dev

Mainnet still depended on rpc.digitalcash.dev for InstantSend locks and
chain-lock heights. It now resets connections, so production mainnet
showed "Chain-lock RPC unreachable" and could not get a lock.

- Mainnet uses the testnet path from #55: evonodes discovered from the
  masternode list on dapi-client's mainnet seeds (health-checked by
  quorums.mainnet), 3 concurrent DAPI streams, Platform status and the
  ChainLock fallback's height through the EvoSDK, which a funding flow
  now connects on mainnet too. The mainnet list is ~1.2 MB, so mainnet
  waits 8 s before asking a second seed and 25 s before giving up.
- No built-in JSON-RPC service anywhere: MAINNET.rpcUrl and the default
  mainnet endpoint are gone. JSON-RPC remains only for a custom devnet
  that configures its own rpcUrl.
- The build check fails if "digitalcash" appears in any built file; an
  e2e test checks an idle mainnet page contacts neither digitalcash.dev
  nor the seeds.
- The faucet button no longer sends `amount` (the faucet only takes one
  with an API key, which broke the button).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dapi): never broadcast before a stream has delivered data; retry before broadcast

Review follow-ups for mainnet on DAPI, where these now guard real funds.

- Readiness means a stream delivered data: subscribe waits up to 15 s for
  the first message (streams replay the last 10 blocks first, so a live
  one answers in about a second) and otherwise rejects before broadcast.
  The old 3 s cap could broadcast with no stream known to be listening
  and miss a fast IS lock.
- A subscription that fails before broadcast is retried twice (after 5 s
  and 15 s; disconnect stops the wait). The final error says nothing was
  broadcast and the deposit is unspent and recoverable from the key backup.
- A list past its 10-minute age is served while it is read again (up to
  an hour), so a subscription after a long deposit wait doesn't wait up
  to 25 s for a full mainnet list before broadcasting.
- Quorum records without platform_https use their platformHTTPPort (443
  on mainnet) instead of 1443.
- Tests: mainnet health hint uses the mainnet quorum service, mainnet
  list timing, readiness timeout, retry/abort, stale-while-revalidate;
  the mainnet idle e2e also forbids SDK and /masternodes requests.
  Stale testnet-only and JSON-RPC comments fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: case-insensitive digitalcash guard; mainnet lists are parsed as mainnet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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