Skip to content

feat(sdk): verify the block proofs of getBlocks and getOwnerTransactionsInBlock - #5834

Merged
QuantumExplorer merged 24 commits into
v5.1-devfrom
feat/sdk-verify-block-proofs
Nov 10, 2026
Merged

QuantumExplorer merged 24 commits into
v5.1-devfrom
feat/sdk-verify-block-proofs

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: #5815 lets a client ask a node for blocks, or for one identity's state transitions in a block, and get back what proves the answer: the block header, the validator quorum's signature over it, and Merkle paths. Nothing on the client checked any of that. This adds the check to the Rust SDK, and moves the hashing out of rs-dapi into a crate the node and the client both use, so they cannot disagree on what a valid proof is.

Value: A Rust SDK user can trust getBlocks and getOwnerTransactionsInBlock answers from a node they do not trust: a block is accepted only if a validator quorum signed it and it holds exactly the transactions and results returned. Before this, prove = true returned data that had to be taken on the node's word.

Risks: Low for existing behaviour: no consensus code, no wire format and no stored data change. Two things to know. No block signed by a real quorum has gone through the verifier yet; every step is pinned to Tenderdash's own vectors or to code that already verifies real commits, but the whole chain has only run on blocks signed by a test key. And rs-dapi now builds against drive-proof-verifier, which adds about 38 crates to its build (drive with verify, GroveDB).

Issue being fixed or feature implemented

Follows #5815, now merged into v5.1-dev. That PR builds TenderdashBlockProof and TenderdashTransactionProof in rs-dapi and checks them there before they leave, but no client verified them, and the hashing lived only in rs-dapi. A client that re-implemented it would be a second definition of a valid proof.

What was done?

One definition of the hashing (packages/rs-drive-proof-verifier/src/block_proof/)

  • header.rs: header_hash, state_id_hash, header_time_ms, check_header, with Tenderdash's TestHeaderHash and TestHeaderHashVector vectors.
  • merkle.rs: the RFC 6962 tree (merkle_root, MerkleTree, root_from_path), with Tenderdash's ProofsFromByteSlices vector for building and for following paths.
  • transaction.rs: transaction_hash, result_leaf, check_block_contents, verify_transaction_proof.
  • block.rs: verify_block_proof and check_block_fields.
  • rs-dapi's platform_service/block_proof.rs keeps the RPC decoding and the building of the proof messages and calls the shared code for every hash and check. It no longer needs dapi-grpc's tenderdash-proto feature.

The verifier

  • verify_block_proof recomputes the block hash and the state id from the header and compares them with the block id, then verifies the threshold signature over the precommit vote. The sign hash comes from tenderdash-abci's Commit::calculate_sign_hash, the call drive-abci verifies every commit with. The quorum key comes from the context provider. The key lookup and the BLS check are the two helpers split out of verify_tenderdash_signature in verify.rs, so GroveDB proofs and block proofs share them.
  • OwnerTransactionsInBlock::from_proved_response: the proof must be of the requested height; each transaction needs both paths, to data_hash and to results_hash; transactions must be in block order, none twice, and agree on the block's size; each must decode under the block's protocol version and report the requested owner. A transaction that is proved to be in the block and does not decode is Error::UnusableVerifiedResult, not an invalid proof: every honest node answers with the same bytes.
  • Blocks::from_proved_response: blocks must be consecutive from the start height and no more than asked for; each must repeat the fields of its signed header and hold exactly the transactions and results the header commits to. Its transactions decode under the block's protocol version, with the same UnusableVerifiedResult for one that does not.

The SDK (packages/rs-sdk/src/platform/blocks.rs)

  • Sdk::fetch_blocks and Sdk::fetch_owner_transactions_in_block, following the SDK's proof setting.
  • These are Sdk methods and not Fetch impls: FromProof returns ResponseMetadata and a GroveDB Proof, and these answers carry neither. So nothing here is held to the freshness tolerances (a block is what it is at any age) and nothing is learned about the protocol version.
  • sdk/quorum_key.rs: the fetch-a-missing-quorum-key-and-verify-again loop is now verify_fetching_quorum_keys, used by both proof kinds. The validator set rotates within a ten block page, so a page can be signed by two quorums: the loop fetches each named quorum once for each Core height it is named at (a provider may serve a fetched key only near the height it was fetched for), up to the number of blocks asked for and never more than MAX_BLOCKS_PER_REQUEST. The answer is borrowed, so verifying again after a fetch does not copy it. GroveDB proofs keep their bound of one.

CI: rs-dapi's entries in .github/package-filters now follow rs-drive-proof-verifier.

Follow-up, tracked upstream: the Merkle root, Merkle paths and header hash are Tenderdash primitives. Moving them to rs-tenderdash-abci is tracked in dashpay/rs-tenderdash-abci#230, with the fix open as dashpay/rs-tenderdash-abci#231. Platform drops its copies in block_proof/{merkle,header}.rs once it builds on a release with them (it pins v1.8.1 today).

Before and after

Before, the only way to these queries from Rust was the raw request, and the answer was unchecked:

let response = request.execute(&sdk, RequestSettings::default()).await?; // GetBlocksResponse, as the node gave it

After:

let Blocks(blocks) = sdk
    .fetch_blocks(BlocksQuery { start_height: 1_000, count: 10 })
    .await?; // every block signed by a validator quorum, with exactly its transactions

let mine = sdk
    .fetch_owner_transactions_in_block(OwnerTransactionsInBlockQuery { height: 1_000, owner_id })
    .await?; // each transition is in block 1000, with that result, and is owner_id's

A node that changes one result code in a block now gets Error::Proof(InvalidBlockProof(ResultsRootMismatch { height: 1000 })) and the request moves to another node.

Public interface changes

Everything is added. No existing public item changes its signature, and existing callers compile unchanged.

drive-proof-verifier

  • New module block_proof:
    pub fn header_hash(header: &Header) -> [u8; 32];
    pub fn state_id_hash(header: &Header) -> Result<[u8; 32], BlockProofError>;
    pub fn header_time_ms(header: &Header) -> Result<u64, BlockProofError>;
    pub fn check_header(header: &Header, block_id: &BlockId) -> Result<(), BlockProofError>;
    pub fn merkle_root<T: AsRef<[u8]>>(leaves: &[T]) -> [u8; 32];
    pub struct MerkleTree { pub root: [u8; 32], pub paths: Vec<Vec<Vec<u8>>> } // MerkleTree::new(leaves, selected)
    pub fn root_from_path(index: u32, total: u32, leaf: &[u8], path: &[Vec<u8>]) -> Result<[u8; 32], BlockProofError>;
    pub fn transaction_hash(transaction: &[u8]) -> [u8; 32];
    pub fn result_leaf(code: u32, data: &[u8], gas_used: i64) -> Vec<u8>;
    pub fn check_block_contents<T: AsRef<[u8]>, R: AsRef<[u8]>>(header: &Header, transaction_hashes: &[T], result_leaves: &[R]) -> Result<(), BlockProofError>;
    pub fn check_block_fields(proof: &TenderdashBlockProof, block: &Block) -> Result<(), BlockProofError>;
    pub fn proof_parts(proof: &TenderdashBlockProof) -> Result<(&Header, &BlockId), BlockProofError>;
    pub fn verify_block_proof<'a>(proof: &'a TenderdashBlockProof, provider: &dyn ContextProvider) -> Result<&'a Header, Error>;
    pub fn verify_transaction_proof(header: &Header, transaction_hash: &[u8; 32], result_leaf: &[u8], proof: &TenderdashTransactionProof) -> Result<(), BlockProofError>;
    pub enum BlockProofError { /* one variant per refusal, each naming the height or position */ }
  • block_proof::fixtures, behind the mocks feature: blocks signed by test quorums and the answers a node would give for them (TestQuorum, signed_proof, header_of, block_answer, owner_answer, sign, quorum_public_key). The keys are derived from fixed bytes; a verifier accepts these blocks only from a provider that answers a test key. dash-sdk enables mocks by default, so this is in default builds.
  • New variant Error::InvalidBlockProof(BlockProofError), appended. A match on Error without a wildcard arm needs one more arm.
  • New module types::blocks: Block, Blocks(pub Vec<Block>), BlockTransaction, OwnerTransactionsInBlock, with from_proved_response(request: &Request, response: &Response, provider) and from_unproved_response(request: &Request, response: &Response, platform_version) on Blocks and OwnerTransactionsInBlock; both borrow the response. Also MAX_BLOCKS_PER_REQUEST: u32 = 10, the most blocks a node returns for one getBlocks request. Transactions are decoded StateTransitions. The position of an owner's transaction in its block is not exposed: the paths prove membership, and the position only if the node's claimed block size is right.
  • verify_block_proof reports the header's Core height to ContextProvider::core_height_verified once the signature verifies, as GroveDB proofs do. For an old block that is an old height.
  • New dependency sha2. The transport-free check and the wasm32 build still pass.

dash-sdk

  • New module platform::blocks: BlocksQuery { start_height, count }, OwnerTransactionsInBlockQuery { height, owner_id }, both Query impls, and the re-exported result types and MAX_BLOCKS_PER_REQUEST.
  • New methods: Sdk::fetch_blocks, Sdk::fetch_blocks_with_settings, Sdk::fetch_owner_transactions_in_block, Sdk::fetch_owner_transactions_in_block_with_settings.
  • With proofs on, a refused answer is Error::Proof(..), which the retry loop moves past. A verified answer that holds a transaction this build cannot decode is Error::InvalidRequest(..): it is not retried and the node is not blamed. With proofs off the answer is read as the node gave it.
  • The mock SDK loads recorded GetBlocksRequest and GetOwnerTransactionsInBlockRequest expectations. There is no expect_fetch for these two methods, since they are not Fetch.

rs-dapi: no change to requests, responses or status codes. Its getBlocks count limit is now read from drive_proof_verifier::types::blocks::MAX_BLOCKS_PER_REQUEST, the same value. The text of the internal error for a proof its own data does not satisfy now comes from BlockProofError.

Unchanged: the proto messages, GroveDB proof verification and its errors, version tables, anything stored.

How Has This Been Tested?

  • cargo test -p drive-proof-verifier --lib block (76) and --lib verify (22):
    • block_proof/header.rs, merkle.rs: the Tenderdash vectors, and which hash each header field changes.
    • block_proof/block.rs: a signed block is accepted; refused for a header that does not hash to the block id or the state id, a consistent header the quorum did not sign, another block's signature, a changed round or part set, another key, a malformed signature, an unknown quorum.
    • block_proof/transaction.rs: wrong transaction, result, path, index, block.
    • proof/blocks.rs: each rule of the two answers, including a transaction really in the block that belongs to another owner.
    • The tests sign with a sign hash written out by hand from Tenderdash's definition, not with the verifier's own code.
  • cargo test -p rs-dapi --lib platform_service (151): the existing tests, plus a commit in RPC JSON form signed by a test quorum that goes through build_block_proof and transaction_proofs and is accepted by the client verifier.
  • cargo test -p dash-sdk --lib block_query_tests (10): both methods against a mock node, a page signed by two quorums with neither key cached, proofs off, a forged signature, an old block under a tight freshness tolerance. --lib quorum_key (32): the existing key recovery tests pass on the shared loop.
  • cargo clippy --all-features --all-targets -- -D warnings for the three crates, cargo fmt --all, cargo check -p drive-proof-verifier --locked with the transport-free tree check, and wasm32 checks of drive-proof-verifier and dash-sdk.

Not tested

  • A block a real quorum signed. It needs the commit, block, block_results and validators RPC results of a Tenderdash node for one height; that port is not public. The test would sit next to should_build_proofs_a_client_accepts_from_a_commit_the_quorum_signed in rs-dapi, whose serde types read the RPC JSON as is.
  • Recorded SDK vectors and a tests/fetch test: they need a devnet at protocol 15 that serves both queries.
  • Whether context providers can still supply the key of a quorum that signed an old block.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · f576193

  • Bots — thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build running
  • Approvals
    • github (.github/package-filters/rs-packages-no-workflows.yml, .github/package-filters/rs-packages.yml) — ktechmidas or shumkov
    • files with no dedicated owner — you own it
    • rust-dapi (packages/rs-dapi/Cargo.toml, packages/rs-dapi/src/services/platform_service/block_proof.rs, packages/rs-dapi/src/services/platform_service/get_blocks.rs and 1 more) — lklimek or shumkov
    • rust-sdk (packages/rs-sdk/src/mock/sdk.rs, packages/rs-sdk/src/platform.rs, packages/rs-sdk/src/platform/blocks.rs and 3 more) — lklimek or shumkov

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

QuantumExplorer and others added 22 commits November 9, 2026 07:35
Both queries are answered by rs-dapi from the blocks Tenderdash stores,
because Drive keeps no per-block record of transactions. Neither carries
a proof.

getOwnerTransactionsInBlock returns the state transitions of one owner in
the block at a height. getBlocks returns up to 10 consecutive blocks with
a response size cap, and the gateway allows each IP 30 requests per hour
so that DAPI is not used to sync Tenderdash.

Tenderdash errors for a height the node lacks now map to NotFound instead
of Internal, so a client does not ban a healthy node for them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d clients

A block the node holds without its execution results was treated as the end
of the chain and dropped from the range. Only a missing block ends the range
now, decided from a typed check rather than by building a gRPC status.

Also moves the Tenderdash height bound to the client, teaches the envoy spec
the !ignore tag, and adds the generated clients for the two new RPCs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The 10 second default covers the whole response, so a getBlocks answer near
its 4 MB budget could never finish on a slow link, and each retry used up
the hourly limit. An owner query in a full block has the same problem and
would also ban the healthy node.

Splits read_block out of fetch_block so a test can cover the difference
between a missing block and a missing result set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drive answers this method with unimplemented, so a route pointing anywhere
else would pass the order and rate limit checks and still be broken.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
getBlocks and getOwnerTransactionsInBlock take a `prove` flag. When it is
set the response carries the signed Tenderdash header, block id, round,
quorum and threshold signature, and the owner query adds each returned
transaction's Merkle paths to data_hash and results_hash. The node rebuilds
both trees and compares them with the header, so it fails rather than hand
out a proof its own data cannot satisfy. Owner proofs show inclusion, not
that the list is complete.

getBlocks now reads its whole range in one JSON-RPC batch instead of up to
three calls per block.

Both queries also return each transaction's result_data and gas_used, the
other two fields results_hash covers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Taken from the diff the client generator printed in CI for c18e683.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each returned transaction adds two Merkle paths, so a block full of one
owner's small transitions can pass the 4 MiB a gRPC client decodes by
default even though the block itself fits. Fail with FAILED_PRECONDITION
rather than drop transactions; getBlocks returns that block within the limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
getOwnerTransactionsInBlock decoded every block with the current depth limit,
so a document batch nested past 256 levels, which protocol 12 and earlier
accept, failed the query for every owner at that height. Decode as Drive did,
using the version in the block's header.

Root-only checks no longer build every Merkle path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A proved owner query for one transaction built and stored a path for every
transaction in the block. Keep only the requested paths; the full-block root
checks are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
getBlocks and getOwnerTransactionsInBlock read whole blocks from
Tenderdash and hold them while in flight, and only Envoy's limit of 100
requests to rs-dapi bounded how many ran at once. Allow 4 and 16 at a
time, answering RESOURCE_EXHAUSTED beyond that. Cached answers are still
served at the limit.

Give the runtime's threads an 8 MiB stack, the same as Drive, since
decoding state transitions recurses with the nesting of their values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rs-dapi now refuses getOwnerTransactionsInBlock with RESOURCE_EXHAUSTED
when too many are in progress. A busy node is not a failed one, and a
ban would take it away from the client's other requests too. The client
still retries on another node, as it already does for getBlocks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
getOwnerTransactionsInBlock decoded every transition of a block inside
the handler. rs-dapi has four async threads and lets 16 of these
requests run at once, so a burst on full blocks could hold all four and
stall every other request.

The decode now runs on the blocking pool. A blocking task cannot be
cancelled, so it carries the concurrency permit: a request whose caller
went away still counts against the limit until its decode ends.

Co-Authored-By: Claude <[email protected]>
A proved answer rebuilt the transaction and result trees but never
checked the header itself. `build_block_proof` now recomputes the block
hash and the state id from the header and fails the request when either
differs from the block id the quorum signed.

The block hash is pinned to Tenderdash's own `TestHeaderHash` and
`TestHeaderHashVector` vectors.

The proof's API comments said the block hash covers every header field.
It leaves out the core chain locked height, which only the state id
commits to, so a client has to recompute both.

Co-Authored-By: Claude <[email protected]>
…done

The permit of getBlocks and getOwnerTransactionsInBlock lived in the handler,
which is dropped when its caller goes away or its deadline passes. The request
already sent to Tenderdash carries on there, so the limit no longer bounded
the work in progress.

Both queries now run their backend work in a task that owns the permit and is
not dropped with the handler. The permit comes back when Tenderdash answers or
rs-dapi's own request timeout to Tenderdash passes, and what an abandoned
request read is still cached for the next caller.

Co-Authored-By: Claude <[email protected]>
getBlocks reads a block's time, core chain locked height, app hash and
proposer from Tenderdash's `block` answer and its proof from the `commit`
answer. Only the height, the hash and the two roots were compared, so the
other fields could differ from the header the quorum signed.

With `prove`, every field a block repeats from its header is now compared
with the signed header, and the request fails if one differs. The proto
comment tells clients to make the same comparison.

Co-Authored-By: Claude <[email protected]>
…able

Tenderdash stores a block before its results, so the newest block can be
without them for a moment. Both block queries answered that as NotFound,
the status of a height the node does not have. It is now Unavailable, which
a client retries. Other failures to read the results are unchanged.

Co-Authored-By: Claude <[email protected]>
A block query's work kept its permit until the work ended, and the work
ended when the 30 second deadline of the Tenderdash HTTP client passed,
while Tenderdash goes on with a request whose caller has gone. What a
block query asks of Tenderdash now goes through a client without a
deadline, which waits until Tenderdash answers or closes the connection
(keepalive probes end it if Tenderdash is gone), so the permit lasts as
long as the work there. The caller still gets an answer after 30
seconds: `DeadlineExceeded`, with the request still counted.

A proved block without transactions is now checked against its header's
results root as well, which is the root of no results.

Co-Authored-By: Claude <[email protected]>
The previous commit made a block query's handler stop waiting after 30
seconds. The gRPC server already ends every unary handler at its own
deadline and answers DeadlineExceeded, so that second wait never ran in
the server. The work still runs in its own task, with no deadline on what
it asks of Tenderdash, and keeps its place in the limit until Tenderdash
answers or closes the connection.

The two regression tests now drop their callers and move the clock an
hour ahead instead of waiting for the removed deadline.

Co-Authored-By: Claude <[email protected]>
A batch can carry ten full blocks. Reading its JSON, and decoding and hashing
every transaction of those blocks, now runs on the blocking pool, so the async
threads keep serving other requests. The query still counts against its limit
until that work is done.

The handlers are now also tested against a stand-in Tenderdash that answers:
a proved answer too large to send is refused and not cached, the same block
is served without a proof, and a small proved answer is built and cached.

Co-Authored-By: Claude <[email protected]>
`getOwnerTransactionsInBlock` and `getBlocks` are now methods of the Node and
web `PlatformPromiseClient`, like every other platform query.

Co-Authored-By: Claude <[email protected]>
Proving an owner's transactions hashes every transaction of the block again
and encodes every result. For a full block that would hold up the other
requests an async thread serves, so the answer is now built on the blocking
pool. The query still counts against its limit until that work is done.

Co-Authored-By: Claude <[email protected]>
…onsInBlock

A Rust SDK user can now trust the answers of the two block queries when
proofs are on: Sdk::fetch_blocks and Sdk::fetch_owner_transactions_in_block
check each block against the validator quorum's signature and each
transaction and result against the two roots of the signed header.

The hashing and the checks rs-dapi runs before a proof leaves move out of
rs-dapi into drive-proof-verifier::block_proof (header hash, state id,
RFC 6962 tree and paths, result leaf, block contents, block fields), with
Tenderdash's test vectors, so the node that builds a proof and the client
that checks it share one definition. rs-dapi now depends on
drive-proof-verifier and no longer needs dapi-grpc's tenderdash-proto
feature.

The verifier recomputes the block hash and state id from the header,
verifies the threshold signature over the precommit vote through
tenderdash-abci's Commit sign hash with the quorum key from the context
provider, then follows each Merkle path to data_hash and results_hash.
An owner answer must also be for the requested height, in block order,
and every transaction must report the requested owner. A page of blocks
must be consecutive from the start height, repeat the fields of its
signed headers, and hold exactly the committed transactions and results.

The SDK fetches quorum keys the provider has not cached, one per quorum
that signed a page, through the loop it already used for GroveDB proofs,
now shared. Block answers are not held to the freshness tolerances.

Not covered: no test against a block a real quorum signed (no fixture of
a signed commit exists), and no recorded SDK test vectors, which need a
devnet that serves the two queries.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f95aa74 and f576193.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 27

  • .github/package-filters/rs-packages-no-workflows.yml
  • .github/package-filters/rs-packages.yml
  • packages/rs-dapi/Cargo.toml
  • packages/rs-dapi/src/services/platform_service/block_proof.rs
  • packages/rs-dapi/src/services/platform_service/get_blocks.rs
  • packages/rs-dapi/src/services/platform_service/get_owner_transactions_in_block.rs
  • packages/rs-drive-proof-verifier/Cargo.toml
  • packages/rs-drive-proof-verifier/src/block_proof.rs
  • packages/rs-drive-proof-verifier/src/block_proof/block.rs
  • packages/rs-drive-proof-verifier/src/block_proof/error.rs
  • packages/rs-drive-proof-verifier/src/block_proof/fixtures.rs
  • packages/rs-drive-proof-verifier/src/block_proof/header.rs
  • packages/rs-drive-proof-verifier/src/block_proof/merkle.rs
  • packages/rs-drive-proof-verifier/src/block_proof/transaction.rs
  • packages/rs-drive-proof-verifier/src/error.rs
  • packages/rs-drive-proof-verifier/src/lib.rs
  • packages/rs-drive-proof-verifier/src/proof.rs
  • packages/rs-drive-proof-verifier/src/proof/blocks.rs
  • packages/rs-drive-proof-verifier/src/types.rs
  • packages/rs-drive-proof-verifier/src/types/blocks.rs
  • packages/rs-drive-proof-verifier/src/verify.rs
  • packages/rs-sdk/src/mock/sdk.rs
  • packages/rs-sdk/src/platform.rs
  • packages/rs-sdk/src/platform/blocks.rs
  • packages/rs-sdk/src/sdk.rs
  • packages/rs-sdk/src/sdk/block_query_tests.rs
  • packages/rs-sdk/src/sdk/quorum_key.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thepastaclaw

thepastaclaw commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress — actively reviewing now (commit f576193) · triage: critical · Phase 2 only (queue backlog)
█████████████░░░░░░░ 63% · about 5 min left · running for 11 min
✅ triage → ⏭️ Phase 1 → ⏳ Phase 2 (0/6 lanes) → ▫️ verify 2 → ▫️ publish
Estimated from recent reviews of this tier · updated 11:05 UTC · live progress

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The new verification path checks block signatures and transaction commitments, but quorum-key recovery can reject valid multi-block pages because it ignores the height scope of cached evidence. Five additional non-blocking findings cover authenticated decode errors, request bounds, upstream hashing ownership, historical-version test coverage, and response copying. This was a static review of head 6812b54; current CI shows successful Kotlin and policy checks, no Rust verifier-test result, and the automated review still pending.

🔴 1 blocking | 🟡 5 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, intricate diff directly implements cryptographic proof acceptance in block_proof/block.rs::verify_block_proof and proof/blocks.rs, including quorum signature verification, signed-header binding, and transaction Merkle-path validation.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions are optional: fix them forward in a later PR rather than pushing another round just for them.
- Address every current finding in one push: self-review the full diff first, and don't push piecemeal.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-sdk/src/sdk/quorum_key.rs`:
- [BLOCKING] packages/rs-sdk/src/sdk/quorum_key.rs:75-77: Include Core height when deduplicating quorum-key fetches
  Fetching a quorum key establishes availability at the requested Core height, not at every height where that quorum signed. VerifiedHttpContextProvider delegates lookup to proof_fetches::Cached::serves, which restricts availability to lo..=hi + 24. A cold-cache page containing the same quorum at Core heights H and H+25 can therefore legitimately need two fetches. After fetching for H, this pair-only comparison rejects the lookup failure at H+25 as a provider contract violation without attempting the second fetch. A valid no-retry request fails with QuorumSourceUnavailable, and retry-enabled requests unnecessarily consume another attempt. Compare the full (quorum_type, quorum_hash, core_chain_locked_height) tuple, retain the bounded fetch budget, and add a page regression with a height-sensitive provider; both current block-query test providers ignore height.

In `packages/rs-drive-proof-verifier/src/proof/blocks.rs`:
- [SUGGESTION] packages/rs-drive-proof-verifier/src/proof/blocks.rs:97-103: Do not classify authenticated decode failures as invalid proofs
  Both proved call sites decode transactions only after verifying the quorum signature and the transaction/result commitments. Nevertheless, this error becomes ProtocolError, which the SDK converts to retryable Error::Proof and can attribute to the responding node. The future-version fallback explicitly permits authenticated headers newer than this binary; a legitimate transaction using an unfamiliar encoding can then fail decoding even though its proof is valid. Every honest responder returns the same committed bytes, so rotating through nodes cannot fix the failure. At the proved call sites, map authenticated decoding failures to UnusableVerifiedResult or an equivalent non-node-blaming error, while retaining ordinary decode errors for unproved responses. Add coverage for a valid signed commitment containing bytes the current SDK cannot decode.
- [SUGGESTION] packages/rs-drive-proof-verifier/src/proof/blocks.rs:34-36: Exercise historical protocol selection through both proved response types
  The proved-response tests generate headers at PlatformVersion::latest(), apart from the future-version fallback test. None demonstrates that a historical signed app_version selects different decoding rules, so replacing this arm with latest() would leave the current tests passing. Add proved-response regressions for both Blocks and OwnerTransactionsInBlock using a transaction whose acceptance differs across historical snapshots. The deeply nested batch in rs-dapi's should_decode_a_block_under_its_own_protocol_version already supplies such a case: it decodes under protocol 12 but exceeds protocol 13's document-value depth limit. Sign the historical headers and verify that decoding follows their app_version.

In `packages/rs-sdk/src/platform/blocks.rs`:
- [SUGGESTION] packages/rs-sdk/src/platform/blocks.rs:77-85: Enforce the supported block-query bounds before sending
  BlocksQuery documents count as 1..=10, but query() accepts every u32, and BlockRequest::max_blocks() subsequently uses that value directly as the quorum-fetch budget. Honest DAPI servers reject these invalid requests, causing an avoidable round trip; if a caller supplies an oversized count and a node answers it, the verifier also permits a page and recovery budget larger than the supported API bound. Validate the supported count and height range before encoding, including the last requested height, and cap the recovery budget independently. Keep the limit shared or otherwise tied to the endpoint's supported bound rather than introducing an unrelated literal.
- [SUGGESTION] packages/rs-sdk/src/platform/blocks.rs:283-288: Avoid cloning the complete block page for every key-recovery attempt
  The verification closure clones the entire response before every attempt, including attempts that immediately discover a missing quorum key. With several uncached signers, the same multi-megabyte page is copied once initially and again after each successful key fetch, even though the response itself never changes. Unlike the small quorum lookup inputs, this includes every serialized transaction and result. Allow the block-response verifier to borrow the response and copy only data needed for the returned result, or separate key discovery from consuming response decoding, so recovery does not repeatedly copy the full page.

In `packages/rs-drive-proof-verifier/src/block_proof/merkle.rs`:
- [SUGGESTION] packages/rs-drive-proof-verifier/src/block_proof/merkle.rs:33-42: Track canonical Tenderdash hashing primitives upstream
  Sharing these helpers between DAPI and the SDK removes duplication within Platform, but the RFC 6962 root algorithm already exists in dashpay/rs-tenderdash-abci's abci/src/merkle.rs at both the pinned revision eebfc46cc64b and current default revision 384efe48713a. It is private, and the required header/path helpers are missing, so Platform still maintains another implementation of a Tenderdash-owned primitive. Track an upstream change to expose the canonical root helper and supply the missing hashing/path functionality, leaving Platform-specific response adaptation and proof composition here. No matching item was found among the upstream open issues or PRs, and none is linked in this PR; a linked upstream issue or follow-up PR is sufficient to defer the extraction.

Comment thread packages/rs-sdk/src/sdk/quorum_key.rs Resolved
Comment thread packages/rs-sdk/src/platform/blocks.rs Resolved
Comment thread packages/rs-sdk/src/platform/blocks.rs Resolved
…s it at

A context provider that proves a quorum's key for a Core height serves it
only near that height. The key fetch loop compared the quorum alone, so a
page whose blocks named one quorum at Core heights further apart took the
second miss for a provider that forgot its key and failed. It now compares
the Core height too, within the same fetch budget.

Also from review:
- A transaction that is proved to be in a block and does not decode under
  the block's protocol version is `UnusableVerifiedResult`, not an invalid
  proof: every honest node answers with the same bytes, so the node is not
  blamed and no other node is asked. Unproved answers keep the decode error.
- The key fetch budget of a block page is capped at the most blocks a node
  serves, `MAX_BLOCKS_PER_REQUEST`, now defined once in drive-proof-verifier
  and used by rs-dapi for its request check.
- The block answer verifiers borrow the response, so verifying again after
  a key fetch no longer copies the page.
- Tests decode proved answers under a historical protocol version through
  both answer types.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

At head 293dde9, no blocking defect was confirmed; one non-blocking suggestion remains to make the RPC-to-verifier regression authenticate an already-signed source commit. The upstream hashing extraction is now tracked. This was a static review: current CI shows successful Kotlin and policy checks with the review pending, but no dedicated Rust build or test result.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

⏸️ Awaiting tracking link (1): Track canonical Tenderdash hashing primitives upstream (thread). Link an issue on its thread, or ask there and PastaClaw files it.

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Sign the source RPC commit before converting it into a proof
packages/rs-dapi/src/services/platform_service/block_proof.rs:409-414

The incoming RPC commit still contains the fixture's three-byte AQID signature: sign(&mut proof) replaces it only after build_block_proof returns. The resulting signature therefore agrees with whatever signing inputs the conversion produced, so this regression does not independently establish that an already-signed source commit survives conversion unchanged. Construct and sign a deterministic source header and block ID first, place that signature in the RPC commit's base64 field, and then verify the untouched proof returned by build_block_proof. This exercises the advertised RPC-to-client authentication boundary without requiring a real node.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that adds cryptographic block-header, Merkle-proof, transaction-proof, quorum-signature, and key-lookup verification across the Rust SDK and shared verifier, directly changing a critical cryptography and signature-validation surface in functions such as verify_block_proof and verify_tenderdash_signature.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Code unchanged since the last final review (6812b540): 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions are optional: fix them forward in a later PR rather than pushing another round just for them.
- Address every current finding in one push: self-review the full diff first, and don't push piecemeal.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-drive-proof-verifier/src/block_proof/merkle.rs`:
- [SUGGESTION] packages/rs-drive-proof-verifier/src/block_proof/merkle.rs:33-42: Track canonical Tenderdash hashing primitives upstream
  (awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed; thread: https://github.com/dashpay/platform/pull/5834#discussion_r4522155322)

Base automatically changed from feat/dapi-block-queries to v5.1-dev November 10, 2026 10:12
@github-actions github-actions Bot added this to the v5.1.0 milestone Nov 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-self-review Waiting for the author to post /self-reviewed label Nov 10, 2026
#5815 was squash-merged into v5.1-dev, so its block query files were added
on both sides. Resolved to v5.1-dev with this branch's changes on top, the
same tree a rebase of this branch's two commits gives.

The block queries now set `possibly_accepted: false` on the `ExecutionError`
they build, the field v5.1-dev added in #5556: they are reads, and the
error comes from verifying an answer that arrived.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 10, 2026
@QuantumExplorer
QuantumExplorer merged commit f970f0e into v5.1-dev Nov 10, 2026
26 of 28 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/sdk-verify-block-proofs branch November 10, 2026 11:07
QuantumExplorer added a commit that referenced this pull request Nov 10, 2026
…uests

Brings in #5556 (shared broadcast keeps uncertain submission outcomes),
#5823 (proven state transition outcome, getRecentStateTransitionStatus),
#5815, #5834, #5825, #5835, #5838 and #5839.

One textual conflict, in packages/rs-sdk/src/platform/transition/broadcast.rs
at the end of broadcast_with_retries. This branch (#5837) had the shared
broadcast fail over on a nonce-ahead answer and on a missing DPNS owner
(retry_with_additional_error, from #5562), and made is_address_nonce_ahead
public for the wallet's single-dispatch broadcast. #5556 replaced both
failovers with the plain shared retry, so that a concrete refusal ends
sending, with tests saying so (should_stop_on_nonce_rejection_without_
rebuilding_or_resending, should_stop_on_concrete_rejection_regardless_of_
node_failover_settings), and removed is_address_nonce_ahead and
is_missing_transition_owner. The file is taken as v5.1-dev has it.

The wallet's single-dispatch broadcast (broadcast_outcome::track_delivery)
still goes on to the next dispatch after a nonce-ahead answer, as #5837
meant: the classifier moves into broadcast_outcome.rs, unchanged, and its
doc no longer says the SDK's own broadcast fails over too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants