Skip to content

fix(sdk)!: enforce a per-protocol-version minimum GroveDB proof envelope (V1 from v14) - #4701

Merged
QuantumExplorer merged 8 commits into
v4.2-devfrom
codex/require-v1-grovedb-proofs
Sep 13, 2026
Merged

fix(sdk)!: enforce a per-protocol-version minimum GroveDB proof envelope (V1 from v14)#4701
QuantumExplorer merged 8 commits into
v4.2-devfrom
codex/require-v1-grovedb-proofs

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 11, 2026

Copy link
Copy Markdown
Member

Problem

A signed DAPI response could supply a GroveDB V0 proof envelope. V0's historical item binding can return different item bytes while preserving the authenticated root, so Tenderdash root authentication alone does not make the returned value safe.

Change

  • add SystemLimits::minimum_grovedb_proof_envelope_version: the lowest GroveDB proof envelope a client accepts, 0 for every shipped protocol version and 1 from protocol version 14
  • reject any envelope below that floor before a direct proof reaches Drive through drive-proof-verifier, in every FromProof and in verify_tenderdash_proof
  • validate both components of identity double proofs and compacted address proofs against the same floor
  • keep raw Merk trunk proofs on their distinct format path
  • apply the same floor to public wasm-drive-verify JavaScript and native entry points
  • keep GroveDB's frozen V0 implementation unchanged

The gate is version < minimum, so envelopes newer than the client knows pass the gate and fail in GroveDB's own decoder. Rejections are typed: Drive gains ProofError::InvalidGroveDBProofEnvelope and ProofError::UnsupportedGroveDBProofEnvelopeVersion (each naming which proof was read: the proof, the predecessor proof, or the forward proof), and drive-proof-verifier maps the latter onto its own Error::UnsupportedGroveDBProofVersion so SDK callers see one variant for direct and nested rejections alike. The message reads unsupported GroveDB proof envelope version 0 in the proof: protocol version 14 requires at least version 1. A client verifying with protocol version 13 tables still accepts V0; one verifying with 14 does not. Protobuf request and response Version::V0 remains supported because it is unrelated to the GroveDB proof-envelope version. GroveDB only emits V1 envelopes from grove version 3, which Platform v13 introduced, so current mainnet and testnet responses already satisfy the floor.

Related: dashpay/grovedb#852

Recorded rs-sdk test vectors

The offline rs-sdk vectors were recorded on devnets running protocol versions 4 to 12, so 72 of the 105 vector directories carried V0 envelopes and 92 offline tests failed against this policy.

  • 70 files in 48 directories are re-encoded as V1 envelopes with identical Merk layers. The signed root hash and every verified value are unchanged, and the verifier accepts them because they contain no shape the V1 rules reject.
  • 24 tests replay proofs that cannot be upgraded: V1 rejects a KVValueHash node that carries an item, and a non-empty subtree reported without its child hash. Those are the identity/token/group reads and the contested-resource family. They are gated behind offline-testing ignores whose reason says to regenerate against a running Platform; the contested-name cases also depend on the prerequisite seeding tracked in Seed DPNS contested-name prerequisites via SDK_TEST_DATA (extend create_sdk_test_data) #3720. Their directories keep the original V0 recordings so the regeneration overwrites them in place.
  • The live-network prerequisite check for masternode voting tests is skipped in offline runs, so the error-path cases that never needed a proof keep running.
  • rs-sdk-ffi replays the same directories through the FFI mock handle; the 7 tests that hit the V0-only recordings carry the same ignore reason.

Tests

  • a table-driven regression in drive-proof-verifier feeds a V0 envelope to 43 direct-proof FromProof paths (identity, contract, address, epoch, upgrade, path-element, credits, proposer, shielded, token, and group queries) at the latest protocol version and expects the typed rejection; the context provider panics if reached, so a path that loses its gate fails loudly
  • a recorded V1 identity-balance proof from the drive-proof-verifier regression corpus is verified through the exported WASM verifyIdentityBalanceForIdentityId, pinning the expected root hash and balance
  • the shared WASM mock_proof fixture now starts with the bincode-encoded V1 envelope discriminant, so the existing empty-request success tests still reach Drive instead of stopping at the envelope gate
  • native wasm-drive-verify entry points reject V0 for identity, contract, and document proofs at the latest protocol version, let it through at protocol version 13, and pass a V1 envelope through to Drive
  • the identity double proof rejects a V0 outer proof as well as a V0 inner one (drive-proof-verifier), with the same two cases on the WASM double-proof entry point
  • envelope helpers are imported rather than spelled as inline crate paths at each call site

Validation

  • cargo test -p drive-proof-verifier --lib --locked (277 passed)
  • cargo test -p wasm-drive-verify --lib --locked (24 passed)
  • cargo test -p dash-sdk --test main (108 passed, 28 ignored, 0 failed)
  • cargo test -p rs-sdk-ffi --test integration (27 passed, 7 ignored, 0 failed)
  • cargo check -p wasm-drive-verify --tests --target wasm32-unknown-unknown
  • cargo check -p drive --no-default-features --features verify
  • cargo test -p drive verify_compacted_address_balance_changes --lib --locked (13 passed)
  • cargo test -p dash-platform-queries --lib --locked (57 passed)
  • cargo check -p dash-sdk --locked
  • cargo check -p wasm-sdk --locked
  • cargo clippy -p platform-version -p drive-proof-verifier -p wasm-drive-verify --all-targets --locked --no-deps -- -D warnings
  • cargo fmt --all -- --check

🤖 Generated with Claude Code

Reject legacy and unknown GroveDB proof envelopes at Platform client verification boundaries before handing their bytes to Drive. Validate nested identity and compacted proofs while preserving raw Merk sync proof handling.
@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1ee36cd1-def8-46a8-8dd7-2b68c2a960e7

📥 Commits

Reviewing files that changed from the base of the PR and between d020728 and 994b821.

📒 Files selected for processing (76)
  • packages/rs-drive-proof-verifier/src/error.rs
  • packages/rs-drive-proof-verifier/src/proof.rs
  • packages/rs-drive-proof-verifier/src/proof/chained_document.rs
  • packages/rs-drive-proof-verifier/src/proof/composite_document.rs
  • packages/rs-drive-proof-verifier/src/proof/document_average.rs
  • packages/rs-drive-proof-verifier/src/proof/document_count.rs
  • packages/rs-drive-proof-verifier/src/proof/document_having.rs
  • packages/rs-drive-proof-verifier/src/proof/document_ranked.rs
  • packages/rs-drive-proof-verifier/src/proof/document_sum.rs
  • packages/rs-drive-proof-verifier/src/proof/groups.rs
  • packages/rs-drive-proof-verifier/src/proof/identity_token_balance.rs
  • packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs
  • packages/rs-drive-proof-verifier/src/proof/token_direct_purchase.rs
  • packages/rs-drive-proof-verifier/src/proof/token_info.rs
  • packages/rs-drive-proof-verifier/src/proof/token_perpetual_distribution_last_claim.rs
  • packages/rs-drive-proof-verifier/src/proof/token_pre_programmed_distributions.rs
  • packages/rs-drive-proof-verifier/src/proof/token_status.rs
  • packages/rs-drive-proof-verifier/src/proof/token_total_supply.rs
  • packages/rs-drive-proof-verifier/src/verify.rs
  • packages/rs-drive/src/verify/address_funds/verify_compacted_address_balance_changes/v1/mod.rs
  • packages/wasm-drive-verify/src/contract/verify_contract.rs
  • packages/wasm-drive-verify/src/contract/verify_contract_history.rs
  • packages/wasm-drive-verify/src/document/verify_proof.rs
  • packages/wasm-drive-verify/src/document/verify_proof_keep_serialized.rs
  • packages/wasm-drive-verify/src/document/verify_start_at_document_in_proof.rs
  • packages/wasm-drive-verify/src/group/verify_action_signers.rs
  • packages/wasm-drive-verify/src/group/verify_action_signers_total_power.rs
  • packages/wasm-drive-verify/src/group/verify_active_action_infos.rs
  • packages/wasm-drive-verify/src/group/verify_group_info.rs
  • packages/wasm-drive-verify/src/group/verify_group_infos_in_contract.rs
  • packages/wasm-drive-verify/src/identity/verify_full_identities_by_public_key_hashes.rs
  • packages/wasm-drive-verify/src/identity/verify_full_identity_by_identity_id.rs
  • packages/wasm-drive-verify/src/identity/verify_full_identity_by_non_unique_public_key_hash.rs
  • packages/wasm-drive-verify/src/identity/verify_full_identity_by_unique_public_key_hash.rs
  • packages/wasm-drive-verify/src/identity/verify_identities_contract_keys.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_balance_and_revision_for_identity_id.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_balance_for_identity_id.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_balances_for_identity_ids.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_contract_nonce.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_id_by_non_unique_public_key_hash.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_id_by_unique_public_key_hash.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_ids_by_unique_public_key_hashes.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_keys_by_identity_id.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_nonce.rs
  • packages/wasm-drive-verify/src/identity/verify_identity_revision_for_identity_id.rs
  • packages/wasm-drive-verify/src/native.rs
  • packages/wasm-drive-verify/src/single_document/verify_single_document.rs
  • packages/wasm-drive-verify/src/state_transition/verify_state_transition_was_executed_with_proof.rs
  • packages/wasm-drive-verify/src/system/verify_epoch_infos.rs
  • packages/wasm-drive-verify/src/system/verify_epoch_proposers.rs
  • packages/wasm-drive-verify/src/system/verify_total_credits_in_system.rs
  • packages/wasm-drive-verify/src/system/verify_upgrade_state.rs
  • packages/wasm-drive-verify/src/system/verify_upgrade_vote_status.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_balance_for_identity_id.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_balances_for_identity_id.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_balances_for_identity_ids.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_contract_info.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_direct_selling_price.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_direct_selling_prices.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_info_for_identity_id.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_infos_for_identity_id.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_infos_for_identity_ids.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_perpetual_distribution_last_paid_time.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_pre_programmed_distributions.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_status.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_statuses.rs
  • packages/wasm-drive-verify/src/tokens/verify_token_total_supply_and_aggregated_identity_balance.rs
  • packages/wasm-drive-verify/src/utils/mod.rs
  • packages/wasm-drive-verify/src/utils/proof.rs
  • packages/wasm-drive-verify/src/voting/verify_contests_proof.rs
  • packages/wasm-drive-verify/src/voting/verify_identity_votes_given_proof.rs
  • packages/wasm-drive-verify/src/voting/verify_masternode_vote.rs
  • packages/wasm-drive-verify/src/voting/verify_specialized_balance.rs
  • packages/wasm-drive-verify/src/voting/verify_vote_poll_vote_state_proof.rs
  • packages/wasm-drive-verify/src/voting/verify_vote_poll_votes_proof.rs
  • packages/wasm-drive-verify/src/voting/verify_vote_polls_end_date_query.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change enforces GroveDB proof envelope version 1 across Rust and WASM verification paths. It adds version errors, validates nested proofs, routes proof bytes through shared helpers, updates compacted proof checks, and adjusts Tenderdash signature verification.

Changes

GroveDB proof validation

Layer / File(s) Summary
Core proof validation and Tenderdash flow
packages/rs-drive-proof-verifier/src/error.rs, packages/rs-drive-proof-verifier/src/verify.rs, packages/rs-drive-proof-verifier/src/proof.rs
Adds UnsupportedGroveDBProofVersion, validates version 1 envelopes, separates signature verification, and routes core identity, address, contract, document, epoch, governance, proposer, and shielded-pool paths through validated proof bytes.
Rust query adapter updates
packages/rs-drive-proof-verifier/src/proof/*
Updates document, group, identity-token, and token verifiers to use version-aware proof extraction.
Compacted proof validation
packages/rs-drive/src/verify/address_funds/verify_compacted_address_balance_changes/v1/mod.rs
Validates both nested compacted proof envelopes and adds version 0 rejection coverage.
WASM proof validation helper
packages/wasm-drive-verify/src/utils/*, packages/wasm-drive-verify/src/native.rs
Adds proof-envelope validation, WASM error conversion, module wiring, and native validation before verification.
WASM verification entry points
packages/wasm-drive-verify/src/{contract,document,group,identity,state_transition,system,tokens,voting,single_document}/*
Converts raw proof bytes through current_grovedb_proof before Drive verification across the exposed entry points.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant WASMVerificationEntryPoint
  participant current_grovedb_proof
  participant Drive
  WASMVerificationEntryPoint->>current_grovedb_proof: validate raw proof bytes
  current_grovedb_proof-->>WASMVerificationEntryPoint: current proof or verification error
  WASMVerificationEntryPoint->>Drive: invoke verification with current proof
Loading

Merge Risk: ⚪ Minimal · up to 994b8

The proof-version enforcement is consistently applied across the changed verification paths, with no concrete merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 141 functions across 50 files. (26 skippe… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: enforcing a minimum GroveDB proof envelope version, with V1 required from protocol version 14. This matches the proof validation changes across SDK and WAS…
Full details: Docstring Coverage

Explanation

Docstring coverage is 57.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 141 functions across 50 files. (26 skipped: 26 over the file limit.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/require-v1-grovedb-proofs

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

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 1st in line, estimated start in ~30 min (commit 7b80d8d)
Estimated review time once started: ~0.9 h (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

@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 2 only (queue backlog)

The V1 envelope guards are present in the inspected direct verification paths, including both identity double-proof components, while raw Merk trunk proofs retain their separate handling. One non-blocking regression-coverage suggestion is confirmed; no supplied finding establishes an in-scope correctness defect. Validation was source-based; no tests were independently executed.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: critical by gpt-6-astra (effort low) — The diff makes a large, cross-cutting change to cryptographic proof acceptance in packages/rs-drive-proof-verifier/src/verify.rs and proof.rs, enforcing V1 envelopes across native and WASM entry points while separately handling nested proofs and raw Merk signature-authentication paths.
  • Phase 1 reviewers: not run (skipped for throughput: 19 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/wasm-drive-verify/src/utils/proof.rs`:
- [SUGGESTION] packages/wasm-drive-verify/src/utils/proof.rs:35-40: Test envelope enforcement through public verification entry points
  The two new tests exercise only the private envelope discriminator, so removing a guard from native.rs or either component of the WASM identity double-proof entry point would leave them passing. Existing identity tests do not assert the new unsupported-envelope error, and the V1 helper test checks only a serialized version number rather than a verifiable proof. Add public-entry-point regressions asserting the specific V0 rejection, including V0 independently in each identity double-proof component, plus a valid V1 fixture that still verifies. This would protect the newly introduced security policy against both missing guards and over-rejection.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Align generated ES-module wrappers with wasm-bindgen exports — The package exports route consumers to dist modules generated by scripts/build-modules.sh. Its identity module imports snake_case names such as verify_full_identity_by_identity_id, but the Rust binding exports verifyFullIdentityByIdentityId through wasm-bindgen; its wrapper also omits the required is_proof_subset argument. These concrete mismatches prevent the generated identity module from importing and invoking the binding correctly. Both predate this PR, which changes neither the generator nor the exported signature.
    • Follow-up: Track a separate fix synchronizing generated imports and argument lists with wasm-bindgen exports, with a JavaScript smoke test for the published package entry points.

Comment thread packages/wasm-drive-verify/src/utils/proof.rs Outdated
QuantumExplorer and others added 2 commits September 13, 2026 16:59
Import the envelope helpers instead of spelling out crate paths at every
call site in drive-proof-verifier and wasm-drive-verify.

Add regressions that reach the policy through public entry points: the
native wasm-drive-verify functions reject V0 and unknown envelopes for
identity, contract, and document proofs while a V1 envelope reaches
Drive; the identity double proof rejects a V0 outer proof as well as a
V0 inner one; the WASM double-proof entry point gets the same two cases.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The offline rs-sdk vectors were recorded before GroveDB emitted V1
envelopes, so every replayed proof now fails the V1 requirement.

Where a recorded V0 proof contains only Merk layers that the V1
verifier accepts, re-encode it as a V1 envelope with identical Merk
layers; the signed root hash and every verified value are unchanged.
That covers 70 files in 48 vector directories.

Proofs that report an item in a KVValueHash node or a non-empty
subtree without its child hash cannot be upgraded: V1 rejects exactly
those shapes. Gate the 24 tests that replay them behind
`offline-testing` ignores that say to regenerate against a running
Platform (contested-name cases also need #3720), and
skip the live-network prerequisite check in offline runs so the
error-path cases that never needed a proof keep running.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@QuantumExplorer QuantumExplorer changed the title fix(proof-verification)!: require V1 GroveDB proof envelopes fix(sdk)!: require V1 GroveDB proof envelopes Sep 13, 2026

@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 V1 envelope gate is applied consistently across the reviewed public verification paths, and the newly added rejection tests address the previously identified guard-coverage gap. However, several existing WASM integration success tests still use the 0xAB mock proof, which now fails the envelope gate even when the requested result is empty; the public WASM suite also still lacks a genuinely verifiable V1 proof fixture.

🟡 2 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Update WASM success-test fixtures for the new envelope requirement
packages/wasm-drive-verify/tests/common/mod.rs:7-10

mock_proof still returns an all-0xAB buffer. The new public verification functions call current_grovedb_proof before Drive verification, so this buffer decodes as an unsupported envelope version rather than reaching the intended verification logic. In particular, test_verify_multiple_identities_empty_array, test_verify_token_balances_empty_identity_array, and test_verify_token_statuses_empty_array expect Ok for empty requests but now receive an envelope-version error. Make the shared fixture begin with the big-endian V1 envelope discriminator while preserving invalid-payload behavior, or replace the affected success fixtures with valid V1 proof fixtures.

pub fn mock_proof(size: usize) -> Vec<u8> {
    let mut proof = vec![0xAB; size];
    if proof.len() >= 4 {
        proof[..4].copy_from_slice(&1u32.to_be_bytes());
    }
    proof
}

source: gpt-6-astra (phase2-reviewer: general, ffi-engineer, rust-quality, security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: ffi-engineer); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: security-auditor); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: critical by gpt-6-astra (effort low) — This is a large, intricate cross-cutting change to cryptographic proof verification and peer-facing response deserialization, including identity double proofs and compacted address proofs in drive-proof-verifier and wasm-drive-verify.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — ffi-engineer (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (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 below 15% reserve: weekly 11% left, 5h 100% left), glm-5.3-flash (zai below 15% reserve: 5h 99% left, weekly 13% left)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/wasm-drive-verify/tests/common/mod.rs`:
- [SUGGESTION] packages/wasm-drive-verify/tests/common/mod.rs:7-10: Update WASM success-test fixtures for the new envelope requirement
  `mock_proof` still returns an all-`0xAB` buffer. The new public verification functions call `current_grovedb_proof` before Drive verification, so this buffer decodes as an unsupported envelope version rather than reaching the intended verification logic. In particular, `test_verify_multiple_identities_empty_array`, `test_verify_token_balances_empty_identity_array`, and `test_verify_token_statuses_empty_array` expect `Ok` for empty requests but now receive an envelope-version error. Make the shared fixture begin with the big-endian V1 envelope discriminator while preserving invalid-payload behavior, or replace the affected success fixtures with valid V1 proof fixtures.

In `packages/wasm-drive-verify/tests/identity_tests.rs`:
- [SUGGESTION] packages/wasm-drive-verify/tests/identity_tests.rs:104-106: Test envelope enforcement through public verification entry points
  The added WASM public-entry-point tests verify V0 rejection and that a truncated V1 envelope passes the policy gate, but they do not successfully verify a real V1 proof through a wasm-bindgen export. The recorded successful V1 vectors are exercised by `drive-proof-verifier`, not by these WASM exports. Consequently, a regression in copying the V1 payload from `Uint8Array` or in accepting a valid V1 proof after the discriminator would remain undetected. Add a real verifiable V1 fixture through at least one exported WASM verifier, while retaining the independent V0 rejection tests for both components of the identity double proof.

Comment thread packages/wasm-drive-verify/tests/identity_tests.rs
…oof in WASM

rs-sdk-ffi replays the rs-sdk vector directories through the FFI mock
handle, so the seven tests that hit the V0-only recordings get the same
ignore reason as their rs-sdk counterparts.

In wasm-drive-verify, the shared mock proof now starts with the
bincode-encoded V1 envelope discriminant so the empty-request success
tests still reach Drive, and a recorded V1 identity-balance proof from
the drive-proof-verifier corpus is verified through the exported
verifyIdentityBalanceForIdentityId, pinning its root hash and balance.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.84466% with 219 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.31%. Comparing base (91bee46) to head (7b80d8d).
⚠️ Report is 1 commits behind head on v4.2-dev.

Files with missing lines Patch % Lines
packages/rs-drive-proof-verifier/src/proof.rs 37.41% 87 Missing ⚠️
...verify_compacted_address_balance_changes/v1/mod.rs 62.00% 38 Missing ⚠️
packages/rs-drive-proof-verifier/src/verify.rs 54.71% 24 Missing ⚠️
...s-drive-proof-verifier/src/proof/document_count.rs 16.00% 21 Missing ⚠️
.../rs-drive-proof-verifier/src/proof/document_sum.rs 19.04% 17 Missing ⚠️
...drive-proof-verifier/src/proof/document_average.rs 25.00% 12 Missing ⚠️
...c/proof/token_perpetual_distribution_last_claim.rs 0.00% 8 Missing ⚠️
...ckages/rs-drive-proof-verifier/src/proof/groups.rs 75.00% 2 Missing ⚠️
...proof-verifier/src/proof/identity_token_balance.rs 50.00% 2 Missing ⚠️
...ve-proof-verifier/src/proof/token_contract_info.rs 0.00% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4701      +/-   ##
============================================
- Coverage     82.13%   81.31%   -0.83%     
============================================
  Files          2827     2827              
  Lines        387980   389862    +1882     
============================================
- Hits         318684   316998    -1686     
- Misses        69296    72864    +3568     
Components Coverage Δ
dpp 83.73% <ø> (-0.12%) ⬇️
drive 82.14% <62.00%> (-0.01%) ⬇️
drive-abci 83.29% <ø> (-1.05%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 66.08% <ø> (-4.83%) ⬇️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 32.62% <41.98%> (-17.16%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@QuantumExplorer QuantumExplorer changed the title fix(sdk)!: require V1 GroveDB proof envelopes fix(sdk)!: enforce a per-protocol-version minimum GroveDB proof envelope (V1 from v14) Sep 13, 2026
QuantumExplorer and others added 4 commits September 13, 2026 19:54
Replace the hard-coded "envelope must be V1" check with a per-protocol-
version floor: SystemLimits::minimum_grovedb_proof_envelope_version is 0
for every shipped protocol version and 1 from v14, and the gates reject
only envelopes below it. Newer envelopes pass the gate and fail in
GroveDB's own decoder if the client does not know them.

drive-proof-verifier reads the floor in supported_grovedb_proof_bytes
and verify_tenderdash_proof (platform_version is now threaded through),
wasm-drive-verify in supported_grovedb_proof for the JavaScript and
native entry points, and Drive's compacted address proof v1 for its two
nested proofs. The error now names the envelope version, the floor, and
the protocol version that set it.

Tests cover both sides of the boundary: v14 rejects V0, v13 still lets
it through, and V1 and newer pass the gate.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Both sides appended fields to SystemLimits: the time-range TTL pair from #4581 and the GroveDB proof envelope floor. Keep both, base fields first.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A policy rejection is not a corrupted proof, so Drive gains two
ProofError variants instead of reusing CorruptedProof:
InvalidGroveDBProofEnvelope when the bytes carry no decodable
discriminant, and UnsupportedGroveDBProofEnvelopeVersion when the
envelope is below the protocol version's floor. Both name which proof
was read (the proof, the predecessor proof, or the forward proof) so
the compacted address verifier can say which half failed.

wasm-drive-verify builds the same variants for its JavaScript and
native entry points, and drive-proof-verifier maps the version variant
onto its own Error::UnsupportedGroveDBProofVersion, which now carries
the proof label too, so SDK callers see one variant for direct and
nested rejections alike.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…lope

Gating the recorded V0 vectors took most of the FromProof paths out of
the offline suite, so add a table-driven regression that feeds a V0
GroveDB envelope to each direct-proof FromProof implementation at the
latest protocol version and expects the typed rejection. The provider
panics if touched, so a path that lost its gate fails loudly rather
than reaching Drive or the context provider.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reviewed

@QuantumExplorer
QuantumExplorer merged commit 49e5af6 into v4.2-dev Sep 13, 2026
16 of 17 checks passed
@QuantumExplorer
QuantumExplorer deleted the codex/require-v1-grovedb-proofs branch September 13, 2026 13:47
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.

2 participants