Repository navigation
fix(platform)!: enforce token policy on document payments - #5325
Conversation
Add document-base state_v2 for unreleased PV14: preserve payer freeze/balance precedence, then meter pause and recipient policy reads, resolving the actual issuer only for frozen recipients. Retain no-movement owner self-payments and shielded validation; freeze shipped validator generations and previous protocol tables. Test would have caught this in CI: ✖ before fix, ✔ after. The signed raw-transition policy suite had 4 passed/9 failed on the unfixed validator, including SuccessfulExecution on all seven paused-payment paths and all seven external forbidden-frozen-recipient paths. The same 13 tests pass with state_v2; all 519 surrounding document tests pass and cargo fmt --all -- --check passes. All-target all-feature drive-abci clippy is running separately.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughValidation version 2 adds pause checks and issuer-configured frozen-recipient checks for transparent document-token payments. The change preserves separate shielded-pool validation and adds tests and documentation for the policy, its read order, and its exceptions. ChangesDocument token payment policy
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant DocumentBaseTransitionAction
participant validate_state_v2
participant V0Validation
participant TokenState
participant RecipientAccount
participant IssuerConfiguration
DocumentBaseTransitionAction->>validate_state_v2: dispatch validation version 2
validate_state_v2->>V0Validation: validate non-shielded action
V0Validation-->>validate_state_v2: validation result
validate_state_v2->>TokenState: read token pause status
TokenState-->>validate_state_v2: pause status
validate_state_v2->>RecipientAccount: read recipient account for transfer
RecipientAccount-->>validate_state_v2: account freeze status
validate_state_v2->>IssuerConfiguration: read issuer policy when recipient is frozen
IssuerConfiguration-->>validate_state_v2: allowTransferToFrozenBalance
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No identified policy regression remains; the change is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 48.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 6 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Final review complete — no blockers (commit 2a6a034) · triage: critical |
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-10-07T17:10:47.191Z |
Document PV14 state validation 2 in entry 84 and qualify the token-cost book behavior. Add owner burn and frozen-owner recipient controls, with opposing external issuer fixtures in both directions. Test would have caught this in CI: removing the owner transfer-effect guard failed the owner burn test (0 passed, 1 failed); removing the burn early return failed the frozen-owner burn test (0 passed, 1 failed). Restoring the validator makes all 15 focused tests pass. Final fmt and clippy pass; production logic is unchanged in this follow-up.
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification found no actionable in-scope defects. The PV14-only validator preserves historical behavior, matches execution's transfer-elision and burn semantics, and meters the added policy reads; the documentation nitpick is not substantiated when read with the surrounding transfer-versus-burn explanation. No builds or tests were run; the supplied CI snapshot still had Rust workspace tests queued and the JS build in progress.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The new document_base_transaction_action/state_v2/mod.rs validator changes consensus acceptance and charged validation reads for token transfers and burns through intricate payer, pause, recipient, issuer-policy, and self-payment branches shared by seven document action 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 below 15% reserve: weekly 15% left, 5h 100% left),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— 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
|
Bots are done — your move: post |
Basic explanation
What this does: Document actions paid with tokens respect pause and the token issuer's policy for transfers to frozen accounts from protocol version 14.
Value: Applies the issuer's movement restrictions to all seven document action paths, including payments using another contract's token.
Risks: Changes consensus acceptance and validation fees in unreleased PV14. Older protocol tables and validator generations remain unchanged; retained beta-PV14 histories need a separately coordinated activation/replay decision. No deployment or recovery action is included.
Issue being fixed or feature implemented
Token-cost document payments checked the payer's freeze state and balance but omitted movement policy. This addresses the token audit's T1 finding; group-burn proof/result work is a separate PR.
What was done?
state_v2, selected by PV14's existing V10 slot. Preserve the shielded-payment branch and existing payer freeze/balance precedence.allowTransferToFrozenBalanceis false (default true). Missing/inconsistent issuer metadata is an internal corruption error.In-place changes to shipped generations
None. Document-base
state_v0andstate_v1, native burn policy, and pre-PV14 tables are unchanged. The dispatcher gains version 2, and only the unreleased PV14 V10 slot selects it.How Has This Been Tested?
cargo test -p drive-abci --lib token_cost_policy -j 2 -- --nocapturecompiled and ran on the unfixed validator: 4 passed / 9 failed. Both seven-path tests observedSuccessfulExecutionfor every restricted payment. After the fix: 13 passed / 0 failed; the final suite with review-requested burn controls: 15 passed / 0 failed / 0 ignored.cargo test -p drive-abci --lib 'batch::tests::document::' -j 2 -- --test-threads=2: 519 passed / 0 failed / 0 ignored, at the initial implementation head, including the policy suite and surrounding document/sponsorship tests. The review follow-up changes tests and documentation only; production logic is identical.cargo test -p drive-abci --lib document_shielded_token_payment_tests -j 2 -- --test-threads=2: 4 passed / 0 failed / 0 ignored, preserving pool transfer/burn, amount agreement, and pre-PV14 rejection behavior.cargo fmt --all -- --check: passed.cargo clippy -p drive-abci --all-features --all-targets -j 2 -- -D warnings: passed, repeated after the review follow-up. Independent Opus review agreed on signed head2a6a0343c435b51a5884c912de014154a6eff462with no unresolved must-fix. No live network transactions or workspace-wide local test run.Breaking Changes
PV14 rejects previously accepted restricted token-cost movements and charges the added validation reads. Mixed binaries using this same protocol version can disagree; activation on an existing beta network is a separate campaign decision. PV13 and earlier behavior is preserved.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
PR Hygiene ·
2a6a034/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.