Repository navigation
feat(platform)!: token marketplace offers (PV16) - #5530
QuantumExplorer wants to merge 89 commits into
Conversation
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]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit ef9b252) · triage: critical |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-12-03T16:48:49.807Z |
…offers Co-Authored-By: Claude Opus 5.5 <[email protected]>
…offers Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-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-160also 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.
…offers Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
…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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
…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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
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]>
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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]>
|
On the blocking finding of this round, "Let bid refunds and sale proceeds fund the signer fee" ( 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 🤖 Addressed by Claude Code |
#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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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.
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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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.
| 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 |
There was a problem hiding this comment.
💬 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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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)
… keys took note 4 Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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)
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 (TokenCancelOrderwith thebidside) 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
biddocuments 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_allowedgate. 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 (
TokenTransitionvariants 21 and 22, appended)TokenPlaceBidamount,price,maxTotalPricemaxTotalPrice),biddocument createdTokenFillBidorderId,minAmount,maxAmount,minTotalReceivedbidrewritten or deletedTokenCancelOrder(bidside)orderId,sideRounding: 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:
Validation
Structure (dpp): the same
validate_token_order_termsas 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::MAXcredits there bumps the nonce withInvalidTokenOrderValueError(10465), in check_tx too. The configuration is read throughtoken_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 withContractHasNoTokensErrororInvalidTokenPositionError; 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):
The offer records the token's decimals when it is placed (the
bidtype declares themgeneratedFromsys.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 signsmaxTotalPrice, 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):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 belowminTotalReceived(TokenOrderPriceLimitError, whose doc already covers a sale's minimum).Advanced structure (batch
advanced_structure2): 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 existingTokenTransferop.TokenBalanceKey::CreditOrderEscrowjoins the repeated-write guard.Proofs:
TokenPlaceBidproves thebiddocument and checks its terms, after sales too:remainingfrom 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). Thebiddoes not record the buyer's signedmaxTotalPrice, so two offers that differ only in their limits leave the samebid: the guarantee classifier givesTokenPlaceBidAffectedState(a listing keepsExecutionProved), and a wait for an offer uses the affected-state APIs;TokenFillBidthe 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 throughtry_to_u64and 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_valueat the order's recorded decimals) and refuses a claim whosemax_total_priceis 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_executionclassifiesTokenPlaceBidasAffectedState, 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 inshould_not_prove_an_offer_whose_signed_limit_is_below_its_escrownow verifies asAffectedState. 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):bidholds the terms, the proof verifies;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), includingoffers::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 withTokenOrderPriceLimitError { total: 100_000_000, limit: 10_000 }, nothing escrowed, the buyer loses only the fee) andoffers::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 gainedmaxTotalPricecases but was not run here (no wasm build in this worktree).Review round 1, in
batch::tests::token::marketplace::offers:InvalidTokenPositionError/ContractHasNoTokensErrorby check_tx and in a block, the escrow untouched;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;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 on2^64and-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 clippyon dpp, drive, drive-abci, wasm-dpp, wasm-dpp2, platform-wallet, platform-version.In-place changes to shipped generations
Every change below adds arms for
TokenPlaceBidandTokenFillBidonly. No arm of an existing transition kind changes, and the batch'sis_allowedgate 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.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, andoutputs_only_bundle_tag_v0in the shielded-proof processor (both list the two kinds among those that touch no shielded pool).BatchTransitionActionv0's used balances: aTokenPlaceBidreports 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.DRIVE_ABCI_VALIDATION_VERSIONS_V1toV10gaintoken_place_bid_transition_*andtoken_fill_bid_transition_*structure and state validation fields, andDRIVE_STATE_TRANSITION_METHOD_VERSIONS_V1toV4gaintoken_place_bid_transitionandtoken_fill_bid_transition, all 0. Only the new arms read them, so before protocol version 16 they are never read.verify_state_transition_was_executed_with_proofv0 (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.is_allowedgate keeps both from reaching it below 16.TokenCancelOrderTransitionActionV0's transformer no longer refuses thebidside, 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'sis_allowedgate refuses everyTokenCancelOrder, unpaid, before 16, so no earlier block reaches it.Breaking Changes
Consensus, from protocol version 16: two new token transitions, and
TokenCancelOrdernow withdraws offers. Earlier protocol versions are unchanged: the new kinds are refused there before anything else runs.API, unreleased:
TokenPlaceBidTransitionV0has nodecimalsormin_filland carriesmax_total_price; its builder (new_token_place_bid_transition) takesmax_total_priceafterprice, and wasm-dpp2'sTokenPlaceBidTransitionoptions takemaxTotalPrice.TokenOrderPriceLimitError's message now names the signer's limit, not the filler's, as it also refuses an offer's escrow.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code