Repository navigation
refactor(platform): read a consumed document through generation 0's lookup and test the PV14 consume path - #5874
Conversation
…5 and pin consume fees Document reference validation 0 and the create conversion 0 are still what protocol version 14 runs. #5360 moved the consume tests to PlatformVersion::latest(), which now selects generation 1, so no test ran generation 0's contested arm (a ForceDeleteDocument for each consumed document). Breaking that arm would have left CI green. The plain, onlyWhenConsumed, contested and shared-bucket (ticket) consume tests now run at protocol versions 14 and 15. should_pin_the_fees_of_a_consume_through_a_plain_and_a_contested_create pins the processing fee, the storage fee and the commitment owner's refund at both versions. The DPNS v3 consume tests stay at latest(): DPNS v3 exists only from protocol version 15. Test would have caught a broken generation-0 contested arm. With the arm's delete loop skipped: - ✖ should_consume_a_commitment_its_owner_can_not_delete_through_a_contested_create fails with "expected the commitment consumed at 14". - ✖ the fee pin fails on its 14 row (refund 0, processing 2_600_980 where 3_489_420 is pinned). - The 15 row is unchanged, which is why the latest()-only tests missed the break. ✔ Both pass once the arm is restored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ookup (PV15) At protocol version 15, a refersTo lookup declaring consume read the document it found through query_documents_with_flags, in a copy of generation 0's lookup helper. The only reason was to carry ConsumedDocumentRead.storage_flags to the delete, and no delete operation carries those flags: GroveDB refunds a removed element by the flags stored on it. The flags plumbing was dead consensus surface, and the comments saying the delete refunds by those flags were wrong. Document reference validation 1 now reads every lookup through generation 0's fetch_document_through_lookup and keeps only the document: - ConsumedDocument.read is an Option<Document>. - ConsumedDocumentRead and the copied v1/lookup.rs are removed. - force_delete_read_document_for_contract_operations loses its storage_flags parameter, and its doc gains # Parameters and # Returns. - The read that #5360 saved stays saved: conversion 1 still deletes from the document the lookup read, without reading it again by id. No fee or state change at protocol version 15 or 14. Fees (processing, storage, refund) and the GroveDB root hash after seven consume flows were identical before and after this change, at both versions where a flow runs: - a plain create and a contested create - a ttl preorder chosen first among its competitors - a ticket sharing its index bucket with the one it consumes - a voucher found by a plain lookup - a DPNS v3 name, plain and contested (protocol version 15 only) The fee pins pass unchanged: - should_pin_the_fees_of_a_consume_through_a_plain_and_a_contested_create - should_pin_the_fees_of_a_reveal_choosing_the_first_of_its_preorders - should_charge_a_name_at_protocol_versions_14_and_15 should_delete_a_read_document_as_a_force_delete_does_less_its_read now compares the by-id delete, which carries the stored element's flags, with a read delete given none, and their operations are equal. The v15 note now says a consume pays for one read fewer, a saving that differs from create to create, rather than a fixed 10,660 credits. Refs #5360 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Text only, no code change. - Document reference validation 1 carried the replay-safety notes of the generation it was copied from: "in place in generation 0, which every table selects", "reached from protocol version 14 only". Generation 1 is selected only by protocol version 15, which has not shipped, so it needs no in-place argument. Those notes are removed. - Generation 0 of reference validation and of the create conversion said "which every table selects", which stopped being true when protocol version 15 selected generation 1 of both. That phrase is dropped. - The book said a consuming create pays for one read of the commitment. A chooseFirst scan can read it again, so the book now says one read fewer than before. Refs #5360 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 64fe5df) · triage: normal · Phase 2 only (queue backlog) |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-11-11T17:44:40.885Z |
|
@coderabbitai review |
Action performed
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (queue backlog)
Static verification of 7089480..64fe5df found no actionable in-scope issues. The shared lookup preserves validation and billing, stored-element flags remain authoritative for refunds, and the expanded tests cover PV14/PV15 consumption and fee behavior without changing historical execution. No builds or tests were run locally; current CI reports all completed code checks passing, including Rust workspace, wasm32, JavaScript, Swift, and Kotlin checks, with only review/hygiene checks pending.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The diff primarily simplifies the PV15 consume lookup and deletion plumbing and restores PV14 test coverage; despite its size and consensus-adjacent location, it does not clearly introduce a large or intricate change to consensus rules or storage behavior. - Phase 1 reviewers: not run (skipped for throughput: 13 PRs queued, above the 10 limit)
- Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
|
Bots are done — your move: post |
…the decision proposals contract `should_pin_the_fees_of_a_consume_through_a_plain_and_a_contested_create` came in with v5.1-dev (#5874) and pins the fee of a contested create at protocol version 15. On this branch the decision proposals contract, registered at genesis from 15, has a contested index of its own (`choice`), so the tree of contracts holding contests has one entry more and a write below it pays for the larger tree: 3_528_980 rather than 3_478_880. The plain create, the storage fee, the refund and every protocol version 14 figure are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Issue being fixed or feature implemented
Follow-up to #5360 (delete a consumed document from what its lookup read, PV15), fixing findings from its review.
refersTolookup declaringconsumeread the document it found throughquery_documents_with_flags, in a near-copy of generation 0's lookup helper, only to carryConsumedDocumentRead.storage_flagsto the delete. No operation the delete builds carries those flags: when it is not estimating, the flags only reach size inputs that are ignored, and GroveDB refunds a removed element by the flags stored on it. So the flags plumbing was dead consensus surface, and the comments saying the delete "refunds by" them were wrong.latest()(PV15, generation 1), so no test ran generation 0's contested arm (ForceDeleteDocumentfor each consumed document). A broken generation-0 delete loop would have kept CI green.What was done?
validate_document_references_v1callsfetch_document_through_lookup(query_documents) for every lookup and keeps only theDocumentit found:ConsumedDocument.readis nowOption<Document>.ConsumedDocumentRead,document_reference_validation/v1/lookup.rs(the 177-line copy), and thestorage_flagsparameter ofDrive::force_delete_read_document_for_contract_operations. The read delete passes the document with no flags.# Parametersand# Returnssections.CONSUME_PROTOCOL_VERSIONS):should_create_a_domain_revealing_its_writers_old_enough_commitment_and_consume_itshould_consume_a_commitment_its_owner_can_not_deleteshould_consume_a_commitment_its_owner_can_not_delete_through_a_contested_createshould_create_a_ticket_that_consumes_an_earlier_ticket_of_its_writer(both tickets share an index bucket, so this covers generation 0's add-then-delete order)should_pin_the_fees_of_a_consume_through_a_plain_and_a_contested_create, at 14 and 15.dpns_v3tests stay atlatest(). DPNS v3 exists from protocol version 15 only, and PV14 keeps DPNS v2 and its create trigger, so that flow cannot run at 14.refers-to-lookup.md) and the v15 note now say "one read fewer". AchooseFirstscan may read the commitment again, so a consume does not always pay for exactly one read.How Has This Been Tested?
No fee or state change. A temporary test (not committed) ran seven consume flows and printed the fee result and the committed GroveDB root hash after each consume. I ran it twice on the base commit, which gave the same output both times, and then once after the change. The output was identical before and after:
ttlpreorder,chooseFirstshould_pin_the_fees_of_a_consume_through_a_plain_and_a_contested_create(new; plain and contested, at 14 and 15)should_pin_the_fees_of_a_reveal_choosing_the_first_of_its_preorders(ttlpreorder)should_charge_a_name_at_protocol_versions_14_and_15(DPNS v3)should_delete_a_read_document_as_a_force_delete_does_less_its_readnow compares the by-id delete, which carries the stored element's flags, with a read delete given none. Their operations are equal.Restored PV14 coverage, red → green. I removed the delete loop of generation 0's contested arm (
document_create_transition.rs, conversion 0) on purpose:should_consume_a_commitment_its_owner_can_not_delete_through_a_contested_createfailed with "expected the commitment consumed at 14".latest()-only tests could not catch this.Local gate:
cargo test -p drive --lib: 4406 passed, 0 failed, 6 ignored.RUST_MIN_STACK=4194304 cargo test -p drive-abci --lib: 4628 passed, 0 failed, 17 ignored.cargo clippy -p drive -p drive-abci -p platform-version --all-features --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.Breaking Changes
None. PV15 fees and state are unchanged (see above), and PV14 and earlier run no changed code. PV15 has not been released or activated on any network.
In-place changes to shipped generations
Tests and comments only:
DRIVE_ABCI_VALIDATION_VERSIONS_V1–V10, protocol versions ≤ 14): comment text only ("which every table selects" dropped). No code changed.DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V1–V4, protocol versions ≤ 14): comment text only. No code changed.Drive::force_delete_read_document_for_contract_operationsis called only by create conversion 1, which only PV15 selects. Itsstorage_flagsparameter is removed, and generation 0 of every method is untouched.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
64fe5df/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit
New Features
Documentation