Skip to content

feat(platform)!: destroy a frozen identity's escrowed listings with its funds (PV16) - #5532

Open
QuantumExplorer wants to merge 93 commits into
claude/token-market-historyfrom
claude/token-market-frozen-escrow
Open

QuantumExplorer wants to merge 93 commits into
claude/token-market-historyfrom
claude/token-market-frozen-escrow

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: Closes a loophole the marketplace opened in freezing. A token issuer can freeze an account and then destroy the frozen funds. But tokens an account has listed for sale sit in escrow, not in its balance, so until now they escaped the destroy. From protocol version 16 (the 5.2 line, where the marketplace starts) destroying frozen funds also destroys what the frozen account's open listings hold, and deletes those listings.

Value: Freezing and destroying keep working as issuers expect: someone holding stolen or sanctioned tokens cannot shield them from destruction by listing them before the freeze lands.

Risks: Low-medium. A destroy at protocol version 16 reads the frozen account's listings (a small extra read, charged) and, when there are any, destroys at most 16 per transition, oldest first, so its work stays bounded. Protocol version 15 (the released 5.1 line) and earlier do not change: the read, the new conversion, the limit and the batch lowering that deletes the listings together are selected only by protocol version 16's tables, and no shipped generation is edited. The account's offers hold credits, not tokens, and are left alone.

Issue being fixed or feature implemented

The sixth PR of the token marketplace stack, gated at protocol version 16, on top of #5531 (history). The marketplace moved to 5.2 (protocol version 16, #6253); this PR merged that move and its note is now v16 note 8 (was v15 note 20; #6433 took v16 note 3, #6354 note 4). A frozen account's listings cannot be filled (the listing PR refuses fills of a frozen maker), but nothing could remove the tokens they hold short of the account cancelling them itself.

What was done?

Frozen identity: balance 5,000, listings of 3,000 and 2,000
Before (15's rules): TokenDestroyFrozenFunds burns 5,000; 5,000 stays in escrow, untouchable
After (16):          it burns all 10,000, deletes both listings, records destroyedAmount 10,000
  • Read (DriveTokenOrderEscrowMethodVersions.fetch_frozen_listings, None before 16, Some(0) in DRIVE_TOKEN_METHOD_VERSIONS_V3, which only DRIVE_VERSION_V11, protocol version 16's, selects): Drive::fetch_frozen_token_listings reads the frozen identity's open ask documents of the token through the byOwner index ($ownerId, tokenId, $createdAt), oldest first, at most SystemLimits::max_frozen_listings_destroyed_per_transition (16). With None it refuses with VersionNotActive; the transformer does not call it there (read_frozen_listings returns no listings before 16), and from 16 calls it, and bills the read, only for a signature that performs the destroy or proposes it as a group action: a group signature that does neither records and destroys nothing.
  • Action: TokenDestroyFrozenFundsTransitionActionV0 carries frozen_listings: Option<FrozenListings>, the listings with the token market contract their documents are deleted from, None when there are none. destroyed_amount() is the balance plus every listing's remaining, one checked sum, which the converter, the history and the group event all use.
  • Conversion (token_destroy_frozen_funds_transition 1, in the new DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V6 that DRIVE_VERSION_V11 selects; DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V5, protocol version 15's, keeps 0): without listings it is generation 0. With listings, one new op TokenDestroyFrozenHolding burns the balance, removes each listing's escrow and lowers the supply once by the destroyed total the converter passes it (so the repeated-write guard sees each key once; it refuses a burn generation other than token.update.burn 0, so a new burn generation has to decide this case too); a DeleteDocument per listing deletes its ask document, each built against the batch's operations before it (below), so index trees the listings share (a price bucket, a $createdAt bucket, the owner's bucket) are removed and refunded to whoever paid for them; the history and group-action events record the total.
  • Raw converter: earlier rounds added a convert_drive_operations_to_grove_operations 2 here. v5.2-dev ships its own generation 2 at protocol version 15 (sibling history deletes share their pending lifecycle container), so that one is kept unchanged. It already passes the batch's earlier operations to the lowering, so at 16 it builds document operations against them too (should_remove_a_shared_tree_through_the_raw_converter). This PR's other raw converter additions (refusing repeated token writes, merging repeated balance writes) are left out: they would need a new generation 3 for protocol version 16, and no platform code calls the raw converter (the proposer payout credits through apply_drive_operations).
  • Shared read: both transformer routes read and bill the listings through one helper, read_frozen_listings.
  • Batch boundary (lower_document_operation, a new DriveBatchOperationsMethodVersion field: 0 in every table through DRIVE_VERSION_V10, 1 in DRIVE_VERSION_V11): DocumentOperationType::into_low_level_drive_operations_after_ttl_drain reads it. At 0 it behaves exactly as v5.2-dev's: only a delete of a type that keeps history is built against the batch's earlier operations. At 1 every document insert, update and delete is (AddDocument, UpdateDocument, DeleteDocument, ForceDeleteDocument, ForceDeleteReadDocument). A delete therefore sees the batch's earlier writes as pending: one batch destroying a frozen identity's listings of two tokens removes the owner's shared byOwner bucket and refunds it, and an insert into a tree an earlier delete of the batch empties keeps the tree. apply_drive_operations 2 and convert_drive_operations_to_grove_operations 2, protocol version 15's generations, are not edited: they already pass the batch to the lowering. Earlier rounds extended apply_drive_operations 2 in place; it shipped in 5.1, so the change now lives behind the field. Grouped document operations (MultipleDocumentOperationsForSameContractDocumentType) stay built against the group alone at both values: an insert built against the batch can rewrite the batch's earlier operations, so the group's could not be told apart from them; no market flow uses them. This is the latent defect batched_group_drain and SystemLimits::max_transitions_in_documents_batch document (unreachable through a transition while that cap is 1): its five specification cases, #[ignore]d on v5.2-dev, run and pass at the latest version, and the phantom-group characterization is pinned to protocol version 15.
  • Groups: a group destroy reads the listings at every signature, and the one that completes it destroys what the frozen identity holds then, as generation 0 already does with the balance (its state validation compares only the frozen identity, not the amount). A frozen identity can still cancel a listing, but that moves the escrow into the balance, so a cancel between the signatures can only make the destroy larger: the balance takes the cancelled escrow and the next listing joins the oldest 16. Binding the completion to the proposed amount would let the frozen identity block every group destroy with one cancel.
  • Limit: max_frozen_listings_destroyed_per_transition is Option<u16>: None in every shipped table (V1 to V5, backfilled), Some(16) in the new SYSTEM_LIMITS_V6, which PLATFORM_V16 selects. More listings need one more destroy each 16.
  • Docs: book "Frozen accounts" and "History" sections (a destroy closes the listings it takes without a record per order); v16 note 8, the DRIVE_VERSION_V11, SYSTEM_LIMITS_V6 and field comments.

How Has This Been Tested?

  • After the move to protocol version 16: cargo test -p drive --lib -- frozen batch_document_writes order_escrow drive_op_batch batched_group_drain (the drain suite 10 passed, five cases un-ignored at 16 and the phantom pinned at 15), cargo test -p drive-abci --lib -- marketplace frozen destroy_frozen token_history (121), cargo test -p drive-abci --lib -- shielded::nullifier_batch_guard, and destroy_frozen_funds::should_destroy_frozen_funds_through_the_transformer_before_protocol_version_16 at 14 and 15. Tests of earlier rounds that pinned behaviour now left out are removed: should_insert_through_a_group_into_a_tree_an_earlier_deletion_empties (grouped operations stay on their own) and the raw converter generation 2 tests (should_refuse_repeated_token_writes, should_merge_repeated_balance_writes_from_protocol_version_15).

  • cargo test -p drive-abci --lib -- batch::tests::token::marketplace::frozen:

    • a frozen identity with a 5,000 balance and listings of 3,000 and 2,000: one destroy leaves balance 0, both escrows and listings gone, supply down 10,000 and balanced, destroyedAmount 10,000 recorded;
    • 17 listings at increasing block times: the first destroy takes the 16 oldest, the newest waits, the second takes it, supply balanced each time;
    • a frozen identity's offer keeps its credits.
  • cargo test -p drive-abci --lib -- destroy_frozen_funds batch::tests::token perform_events_on_first_block_of_protocol_change (every existing destroy test now goes through generation 1 with no listings).

  • cargo test -p drive --lib -- verify::state_transition drive_op_batch state_transition_action::batch order_escrow; cargo test -p platform-version.

  • Review round 1:

    • marketplace::frozen::should_remove_and_refund_the_index_trees_destroyed_listings_shared: two listings at one price in one block, which share index buckets: the 24 ask trees and items they make shrink, after the destroy, to the same 3 that cancelling the two one by one leaves, and the frozen owner's refund is at least what those cancels refund (the destroy also shrinks the burned balance item). (Before the batch-context change below, deletes built blind to each other left 16 trees and about half the refund.)
    • converter dispatcher tests: at protocol version 15 (generation 0; 14 before the move) the nonce, the burn of the balance and its history, also for an action carrying listings, and a group proposal that does not perform (the group action with its event, no burn) and the completing signature (closes it, burns); at the latest version the holding destroy, the deletes of both listings in order and the history of everything destroyed;
    • fetch_frozen_token_listings::tests::should_refuse_to_read_frozen_listings_before_protocol_version_16: at protocol version 15 the read refuses with VersionNotActive; the destroy there does not call it (review round 6 runs the destroy itself at 14).
  • Review round 2, apply_drive_operations::v2::tests::batch_document_writes:

    • one owner's asks of two tokens deleted by two operations of one batch leave the ask trees that deleting them in two batches leaves, with no tree keyed by the owner;
    • a deletion emptying a bucket and an insert into the same bucket in one batch apply, and leave the trees of the new ask alone;
  • cargo clippy on platform-version, drive, drive-abci.

  • Review round 3:

    • batched_group_drain: the five drain specifications (two deletes in either order, under the shipped batching config, batched against sequential, a two-document move) run un-ignored at the latest version; a_batched_drain_leaves_a_phantom_group_that_verifies_and_proves applies its batch at protocol version 14 and still finds the phantom;
    • batch_document_writes::should_insert_through_a_group_into_a_tree_an_earlier_deletion_empties: a deletion and a grouped insert into the same bucket apply and leave the new document's trees alone (it failed with an insertion order error when grouped operations started a fresh accumulator);
    • converter at the latest version in a group with listings: a non-performing proposal records the balance plus escrow (500) and destroys nothing; the completing signature closes the action, destroys the holding, deletes both listings and records the total.
  • Review round 4, marketplace::frozen::should_destroy_at_least_what_a_group_proposed_after_the_frozen_identity_cancels: a group of two must sign the destroy; the frozen identity has 17 listings of 10, 20, ... 170 and 100 in its balance. The proposal destroys nothing; the frozen identity then cancels its oldest listing (balance 110); the completion leaves balance 0, destroys the 16 listings left (the newest, past the limit at the proposal, included), lowers the supply by everything the identity held (1,630, more than the 1,460 proposed) and records 1,630.

  • Review round 5: apply_drive_operations::v2::tests::should_refuse_repeated_token_writes_through_the_raw_converter: at the latest version the raw converter refuses a frozen holding destroy naming one listing twice, and two destroys of one holding. The converter dispatcher tests (token_destroy_frozen_funds_transition::tests) pass with generation 0 in its own module (cargo test -p drive --lib -- token_destroy_frozen_funds_transition should_refuse_repeated_token_writes_through_the_raw_converter, 37 tests).

  • Review round 6 (a max code review of this PR):

    • destroy_frozen_funds::should_destroy_frozen_funds_through_the_transformer_at_protocol_version_14: a destroy at protocol version 14 goes through the shared transformer, reads no listings and burns the balance;
    • convert_drive_operations_to_grove_operations::v2::tests: the repeated token write refusal, matched by its message (the earlier test passed on any CorruptedCodeExecution, which the missing token tree also raised), and two credits to one identity: generation 1 (protocol version 14) writes the balance twice, generation 2 once with both;
    • summable_off_count_index_e2e_tests::should_refuse_two_likes_only_from_the_convert_generation_that_checks_counter_moves refuses at 14 and 15;
    • batched_group_drain: the two inverse-shape cases run at protocol version 14 (generation 1) and the latest;
    • the group destroy test reads the proposal's recorded amount (1,460) instead of comparing two constants;
    • converter tests: at the latest version without listings the operations equal generation 0's, alone and in a group; with listings a DeleteDocument per listing;
    • test fixtures shared: one market builder with an optional group member, the existing transfer and freeze helpers, one subtree walker in drive::util::test_helpers, asks built by TokenOrder::new_document.

In-place changes to shipped generations

  • The converter: generation 0's body moved as it was from the dispatcher into token_destroy_frozen_funds_transition/v0/mod.rs; generation 1 is a separate implementation. The dispatcher refuses, at generation 0, an action carrying listings (CorruptedCodeExecution), so the amount the shared history builders derive from the action always equals what generation 0 burns. No transformer builds such an action before protocol version 16 (fetch_frozen_listings is None), so no earlier block reaches the refusal.
  • SystemLimits V1 to V5, DriveTokenOrderEscrowMethodVersions in DRIVE_TOKEN_METHOD_VERSIONS_V1 and DriveBatchOperationsMethodVersion in DRIVE_VERSION_V1 to V10 gain a field (max_frozen_listings_destroyed_per_transition: None, fetch_frozen_listings: None, lower_document_operation: 0) whose value there selects what those versions already do.
  • DocumentOperationType::into_low_level_drive_operations_after_ttl_drain, which every version's batch lowering calls: it reads lower_document_operation, and at 0 (every version before 16) every arm passes exactly what it passed before: the batch's earlier operations to a delete of a type that keeps history, nothing to an insert or update or to another delete. An unknown value is refused with UnknownVersionMismatch.
  • TokenDestroyFrozenFundsTransitionActionV0 (in memory, never serialized) gains frozen_listings, None before 16.
  • The destroy transformer (TokenDestroyFrozenFundsTransitionActionV0's two transformer routes), which every protocol version runs: it calls read_frozen_listings, which returns no listings at once where fetch_frozen_listings is None (every version before 16), so no read is made or billed and the action is what it was. should_destroy_frozen_funds_through_the_transformer_before_protocol_version_16 runs a destroy through it at 14 and 15.
  • TokenTransitionAction::associated_token_event, reached at every version by build_historical_document: for a destroy it records destroyed_amount(), which equals the frozen balance wherever the action carries no listings (every version before 16). Its only consensus caller (token_history_operation) runs for the marketplace transitions alone.

Breaking Changes

Consensus, from protocol version 16: TokenDestroyFrozenFunds also destroys the frozen identity's escrowed listings and reads them first. Earlier protocol versions are unchanged.

Rust API of the drive crate (source-breaking for code that builds or reads these actions itself):

  • TokenTransitionAction::associated_token_event returns Result<TokenEvent, Error>: a destroy's event records destroyed_amount(), a checked sum that fails only on overflow. A caller handles the error.
  • TokenDestroyFrozenFundsTransitionActionV0 gains the public field frozen_listings: Option<FrozenListings> (the listings and the token market contract). A struct literal sets it to None before protocol version 16; the transformer fills it from 16.
  • TokenOperationType gains the public variant TokenDestroyFrozenHolding { token_id, holder_id, balance_amount, order_ids, destroyed_amount }, which removes the frozen balance and each listing's escrow and lowers the total supply once by destroyed_amount. The enum is not #[non_exhaustive], so an exhaustive match on it needs a new arm.

Rust API of the platform-version crate (source-breaking for struct literals of these tables, such as a custom or test PlatformVersion):

  • DriveTokenOrderEscrowMethodVersions gains the public field fetch_frozen_listings (None before protocol version 16, Some(0) from 16).
  • DriveBatchOperationsMethodVersion gains the public field lower_document_operation (0 before protocol version 16, 1 from 16).
  • SystemLimits gains the public field max_frozen_listings_destroyed_per_transition: Option<u16> (None before protocol version 16, Some(16) in the new SYSTEM_LIMITS_V6).

These are also listed in the Unreleased section of CHANGELOG.md.

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

…ts funds (PV15)

A frozen identity's open listings hold its tokens in escrow, out of the
balance a TokenDestroyFrozenFunds burns. From protocol version 15 the
destroy also reads the frozen identity's open listings of the token
(order_escrow.fetch_frozen_listings, byOwner index, oldest first, at most
max_frozen_listings_destroyed_per_transition = 16), destroys what they hold
with the balance through TokenDestroyFrozenHolding (one supply decrement),
deletes their ask documents and records the whole amount. Converter
generation 1 (DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V5) does this; v0's
operations are unchanged. Offers hold credits and are left alone.

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

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

Download the preview from the workflow artifacts.
To view locally: download the artifact, unzip, and open index.html.

Updated at 2026-12-03T16:48:49.054Z

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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 Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 6d7fe1f) · triage: critical

@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 PV15 gates and combined balance/escrow burn appear correct on inspection, but the listing deletions lose pending batch context, leaving empty index structures and withholding their storage refunds. Historical-path coverage and generation isolation also need improvement. This was static verification at head 2a7d869; current reported CI checks pass, but none reports a dedicated Rust test result.

🔴 1 blocking | 🟡 4 suggestion(s)

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: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); 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) — This is a large, intricate change to consensus-critical token destruction, escrow removal, supply accounting, state-transition version dispatch, and persisted storage operations in files such as token_destroy_frozen_funds_transition.rs and the Drive batch operation code.
  • 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. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs`:
- [BLOCKING] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs:146-155: Preserve pending operations across the listing deletions
  Each listing becomes a separate DeleteDocument, whose lowering in util/batch/drive_op_batch/document.rs passes None for previous_batch_operations. apply_drive_operations_v1 lowers all operations before applying the batch, so each deletion still sees the other listings in storage. With two listings at the same price, neither deletion prunes their shared depth bucket; byOwner ancestors also remain, and listings sharing a creation timestamp leave their shared timestamp buckets behind. The documents and escrow disappear, but empty index trees remain and the identities that paid for those trees do not receive their storage refunds. Both the pinned and current GroveDB implementations already support pending-operation-aware pruning. Build these deletions together in Drive's document-operation lowering and pass the accumulated low-level operations to each deletion, following AddDocumentAndDeleteConsumed, without changing historical protocol paths. Add a regression asserting shared-index cleanup and the associated refunds, not only document absence and token conservation.
- [SUGGESTION] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs:35-38: Add behavioral coverage for the pre-PV15 dispatcher path
  Generation 0 now delegates to the shared helper, and both transformers call the new version-gated listing fetch. The existing destroy integration tests and the new marketplace tests use PlatformVersion::latest(), so they exercise generation 1; the action accessor tests do not exercise conversion. Comparison with the base revision shows the generation-0 operation sequence is currently preserved, but no behavioral test protects that claim. Add a dispatcher-level test pinned to PlatformVersion::get(14) that verifies nonce, burn, history and group-action operations, including perform_action=false. Also verify that the historical listing-fetch gate returns an empty result at zero cost without marketplace state. This supplies the historical regression evidence required by the book's in-place-change checklist.
- [SUGGESTION] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs:35-38: Keep the converter generations structurally separate
  The version tables correctly select generation 1 only for PV15, and the false branch currently preserves generation 0's output. However, both generations execute the same listing-aware body through a destroy_listings flag. book/src/versioning/versioned-dispatch.md explicitly calls for separate generation implementations and identifies a shared helper with a flag as the pattern that separation replaces. Retain the balance-only implementation in generation 0 and put the listing-aware implementation in generation 1, selected by the existing table bump. This makes historical replay independent of later edits to PV15 operation ordering, history and group events. This is a structural replay-safety concern, not evidence of a current PV14 behavioral difference.
- [SUGGESTION] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs:64-68: Avoid cloning the owned action's listing vector
  This helper owns self but clones every escrowed TokenOrder into a new vector. The following code only reads those orders and collects their id/remaining pairs, so the allocation and full-order copies are unnecessary on each listing-aware destroy. Borrow the listing slice until its final use, adjusting the loop accordingly, or move the vector out of the owned action. The borrow can end before public_note_owned consumes self.

In `packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs`:
- [SUGGESTION] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs:151-166: Share the new listing-fetch and billing sequence
  The owned constructor's fetch, processing-fee update and optional market-contract lookup are repeated in the borrowed constructor at lines 318–333. These operations have identical semantics; only the frozen identity argument needs dereferencing. Keeping this new sequence in two places makes later changes to fee accounting or contract handling liable to diverge between transformation routes. Extract a helper used by both constructors that returns the listings, optional contract and read cost, or updates the FeeResult. This is a maintainability suggestion rather than a layer-ownership or current correctness violation.

QuantumExplorer and others added 3 commits October 22, 2026 10:16
…rozen-escrow

fetch_frozen_listings joins the escrow methods as an OptionalFeatureVersion (None in V1, Some(0) in V3); DRIVE_VERSION_V10 keeps both sides' changes.

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

- New document operation DeleteDocuments: several documents of one type
  deleted in one conversion, each delete built against the ones before it,
  so index trees they share are removed and refunded. Generation 1 of the
  destroy-frozen-funds converter deletes the listings through it; separate
  DeleteDocuments each read the others as stored and left shared trees
  behind, unrefunded.
- The converter's generation 0 is restored to its shipped implementation;
  generation 1 is its own function, and collects only the (id, remaining)
  pairs it needs instead of cloning the orders.
- Both transformer routes read and bill the listings through one helper.
- Tests: two listings sharing index buckets destroyed together leave the
  ask trees cancelling them one by one leaves and refund at least as much;
  dispatcher tests at protocol version 14 (nonce, burn, history, group
  proposal and completion) and 15; the listing read at 14 returns none at
  zero cost.

Co-Authored-By: Claude Opus 5.5 <[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 086cbf0, four prior findings are fixed, but pending-operation context still stops at each DeleteDocuments operation, leaving shared index trees and their refunds behind when one batch destroys holdings of two tokens. Current reported CI checks pass, although they provide no dedicated Rust test or clippy results; this verification was static only.

🔴 1 blocking

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: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); 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 intricate changes in token_destroy_frozen_funds_transition.rs and the TokenDestroyFrozenHolding batch operation alter consensus-critical destruction of balances, escrow holdings, and token supply, together with batch-aware listing deletion and storage refunds.
  • 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. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive/src/util/batch/drive_op_batch/document.rs`:
- [BLOCKING] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:635-644: Preserve pending operations across the listing deletions
  The grouped deletion fixes shared-tree pruning within one destroy, but this fresh vector excludes deletions from other operations in the same batch. A valid BatchTransition can destroy one frozen identity's holdings of two tokens from distinct contracts controlled by the signer: their contract nonces, token balances, supplies and escrows are distinct, so the nonce validation and repeated-token-write guard permit this. Conversion emits two DeleteDocuments operations, and apply_drive_operations_v1 lowers both before applying either. Their listings share the marketplace's byOwner/$ownerId index bucket. Each group sees the other token's subtree still in storage, so neither prunes the shared owner bucket; execution removes the listings but leaves empty index structure and withholds its storage refund. Your regression verifies the single-token case, not this enclosing-batch boundary. Thread relevant accumulated operations through document lowering, or coalesce compatible deletion groups in a PV15-only path. Both pinned and current GroveDB already support pending-aware pruning. Add a two-token, two-contract destroy-batch regression comparing remaining index paths and owner refunds with sequential destroys.

QuantumExplorer and others added 5 commits October 22, 2026 11:20
…atch's earlier operations

apply_drive_operations 2 (protocol version 15, unreleased, extended in
place) builds every operation against the operations of its GroveDB batch
built before it and appends its own
(DriveOperation::append_low_level_drive_operations_after_ttl_drain). Every
document insert, update and deletion, DeleteDocuments included, gets them as
previous_batch_operations: one batch destroying a frozen identity's
listings of two tokens removes the owner's shared byOwner bucket and refunds
it, and an insert into a bucket an earlier deletion of the batch empties
keeps the tree. Protocol version 14 and earlier keep generation 1.

Co-Authored-By: Claude Opus 5.5 <[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

Verified the complete diff at 5429998 and confirmed that all six prior findings are fixed. One blocking issue remains: pending-aware batch lowering fixes behavior that an existing non-ignored test still asserts is defective; two non-blocking gaps concern grouped-operation context and PV15 group-action coverage. Validation was static only; current CI checks pass, but none reports the native Drive test suite.

🔴 1 blocking | 🟡 2 suggestion(s)

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: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: 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) — The large, intricate diff changes consensus-critical token destruction and escrow accounting in token_destroy_frozen_funds_transition.rs and shared pending-write batch semantics in apply_drive_operations/v2/mod.rs.
  • 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
  • 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, 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. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs`:
- [BLOCKING] packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs:134-138: Update the ranked-drain test that still asserts the pre-PV15 defect
  Passing the enclosing batch's pending operations also fixes the ranked-index drain characterized by the non-ignored `a_batched_drain_leaves_a_phantom_group_that_verifies_and_proves` test in `packages/rs-drive/src/drive/contract/insert/insert_contract/v0/tests/batched_group_drain.rs:577`. Its helpers select `PlatformVersion::latest()` and call `apply_drive_operations`, so they now use this path. The second deletion sees the first pending deletion and prunes the empty `beta` group, but the assertion at lines 594–599 still requires both `alpha` and `beta` to remain. This leaves a failing test in the native Drive suite, outside the targeted filters listed in the PR description. Retain the old characterization under PV14 if historical coverage is needed, and update or enable the desired-behavior drain cases for PV15.

In `packages/rs-drive/src/util/batch/drive_op_batch/document.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:590-601: Preserve enclosing batch context through grouped document operations
  The new append path preserves enclosing batch context for individual document operations but drops it for `MultipleDocumentOperationsForSameContractDocumentType`. That variant reaches this fallback, and its existing lowering starts a fresh accumulator at line 1011. Its inserts and updates therefore see only their group's predecessors. Expressing the replacement insert in `should_insert_into_a_tree_an_earlier_deletion_of_the_batch_empties` as a one-member grouped `AddOperation` exposes the gap: the earlier deletion schedules removal of shared index trees, while the grouped insert sees those trees in storage but cannot cancel their pending removal. The marketplace's current `DeleteDocuments` path is fixed, but the shared API's pending-context guarantee still depends on how equivalent writes are packaged. Pass the enclosing accumulator through grouped lowering and add the grouped equivalent of the delete-then-insert regression. This is a completeness gap in the shared batch abstraction, not a violation of layer ownership.

In `packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs`:
- [SUGGESTION] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs:428-430: Exercise PV15 group actions with escrowed listings
  The listing-aware dispatcher test constructs only an ungrouped, performing action. The new group-action dispatcher tests select PV14, and the existing latest-version group integration tests contain no listings. No test therefore protects generation 1's combination of a listing-inclusive group event and deferred execution: recording only the liquid balance in that event would pass the current tests. Add latest-version cases with nonempty listings for a non-closing proposal and a completing signature. Assert that the proposal records the balance-plus-escrow total without emitting holding destruction, document deletion or history, and that completion closes the group action and emits the listing destruction and total-valued history.

QuantumExplorer and others added 2 commits October 22, 2026 14:26
…erations see the batch

- apply_drive_operations 2 builds the operations of a
  MultipleDocumentOperationsForSameContractDocumentType group against the
  enclosing batch's operations too, instead of a fresh accumulator.
- batched_group_drain: the five drain specifications, #[ignore]d as a latent
  defect while the documents batch cap is 1, run and pass at the latest
  version; the phantom-group characterization applies its batch at protocol
  version 14 (generation 1). The module, case and SystemLimits docs say
  protocol version 15 removes the hazard and that the cap's other
  dependencies still stand.
- Tests: a deletion and a grouped insert into the same bucket in one batch;
  the frozen-funds converter at the latest version in a group with
  listings (proposal records balance plus escrow, completion destroys and
  records the total).

Co-Authored-By: Claude Opus 5.5 <[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

The complete diff at the requested head has no blocking consensus, accounting, security, or historical-replay defects. Two non-blocking improvements remain: make the new batch append match exhaustive for the currently delegated variants, and add coverage for destroying partially filled listings. Available CI checks pass, although the supplied snapshot does not include native Rust test results.

🟡 2 suggestion(s)

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: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: 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 consensus-critical change that alters protocol-versioned state-transition logic, token destruction and escrowed-fund movement, listing deletion, supply accounting, and persistent GroveDB operations.
  • 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
  • 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, 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. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive/src/util/batch/drive_op_batch/document.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:654-665: Match remaining document operations explicitly instead of a wildcard
  The new append path handles inserts, updates, deletions, and grouped writes with the enclosing batch as pending context, but the trailing wildcard delegates `AddContestedDocument`, `AddWithdrawalDocument`, and `DocumentHistory` to the standalone lowering path. That is the current intended behavior for those variants, but the wildcard removes exhaustiveness checking: a future `DocumentOperationType` variant would silently bypass the pending-aware path. Enumerate the three remaining variants explicitly so every new document operation requires an intentional pending-context decision.

In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/marketplace/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/marketplace/mod.rs:2593-2602: Exercise destruction after a listing has been partially filled
  The new frozen-listing tests create each order with `TokenOrder.amount` equal to `TokenOrder.remaining`, so they cannot distinguish burning the original listing amount from burning only the escrow still present. The implementation currently uses `remaining`, but both fields share the same type and a regression to `amount` would pass these tests. Add a partial-fill case before freezing—such as filling 1,000 tokens from a listing—and assert that destruction lowers supply and records history by the remaining amount, preserves the counterparty's purchased tokens, and removes the remaining escrow and document.

@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 c832240, the PV15 frozen-listing destruction path preserves historical dispatch and propagates pending operations through document application; all 11 prior findings are addressed in source. One non-blocking consistency gap remains in the alternate raw batch-conversion API. Current reported CI checks pass, but they do not establish native Drive or Drive-ABCI test success; this verification was static-only.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-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: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 15: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 16: 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 large, intricate diff changes consensus-critical protocol-version dispatch, token supply destruction, escrowed funds movement, and persistent document/index deletion in functions such as token_destroy_frozen_funds_transition and apply_drive_operations.
  • 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
  • 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, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — architecture-layering (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, 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
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 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/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v2/mod.rs:134-141: Share pending-aware lowering with the raw batch converter
  The application path now preserves enclosing batch context, but the public convert_drive_operations_to_grove_operations API still selects generation 1 at PV15, delegates to generation 0, and lowers each operation independently. In particular, each newly added DeleteDocuments operation starts a fresh accumulator in document.rs. Converting two such operations for one owner's asks of different tokens therefore still leaves their shared byOwner bucket behind: neither group sees the other's pending deletions. Existing RawConversion document tests establish that document batches are supported by this API. This is a non-blocking completeness gap in Drive's shared batch abstraction, not a misplaced-layer violation or a blocker for marketplace execution: the current production caller converts identity payouts, not documents. Add a PV15 raw-converter generation that uses the pending-aware accumulator, preserves the existing debt and ephemeral-operation refusals, and exercises the two-token cleanup case through both entry points.

QuantumExplorer and others added 2 commits October 22, 2026 23:19
… batch's earlier ones at protocol 15

convert_drive_operations_to_grove_operations 2, selected by DRIVE_VERSION_V10,
is generation 1 (repeated counter moves refused, TTL preparation) with every
operation appended through append_low_level_drive_operations_after_ttl_drain,
as apply_drive_operations 2 does, so two deletions emptying a shared index
tree remove it on this entry point too. Credits that repaid a debt and
ephemeral operations are refused as before. New test: one owner's asks of
two tokens deleted through the converter leave the trees deleting them
separately leaves.

Co-Authored-By: Claude Opus 5.5 <[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

The PV15 frozen-listing destruction path is correctly gated, preserves pre-PV15 behavior, and uses pending-aware document lowering with checked accounting. Two non-blocking issues remain: the new listing query performs stateful work during approximate CheckTx transformation, and destroyed-amount history calculation remains an unversioned shared helper. The available CI snapshot shows no relevant Rust build or test failure; the cancelled duplicate Kotlin run is superseded by a successful run.

🟡 2 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: 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 to consensus-critical state-transition, token destruction, escrow, storage, version-dispatch, and funds-movement logic, including deleting listings and burning their held tokens.
  • 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
  • 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, 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. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs`:
- [SUGGESTION] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs:352-387: Avoid stateful frozen-listing reads during CheckTx cost approximation
  (existing thread: https://github.com/dashpay/platform/pull/5532#discussion_r4372880155)
  `read_frozen_listings` does not receive or inspect `approximate_without_state_for_costs`, so once protocol 15 is active it performs a real `fetch_frozen_token_listings` query and decodes up to 16 listing documents even during CheckTx and recheck transformation. The destroy transformer's state authorization runs later, allowing a correctly signed and funded but unauthorized request to trigger this bounded RocksDB and document-decoding workload before block validation rejects it. Existing marketplace reads do not make this newly introduced path harmless; either use a deterministic approximation for this read and its bounded maximum cost, or establish a tracked shared policy that deliberately permits these stateful CheckTx reads across all marketplace transformations.

In `packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/mod.rs:22-40: Keep destroyed-amount history logic in versioned generation modules
  (existing thread: https://github.com/dashpay/platform/pull/5532#discussion_r4371810198)
  `destroyed_amount()` is consensus-visible because its result is written into token-history documents and group-action events, and it is also used by the PV15 converter. The helper has no `PlatformVersion` dispatch and derives its behavior directly from the optional listing field, while `associated_token_event()` and historical-document construction also call it without selecting a generation. The generation-0 converter refusal protects the normal PV14 transformer path, but it does not make the shared public history API generation-aware. Keep the balance-only and listing-inclusive calculations behind generation-owned implementations selected by the existing converter version, or thread the active platform version through the shared history builders.

QuantumExplorer and others added 2 commits October 31, 2026 05:13
…ken-market-frozen-escrow

The frozen listings note becomes v15 note 19, and its slot comments and the
batch estimate note cite it as 19.

Co-Authored-By: Claude Opus 5.5 <[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 the reviewed head, the PV15 activation gates, balance-plus-escrow accounting, history totals, and pending-aware document lowering address the prior blocking findings. One non-blocking CheckTx read-amplification suggestion remains applicable. This was a static review: current listed CI checks pass, but no targeted native Drive or Drive-ABCI test job is listed, and no builds or tests were run locally.

🟡 1 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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: security-auditor); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 10: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 11: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 15: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 16: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 17: 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) — The intricate changes in token_destroy_frozen_funds_transition/v1/mod.rs and TokenOperationType::TokenDestroyFrozenHolding alter consensus-executed token destruction, escrow removal, total supply accounting, and batched document deletion.
  • 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
  • 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, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — platform-versioning (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, 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
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 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/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs`:
- [SUGGESTION] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs:381-388: Avoid stateful frozen-listing reads during CheckTx cost approximation
  (existing thread: https://github.com/dashpay/platform/pull/5532#discussion_r4372880155)
  Keeping concrete listings for accurate deletion estimates is justified, but the current admission pipeline amplifies this new read: ordinary unsponsored Batch CheckTx transforms for advanced-structure validation, discards that action when full state validation is skipped, then transforms again for fee admission. This helper therefore performs two real index queries and decodes up to 32 listing documents before destroy authorization; recheck performs another query. Recording those costs in FeeResult does not collect or reserve them during admission. The fill/cancel point lookups are a relevant precedent for shared policy, but the group-action-info lookup already uses StatelessDirectQuery during approximation, so it does not establish the same precedent. The 16-document cap bounds each query, making this a hardening suggestion rather than a demonstrated denial-of-service vulnerability. Preserve the listing-dependent deletion estimate and protect the fan-out centrally in Drive-ABCI with a shared CheckTx work budget or equivalent admission control. If that policy is handled separately, link a tracking issue; none is present in the supplied discussion.

…e/token-market-frozen-escrow

SYSTEM_LIMITS_V5 sets both max_private_document_entry_size and
max_frozen_listings_destroyed_per_transition. The frozen listings note becomes
v15 note 20, and its slot comments and the batch estimate note cite it as 20.

Co-Authored-By: Claude Opus 5.5 <[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

Verified the complete diff at fe2d450 and revalidated all 31 prior findings. No actionable in-scope defect remains: PV15 activation, checked destruction totals, historical compatibility, and pending-aware document lowering are consistent with the implementation and regression assertions. This was a static review only; current PR checks pass, but the listed checks do not establish native Drive or Drive-ABCI regression-suite success.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); 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); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: 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) — The intricate change directly alters consensus-critical token destruction and escrow accounting in token_destroy_frozen_funds_transition/v1/mod.rs and convert_drive_operations_to_grove_operations/v2/mod.rs, including supply reduction and batched listing deletion.
  • 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
  • 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, 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. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

…into claude/token-market-frozen-escrow

apply_drive_operations 2 keeps this branch's document operations built against
the batch (append_low_level_drive_operations_after_ttl_drain) and lowers the
whole batch into EstimatedLayers::keeping_every_description, resolved once the
batch is lowered. The batch-document-write tests stay beside the estimate
tests; v10 and v15 note 14 keep this branch's word that picking the
description does not change how a batch is applied, as note 20 changes it.

Co-Authored-By: Claude Opus 5.5 <[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

Independently inspected the complete diff at fee5083 and found no remaining actionable in-scope findings. All 31 prior findings were revalidated: 28 are fixed, two are withdrawn, and one is outdated; PV15 activation, historical behavior, checked destruction accounting, and pending-aware document lowering are consistent with the source. Current published CI checks pass, but they provide no dedicated native Drive or Drive-ABCI test result; this verification was static, with no builds or tests run.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

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: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: 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) — The intricate changes in token_destroy_frozen_funds_transition/v1/mod.rs and apply_drive_operations/v2/mod.rs alter consensus-executed token destruction, escrow removal, supply accounting, and batched document deletion.
  • 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
  • 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, 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. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

…de/token-market-frozen-escrow

SYSTEM_LIMITS_V5 sets the private document store's chunk limits beside
max_frozen_listings_destroyed_per_transition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings the move to protocol version 16. Every PV15 table and shipped
generation is v5.2-dev's again (v15.rs, DRIVE_VERSION_V10,
SYSTEM_LIMITS_V5, DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V5,
apply_drive_operations 2, convert_drive_operations_to_grove_operations
2), and the frozen listings move to protocol version 16 tables (v16
note 6):

- DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V6:
  token_destroy_frozen_funds_transition 1, selected by DRIVE_VERSION_V11.
- SYSTEM_LIMITS_V6: max_frozen_listings_destroyed_per_transition
  Some(16), selected by PLATFORM_V16 (None backfilled in V1 to V5).
- DriveBatchOperationsMethodVersion::lower_document_operation, 0 in
  every table through DRIVE_VERSION_V10 and 1 in DRIVE_VERSION_V11: at 1
  the document lowering builds every insert, update and delete against
  the batch's earlier operations, instead of extending the shipped
  apply_drive_operations 2 in place. At 0 it passes what it passed
  before. Grouped document operations stay built against the group.
- batched_group_drain: the five drain cases run un-ignored at 16; the
  phantom group is pinned at 15.

The raw converter additions of earlier rounds (repeated token write
refusal, balance write merging in convert 2) are left out: v5.2-dev
ships its own convert 2 at 15, and nothing on the platform calls it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@QuantumExplorer QuantumExplorer changed the title feat(platform)!: destroy a frozen identity's escrowed listings with its funds (PV15) feat(platform)!: destroy a frozen identity's escrowed listings with its funds (PV16) Dec 1, 2026
QuantumExplorer and others added 2 commits December 2, 2026 05:29
Brings the new bincode tag of the tradeable mode with a minimum fill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#6433 took v16 note 3: the frozen listings note is v16 note 7. The
CHANGELOG entries of this PR move under Unreleased with the history ones,
reworded for protocol version 16 (SYSTEM_LIMITS_V6, lower_document_operation;
the raw converter's balance write merging is no longer part of this PR).

Co-Authored-By: Claude Opus 5.5 <[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

Nothing blocks: no blocking finding stands on this head.

New on this head: This head merges the marketplace’s move to protocol version 16 and ports frozen-funds destruction to the new tables, where it burns escrowed listings and deletes their documents in the same batch. The Kotlin SDK build and tests and the book preview passed; no native Rust test result was listed, and the review check was still pending.

🟡 3 suggestion(s) | 💬 1 nitpick(s)

Still open from earlier rounds (2)

  • 🟡 Suggestion: Retain repeated token-write protection in the PV15 raw converter — packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-27 (thread)
  • 🟡 Suggestion: Preserve pending context for contested document writes — packages/rs-drive/src/util/batch/drive_op_batch/document.rs:651-657 (thread)
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: Deleting the last two index-only rows in one PV16 batch can leave their shared bucket behind
Impact: A direct Drive caller deleting both remaining rows from a non-preallocated index bucket can leave the empty bucket in storage and miss its refund.
packages/rs-drive/src/util/batch/drive_op_batch/document.rs:1032-1041

Both rows can disappear without the shared bucket being pruned. The append path at the last full review forwarded the enclosing operations for DeleteIndexOnlyDocument; the PV16 replacement passes None. For two distinct rows in a bucket with no counter-move index, both commitment checks can pass, but the index-removal walker cannot count the sibling's pending deletion when deciding whether the parent is empty. This affects direct Drive batches, not user-submitted batches under the one-transition cap. Forward pending operations for this arm in generation 1, or narrow the PV16 note and SystemLimits guidance to say which deletions are covered.

source: grok-4.7 (phase2-reviewer: general, security-auditor); gpt-6.2-astra (phase2-reviewer: architecture-layering, platform-versioning, rust-quality)

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: rust-quality); reviewer 3: grok-4.7 (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: grok-4.7 (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate consensus-critical change that alters protocol-versioned token destruction, escrowed funds movement, supply accounting, and persistent listing deletion in the token state-transition and Drive operation paths.
  • 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)
  • New since the last final review (fee50837): 1 suggestion(s) on unchanged code listed as follow-up candidates
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: grok-4.7 (standing in for gpt-6.2-astra) — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, grok-4.7 (standing in for gpt-6.2-astra) — security-auditor (completed, effort high); 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 don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- 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/src/util/batch/drive_op_batch/document.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:574-591: PV15 and PV16 share the document branches that decide which pending writes count
  Impact: A future change meant only for PV16 can affect historical lowering because both generations' pending-context decisions live in the same operation arms.
  The new selector makes reviewers verify the historical path arm by arm. It selects a boolean, then mixes generation-0 and generation-1 policy throughout one match. The false branches preserve the base behavior today; this is not a current replay failure. The book's versioned-dispatch rule calls for generation-owned behavior rather than a shared implementation with a flag. Dispatch to generation-owned pending-context decisions and keep the mechanics common where they are identical.
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:651-657: Preserve pending context for contested document writes
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4365747230)

In `packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs`:
- [NITPICK] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs:226-228: The historical destroy tests are labeled with the wrong protocol versions
  Impact: A maintainer filtering tests by protocol version can select a PV15 refusal test labeled PV16 or miss the PV15 group test labeled PV14.
  The PV16 port updated both historical cases to use `pv15()`, but their names say PV16 and PV14. The equivalence test also names its latest and PV15 results `at_15` and `at_14`. The assertions exercise the intended tables; rename the historical tests to PV15 and use `at_latest` and `at_15` for the comparison.

In `packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-27: Retain repeated token-write protection in the PV15 raw converter
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4395374803)

Comment on lines +574 to +591
let builds_against_batch = match platform_version
.drive
.methods
.batch_operations
.lower_document_operation
{
0 => false,
1 => true,
version => {
return Err(Error::Drive(DriveError::UnknownVersionMismatch {
method:
"DocumentOperationType::into_low_level_drive_operations_after_ttl_drain"
.to_string(),
known_versions: vec![0, 1],
received: version,
}))
}
};

@thepastaclaw thepastaclaw Dec 2, 2026 •

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.

✅ Withdrawn at 6d7fe1f4; see the replies below.

🟡 Suggestion: PV15 and PV16 share the document branches that decide which pending writes count
Impact: A future change meant only for PV16 can affect historical lowering because both generations' pending-context decisions live in the same operation arms.

The new selector makes reviewers verify the historical path arm by arm. It selects a boolean, then mixes generation-0 and generation-1 policy throughout one match. The false branches preserve the base behavior today; this is not a current replay failure. The book's versioned-dispatch rule calls for generation-owned behavior rather than a shared implementation with a flag. Dispatch to generation-owned pending-context decisions and keep the mechanics common where they are identical.

source: grok-4.7 (phase2-reviewer: general, security-auditor); gpt-6.2-astra (phase2-reviewer: architecture-layering, platform-versioning, rust-quality)

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.

Withdrawn (re-reviewed at 6d7fe1f4): ALREADY_REVIEWED: The shared boolean-controlled document lowering is unchanged from the prior full review at b8a89cf, and no current change newly depends on it.

Comment on lines +226 to +228
#[test]
fn should_burn_the_frozen_balance_alone_at_protocol_version_16() {
let operations = convert(action(None, true, vec![]), pv15());

@thepastaclaw thepastaclaw Dec 2, 2026 •

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.

✅ Withdrawn at 6d7fe1f4; see the replies below.

💬 Nitpick: The historical destroy tests are labeled with the wrong protocol versions
Impact: A maintainer filtering tests by protocol version can select a PV15 refusal test labeled PV16 or miss the PV15 group test labeled PV14.

The PV16 port updated both historical cases to use pv15(), but their names say PV16 and PV14. The equivalence test also names its latest and PV15 results at_15 and at_14. The assertions exercise the intended tables; rename the historical tests to PV15 and use at_latest and at_15 for the comparison.

source: grok-4.7 (phase2-reviewer: general, security-auditor); gpt-6.2-astra (phase2-reviewer: architecture-layering, platform-versioning, rust-quality)

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.

Withdrawn (re-reviewed at 6d7fe1f4): ALREADY_REVIEWED: The test names and their pv15() fixtures are unchanged from the prior full review at b8a89cf, so this merge does not introduce the naming mismatch.

@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

New on this head: Since the full review, the marketplace moved to PV16, where a frozen-funds destroy burns the balance and the escrow of up to 16 open listings, leaving credit-backed offers untouched. The latest head merges the marketplace base without changing the frozen-destroy implementation from the previous head. The book preview and Kotlin SDK build and tests passed; the review check is pending.

🟡 4 suggestion(s) | 💬 1 nitpick(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.

Still open from earlier rounds (4)

  • 🟡 Suggestion: Retain repeated token-write protection in the PV15 raw converter — packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-27 (thread)
  • 🟡 Suggestion: PV15 and PV16 share the document branches that decide which pending writes count — packages/rs-drive/src/util/batch/drive_op_batch/document.rs:574-591 (thread)
  • 🟡 Suggestion: Preserve pending context for contested document writes — packages/rs-drive/src/util/batch/drive_op_batch/document.rs:651-660 (thread)
  • 💬 Nitpick: The historical destroy tests are labeled with the wrong protocol versions — packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs:226-228 (thread)
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: The history section promises execution proof for a closed offer
Impact: An SDK integrator verifying a closed offer can expect proof of the exact signed bid even though the verifier returns only affected state.
book/src/data-model/token-marketplace.md:283-285

Closing an offer does not establish which signed placement executed. The merged offer-proof change classifies PlaceBid as AffectedState: the orderPlaced record omits the signed maxTotalPrice, so bids differing only in admissible limits can match the same record. In the history sentence this PR extends to cover frozen destruction, say that the retained record proves placement for a closed listing; for an offer it authenticates the affected state only.

source: gpt-6.2-astra (phase2-reviewer: general)

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: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This large, intricate diff changes consensus-critical token destruction, escrowed funds movement, state-transition conversion, storage operations, and protocol-version dispatch in rs-drive and rs-drive-abci.
  • 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)
  • New since the last final review (fee50837): 1 suggestion(s) on unchanged code listed as follow-up candidates
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); 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 don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- 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-platform-version/src/version/system_limits/mod.rs`:
- [SUGGESTION] packages/rs-platform-version/src/version/system_limits/mod.rs:216-218: The PV16 batch-limit note overstates which deletes see earlier writes
  Impact: A maintainer evaluating whether to raise the one-transition cap can conclude that all document deletion paths already account for earlier batch writes.
  The revised cap note says that PV16 removed this index-pruning hazard for every document delete. `DeleteIndexOnlyDocument` still passes `None` to the index-removal walker, so two index-only deletes draining a shared bucket cannot count each other's pending removals. The consume variants see only operations built within their own conversion. The ordinary drain tests do not cover these paths. Narrow the cap note and selector documentation to the variants that actually receive the enclosing accumulator, and call out the remaining cases before raising the cap.

In `packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-27: Retain repeated token-write protection in the PV15 raw converter
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4395374803)

In `packages/rs-drive/src/util/batch/drive_op_batch/document.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:574-591: PV15 and PV16 share the document branches that decide which pending writes count
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4762895334)
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:651-660: Preserve pending context for contested document writes
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4365747230)

In `packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs`:
- [NITPICK] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs:226-228: The historical destroy tests are labeled with the wrong protocol versions
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4762895348)

Comment on lines +216 to +218
/// its own conversion. From protocol version 16 (`lower_document_operation` 1) every document
/// insert, update and delete is built against the batch's operations built before it, so
/// this blindness is gone there for documents; protocol version 15 and earlier keep it.

@thepastaclaw thepastaclaw Dec 2, 2026 •

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.

✅ Withdrawn at 6d7fe1f4; see the replies below.

🟡 Suggestion: The PV16 batch-limit note overstates which deletes see earlier writes
Impact: A maintainer evaluating whether to raise the one-transition cap can conclude that all document deletion paths already account for earlier batch writes.

The revised cap note says that PV16 removed this index-pruning hazard for every document delete. DeleteIndexOnlyDocument still passes None to the index-removal walker, so two index-only deletes draining a shared bucket cannot count each other's pending removals. The consume variants see only operations built within their own conversion. The ordinary drain tests do not cover these paths. Narrow the cap note and selector documentation to the variants that actually receive the enclosing accumulator, and call out the remaining cases before raising the cap.

source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, platform-versioning, rust-quality, security-auditor)

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.

Withdrawn (re-reviewed at 6d7fe1f4): ALREADY_REVIEWED: The referenced note and lowering code are unchanged from the prior full review at b8a89cf, and this merge does not newly rely on or worsen the documented scope issue.

@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

New on this head: This head merges the token-history/base-branch updates into the frozen-escrow PR and renumbers the related protocol-version documentation to v16 note 8; the frozen-escrow execution code is otherwise unchanged from the prior review head. Book Preview passed, while the Kotlin SDK build and tests remain in progress; no failed code checks are reported.

🟡 4 suggestion(s) | 💬 1 nitpick(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.

Still open from earlier rounds (5)

  • 🟡 Suggestion: The PV16 batch-limit note overstates which deletes see earlier writes — packages/rs-platform-version/src/version/system_limits/mod.rs:216-218 (thread)
  • 💬 Nitpick: The historical destroy tests are labeled with the wrong protocol versions — packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs:227-228 (thread)
  • 🟡 Suggestion: PV15 and PV16 share the document branches that decide which pending writes count — packages/rs-drive/src/util/batch/drive_op_batch/document.rs:574-591 (thread)
  • 🟡 Suggestion: Retain repeated token-write protection in the PV15 raw converter — packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-28 (thread)
  • 🟡 Suggestion: Preserve pending context for contested document writes — packages/rs-drive/src/util/batch/drive_op_batch/document.rs:651-660 (thread)
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: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This large, intricate diff changes consensus-critical token destruction and escrow storage operations, including funds movement, supply accounting, protocol-version dispatch, and batched state-transition execution in token_destroy_frozen_funds_transition and related Drive operation code.
  • 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.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); 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 don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- 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-platform-version/src/version/system_limits/mod.rs`:
- [SUGGESTION] packages/rs-platform-version/src/version/system_limits/mod.rs:216-218: The PV16 batch-limit note overstates which deletes see earlier writes
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4765346275)

In `packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs`:
- [NITPICK] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs:227-228: The historical destroy tests are labeled with the wrong protocol versions
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4762895348)

In `packages/rs-drive/src/util/batch/drive_op_batch/document.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:574-591: PV15 and PV16 share the document branches that decide which pending writes count
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4762895334)
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:651-660: Preserve pending context for contested document writes
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4365747230)

In `packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-28: Retain repeated token-write protection in the PV15 raw converter
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4395374803)

@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

New on this head: This head merges the updated base branch into the frozen-listing implementation; the PR-specific marketplace code is unchanged from the previously reviewed implementation. Book preview and policy checks succeeded, while the Kotlin SDK check and review check remain in progress; no failing code check is reported.

🟡 4 suggestion(s) | 💬 1 nitpick(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.

Still open from earlier rounds (5)

  • 🟡 Suggestion: The PV16 batch-limit note overstates which deletes see earlier writes — packages/rs-platform-version/src/version/system_limits/mod.rs:216-218 (thread)
  • 💬 Nitpick: The historical destroy tests are labeled with the wrong protocol versions — packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs:227-260 (thread)
  • 🟡 Suggestion: PV15 and PV16 share the document branches that decide which pending writes count — packages/rs-drive/src/util/batch/drive_op_batch/document.rs:571-591 (thread)
  • 🟡 Suggestion: Retain repeated token-write protection in the PV15 raw converter — packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-27 (thread)
  • 🟡 Suggestion: Preserve pending context for contested document writes — packages/rs-drive/src/util/batch/drive_op_batch/document.rs:627-658 (thread)
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: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate consensus-critical change that alters token destruction and escrowed-funds movement, state-transition operation conversion, storage reads/deletes, supply accounting, and protocol-version dispatch across rs-drive and rs-drive-abci.
  • 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.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); 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 don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- 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-platform-version/src/version/system_limits/mod.rs`:
- [SUGGESTION] packages/rs-platform-version/src/version/system_limits/mod.rs:216-218: The PV16 batch-limit note overstates which deletes see earlier writes
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4765346275)

In `packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs`:
- [NITPICK] packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition/mod.rs:227-260: The historical destroy tests are labeled with the wrong protocol versions
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4762895348)

In `packages/rs-drive/src/util/batch/drive_op_batch/document.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:571-591: PV15 and PV16 share the document branches that decide which pending writes count
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4762895334)
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/document.rs:627-658: Preserve pending context for contested document writes
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4365747230)

In `packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/convert_drive_operations_to_grove_operations/v2/mod.rs:22-27: Retain repeated token-write protection in the PV15 raw converter
  (carried; thread: https://github.com/dashpay/platform/pull/5532#discussion_r4395374803)

@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

New on this head: This head is a merge of the token-market-history base branch and adds unrelated SDK, contract, documentation, and platform changes; the frozen-escrow implementation and its previously reviewed Drive/platform-version files are unchanged. The book preview, policy, and PR-title checks passed; the current Kotlin SDK build and tests remain in progress, with no failed code check reported.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

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: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate consensus-critical change that alters token destruction, escrowed funds, supply accounting, state-transition serialization, and persisted marketplace documents in protocol-versioned Drive code.
  • 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.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

Comment on lines +574 to +591
let builds_against_batch = match platform_version
.drive
.methods
.batch_operations
.lower_document_operation
{
0 => false,
1 => true,
version => {
return Err(Error::Drive(DriveError::UnknownVersionMismatch {
method:
"DocumentOperationType::into_low_level_drive_operations_after_ttl_drain"
.to_string(),
known_versions: vec![0, 1],
received: version,
}))
}
};

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.

Withdrawn (re-reviewed at 6d7fe1f4): ALREADY_REVIEWED: The shared boolean-controlled document lowering is unchanged from the prior full review at b8a89cf, and no current change newly depends on it.

Comment on lines +226 to +228
#[test]
fn should_burn_the_frozen_balance_alone_at_protocol_version_16() {
let operations = convert(action(None, true, vec![]), pv15());

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.

Withdrawn (re-reviewed at 6d7fe1f4): ALREADY_REVIEWED: The test names and their pv15() fixtures are unchanged from the prior full review at b8a89cf, so this merge does not introduce the naming mismatch.

Comment on lines +216 to +218
/// its own conversion. From protocol version 16 (`lower_document_operation` 1) every document
/// insert, update and delete is built against the batch's operations built before it, so
/// this blindness is gone there for documents; protocol version 15 and earlier keep it.

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.

Withdrawn (re-reviewed at 6d7fe1f4): ALREADY_REVIEWED: The referenced note and lowering code are unchanged from the prior full review at b8a89cf, and this merge does not newly rely on or worsen the documented scope issue.

This branch has not been deployed

No deployments
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