Repository navigation
fix(testnet): discover evonodes with the published dapi-client instead of a stale built-in list - #55
Conversation
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>
|
Warning Review limit reachedYou'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. View limit details
|
| 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
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: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title names the main change: testnet evonode discovery now uses the published
@dashevo/dapi-clientinstead 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.
…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>
…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>
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-client5.0.2 (dash-spv 6.0.2, dashcore-lib 0.26.1) parses V24 again. Simply droppingTESTNET.dapiAddressesisn't enough, though, for three reasons:end, so the provider drops its stream without settling the pending read. MeanwhileReconnectableStreamkeeps 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
@dashevo/dapi-client5.0.2 and@dashevo/dashcore-lib0.26.1 (exact). The tree now has a single dashcore-lib (0.26.1); the old nested parser is gone.src/api/evonode-discovery.ts):subscribeToMasternodeListwith 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.getPlatformHTTPSEndpoint(), which also handles extended-address evonodes.TESTNET.dapiAddressesis removed.nullfor 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
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 onmainand passes 5/5 alone.seed-1.pshenmic.devis skipped.main.?retry=reload recovered it; the SDK and discovery both finished before the key-backup download.UNIMPLEMENTEDfrom a node). That path is outside this change, and the run before it and the one after it passed.digitalcash.devrequest.rpc.digitalcash.devcurrently resets connections (production shows "Chain-lock RPC unreachable" too). In Node, dapi-client mainnetgetStatus(the ChainLock fallback's last resort) now succeeds where 3.1.0-dev.7 threwgetTotalSyncedTime.Not verified / follow-ups
wasm-dpp5.0.2, which dapi-client requires. Idle visitors download that chunk during warm-up.getBestBlockHeightrequests to blackholed nodes stay open after the 8 s race deadline (pre-existing).🤖 Generated with Claude Code
Summary by CodeRabbit