wallet: typed chain-daemon client for the Cuprate parity gaps #94

Merged
sirius merged 1 commit from wt/t_f1ddee23 into feat/wallet-create-import 2026-09-17 04:35:00 +00:00
Owner

Phase 2a of the Cuprate integration: the three parity-gap workarounds from Spike A, applied to the wallet client's chain side.

What changed

The chain probe was a hand-rolled brace-scanner in src/node.rs. Cuprate breaks three of its assumptions, all measured in the spike (docs/cuprate-launch-spike.md section "Parity gaps", raw bodies in that spike's rpc-evidence/):

  1. A height above the tip is a bare HTTP 500 with an empty body. monerod answers a JSON-RPC error object instead (TOO_BIG_HEIGHT, code -2). src/wallet.rs now parses the HTTP status once, de-chunks chunked bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk) and maps both spellings of the height failure to one typed WalletError::DaemonHeightOutOfRange. get_height and get_block are height-addressed, so their 5xx is the height error; get_info is not, so its 5xx is WalletError::DaemonHttpStatus.

  2. get_info metrics are not measurements. Cuprate reports zero peers while it is downloading blocks, its restricted server answers a placeholder database_size (exactly 5 GiB) and an empty version, and free_space is u64::MAX on both servers. DaemonInfo carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line now comes from block-height movement between two probes: "connected to P2P" requires the height to have moved, a stalled daemon gets "no new blocks", and Cuprate's at-rest synchronized = true with target_height = 0 reads as unknown instead of 1160/0.

  3. get_height is a URI endpoint - the method over /json_rpc is rejected with 422 - so the client uses GET /get_height, which both daemons answer. The wallet-child routing rule is pinned as well: it dials the daemon's unrestricted listener (monerod's --rpc-bind-port, and whatever port an in-process Cuprate binds for its unrestricted RPC), never the restricted one. A restricted listener answers, so a mix-up shows up as a wrong number rather than as an error.

Scope deviations, stated plainly

  • The card names src/wallet.rs plus the TUI bindings. The probe itself lived in src/node.rs; it now delegates to the typed client (net -100 lines there), and the routing constant and its test live in src/wallet_child.rs. Tests are in tests/wallet.rs, tests/tui_spec.rs and src/wallet_child.rs's test module.
  • daemon_get_block() is not called by anything yet: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it must survive is item 1, so the mapping lives with the client.
  • The card gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 is the restricted port, and the app's local source already dials the unrestricted 18081. What is pinned is the rule, not those numbers.
  • docs/cuprate-launch-spike.md merged to main after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here.
  • Based on feat/wallet-create-import (the unmerged wallet line): the daemon client has no home on main. Retarget to main when that line lands.

Proof

  • cargo test --locked: 306 passed, 0 failed (16 of them new: 11 in tests/wallet.rs, 4 in tests/tui_spec.rs, 1 in src/wallet_child.rs).
  • cargo clippy --locked --all-targets -- -D warnings: clean.
  • rustfmt --edition 2024 --check: no new hunk on any touched file; the inherited hunks in src/node.rs, src/tui.rs and tests/tui_spec.rs keep their count and region.
Phase 2a of the Cuprate integration: the three parity-gap workarounds from Spike A, applied to the wallet client's chain side. ## What changed The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate breaks three of its assumptions, all measured in the spike (`docs/cuprate-launch-spike.md` section "Parity gaps", raw bodies in that spike's `rpc-evidence/`): 1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). `src/wallet.rs` now parses the HTTP status once, de-chunks chunked bodies (axum/hyper; the old brace-scan is not a parse once a blob spans more than one chunk) and maps both spellings of the height failure to one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block` are height-addressed, so their 5xx is the height error; `get_info` is not, so its 5xx is `WalletError::DaemonHttpStatus`. 2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while it is downloading blocks, its restricted server answers a placeholder `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so there is no field for a placeholder to reach the UI. The wallet screen's sync line now comes from block-height movement between two probes: "connected to P2P" requires the height to have moved, a stalled daemon gets "no new blocks", and Cuprate's at-rest `synchronized = true` with `target_height = 0` reads as unknown instead of `1160/0`. 3. **`get_height` is a URI endpoint** - the method over `/json_rpc` is rejected with 422 - so the client uses `GET /get_height`, which both daemons answer. The wallet-child routing rule is pinned as well: it dials the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and whatever port an in-process Cuprate binds for its unrestricted RPC), never the restricted one. A restricted listener answers, so a mix-up shows up as a wrong number rather than as an error. ## Scope deviations, stated plainly - The card names `src/wallet.rs` plus the TUI bindings. The probe itself lived in `src/node.rs`; it now delegates to the typed client (net -100 lines there), and the routing constant and its test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`, `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module. - `daemon_get_block()` is **not called by anything yet**: it is the entry point the wallet's own block scan (Phase 2) needs, and the out-of-range answer it must survive is item 1, so the mapping lives with the client. - The card gives the unrestricted port as 18089 and the restricted one as 28089. In monerod's numbering 18089 *is* the restricted port, and the app's local source already dials the unrestricted 18081. What is pinned is the rule, not those numbers. - `docs/cuprate-launch-spike.md` merged to `main` after this branch's base commit, so it is not in this tree and its Recommendation bullets are not updated here. - **Based on `feat/wallet-create-import`** (the unmerged wallet line): the daemon client has no home on `main`. Retarget to `main` when that line lands. ## Proof - `cargo test --locked`: 306 passed, 0 failed (16 of them new: 11 in `tests/wallet.rs`, 4 in `tests/tui_spec.rs`, 1 in `src/wallet_child.rs`). - `cargo clippy --locked --all-targets -- -D warnings`: clean. - `rustfmt --edition 2024 --check`: no new hunk on any touched file; the inherited hunks in `src/node.rs`, `src/tui.rs` and `tests/tui_spec.rs` keep their count and region.
wallet: typed chain-daemon client for the Cuprate parity gaps
All checks were successful
ci / test (pull_request) Successful in 4m27s
ci / sdk (pull_request) Successful in 1m15s
4e19b35de2
The chain probe was a hand-rolled brace-scanner in `src/node.rs`. Cuprate
breaks three of its assumptions, all measured in Spike A
(`docs/cuprate-launch-spike.md` §Parity gaps, evidence in that spike's
`rpc-evidence/`):

1. **A height above the tip is a bare HTTP 500 with an empty body.** monerod
   answers a JSON-RPC error object instead (`TOO_BIG_HEIGHT`, code -2). The
   client now parses the HTTP status once, de-chunks `Transfer-Encoding:
   chunked` bodies (axum/hyper; the old brace-scan is not a parse once a blob
   spans more than one chunk), and maps both spellings of the height failure to
   one typed `WalletError::DaemonHeightOutOfRange`. `get_height` and `get_block`
   are height-addressed: their 5xx is the height error. `get_info` is not: its
   5xx is `WalletError::DaemonHttpStatus`.

2. **`get_info` metrics are not measurements.** Cuprate reports zero peers while
   it downloads blocks, its restricted server answers a placeholder
   `database_size` (exactly 5 GiB) and an empty `version`, and `free_space` is
   `u64::MAX` on both servers. `DaemonInfo` carries height and target only, so
   there is no field for a placeholder to reach the UI. The wallet screen's sync
   line is now built from block-height movement between two probes: "connected
   to P2P" needs the height to have moved, "no new blocks" is what a stalled
   daemon gets, and Cuprate's at-rest `synchronized = true` with
   `target_height = 0` reads as unknown instead of `1160/0`.

3. **`get_height` is a URI endpoint**: `{"method":"get_height"}` over
   `/json_rpc` is rejected with 422, so the client uses `GET /get_height`, which
   both daemons answer. The wallet-child routing rule is pinned too: it dials
   the daemon's *unrestricted* listener (monerod's `--rpc-bind-port`, and
   whatever port an in-process Cuprate binds for `[rpc.unrestricted]`), never the
   restricted one — a restricted listener answers, so a mix-up shows up as a
   wrong number rather than as an error.

Scope deviations, stated plainly:

- the card names `src/wallet.rs` + the TUI bindings. The probe itself lived in
  `src/node.rs`; it now delegates (net -100 lines there), and the routing
  constant/test live in `src/wallet_child.rs`. Tests are in `tests/wallet.rs`,
  `tests/tui_spec.rs` and `src/wallet_child.rs`'s test module.
- `daemon_get_block()` is **not called by anything yet**: it is the entry point
  the wallet's own block scan (Phase 2) needs, and the out-of-range answer it has
  to survive is item 1, so the mapping lives with the client.
- the card's item 3 gives the unrestricted port as 18089 and the restricted one
  as 28089. In monerod's numbering 18089 *is* the restricted port; the app's
  local source already dials the unrestricted 18081. The rule is what is pinned,
  not those numbers.
- `docs/cuprate-launch-spike.md` merged to `main` after this branch's base
  commit, so it is not in this tree and its Recommendation bullets are not
  updated here.
- based on `feat/wallet-create-import` (the wallet line, unmerged): the daemon
  client has no home on `main`. Retarget to `main` when that line lands.

Proof: `cargo test --locked` 306 passed / 0 failed, `cargo clippy --locked
--all-targets -- -D warnings` clean, `rustfmt --edition 2024 --check` adds no
hunk to any file (the inherited hunks in `src/node.rs`/`src/tui.rs`/
`tests/tui_spec.rs` are unchanged in count or region).
sirius force-pushed wt/t_f1ddee23 from 4e19b35de2
All checks were successful
ci / test (pull_request) Successful in 4m27s
ci / sdk (pull_request) Successful in 1m15s
to e6b5024ad3
Some checks failed
ci / test (pull_request) Failing after 1m30s
ci / sdk (pull_request) Successful in 1m16s
2026-09-17 04:34:17 +00:00
Compare
sirius merged commit ba485ae7b5 into feat/wallet-create-import 2026-09-17 04:35:00 +00:00
Sign in to join this conversation.
No reviewers
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
sirius/onionwire!94
No description provided.