Stub: follow live on-chain evonode list for Platform reads #20

Merged
rhelwig merged 2 commits from feat/live-evonode-list into main 2026-10-13 11:02:36 +00:00
Owner

Closes #19.

Fix (discovery order, DNS-free first)

  1. Direct DAPI (primary, no DNS). gRPC-web Core/subscribeToMasternodeList against https://<ip>:<port> evonodes. The first message is the full list (CBOR protx diff). Candidates, in order: the saved last-known list, then the SDK's built-in seed IPs (evonode-bootstrap.ts, generated from wasm-sdk), then DECENT_SITE_DASH_DISCOVERY_SEEDS. Up to 8 nodes are dialled, and a second node must agree (same block: identical evonode set; nearby block: ≥90% overlap). A lone answer is accepted only when no other node answered, and disagreeing answers are rejected. At least 3 usable evonodes are required.
  2. Last resort: https://quorums.<network>.networks.dash.org/masternodes (needs DNS), only if every direct attempt fails.
  3. Fallbacks: in-memory list, then the saved file next to the Stub cache, then SDK defaults. Never blocks the warm cache.
  • Only valid (non-PoSe-banned) evonodes with a Platform HTTPS port are kept. Refresh is about every 24 h, with a retry within 1 h on failure. The SDK reconnects when the list changes.
  • DECENT_SITE_DASH_DAPI_ADDRESSES pins the list (discovery off). DECENT_SITE_DASH_DISCOVERY=off / DECENT_SITE_DASH_DISCOVERY_DIRECT=off are the opt-outs.
  • Explicit and discovered addresses keep trusted-context proof verification (previously dropped for withAddresses).

Quorum keys (remaining DNS dependency)

Trusted mode still fetches Platform quorum public keys from quorums.<network>.networks.dash.org at connect. Findings:

  • The DAPI mnlistdiff already carries them (newQuorums[].quorumPublicKey, including llmqType 4, the Platform quorums).
  • evo-sdk 4.0.0 accepts a trusted context only via WasmTrustedContext.prefetch*WithUrl (an HTTP quorum service). WasmContext has no public constructor.
  • Taking keys from one evonode without verifying them (merkleRootQuorums in the coinbase plus a chainlock/header check) would let a single node forge proofs. Proofs-off is not acceptable.

Follow-ups (tracked on #19)

  • Obtain Platform quorum keys DNS-free: derive them from the DAPI mnlistdiff with verification (cross-node agreement plus merkleRootQuorums/chainlock checks), then feed the SDK, e.g. through a loopback quorum-service shim for prefetchMainnetWithUrl, or upstream support for a custom context provider in evo-sdk.
  • Optional: verify merkleRootMNList from the coinbase against the received list.

Tests (tsx, Node 20)

  • tests/dapi-masternode-list.test.ts and tests/evonode-discovery.test.ts: 21 pass. They use a real captured mainnet gRPC-web frame, trimmed to 8 KB (5 valid evonodes, 2 PoSe-banned, 3 regular), and cover CBOR/gRPC-web decoding, filtering, cross-check rules, candidate order, fallback, persistence and config.
  • Existing platform-metadata, stub-cache, stub-http and shared-contract tests: 27 pass. tsc --noEmit is clean for dash and stub.

Manual mainnet check

With dns.lookup stubbed to throw and the HTTPS fallback disabled, direct discovery got 355 evonodes from 185.209.230.13, confirmed by 144.91.99.105, in about 2.7 s with zero DNS lookups. The SDK then resolved rhelwig7.dash with proofs over those addresses.

Do not merge until reviewed.

Closes #19. ## Fix (discovery order, DNS-free first) 1. **Direct DAPI (primary, no DNS).** gRPC-web `Core/subscribeToMasternodeList` against `https://<ip>:<port>` evonodes. The first message is the full list (CBOR `protx diff`). Candidates, in order: the saved last-known list, then the SDK's built-in seed IPs (`evonode-bootstrap.ts`, generated from wasm-sdk), then `DECENT_SITE_DASH_DISCOVERY_SEEDS`. Up to 8 nodes are dialled, and a second node must agree (same block: identical evonode set; nearby block: ≥90% overlap). A lone answer is accepted only when no other node answered, and disagreeing answers are rejected. At least 3 usable evonodes are required. 2. **Last resort:** `https://quorums.<network>.networks.dash.org/masternodes` (needs DNS), only if every direct attempt fails. 3. **Fallbacks:** in-memory list, then the saved file next to the Stub cache, then SDK defaults. Never blocks the warm cache. - Only valid (non-PoSe-banned) evonodes with a Platform HTTPS port are kept. Refresh is about every 24 h, with a retry within 1 h on failure. The SDK reconnects when the list changes. - `DECENT_SITE_DASH_DAPI_ADDRESSES` pins the list (discovery off). `DECENT_SITE_DASH_DISCOVERY=off` / `DECENT_SITE_DASH_DISCOVERY_DIRECT=off` are the opt-outs. - Explicit and discovered addresses keep trusted-context proof verification (previously dropped for `withAddresses`). ## Quorum keys (remaining DNS dependency) Trusted mode still fetches Platform quorum public keys from `quorums.<network>.networks.dash.org` at connect. Findings: - The DAPI mnlistdiff already carries them (`newQuorums[].quorumPublicKey`, including llmqType 4, the Platform quorums). - evo-sdk 4.0.0 accepts a trusted context only via `WasmTrustedContext.prefetch*WithUrl` (an HTTP quorum service). `WasmContext` has no public constructor. - Taking keys from one evonode without verifying them (merkleRootQuorums in the coinbase plus a chainlock/header check) would let a single node forge proofs. Proofs-off is not acceptable. ## Follow-ups (tracked on #19) - [ ] Obtain Platform quorum keys DNS-free: derive them from the DAPI mnlistdiff with verification (cross-node agreement plus merkleRootQuorums/chainlock checks), then feed the SDK, e.g. through a loopback quorum-service shim for `prefetchMainnetWithUrl`, or upstream support for a custom context provider in evo-sdk. - [ ] Optional: verify `merkleRootMNList` from the coinbase against the received list. ## Tests (tsx, Node 20) - `tests/dapi-masternode-list.test.ts` and `tests/evonode-discovery.test.ts`: 21 pass. They use a real captured mainnet gRPC-web frame, trimmed to 8 KB (5 valid evonodes, 2 PoSe-banned, 3 regular), and cover CBOR/gRPC-web decoding, filtering, cross-check rules, candidate order, fallback, persistence and config. - Existing platform-metadata, stub-cache, stub-http and shared-contract tests: 27 pass. `tsc --noEmit` is clean for dash and stub. ## Manual mainnet check With `dns.lookup` stubbed to throw and the HTTPS fallback disabled, direct discovery got 355 evonodes from 185.209.230.13, confirmed by 144.91.99.105, in about 2.7 s with zero DNS lookups. The SDK then resolved `rhelwig7.dash` with proofs over those addresses. Do not merge until reviewed.
Fetch the masternode list at startup and daily, keep enabled non-banned
evonodes with a Platform HTTPS port, persist the last good list beside the
Stub cache, and reconnect the SDK when it changes. Pinned
DECENT_SITE_DASH_DAPI_ADDRESSES disable discovery. Explicit and discovered
addresses now keep trusted-context proof verification.
Ask IP-literal evonodes directly for the full list via gRPC-web
Core/subscribeToMasternodeList (CBOR protx diff), seeded from the saved
list, the SDK's built-in seed IPs and DECENT_SITE_DASH_DISCOVERY_SEEDS,
with a second-node cross-check. The quorums.<network> HTTPS service is
now the last resort. Document the remaining DNS dependency for trusted
quorum keys.
Sign in to join this conversation.
No reviewers
No labels
feature request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rhelwig/DecentSite!20
No description provided.