Skip to content

feat(platform)!: token marketplace offers (PV16) - #5530

Open
QuantumExplorer wants to merge 89 commits into
claude/token-market-listingsfrom
claude/token-market-offers
Open

QuantumExplorer wants to merge 89 commits into
claude/token-market-listingsfrom
claude/token-market-offers

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: Lets anyone make an offer for a tradeable token on Platform. A buyer offers a price for an amount (TokenPlaceBid): what the offer is worth leaves their credit balance and waits in escrow. A holder sells into it (TokenFillBid): the tokens go to the buyer and the seller is paid out of the escrow in the same block. The buyer can withdraw the offer at any time (TokenCancelOrder with the bid side) and gets back what is left.

Value: Completes the order book: holders can list (the previous PR) and buyers can bid, so a token can be priced from both sides without trusting anyone. Offers are bid documents of the token market contract, readable with the queries and proofs SDKs already have, and the depth at each price is one proven sum of what the bids hold in escrow.

Risks: Medium. Two new token transitions and a new use of the credit escrow, from protocol version 16 only (the 5.2 line); before 16 both are refused unpaid at the batch's is_allowed gate. A buyer signs the most the escrow may hold, so a change of the token's decimals before the offer lands cannot take more. The tests check each credit movement exactly (the escrow, each payment, the rounding left over and the fees) and that a sale can never pay more than the offer holds.

Issue being fixed or feature implemented

The fourth PR of the token marketplace stack, gated at protocol version 16, on top of #5529 (listings). The marketplace moved to 5.2 (protocol version 16, #6253); this PR merged #5529's move and its offers note is now v16 note 6 (was v15 note 18; #6433 took v16 note 3, #6354 note 4). Listings let holders sell at their price; this adds the other side, where buyers name the price.

What was done?

Transitions (TokenTransition variants 21 and 22, appended)

Transition Fields Effect
TokenPlaceBid amount, price, maxTotalPrice Buyer's credits to escrow (what the offer is worth at the token's decimals, rounded up, at most maxTotalPrice), bid document created
TokenFillBid orderId, minAmount, maxAmount, minTotalReceived Seller's tokens to the buyer, escrow credits to the seller, bid rewritten or deleted
TokenCancelOrder (bid side) orderId, side Escrow back to the buyer, offer deleted
Before: a buyer cannot make an offer for a token on Platform; TokenCancelOrder of a bid finds none.

After, an offer for 1,000 base units at 10 credits each:
  place                          buyer -10,000 credits (plus fee), 10,000 in escrow
  sell 400, minimum 4,000        seller -400 tokens, +4,000 credits; buyer +400 tokens; escrow 6,000
  sell up to 10,000, minimum 1   takes the 600 still wanted; escrow empty, the offer closes and the
                                 buyer gets its storage back

Rounding: an offer holds its value rounded up, each sale is paid the change in its running total rounded down, and what is left goes back to the buyer when it closes:

1.5 credits per base unit, an offer for 7 holds 11:  sales of 3, 3, 1 are paid 4 + 5 + 1, and 1 credit returns

Validation

  • Structure (dpp): the same validate_token_order_terms as a listing (feat(platform)!: token marketplace listings (PV16) #5529); a sale's range like a listing fill. An offer has no expiry: it stays open until it is filled entirely or cancelled.

  • Transformer (drive): an offer's escrow is worked out here at the token's decimals as the token has them now. One worth more than i64::MAX credits there bumps the nonce with InvalidTokenOrderValueError (10465), in check_tx too. The configuration is read through token_configuration_or_position_error (feat(platform)!: token marketplace listings (PV16) #5529), so an offer naming a token its contract does not define bumps the nonce with ContractHasNoTokensError or InvalidTokenPositionError; a sale checks the same before reading the offer.

  • No signed decimals or minimum fill, as for a listing (feat(platform)!: token marketplace listings (PV16) #5529):

    Before: TokenPlaceBid { amount, price, decimals, minFill }
    After:  TokenPlaceBid { amount, price, maxTotalPrice }
    

    The offer records the token's decimals when it is placed (the bid type declares them generatedFrom sys.tokens.decimals, feat(platform)!: generatedFrom sys.tokens.decimals generates a token's decimals (PV15) #5604). Whoever controls the token's conventions can change them while a signed offer waits, so the buyer signs maxTotalPrice, the most credits the escrow may hold, and the transformer refuses an offer whose escrow at the decimals it executes at is more (TokenOrderPriceLimitError, 40754, paid, in check_tx too):

    1,000 base units at 1,000,000,000 credits per whole token, maxTotalPrice 10,000
      token at 8 decimals when placed   escrow 10,000         placed
      token at 4 decimals when placed   escrow 100,000,000    refused, nothing escrowed, nonce bumped
    

    The wallet's signing summary shows the tokens wanted, the price per whole token and the limit (at most N credits), and the row's credit amount is that limit. An offer of less than the token's minimum fill is refused (10463), and every sale reads the token's minimum fill as the token has it then.

  • Decimals: an offer records the token's decimals when it is placed (bid.decimals), and its escrow and every sale into it are worked out at them. A conventions update after placement cannot reprice an open offer or drain its escrow early; a sale reads the token's minimum fill, not its decimals. A sale reads the offer and refuses not found, self fill, fill range and a payment below minTotalReceived (TokenOrderPriceLimitError, whose doc already covers a sale's minimum).

  • Advanced structure (batch advanced_structure 2): a tradeable token and an amount of at least its minimum fill for an offer (validate_token_order_terms_for_token, shared with a listing), a still tradeable token for a sale.

  • State: not paused; for an offer the buyer not frozen unless the token allows transfers to frozen balances (a sale moves tokens to them); for a sale the seller not frozen and holding the amount, the buyer not frozen unless allowed.

  • The offer's escrow counts in the batch's used balances, so fee validation checks the buyer can pay it.

Execution (drive): the credits move through identity balance operations, so the batch's balance merging sees them, and two new token ops hold and set the offer's escrow (TokenHoldCreditsInOrderEscrow, TokenSetCreditsInOrderEscrow); the seller's tokens move with the existing TokenTransfer op. TokenBalanceKey::CreditOrderEscrow joins the repeated-write guard.

Proofs: TokenPlaceBid proves the bid document and checks its terms, after sales too: remaining from the amount down to 1 and an escrow equal to what the offer is worth less what was paid for what is filled (TokenOrder::escrow_after_fills), so a client asking for the proof after a sale still confirms the placement (an offer filled entirely is proved through its history record from #5531). The bid does not record the buyer's signed maxTotalPrice, so two offers that differ only in their limits leave the same bid: the guarantee classifier gives TokenPlaceBid AffectedState (a listing keeps ExecutionProved), and a wait for an offer uses the affected-state APIs; TokenFillBid the seller's token balance; the cancel arm already proves the absence for either side.

Bindings and docs: wasm-dpp2 TokenPlaceBidTransition, TokenFillBidTransition (every integer setter takes a BigInt through try_to_u64 and leaves the transition unchanged when it is out of range); wasm-dpp kinds; wallet signing summary rows; book "Offers" section; v16 note 6. Structure validation unit tests for all four order kinds.

How Has This Been Tested?

  • Review round of 2026-12-01 (feat(platform)!: record token marketplace events in token history (PV16) #5531 thread r4762216235): an offer's proof checks the buyer's signed limit. The verifier recomputes the escrow the offer took at placement (TokenOrder::order_value at the order's recorded decimals) and refuses a claim whose max_total_price is below it (d264556). offers::should_not_prove_an_offer_whose_signed_limit_is_below_its_escrow: 10,000 escrowed; a claimed limit of 10,000 verifies, 9,999 is refused. cargo test -p drive-abci --lib -- marketplace (64).

  • Review round of 2026-12-02 (thread r4762694290): an offer's proof does not tell which signed limit executed (every limit the escrow fits passes the check), so state_transition_proof_binds_execution classifies TokenPlaceBid as AffectedState, as it does a document paid from a shielded pool. The marketplace tests assert each kind's guarantee on every proof (checked_result), so the claim re-signed with another sufficient limit in should_not_prove_an_offer_whose_signed_limit_is_below_its_escrow now verifies as AffectedState. Book updated. cargo test -p drive-abci --lib -- batch::tests::token::marketplace (55).

  • cargo test -p drive-abci --lib -- batch::tests::token::marketplace (36 tests, 16 for offers):

    • an offer holds its value in escrow, the buyer pays exactly escrow plus fee, the bid holds the terms, the proof verifies;
    • a partial sale then the rest: exact seller payments (payment minus the reported fee), the buyer unchanged by sales, escrow and document follow, supply balanced, the sale proof verifies; the buyer gets exactly the storage refund on close;
    • running-total rounding: payments 4, 5, 1 and the 1 credit left over returned;
    • cancel returns exactly what the escrow held, the absence proof verifies;
    • refusals: not tradeable and value too large (unpaid, check_tx too), buyer cannot pay, selling into one's own offer, below the seller's minimum, more than the seller holds, not the owner, paused (cancel still works).
  • cargo test -p drive-abci --lib -- token_marketplace_gate: both new kinds refused at 14 and 15 under their names, allowed from 16.

  • After the move to protocol version 16 and the signed escrow limit (review thread r4760123907): cargo test -p drive-abci --lib -- marketplace (63 passed), including offers::should_refuse_an_offer_whose_escrow_at_the_tokens_decimals_passes_its_limit (signed at 8 decimals with a limit of 10,000, the contract owner moves the token to 4, the offer is refused by check_tx and in a block with TokenOrderPriceLimitError { total: 100_000_000, limit: 10_000 }, nothing escrowed, the buyer loses only the fee) and offers::should_place_an_offer_at_the_tokens_decimals_when_it_executes_within_its_limit; cargo test -p platform-wallet --lib -- state_transition_summary (24); cargo check -p wasm-dpp2; clippy on dpp, drive, drive-abci, platform-wallet, wasm-dpp2, platform-version. The wasm-dpp2 mocha spec gained maxTotalPrice cases but was not run here (no wasm build in this worktree).

  • Review round 1, in batch::tests::token::marketplace::offers:

    • placement at 8 decimals, a sale of 100, a conventions update to 2, a second sale of 100: paid 1,000 credits at the offer's 8 decimals (at 2 it would take 1,000,000,000 out of an escrow of 9,000), then the remaining 800 sell for exactly the 8,000 left; an offer placed after the update records 2 and holds 100,000,000 for 10 base units;
    • an offer naming position 1 of a one-token contract or DPNS (no tokens), and a sale naming position 1, are refused paid with InvalidTokenPositionError / ContractHasNoTokensError by check_tx and in a block, the escrow untouched;
    • a buyer short of the fee and a buyer short of the escrow are each refused with exactly one UnpaidConsensusError(IdentityInsufficientBalanceError), credits and nonce unchanged.
  • Round 5 (minimum fill and decimals from the token):

    • offers::should_place_an_offer_at_the_tokens_decimals_when_it_executes (since replaced by the two limit tests above): the buyer signs while the token has 8 decimals, the contract owner changes them to 4, and the offer executes at 4, holding 100,000,000 credits and recording 4 (it replaces the earlier test refusing an offer signed at other decimals with 40758, which is now unused);
    • offers::should_refuse_an_offer_of_less_than_the_tokens_minimum_fill: 99 at a minimum of 100 is refused with 10463;
    • the value refusal (10465) is now paid, from the transformer;
    • the wallet's offer row shows the tokens and the price (it now also shows the signed limit);
    • cargo test -p drive-abci --lib -- tests::token::marketplace (53 passed), cargo test -p dpp --all-features --lib -- token_order token_place (19), cargo test -p drive --lib -- verify order_escrow (339), cargo test -p platform-wallet --lib state_transition_summary (23).
  • yarn workspace @dashevo/wasm-dpp2 exec mocha tests/unit/TokensTransitions.spec.ts: each offer and sale setter sets a value in range and throws on 2^64 and -1, keeping the previous value.

  • cargo test -p drive-abci --lib -- batch::tests::token (regressions).

  • cargo test -p dpp --features all_features --lib -- validate_structure::v0::tests token_order.

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

  • cargo clippy on dpp, drive, drive-abci, wasm-dpp, wasm-dpp2, platform-wallet, platform-version.

In-place changes to shipped generations

Every change below adds arms for TokenPlaceBid and TokenFillBid only. No arm of an existing transition kind changes, and the batch's is_allowed gate refuses both kinds, unpaid, before protocol version 16, so on protocol versions 1 through 15 none of the new arms is reached and every block replays as before.

  • Batch validation and execution, v0 paths selected at every protocol version: BatchTransition::validate_base_structure_v0 (each kind's structure validation), the batch transformer v0 (each kind's transformation), the batch state validation v0 (each kind's state validation) and its accepted token pool nullifiers, and outputs_only_bundle_tag_v0 in the shielded-proof processor (both list the two kinds among those that touch no shielded pool).
  • BatchTransitionAction v0's used balances: a TokenPlaceBid reports the escrow it moves out of the buyer's balance, so the fee check counts it as principal. Only a placed offer reaches the arm.
  • Version tables: DRIVE_ABCI_VALIDATION_VERSIONS_V1 to V10 gain token_place_bid_transition_* and token_fill_bid_transition_* structure and state validation fields, and DRIVE_STATE_TRANSITION_METHOD_VERSIONS_V1 to V4 gain token_place_bid_transition and token_fill_bid_transition, all 0. Only the new arms read them, so before protocol version 16 they are never read.
  • Proof paths: verify_state_transition_was_executed_with_proof v0 (which its v1 dispatcher generation also calls), the execution path queries a node proves a transition with, and the proof guarantee classifier gain arms for the two kinds. A proof of any transition an earlier protocol version admits verifies, or is refused, exactly as before. These paths are not consensus: they build and check proofs for clients, and no node's state or result depends on them.
  • The batch's advanced structure validation 2, which protocol version 15 (5.1) selects, gains the two kinds' arms only; the is_allowed gate keeps both from reaching it below 16.
  • TokenCancelOrderTransitionActionV0's transformer no longer refuses the bid side, so a cancel of an offer is built. It is not a shipped generation: feat(platform)!: token marketplace listings (PV16) #5529 adds it for protocol version 16, and the batch's is_allowed gate refuses every TokenCancelOrder, unpaid, before 16, so no earlier block reaches it.

Breaking Changes

Consensus, from protocol version 16: two new token transitions, and TokenCancelOrder now withdraws offers. Earlier protocol versions are unchanged: the new kinds are refused there before anything else runs.

API, unreleased: TokenPlaceBidTransitionV0 has no decimals or min_fill and carries max_total_price; its builder (new_token_place_bid_transition) takes max_total_price after price, and wasm-dpp2's TokenPlaceBidTransition options take maxTotalPrice. TokenOrderPriceLimitError's message now names the signer's limit, not the filler's, as it also refuses an offer's escrow.

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

Buyers can offer credits for an amount of a tradeable token (TokenPlaceBid),
holders can sell into an open offer (TokenFillBid), and TokenCancelOrder now
withdraws offers too. An offer holds what it is worth, rounded up, in the
prefunded specialized balances escrow; each sale is paid the change in the
offer's running total rounded down, and whatever the rounding leaves goes back
to the buyer when the offer closes.

TokenTransition variants 21-22, refused unpaid before protocol version 15 by
the is_allowed gate; the tradeable and expiry rules run with batch advanced
structure 2 (check_tx too), the offer's value in its transformer, paused,
frozen and seller balance in state validation. The escrow counts as a
purchase in the batch's used balances. Proofs, wasm-dpp2 bindings, wallet
summary rows, the book and v15 note 8, plus structure validation unit tests
for every order kind.

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

coderabbitai Bot commented Oct 21, 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 21, 2026 •

Copy link
Copy Markdown
Collaborator

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

@github-actions

github-actions Bot commented Oct 21, 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.807Z

@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 bid implementation is broadly integrated with the existing versioned validation, escrow, proof, and operation pipelines. However, the reviewed range contains four blocking correctness issues: fills use mutable token decimals instead of the placement-time denomination, malformed expiries can surface as internal errors, missing token positions are dereferenced before consensus validation, and WASM setters silently narrow out-of-range bigint values. The provided CI checks pass, but none cover the changed Rust marketplace paths or WASM tests.

🔴 4 blocking | 🟡 1 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: ffi-engineer); 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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 10: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 11: gpt-6-astra (agent: phase2-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 large cross-cutting diff changes consensus-critical token state transitions and credit escrow funds movement across DPP, Drive, and rs-drive-abci, including protocol-version dispatch and proof execution 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 (lane 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 — ffi-engineer (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 — 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
  • 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_fill_bid_transition_action/v0/transformer.rs`:
- [BLOCKING] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_fill_bid_transition_action/v0/transformer.rs:159-175: Do not reprice an open bid from mutable token decimals
  PlaceBid calculates and persists the escrow using the token's decimals at placement, but FillBid reads the current decimals at line 159 for every payout. Token conventions are mutable through an authorized `TokenConfigurationChangeItem::Conventions` update: the DPP update validator allows this when the change-control rules authorize it, and applying the item replaces the conventions object. If a bid for 1,000 base units at 100 credits per whole token is placed with two decimals, it holds 1,000 credits; changing the token to one decimal makes a 100-base-unit fill demand 1,000 credits instead of 100. A partial fill can therefore drain the entire escrow while leaving the order open, and a later fill can fail with the checked subtraction overflow. Persist the placement-time denomination or reject convention changes while bids are open, and exercise placement, partial fill, convention update, and subsequent fill in execution tests.

In `packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_place_bid_transition/validate_structure/v0/mod.rs`:
- [BLOCKING] packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_place_bid_transition/validate_structure/v0/mod.rs:36-41: Reject expiries that cannot be represented in the order document
  `expires_at` is an unrestricted `u64`, but `TokenOrder::properties()` stores it as a signed `i64`. This validator checks amount, price, and minimum fill but not the expiry range, so a valid-looking bid with `expires_at = Some(i64::MAX as u64 + 1)` reaches `TokenOrder::new_document()` and returns `ProtocolError::Overflow` before the later block-time expiry validation runs. That turns malformed user input into an internal processing error instead of a normal consensus rejection and nonce-bump result. Add the representability check in the DPP order-field validation, preferably shared with the ask validator, while retaining the separate block-relative expiry check; cover `i64::MAX` and `i64::MAX + 1` through check_tx and block processing.

In `packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_place_bid_transition_action/v0/transformer.rs`:
- [BLOCKING] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_place_bid_transition_action/v0/transformer.rs:102-103: Validate token existence before dereferencing its configuration
  The base action construction copies `token_contract_position` without proving that the position exists. The bid transformer then calls `base_action.token_configuration()?` before the existing token-base consensus validator can return `ContractHasNoTokensError` or `InvalidTokenPositionError`. A bid naming a missing position therefore produces `ProtocolError::CorruptedCodeExecution` rather than the expected paid consensus rejection and nonce bump; the FillBid transformer has the same dereference at line 159. Move token-position validation ahead of configuration-dependent escrow and pricing calculations, or use a shared helper that returns the existing typed consensus errors, and cover both a tokenless contract and an invalid position in check_tx and block processing.

In `packages/wasm-dpp2/src/state_transitions/batch/token_transitions/token_fill_bid.rs`:
- [BLOCKING] packages/wasm-dpp2/src/state_transitions/batch/token_transitions/token_fill_bid.rs:139-145: Reject lossy bigint conversion in bid transition setters
  The constructors use `try_to_u64`, but the new setters accept raw `TokenAmount` and `Credits` aliases, which are `u64` values. At the JavaScript/WASM boundary an out-of-range bigint can therefore be narrowed modulo 2^64 instead of being rejected. Assigning `1n << 64n` to `minTotalReceived`, for example, silently stores zero and removes the seller's minimum-payout protection; the same issue applies to `minAmount` and `maxAmount` here and to `amount`, `price`, `minFill`, and `expiresAt` in `TokenPlaceBidTransitionWasm`. Match the existing checked setter pattern used by `TokenTransferTransitionWasm`: accept a `&js_sys::BigInt` (and the checked optional conversion for `expiresAt`), call `try_to_u64`, return `WasmDppResult<()>`, and leave the previous value unchanged on conversion failure.

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:1235-1242: Assert the specific insufficient-funds rejection
  This test only asserts that execution was not successful. It would also pass for an internal error, an unrelated consensus error, or an empty result list, so it does not prove that the bid escrow was included in the used-balance pre-check. Match the expected insufficient-balance consensus error and paid/unpaid classification, assert exactly one execution result, and check the relevant balance and nonce effects. The current fixture gives the buyer exactly the escrow principal, so add a case below the principal as well as the existing principal-plus-fee shortfall.
Out-of-scope follow-up suggestions (1)

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

  • Existing listing fills also use mutable token decimals — The pre-existing listing-side transformer at packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_fill_ask_transition_action/v0/transformer.rs:159-160 also prices fills using live conventions. A conventions authority can therefore reprice an open ask after placement. This is the same underlying denomination issue but predates this bid PR.
    • Follow-up: Track a coordinated fix for ask and bid order denomination persistence, or address the listing-side exposure in a separate marketplace follow-up.

QuantumExplorer and others added 4 commits October 22, 2026 09:32
- An offer records the token's decimals when it is placed; its escrow and
  every sale into it are worked out at them, so a conventions update cannot
  reprice an open offer or drain its escrow early. Sales read no token
  configuration.
- TokenPlaceBid validates its terms with the shared
  validate_token_order_terms, refusing an expiresAt above i64::MAX with
  InvalidTokenOrderExpiryError (10464).
- An offer or a sale naming a token its contract does not define bumps the
  nonce with ContractHasNoTokensError or InvalidTokenPositionError.
- The PlaceBid proof check also requires remaining == amount and an escrow
  equal to the offer's value at its decimals.
- wasm-dpp2 offer and sale setters convert BigInts with try_to_u64 and leave
  the transition unchanged when out of range.
- The cannot-pay test asserts the exact unpaid IdentityInsufficientBalanceError
  for a buyer short of the fee and one short of the escrow.

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 306c99f, all five prior findings are fixed. One blocking issue remains: a successful bid placement cannot be confirmed with the current-state proof after a subsequent partial or complete fill. This was a static verification; current PR checks pass, but they do not provide dedicated Rust/WASM test or clippy results.

🔴 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: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); 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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-layer diff directly changes consensus-controlled funds movement in packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_fill_bid_transition.rs and the bid transformers, including escrow funding, settlement, rounding, and 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 — ffi-engineer (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/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1408-1416: Preserve placement confirmation after an offer is filled
  Placement verification requires the live offer to remain untouched, but confirmation does not retrieve a placement-time snapshot. DAPI's wait handler fetches the proof when servicing the request, `query_proofs_v0` calls `prove_state_transition(..., None, ...)`, and the order query requests the latest document without history. Place an offer for 1,000 units with 10,000 credits in escrow, sell 400 units into it, then wait for the placement result after reconnecting: the authentic document now has `remaining = 600` and `escrow = 6,000`, so these checks reject the successful placement. A complete fill deletes the document and instead fails the existence check above. The buyer has already funded the offer and received tokens, yet proof-backed confirmation returns an error. Preserve authenticated placement evidence through subsequent fills and closure, using durable execution evidence or an authenticated historical proof rather than requiring an untouched live order; absence alone must not establish placement. Add placement→partial-fill→placement-proof and placement→complete-fill→placement-proof regressions, and check the matching PlaceAsk mechanism when fixing the shared lifecycle assumption.

QuantumExplorer and others added 4 commits October 22, 2026 11:05
The PlaceBid proof accepted only an untouched bid. Like a listing, an
offer's order id is the transition's alone, so a bid holding its terms
proves the placement after sales: remaining from the amount down to 1, and
an escrow equal to what the offer is worth less what was paid for what is
filled (TokenOrder::escrow_after_fills).

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 combined reviewer findings and all six prior findings against a3ed2d0. Five prior findings are fixed; placement confirmation still fails after an offer closes, leaving one blocking issue that the linked history work does not resolve for history-disabled tokens. This was a static review: current GitHub checks pass, but no dedicated Rust test or clippy result is listed.

🔴 1 blocking

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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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 directly changes funds movement and consensus validation, notably in token_fill_bid_transition_action/v0/transformer.rs and action_convert_to_operations/batch/token/token_fill_bid_transition.rs, which calculate escrow payouts and apply token and credit transfers.
  • 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 — ffi-engineer (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/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1403-1407: Preserve placement confirmation after an offer is filled
  (existing thread: https://github.com/dashpay/platform/pull/5530#discussion_r4345904240)
  The partial-fill fix works while the bid remains open, but this existence check still rejects placement confirmation after a complete fill or cancellation deletes the document. The regression at marketplace/mod.rs:1452–1454 explicitly expects that failure. DAPI obtains the proof when servicing the wait request, and query_proofs_v0 proves current state rather than a placement-time snapshot. Consequently, the buyer can successfully fund an offer and receive tokens yet be unable to confirm its placement; placement followed by a complete fill in the same block leaves no committed live-order state to retrieve even with an immediate request. PR #5531 is still open on top of this PR, and its described fallback only works when transfer history is enabled, leaving valid history-disabled bids affected. This is a defect in the newly added confirmation path, not an unrelated follow-up. Preserve authenticated placement evidence independently of optional transfer history, or provide an authenticated historical proof, and require successful confirmation in complete-fill and cancellation regressions. Absence alone must remain insufficient evidence of placement.

QuantumExplorer and others added 6 commits October 22, 2026 12:51
As a listing does (#5529): TokenPlaceBidTransitionV0 gains a signed
`decimals` (constructor, wasm-dpp2 wrapper). The transformer refuses the
offer with TokenOrderDecimalsMismatchError (40758, check_tx too) unless they
are the token's, before the escrow is worked out from them, so whoever
controls the token's conventions cannot change them between signing and
execution and make the buyer escrow more (1,000 base units at 1,000,000,000
credits per whole token hold 10,000 credits at 8 decimals, 100,000,000 at
4). The order records them and the placement proof compares them.

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

Two blocking issues remain at the reviewed head. Placement confirmation still fails after a bid is completely filled because the live order document is deleted and no durable placement evidence is queried, while the wallet approval summary omits the signed denomination and resulting escrow commitment. The available CI snapshot reports successful Kotlin and book checks, but no Rust marketplace test result.

🔴 2 blocking

1 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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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 token state transitions, credit escrow and settlement funds movement, signed transition serialization, validation gates, storage operations, and proof verification in files such as token_place_bid_transition, token_fill_bid_transition, and their rs-drive-abci validators.
  • 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 — ffi-engineer (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-platform-wallet/src/wallet/identity/network/state_transition_summary.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/network/state_transition_summary.rs:624-630: Show the signed denomination and credit exposure before approving a bid
  The PlaceBid approval projection shows price, minimum fill, expiry, and the requested token count, but it omits the signed `decimals` field and leaves the credit amount unset. The denomination materially changes the escrow commitment: 1,000 base units at a price of 1,000,000,000 credits per whole token require 10,000 credits at 8 decimals but 100,000,000 credits at 4 decimals. Those requests otherwise render the same approval details, so a user cannot distinguish the credit exposure they are authorizing. The summary should display the signed decimals and the escrow commitment calculated with the canonical DPP `TokenOrder::order_value` logic; changing only decimals should have a regression showing a different approval summary.

In `packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1404-1409: Preserve placement confirmation after an offer is filled
  (existing thread: https://github.com/dashpay/platform/pull/5530#discussion_r4345904240)
  The partial-fill path now validates the live bid correctly, but a complete fill still removes the only placement evidence this verifier accepts. In the sequence PlaceBid → full FillBid → placement confirmation, `verify_token_order_document` returns `None` after the bid document is deleted and this branch returns `IncorrectProof`, even though the placement and sale succeeded. The marketplace regression at lines 1720–1722 explicitly asserts this failure. The proof-backed confirmation path must retain authenticated placement evidence through closure, such as an authenticated historical execution record; absence alone cannot prove that the placement occurred. The referenced #5531 is not part of this reviewed head.

QuantumExplorer and others added 2 commits October 22, 2026 19:23
…credits it escrows

The PlaceBid approval row left its credit amount unset and did not show the
signed decimals, so two offers committing 10,000 or 100,000,000 credits
(1,000 base units at 1,000,000,000 credits per whole token at 8 or 4
decimals) looked the same. The row's amount is now the escrow, worked out
with TokenOrder::order_value, with a detail line when Platform would refuse
it as too large, and the price line names the decimals (listings too).

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 findings against head 328b6ba: six prior findings are fixed, but placement confirmation after closure remains broken, and placement proofs also accept forbidden group metadata as execution-proved. One non-blocking coverage suggestion remains for bid-side frozen-account roles. The currently reported GitHub checks pass; this verification was static, with no local builds or tests run.

🔴 2 blocking | 🟡 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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); 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: 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 large, intricate diff changes consensus-critical token transition rules and directly implements credit escrow, payment, refund, fee, and signature handling across DPP, Drive, and ABCI validation 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 — ffi-engineer (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/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1391-1403: Reject forbidden group metadata before proving a bid placement
  This arm does not reject base.using_group_info(). Adding group metadata to an otherwise matching placement leaves its derived order ID, document-term comparisons, and owner-balance query unchanged, so the authentic placement proof still passes. However, DPP's batch basic-structure validator rejects that request with GroupActionNotAllowedOnTransitionError because PlaceBid cannot calculate a group action ID. The classifier nevertheless labels PlaceBid as ExecutionProved unconditionally, and the SDK proof path performs no intervening structural validation, allowing a strict wait to accept terminal success for a request that could never execute. Reject prohibited group metadata at the Drive verification boundary and check the matching PlaceAsk path. Add a regression that verifies an authentic placement proof against the same transition with group metadata added. The guard present in the child #5531 is absent from this reviewed head.
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1404-1408: Preserve placement confirmation after an offer is filled
  (existing thread: https://github.com/dashpay/platform/pull/5530#discussion_r4345904240)
  Partial fills now preserve placement confirmation, but complete fills and cancellation delete the only evidence this verifier accepts. DAPI obtains the proof when servicing the wait request, and query_proofs_v0 proves current state rather than a placement-time snapshot. A buyer reconnecting after closure therefore cannot obtain proof-backed confirmation of a placement that successfully committed their credits; the new marketplace regression explicitly expects this failure after the final fill at line 1722. The linked #5531 is an open child PR, not part of this head, and its fallback explicitly rejects closed offers when transfer history is disabled, a configuration this PR supports. This is a failure introduced by the new placement path, so the tracked follow-up does not make it safely deferrable. Preserve authenticated placement evidence for every supported offer, or supply an authenticated execution-time proof that remains usable after closure, and cover both complete fill and cancellation with transfer history disabled.

In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_fill_bid_transition_action/state_v0/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_fill_bid_transition_action/state_v0/mod.rs:86-94: Exercise the bid-side frozen-account roles
  FillBid applies different rules to the signer, who sells tokens, and the order maker, who receives them: the seller must always be unfrozen, while a frozen buyer may receive tokens when the configuration allows it. The marketplace frozen-account regressions exercise FillAsk, not the new FillBid validator, so swapping the participant identities or applying the recipient exception to the seller would not be detected by the offer suite. Add execution cases that freeze the buyer after placement under both values of is_allowed_transfer_to_frozen_balance, and cases that reject a frozen seller under either value. Assert that the typed error names the correct participant, rejected fills preserve token balances and escrow, and the frozen buyer can still cancel and recover the remaining escrow.

QuantumExplorer and others added 2 commits October 22, 2026 20:22
…t sales' frozen-account roles

- The PlaceBid proof arm refuses group information first, as the PlaceAsk
  arm does (#5529): a placement is never a group action, and the verifier
  does not run the node's structure validation.
- Tests: an executed offer re-sent with group information is refused and
  the offer itself proves; a sale into an offer is refused naming the frozen
  seller whatever the token allows, and naming the frozen buyer unless the
  token allows transfers to frozen balances (then the tokens land in the
  frozen balance); a frozen buyer cancels and recovers its escrow.

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 combined reviewer evidence and all 20 prior findings against head 7ca4bfb. Two blockers remain: execution-time decimals can increase an already-signed buyer commitment, and closing an offer can prevent confirmation of its successful placement; the fee-funding finding is withdrawn as an intentional shared upfront-fee policy, and the separate wallet finding is consolidated into the authorization issue. This was static verification only: current checks pass, including Kotlin and the book preview, but they do not establish targeted Rust test results.

🔴 2 blocking

2 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: ffi-engineer); 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: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, intricate diff directly changes consensus-governed funds movement in token_place_bid_transition.rs, token_fill_bid_transition.rs, and token_cancel_order_transition.rs, adding escrow deposits, seller payouts, refunds, and rounding-sensitive partial fills.
  • 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 — ffi-engineer (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_place_bid_transition_action/v0/transformer.rs`:
- [BLOCKING] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_place_bid_transition_action/v0/transformer.rs:100-108: Bound bid escrow by a buyer-signed credit limit
  (existing thread: https://github.com/dashpay/platform/pull/5530#discussion_r4430262709)
  TokenPlaceBidTransitionV0 signs amount and price, but this calculation uses decimals that another identity can change before execution. The regression should_place_an_offer_at_the_tokens_decimals_when_it_executes confirms that an offer signed for 1,000 base units at 1,000,000,000 credits per whole token while decimals are 8 is accepted after an update to 4, increasing its escrow from 10,000 to 100,000,000 credits. An administrator authorized to change conventions and holding token inventory can arrange the update before placement and then sell into the inflated offer. The balance check only prevents an insolvent debit; it does not restrict a solvent buyer to the credit commitment they approved. Recording decimals after placement protects subsequent fills, not this signing-to-placement interval. Add a buyer-signed maximum escrow commitment, enforce it against the resolved escrow before execution, and carry that enforceable bound through the builders, bindings, and wallet approval summary. Add a regression rejecting an unchanged signed offer when a conventions update would exceed its ceiling.

In `packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1427-1432: Preserve placement confirmation after an offer is filled
  (existing thread: https://github.com/dashpay/platform/pull/5530#discussion_r4345904240)
  The partial-fill case now verifies, but a fully filled or cancelled offer still fails placement verification because its live bid document is absent. This can happen before the buyer's first confirmation: DAPI fetches the proof after waiting for the transaction, and query_proofs_v0 proves current state rather than a placement-time snapshot, so another transition can close the order before that proof is generated. The regression should_prove_an_offer_after_it_is_partly_filled explicitly asserts failure after the final sale. The linked #5531 is absent from this head and its documented fallback only covers tokens keeping transfer history; valid no-history offers retain the failure even with that follow-up. This is a defect in the newly added placement-confirmation path, not a deferrable adjacent improvement. Preserve authenticated placement evidence for every supported offer, or require the necessary durable evidence when permitting placement, and verify it after closure. Keep rejecting absence alone, and add complete-fill and cancellation confirmation regressions for no-history tokens.

@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 exact head and revalidated all 20 prior findings against the source and discussion evidence. Two blockers remain: mutable token decimals can increase an already-signed bid's credit commitment, and a fully filled or cancelled offer loses placement-confirmation evidence. Current GitHub checks pass, including Kotlin SDK and book preview checks, but provide no targeted Rust/WASM test results; this verification was static, with no local builds or tests run.

🔴 2 blocking

2 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: ffi-engineer); 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: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-layer diff directly changes consensus-governed funds movement in packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_fill_bid_transition.rs, including escrow payouts, token transfers, partial fills, and rounding 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 — ffi-engineer (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_place_bid_transition_action/v0/transformer.rs`:
- [BLOCKING] packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_place_bid_transition_action/v0/transformer.rs:100-108: Bound bid escrow by a buyer-signed credit limit
  (existing thread: https://github.com/dashpay/platform/pull/5530#discussion_r4430262709)
  The signed PlaceBid model contains amount and price but no denomination or maximum credit commitment, while this transformer derives the debit from mutable execution-time token decimals. The regression `should_place_an_offer_at_the_tokens_decimals_when_it_executes` signs a request for 1,000 base units at 1,000,000,000 credits per whole token with 8 decimals, changes the token to 4 decimals, and then successfully escrows 100,000,000 credits instead of the original 10,000. A conventions controller holding tokens can make that change before placement and sell into the enlarged bid. The available-balance and i64 checks establish affordability and representability, not the buyer's authorized spending limit. Persisting decimals protects later fills but not this initial debit, and leaving the approval summary's credit amount unknown does not protect the signature. Add a buyer-signed maximum escrow commitment or expected denomination, reject a resolved debit that violates it before funding the action, and carry that protection through builders, bindings, the signing summary, and placement verification. Cover the existing conventions-change sequence with rejection when it exceeds the signed authorization.

In `packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1427-1432: Preserve placement confirmation after an offer is filled
  (existing thread: https://github.com/dashpay/platform/pull/5530#discussion_r4345904240)
  Partial-fill confirmation now works, but complete fills and cancellations delete the only placement evidence queried at this head. `query_proofs_v0` proves current state, the PlaceBid execution-path query requests only the live bid document, and this branch rejects its authenticated absence. The regression `should_prove_an_offer_after_it_is_partly_filled` explicitly expects placement verification to fail after the remaining 600 units are sold, so a buyer receiving or retrying confirmation after a fast complete fill gets a proof error for a successful, funded placement. The linked #5531 does not resolve this at the reviewed head, and its documented history fallback deliberately still refuses closed orders for supported tokens without transfer history. This is a lifecycle defect introduced by the new placement path, rather than a wider follow-up that can be cleared solely by tracking it. Preserve authenticated placement evidence through closure for every supported bid, without accepting absence alone as execution evidence, and make placement→complete-fill/cancel→placement-confirmation regressions succeed.

@QuantumExplorer QuantumExplorer added this to the v5.2.0 milestone Nov 11, 2026
QuantumExplorer and others added 2 commits December 2, 2026 02:35
Brings the move to protocol version 16. The offers note becomes v16
note 4; offers are refused below TOKEN_MARKETPLACE_INITIAL_PROTOCOL_VERSION
(16) by the listings' gate. Ports Drive::calculate_fee as a method and
DeleteDocument::deleter_id to the bid transformers and the sale converter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TokenPlaceBid signs max_total_price, the most credits its escrow may
hold. The escrow is worked out at the token's decimals when the offer
executes, so a conventions update between signing and execution could
raise what the buyer pays by a power of ten; the placement transformer
now refuses an escrow past the limit with TokenOrderPriceLimitError
(40754, paid, check_tx too), naming the escrow and the limit.

- dpp: TokenPlaceBidTransitionV0.max_total_price with accessors, the
  batch builders take it; TokenOrderPriceLimitError's text covers it.
- wasm-dpp2: maxTotalPrice option, getter and setter.
- platform-wallet: an offer's row shows the limit as the credits it can
  take.
- tests: the conventions-update regression is now the refusal (10,000
  signed, 100,000,000 at the new decimals), plus a placement within the
  limit at the new decimals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@QuantumExplorer QuantumExplorer changed the title feat(platform)!: token marketplace offers (PV15) feat(platform)!: token marketplace offers (PV16) Dec 1, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Changes requested: 1 blocker

  • Preserve placement confirmation after an offer is filled — packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1448-1459 (thread, carried)
    Impact: A buyer whose offer fills before the SDK retrieves its placement proof gets a verification error for a placement that succeeded and already delivered tokens.

New on this head: This head adds a buyer-signed credit cap to PV16 offer placements, enforces it before escrow is funded, and displays it in the wallet approval summary. The Kotlin SDK build and tests and the book preview passed; no code checks are failing, and only the review check is pending.

🔴 1 blocking

Still open from earlier rounds (1)

  • 🔴 Blocking: Preserve placement confirmation after an offer is filled — packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1448-1459 (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: A bid proof can confirm a placement that exceeded its signed escrow limit
Impact: An SDK caller waiting for a revised offer can receive ExecutionProved for the lower-cap request even though only the earlier, higher-cap offer executed.
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1466-1472

A strict SDK wait can confirm the wrong signed request. If a buyer revises a pending offer's cap while reusing its nonce and the earlier request lands first, both requests name the same order ID: it derives from the token, maker, side, and nonce, not the cap. The wait requests the revised transaction's hash, but the client authenticates the returned state root, not inclusion of that hash. A genuine proof of the earlier bid therefore passes these checks: the verifier matches the amount and price and checks the remaining escrow, but never reads the new max_total_price that the placement transformer enforces. The classifier then returns ExecutionProved, which the strict wait accepts. Reject a proof if the original escrow, computed from the authenticated amount, price, and placement decimals, exceeds the signed cap; the current escrow is too low after partial fills. To distinguish two otherwise valid caps, bind the cap or a placement commitment to the authenticated evidence, or classify the result as AffectedState rather than exact execution evidence.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-astra (phase2-reviewer: general, architecture-layering, platform-versioning, rust-quality, security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: 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 state transitions and credit escrow, including funds movement, validation, serialization, storage operations, and proof execution paths across rs-dpp, rs-drive-abci, and rs-drive.
  • 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 (5d015aa0): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 not confirmed (no longer blocking)
  • 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-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1448-1459: Preserve placement confirmation after an offer is filled
  (carried; thread: https://github.com/dashpay/platform/pull/5530#discussion_r4345904240)

Brings the new bincode tag of the tradeable mode with a minimum fill.

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

Copy link
Copy Markdown
Member Author

On the blocking finding of this round, "Let bid refunds and sale proceeds fund the signer fee" (validate_fees_of_event/v1/mod.rs:348-359): not changed in this PR.

The finding is accurate about the behaviour. Fee validation checks the signer's balance before the transition, less the principal it pays out. So a seller or a cancelling bidder must already hold the fee, even when the transition would credit them enough to pay it. That is how fee validation works for every transition on Platform: incoming credits never fund the fee of the transition that brings them. It costs a little convenience, not funds. Such a user tops up first, and nothing is lost or locked: a bid's escrow stays cancellable once the fee is covered.

Counting incoming credits would need a new validate_fees_of_event generation, selected by protocol version 16, that every transition kind runs. The validation would also have to know what a fill pays before execution, which today is computed only in the transformer. That is a consensus change wider than this PR. It is tracked as an open decision for the maintainer, the same item this review raised on 2026-10-31 and then withdrew. The other item, the in-place section, is in the description: it now names protocol version 16 as the gate and lists the shipped generations the arms are added to.

🤖 Addressed by Claude Code

QuantumExplorer and others added 2 commits December 2, 2026 05:50
#6433 took v16 note 3: the offers note is v16 note 5 and cites the
listings as note 4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The placement transformer refuses a TokenPlaceBid whose escrow at the
token's decimals passes max_total_price, but the proof of an open offer
did not check it, so the proof of an offer signed with a higher limit also
verified a re-signed copy with a lower one. The verifier now recomputes the
escrow the offer took at placement (TokenOrder::order_value at the order's
recorded decimals) and refuses a claim whose limit is below it.

Test: should_not_prove_an_offer_whose_signed_limit_is_below_its_escrow
(10,000 escrowed; a claimed limit of 10,000 verifies, 9,999 does not).

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

Changes requested: 1 blocker

  • A strict wait can confirm a different bid when both signed limits cover the escrow — packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1482-1484 (new)
    Impact: A buyer who revises a pending bid's spending limit while its submission is uncertain can receive terminal success for the revised request even though only the original signed bid executed.

New on this head: The latest commit adds a proof-side check that an executed offer's escrow fits the claimed buyer limit, together with a regression test; the branch also contains the merged typed-definition, wallet, and mobile changes from its base. No code checks have failed; the Kotlin SDK build and review check remain in progress, while policy, title, book preview, and CodeRabbit checks have passed.

🔴 1 blocking | 💬 1 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 large, intricate diff changes consensus-critical token state transitions and directly moves credits through escrow, affecting funds movement, validation, serialization, and Drive execution.
  • 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 (27b7918f): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • 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-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs:1482-1484: A strict wait can confirm a different bid when both signed limits cover the escrow
  Impact: A buyer who revises a pending bid's spending limit while its submission is uncertain can receive terminal success for the revised request even though only the original signed bid executed.
  The new inequality prevents a claimed limit below the executed escrow, but it does not prove that the claimed limit was the one signed by the executed request. The bid order ID is derived from the token, maker, and nonce, while `max_total_price` is neither part of that ID nor stored in the order document. Two separately signed bids can therefore have identical order terms and nonce but different sufficient limits; after the first executes, an authenticated proof of its order passes this check for the second request as long as the second limit also covers the escrow. The classifier still marks `PlaceBid` as `ExecutionProved`, so the SDK's strict wait accepts the proof as confirmation of the wrong request. Bind the placement proof to the executed transition or a durable commitment containing the signed limit/request digest; otherwise classify this document-only evidence as `AffectedState`. The positive regression should use the exact executed request, and a different admissible limit should not receive `ExecutionProved`.

  _Confirmed by an independent pass: A caller can submit a signed `TokenPlaceBid` transition B and a valid quorum-signed state proof produced for a different transition A with the same maker, token, nonce, amount, and price but a different `max_total_price`; a DAPI peer can replay that proof because the authenticated response binds the state root and metadata, not the transition hash. Since the order document and derived order ID contain none of the limit, the new check only verifies that B's limit covers the escrow, then `state_transition_proof_binds_execution` classifies the result as `ExecutionProved`, so the SDK's strict wait reports B as executed even though only A executed._

In `packages/rs-platform-version/src/version/v16.rs`:
- [NITPICK] packages/rs-platform-version/src/version/v16.rs:125-130: The `v16 note 4` reference in the PR description points to listings instead of offers
  Impact: Readers following the PR description's version-note reference are directed to the listings note rather than the offer rules.
  The version table now numbers listings as note 4 and offers as note 5, but the PR description still says that the offers note is v16 note 4. Update the PR description reference to note 5.

QuantumExplorer and others added 2 commits December 2, 2026 10:12
The bid document and its id carry every signed term but the buyer's
max_total_price, so two offers with the same nonce and terms signed with
different limits the escrow fits leave the same offer behind. The proof
cannot tell which executed: classify TokenPlaceBid as AffectedState. The
marketplace tests assert the guarantee on every proof.

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

New on this head: This head classifies live bid proofs as AffectedState: they authenticate the offer document without confirming which signed spending limit executed. The marketplace regression checks that distinction, and GitHub reports that the book preview and Kotlin SDK build and tests passed.

💬 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.

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 adds token marketplace state transitions and directly moves credits, escrowed funds, token balances, and fees in rs-drive-abci and rs-drive execution 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)
  • 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 `book/src/data-model/token-marketplace.md`:
- [NITPICK] book/src/data-model/token-marketplace.md:246-248: The proof guide applies the signed limit to the escrow left after a sale
  Impact: An SDK integrator reading the guide can expect a partially filled bid to verify with a limit that covers the remaining balance but not the original debit.
  A bid that originally escrowed 10,000 credits and now holds 6,000 still fails verification against a claimed limit of 8,000. The paragraph attaches both checks to the remaining escrow, but Drive checks two amounts: the document's current escrow must equal `TokenOrder::escrow_after_fills()`, and the original escrow, recomputed with `TokenOrder::order_value` using the recorded decimals, must not exceed `maxTotalPrice`. State those checks separately.

Comment on lines +246 to +248
that the escrow is what the offer holds after its sales (`TokenOrder::escrow_after_fills`: what it
is worth at its decimals, rounded up, less what its sellers were paid), and at most the
transition's `maxTotalPrice`. The `bid` does not record `maxTotalPrice`, so two offers that differ

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.

💬 Nitpick: The proof guide applies the signed limit to the escrow left after a sale
Impact: An SDK integrator reading the guide can expect a partially filled bid to verify with a limit that covers the remaining balance but not the original debit.

A bid that originally escrowed 10,000 credits and now holds 6,000 still fails verification against a claimed limit of 8,000. The paragraph attaches both checks to the remaining escrow, but Drive checks two amounts: the document's current escrow must equal TokenOrder::escrow_after_fills(), and the original escrow, recomputed with TokenOrder::order_value using the recorded decimals, must not exceed maxTotalPrice. State those checks separately.

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

@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 listings branch's tradeable-token minimum-fill plumbing into the offers branch, affecting Swift, JNI/KDoc, tests, and one book activation-table row; it does not change offer execution or proof Rust code. Book preview and policy checks passed, while the Kotlin SDK build/tests and PastaClaw review were still in progress at the supplied CI snapshot.

💬 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 (1)

  • 💬 Nitpick: The proof guide applies the signed limit to the escrow left after a sale — book/src/data-model/token-marketplace.md:246-248 (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: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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 state transitions and directly moves user credits through escrow, including validation, serialization, execution, proofs, and protocol-version dispatch in files such as token_place_bid_transition, token_fill_bid_transition, and their Drive action transformers.
  • 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 — ffi-engineer (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 `book/src/data-model/token-marketplace.md`:
- [NITPICK] book/src/data-model/token-marketplace.md:246-248: The proof guide applies the signed limit to the escrow left after a sale
  (carried; thread: https://github.com/dashpay/platform/pull/5530#discussion_r4764361055)

@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 base-branch updates affecting document schemas, identity keys, SDKs, wallets, and bindings; the token-offer implementation remains unchanged relative to the prior reviewed offer patch. The book preview, policy, title, and related checks passed, while the Kotlin SDK and review checks were still in progress; no failed code checks were reported.

💬 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 (1)

  • 💬 Nitpick: The proof guide applies the signed limit to the escrow left after a sale — book/src/data-model/token-marketplace.md:246-248 (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 change to consensus-critical token state transitions and credit escrow funds movement, including validation, deterministic transformations, storage operations, and proof verification across DPP, Drive, and ABCI 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)
  • 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 `book/src/data-model/token-marketplace.md`:
- [NITPICK] book/src/data-model/token-marketplace.md:246-248: The proof guide applies the signed limit to the escrow left after a sale
  (carried; thread: https://github.com/dashpay/platform/pull/5530#discussion_r4764361055)

@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 listings base and renumbers the PV16 token offers note from 5 to 6 without changing offer behavior. The Kotlin SDK build and tests and the book preview passed; no checks reported a failure, and the review check was still pending.

💬 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 (1)

  • 💬 Nitpick: The proof guide applies the signed limit to the escrow left after a sale — book/src/data-model/token-marketplace.md:246-248 (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 state transitions and directly moves credits through escrow and payouts, including serialization, validation, storage operations, and proof execution 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)
  • 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 `book/src/data-model/token-marketplace.md`:
- [NITPICK] book/src/data-model/token-marketplace.md:246-248: The proof guide applies the signed limit to the escrow left after a sale
  (carried; thread: https://github.com/dashpay/platform/pull/5530#discussion_r4764361055)

@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 updates from the listings base, including PV16 typed contract definitions, without changing the offers patch relative to its base. The book preview and Kotlin SDK emulator build and tests passed on this head; only the review check remains pending.

💬 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 (1)

  • 💬 Nitpick: The proof guide applies the signed limit to the escrow left after a sale — book/src/data-model/token-marketplace.md:246-248 (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: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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 cross-cutting diff changes consensus-critical token state transitions and credit escrow funds movement, including placement, partial fills, cancellation, rounding, fees, and protocol-version dispatch in files such as token_place_bid_transition, token_fill_bid_transition, and the rs-drive-abci token action validators.
  • 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 — ffi-engineer (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 `book/src/data-model/token-marketplace.md`:
- [NITPICK] book/src/data-model/token-marketplace.md:246-248: The proof guide applies the signed limit to the escrow left after a sale
  (carried; thread: https://github.com/dashpay/platform/pull/5530#discussion_r4764361055)

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