Repository navigation
Conversation
Resolve block records directly through block_by_hash and share captured-view height lookup logic. Render gettxout with the existing script JSON owner instead of deserializing and reserializing its output through a DTO. Refs #1624
There was a problem hiding this comment.
This PR refactors three RPC lookup/projection layers: consolidates record_for_hash/block_by_hash into a single public block_by_hash, eliminates the duplicate block_hash_at_height forwarding function, and replaces the txout_typed/script_pub_key_typed conversion chain with direct JSON construction for gettxout.
Summary of findings: After reviewing all 6 changed files, the refactoring is functionally correct. The rename from record_for_hash to block_by_hash is complete and consistent across all callers. The block_hash_at_height simplification correctly delegates to block_hash_at_height_in_view with a fresh applied_view() capture — the new test at lines 1471–1476 in context.rs specifically covers the genesis fallback case that the old inline code handled. The txout_json direct JSON construction preserves the previous output schema as verified by the comprehensive new test gettxout_preserves_script_schema_and_omits_unset_fields.
No merge-blocking defects were found in the changed code.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
Upgrade only ctutils from 0.4.3 to 0.4.4 in the workspace and fuzz lockfiles. This fixes RUSTSEC-2026-0385 without weakening the cargo-deny advisory gate.
|
Approve (comment only, not a formal review, approval or merge) — reviewed head VerdictNo blocking findings. The refactor is behavior-preserving for the reviewed paths. Prior finding resolution
What was checked (source trace)
Non-blocking notes
Verification and limits
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This scoped cleanup removes confirmed lookup and conversion redundancy from #1624 while retaining the separate Core, REST and Esplora wire contracts.
record_for_hashentrypoint and the forwardingblock_by_hashbody. The existing publicblock_by_hashnow directly owns tree-authoritative identity resolution and log/body metadata enrichment. Update RPC tests and REST callers; Esplora already calls this public entrypoint. The index change only corrects a comment naming the removed helper.block_hash_at_height_in_viewfor fresh height lookups, removing the duplicate tip/genesis/cache branches. A fresh call still captures one publication; retained-view callers still use their original publication. Extend the existing no-tip lookup test to cover hash lookup and its distinct genesis fallback.script_pub_key_typedand replacetxout_typedwith directtxout_jsonconstruction. Previously, gettxout rendered script JSON, deserialized it into ScriptPubKey, serialized the whole typed response, and recursively removed null fields. It now embeds the existing script renderer's JSON directly, preserving the existing sat_to_btc amount conversion. Keep the pinned DTO as a test oracle across every script fixture plus malformed push ASM, amount boundaries, coinbase flags and omitted optional fields.The concrete block path remains Context tree/log resolution -> getblock, REST block/header routes, or Esplora required_block_record -> each format's renderer. Header-only lookup remains separate because detailed getblock must avoid legacy body metadata reads before acquiring the bounded owner permit. Captured AppliedView reads, stable chainstate barriers, reorg/generation fences and request-local Esplora prevout reuse remain intact. Core typed/null-removal helpers still serve other methods with distinct omission rules. REST block envelopes and Esplora script/transaction projections retain their independent schemas. Registry dispatch retains method lookup, blocking admission and parameter/error policy; HTTP surface routing retains framing/authentication ownership. No measured allocation or latency improvement is claimed.
No sync impact: this changes read-only RPC lookup/presentation paths, not an authoritative synchronization, validation or commit path. It preserves the existing tree/log/body capability boundary, tip capture count and stable-read lock lifetime; no SYNC-* transition or persistence format changes. The RPC unit suite exercises captured tips, concurrent swaps, side branches, pruned/unavailable data and existing fencing/error behavior; this is boundary-local evidence, not a whole-node convergence claim.
Validation on WSL/Linux:
cargo fmt --all -- --checkandgit diff --check: passed.cargo test --locked --ignore-rust-version -p bitcoin-rs-rpc --no-default-features --lib --test core_compat --test core_parity --test transaction_methods: 492 + 18 + 15 + 13 passed. Final unit suite rerun after the last test edits: 492 passed.cargo test --locked --ignore-rust-version -p bitcoin-rs --no-default-features --features fjall --test overhaul_process_harness script_decode_cases::block_rest_and_utxo_consumers_share_core_output_scripts -- --exact: passed against the pinned Core 31.1 process.cargo clippy --locked --ignore-rust-version -p bitcoin-rs-rpc --no-default-features --lib --tests --no-deps -- -D warnings -A clippy::duration_suboptimal_units: passed.Local verification limitation: installed Rust is 1.95, while the repository declares 1.99, so Cargo checks used --ignore-rust-version. Unsuppressed Clippy fails on existing duration_suboptimal_units warnings in utxo/src/scan.rs:21 and rpc/src/server.rs:22; these unrelated lines are unchanged. Full toolchain qualification and broader process/crash/contention/interoperability campaigns remain with their existing CI lanes.
Refs #1624.


Confidence Score: 5/5
The PR appears safe to merge; no actionable regression was found.Summary
This PR removes forwarding and conversion layers from read-only RPC paths.
No actionable issues were found. Tests were not run during this review. The previous-review comparison was not used because the target merge bases differ; the full PR diff was reviewed instead.
Reviews (4) · Last reviewed commit: "Merge branch 'main' into refactor/rpc-re..." · Reviewed by Greptile