Repository navigation
fix(grpc): NOT_FOUND for unindexed heights; document real FullTxItem byte order - #64
Open
setavenger wants to merge 1 commit into
Open
setavenger wants to merge 1 commit into
setavenger wants to merge 1 commit into
Conversation
…byte order Unary per-height RPCs (GetFullBlock, GetSpentOutputsShort, GetBlockHashByHeight) answered an unindexed height with OK, an empty block hash and empty data - indistinguishable from an indexed block with nothing in it. They now return codes.NotFound, as GRPC.md already documented. Heights above uint32 no longer alias onto a lower height. No consumer branches on the old behaviour; the streaming RPCs are left unchanged because live clients abort a range scan on a mid-stream error. GRPC.md described FullTxItem.inputs outpoints as little-endian txid and vout. The server emits display-order txids and a big-endian vout. No live consumer decodes the field, so the docs are corrected rather than the wire changed. A test pins the encoding. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Summary
Two gRPC contract mismatches found while building the testkit's fake oracle, which copies this server's behaviour.
1.
FullTxItem.inputsbyte order: docs fixed, wire unchangedinternal/database/dbpebble/store.go:280,internal/server/v2/service.go:333)PreviousOutPoint.Hashreversed)scannerv2/verifyoutputs.goreads onlyTxid/UtxosGetFullBlockcaller)blindbit-lib/src/scanner/utils.rsconstruct_dummy_txNo live consumer decodes
inputs. The Rust parser is wrong on both fields, but the result has no effect: the decoded inputs only feed the dummy transaction'scompute_txid()insidebdk_sp::receive::scan_txouts, andscan_transaction_fullthen replaces that txid withitem.txid.scan_transaction_fullalso has no production caller. Changing the wire would be a silent breaking change for no benefit, so this PR corrects GRPC.md to match the server. The txid/hash conventions are relabelled from "little-endian" to "display order", because the old label is what misled the Rust parser.inputsis also documented as covering only inputs that spend P2TR outputs (internal/indexer/builder.go:496). A new test pins the encoding with a vout (0x00000102) whose two byte orders differ.2. Unindexed height: now
NOT_FOUNDfor unary RPCsBefore this PR,
GetFullBlock,GetSpentOutputsShortandGetBlockHashByHeightanswered an unindexed height with OK, an empty block hash and empty data. A client could not tell that apart from an indexed block with no payments. A height above 2^32 was also truncated and silently served a lower block. These RPCs now returncodes.NotFound, as GRPC.md already said, and returnInternalon database errors.Consumer check: none of blindbit-lib (both pins), blindbit-desktop or blindbit-rs branches on a status code or on an empty-hash response.
GetFullBlockis only called with heights the oracle itself just streamed.resolve_block_hashalready turns an empty hash into an error.GetSpentOutputsShorthas no callers.The streaming RPCs are deliberately unchanged. The Rust scanner calls
stream.message().await.unwrap()(blindbit-lib/src/scanner/scanning.rs:95), so a mid-streamNOT_FOUNDfor a range that starts below the sync height would panic it. GRPC.md now documents what the streams actually do (an empty message for an unindexed height), and a test pins that behaviour.Verification
Tests use in-memory pebble plus bufconn gRPC (
internal/server/v2/service_test.go):go build ./... && go vet ./... && go test ./...: all ok. The same with-tags libsecp256k1andCGO_ENABLED=1: all ok.service.gomakes the NOT_FOUND test fail on all 9 RPC×height cases. Switchingbe32to little-endian makes the wire-encoding test fail.🤖 Generated with Claude Code