feat(rpc): enable get_blocks_by_height + get_output_indexes (S03-1)#6
Open
orrinfrazier wants to merge 1 commit into
Open
feat(rpc): enable get_blocks_by_height + get_output_indexes (S03-1)#6orrinfrazier wants to merge 1 commit into
orrinfrazier wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16
Summary
Enables two wallet-critical binary RPC methods (S03-1) by flipping their
map_requestdispatch arms fromnot_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.GetBlocksByHeight→get_blocks_by_height— block sync by heightGetOutputIndexes→get_output_indexes— global output indices, required for ring/decoy selection when building a spendWhy 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 gracefulnot_available()into a runtime panic:get_blocks_by_heightBlockCompleteEntriesByHeight(storage/blockchain/.../read.rs)get_output_indexesTxOutputIndexes(storage/blockchain/.../read.rs)get_transactionsTransactionsreadtodo!()is_key_image_spentkey_images_spent_vectodo!()get_fee_estimateFeeEstimatetodo!("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_estimateis 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 fillsspent_status(one entry per input), the txpool passpushes results for the unspent subset instead of updating those positions in place, so the response length becomesN+Mand pool-spends land at the wrong index. Fix when the txpool backend is implemented: collect the unspent indices, query that subset, and writespent_status[i] = SpentInPoolback in place.Testing
cargo clippy -p cuprated --all-targets -- -D warnings— cleancargo fmt -p cuprated -- --check— cleanCupratedRpcHandlercan'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 futureNode::launch-based RPC test harness.Refs Cuprate#379 (tracking), Cuprate#505 (basic sync), Cuprate#467 (beta blocker).