Skip to content

feat(rpc): enable get_blocks_by_height + get_output_indexes (S03-1)#6

Open
orrinfrazier wants to merge 1 commit into
mainfrom
fix/s03-1-wallet-rpc
Open

feat(rpc): enable get_blocks_by_height + get_output_indexes (S03-1)#6
orrinfrazier wants to merge 1 commit into
mainfrom
fix/s03-1-wallet-rpc

Conversation

@orrinfrazier
Copy link
Copy Markdown
Owner

@orrinfrazier orrinfrazier commented May 24, 2026

Closes #16

Summary

Enables two wallet-critical binary RPC methods (S03-1) by flipping their map_request dispatch arms from not_available() to the real handlers. Scoped down from the 5 methods originally listed in S03-1 to the 2 that are actually panic-safe — see "Why only two" below.

  • GetBlocksByHeightget_blocks_by_height — block sync by height
  • GetOutputIndexesget_output_indexes — global output indices, required for ring/decoy selection when building a spend

Why only two (the important part)

S03-1's premise was "the handler bodies already exist, so the only change is the dispatch arm." That's true for the handlers, but not for the services they call. Tracing each handler down into the storage/context read layer shows three of the five depend on todo!() stubs — flipping their arms would convert a graceful not_available() into a runtime panic:

Method Backing read Status
get_blocks_by_height BlockCompleteEntriesByHeight (storage/blockchain/.../read.rs) ✅ implemented (reads tapes)
get_output_indexes TxOutputIndexes (storage/blockchain/.../read.rs) ✅ implemented (reads tx_ids/tx_infos)
get_transactions blockchain Transactions read todo!()
is_key_image_spent txpool key_images_spent_vec todo!()
get_fee_estimate context FeeEstimate todo!("finish #297")

Only the two implemented-backend arms are enabled here. The other three should be enabled in follow-ups once their backing reads land (get_fee_estimate is gated on Cuprate#297).

Changes

  • binaries/cuprated/src/rpc/handlers/bin.rs: 2 dispatch arms (+2 / -2).

Notes for a future follow-up

  • is_key_image_spent's handler body has a latent response-construction bug independent of the stub: after the blockchain pass fills spent_status (one entry per input), the txpool pass pushes results for the unspent subset instead of updating those positions in place, so the response length becomes N+M and pool-spends land at the wrong index. Fix when the txpool backend is implemented: collect the unspent indices, query that subset, and write spent_status[i] = SpentInPool back in place.

Testing

  • cargo clippy -p cuprated --all-targets -- -D warnings — clean
  • cargo fmt -p cuprated -- --check — clean
  • No unit tests: CupratedRpcHandler can't be constructed without a full node launch, so there is no RPC unit-test harness in the repo (consistent with how the already-wired arms — get_hashes, get_block, get_height — were enabled). End-to-end verification belongs to a future Node::launch-based RPC test harness.

Refs Cuprate#379 (tracking), Cuprate#505 (basic sync), Cuprate#467 (beta blocker).

S03-1: flip two wallet-critical binary RPC dispatch arms from
`not_available()` to their real handlers. Both backends are
implemented in the storage read layer, so these are panic-safe:

- GetBlocksByHeight -> get_blocks_by_height
    (BlockchainReadRequest::BlockCompleteEntriesByHeight, reads tapes)
- GetOutputIndexes  -> get_output_indexes
    (BlockchainReadRequest::TxOutputIndexes, reads tx_ids/tx_infos)

get_output_indexes provides the global output indices a wallet needs
for ring/decoy selection when building a spend.

The three other methods named in S03-1 are intentionally NOT enabled
here: their backing reads are `todo!()` stubs, so flipping their arms
would turn a graceful `not_available()` into a runtime panic.
  - get_transactions  -> blockchain Transactions read is todo!()
  - is_key_image_spent -> txpool key_images_spent_vec is todo!()
  - get_fee_estimate   -> context FeeEstimate is todo!() (PR Cuprate#297)

Refs Cuprate#379, Cuprate#505, Cuprate#467.
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.

RPC: enable wallet-critical methods left stubbed after #505

1 participant