Skip to content

feat(drive): credit storage refunds to their recorded owners - #4706

Closed
DCG-Claude wants to merge 56 commits into
v5.1-devfrom
dashvm/r12-02
Closed

DCG-Claude wants to merge 56 commits into
v5.1-devfrom
dashvm/r12-02

Conversation

@DCG-Claude

@DCG-Claude DCG-Claude commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

Part 1 of 3 for R12-02 of the smart-contract plan (#4626, section 12).

A storage refund belongs to the owner recorded in the stored bytes' storage flags, which is not always the identity that pays the fee of the transition removing them. Block lifecycle paths that remove owner-attributed bytes outside a state transition need a way to credit those owners, and to settle the part no balance can take.

Scope narrowed on 2026-11-09. This PR first also required the fee history for every refund and priced every owned-transaction write before committing it. #5798 replaced that seam: refunds are now priced at the storing epoch's rate (calculate_fee 1, protocol v15 note 27) and the fee history map is gone. Its description notes that this PR's required-history rule, calculate_fee v1 and price-before-commit generations no longer have a purpose. Those parts are dropped; the recorded-owner credit primitive below is what remains.

What was done?

  • Drive::credit_storage_refunds_to_owners_operations (drive/identity/update/methods/credit_storage_refunds_to_owners_operations) credits each recorded owner of a refund that has a balance element, without consulting any key or permission. It clears an owner's negative credit first and reports what it could not credit in a StorageRefundCreditOutcome: the refunds whose owner has no balance element, and the repaid debt. processing_pool_share() is their sum, for the caller's single processing pool write.
  • DriveIdentityUpdateMethodVersions gains credit_storage_refunds_to_owners: None in identity tables V1 and V2, Some(0) in DRIVE_IDENTITY_METHOD_VERSIONS_V3. DRIVE_VERSION_V10's identity block now builds on V3, and PLATFORM_V15 note 28 describes it. Nothing calls the primitive yet; the lifecycle paths that use it are parts 2 and 3.
  • The fee overview's refund section describes refund ownership, and the changelog has an entry.

In-place changes to shipped generations

  • Drive identity method tables V1 (protocols 1 to 13) and V2 (protocol 14): the new credit_storage_refunds_to_owners slot is backfilled as None. The method returns VersionNotActive for None, and nothing calls it on any path those versions run, so no consensus result changes.

How Has This Been Tested?

  • rs-drive: the primitive's 11 tests cover crediting each owner by the sum of its epochs, an owner without a balance (reported instead of failing), an owner whose keys are all disabled, skipping the owner the caller settles itself, total credits staying balanced once the caller records the pending refunds, refunds below, equal to and above an owner's debt, a positive balance leaving debt alone, reading each owner once, and the method being inactive before the new drive table.
  • Locally: cargo fmt --all, cargo check --workspace --all-targets, cargo clippy -p drive -p drive-abci -p platform-version --all-targets --no-deps -- -D warnings, and targeted tests: drive identity update, fees, calculate_fee and structure (154 passed), platform-version (31 passed), drive-abci identity update and top-up, fee distribution and block fees (145 passed).

Breaking Changes

No consensus change: the primitive is active from protocol version 15 but nothing calls it yet. Rust API: DriveIdentityUpdateMethodVersions gains a field, so struct literals need it.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Decisions taken (provisional values)

  • Provisional: an owner without a balance element is the proxy for a wiped owner. Contracts cannot be deleted yet and identities are never removed, so Drive has no typed "wiped owner" today. The primitive treats a missing balance element as that case and reports the amount for the processing pool. When the owner-encoding refinement types the owner in the storage flags this proxy is replaced; nothing in state depends on it.
  • The primitive reports, the caller writes the pool. add_epoch_processing_credits_for_distribution_operation is a read-modify-write of the epoch's pool sum item, so two of them in one batch collapse last-wins. Returning routed_to_processing_pool and repaid_debt (together processing_pool_share()) lets the caller issue exactly one pool write per batch and keep pending-refund recording with the existing versioned methods. Repaid debt goes to the processing pool because negative credit is processing fee the pools were short of when the identity could not cover it (fee_result_outcome drops that part from the block fees), so clearing it with a refund returns those credits to the pool they were owed to.
  • Protocol 12 schema migration excluded by name. The stripped byte counts were never recorded and the migration never runs again, so there is nothing to correct at protocol version 15; the invariant (written into the DIP in part 3) states that blocks before 15 replay exactly as executed and names this migration as the exception.

Part 1 of 3.

Refs #4675
Refs #4689


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Protocol version 15 prices storage refunds using fee history from the storage epoch and credits the owner recorded with the stored data, who may differ from the fee payer.
    • Refunds that cannot be credited to an owner’s balance, including amounts applied to identity debt, are routed to the processing pool.
    • Document, contract, moderation, group-action, and contested-document operations support updated versioned behavior.
  • Behavior Changes

    • Some storage-removing operations require fee history at protocol version 15. If pricing fails, the operation is not committed.
    • Refunds from vote-poll cleanup are not settled.

PR Hygiene · 6c62f8a

  • Bots — thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — not asked of a bot author
  • Build running
  • Approvals
    • files with no dedicated owner (CHANGELOG.md, book/src/fees/overview.md, packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/mod.rs and 5 more) — QuantumExplorer or shumkov
    • rs-drive (packages/rs-drive/src/drive/identity/update/methods/credit_storage_refunds_to_owners_operations/mod.rs, packages/rs-drive/src/drive/identity/update/methods/credit_storage_refunds_to_owners_operations/v0/mod.rs, packages/rs-drive/src/drive/identity/update/methods/mod.rs and 2 more) — QuantumExplorer or shumkov

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Protocol version 15 adds fee-history-based pricing for owner-attributed storage removals and operations that credit refunds to recorded owners. Versioned Drive methods price operations before committing owned transactions. Tests cover missing fee history, refund routing, and protocol version 14 behavior.

Changes: Storage refund pricing and settlement

Layer / File(s) Summary
Fee-history pricing
packages/rs-drive/src/fees/*, book/src/fees/overview.md
Fee calculation version 1 uses persisted fee history to price owner-attributed storage removals. It returns CorruptedCodeExecution when required history is missing. The fee documentation describes refund ownership and fee-version history.
Owner refund crediting
packages/rs-drive/src/drive/identity/update/*, packages/rs-platform-version/src/version/drive_versions/drive_identity_method_versions/*
A new operation credits refunds to owners with balance elements, accounts for identity debt, and routes refunds for missing balance elements to the processing pool. Its outcome reports owner credits, repaid debt, and routed amounts. Protocol version 15 enables the operation.
Batch and group-action operations
packages/rs-drive/src/util/batch/drive_op_batch/*, packages/rs-drive/src/drive/group/*, packages/rs-drive/src/verify/group/*, packages/rs-drive/src/structure/tests.rs
Batch-operation version 2 calculates fees before committing an owned transaction. It handles refund forfeiture and processing-pool credits. Group-action version 1 is added, with tests for fee-history-backed closures and failures without history.
Document and contract writers
packages/rs-drive/src/drive/document/*, packages/rs-drive/src/drive/contract/apply/*, packages/rs-drive/src/drive/contract/update/*, packages/rs-drive/src/drive/contract/migration/*
Versioned document and contract operations calculate fees before committing owned transactions. Regression tests cover missing fee history, unchanged state on failure, successful operations with history, and related fee-history test updates.
Moderation writers
packages/rs-drive/src/drive/contract/moderation/*
Version 1 moderation operations add and remove warnings, bans, and suspensions. Their wrappers calculate fees before committing owned transactions. Tests cover failures without fee history and fee-history-backed replacements and removals.
Protocol version selection
packages/rs-platform-version/src/version/drive_versions/*, packages/rs-platform-version/src/version/v15.rs
Protocol-version tables select the new method generations. Their documentation describes the protocol-version-15 fee-history and transaction behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant apply_drive_operations_v2
  participant calculate_fee_v1
  participant OwnedTransaction
  Caller->>apply_drive_operations_v2: Submit operations and fee history
  apply_drive_operations_v2->>calculate_fee_v1: Calculate batch fees
  calculate_fee_v1-->>apply_drive_operations_v2: Return fee result or pricing error
  apply_drive_operations_v2->>OwnedTransaction: Commit after successful pricing
Loading

Possibly related issues

  • dashpay/platform#5575 — The PR changes pricing and crediting for owner-attributed storage refunds, but does not correct moderator storage flags.
  • dashpay/platform#5574 — The PR changes refund processing for owner-attributed removals, but does not add move-aware re-key accounting.

Possibly related PRs

  • dashpay/platform#5579 — Both changes use the contract-application generation and its transaction wrapper behavior.
Merge Risk: Minimal · up to 19fd7

No actionable merge-blocking risk is established in the reviewed context.

Security architecture risk: Moderate · up to c0f72

Refunds now fail rather than use an incorrect price when fee history is missing, and owned writes are priced before they commit. One document entrypoint cannot receive that history, however, so a valid refund-producing override fails through that route. The production impact of that limitation is not established.

Retained concerns

  • Medium · reliability · observed: The versioned add_document entrypoint cannot forward fee history. An owner-attributed override that removes storage therefore fails through this path even when the removing block has valid history; the by-contract entrypoint has a history parameter. This preserves the no-fallback rule but leaves a divergent write contract whose production exposure is unresolved.
Security review details

Security Blast Radius

  • inferred — The independently affected scope is the protocol-versioned Drive fee and document-write boundary, including persisted storage and identity-credit accounting. The examined entrypoints do not establish remote attacker reachability or exposure across tenants or environments.

Trust Boundaries and Controls

  • observed — The fee calculator enforces the presence of history before pricing an owner-attributed removal, and the examined owned-transaction wrappers commit after successful pricing. These controls limit the demonstrated missing-history case to rejection rather than a committed, incorrectly priced write.

Resilience and Maintainability Implications

  • inferred — End-to-end owner attribution, caller-owned transaction cleanup, and once-only settlement cannot be established from the examined wrappers and credit primitive. In particular, the primitive reports missing-owner credits for a separate pool write; it is not evidence that every lifecycle caller performs the complete settlement.

Hardening Proposals

  • proposed — Define which document and lifecycle entrypoints may remove owner-flagged storage, supply them with authenticated removing-block fee history, and verify that owner credit, missing-owner pool routing, and pending-refund accounting complete together exactly once under failure and retry.
Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(drive): credit storage refunds to their recorded owners" matches a central change in the changeset. The PR adds a versioned operation, credit_storage_refunds_to_owners_operations, that…
Full details: Title check

Explanation

The title "feat(drive): credit storage refunds to their recorded owners" matches a central change in the changeset. The PR adds a versioned operation, credit_storage_refunds_to_owners_operations, that credits storage refunds to the owners recorded in storage flags. The PR also adds fee-history requirements and other protocol version 15 changes, which the title does not name. The title covers the main point and is specific enough for a reviewer to find the change in history.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 390ea68 and 19fd7d4.

Files selected for processing: 1

  • packages/rs-drive/src/fees/op.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

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

Updated at 2026-11-09T17:18:45.614Z

@thepastaclaw

thepastaclaw commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress — actively reviewing now (commit 6c62f8a) · triage: critical
███████████████░░░░░ 75% · about 10 min left · running for 25 min
✅ triage → ✅ Phase 2 → ✅ Phase 1 → ✅ verify 2 → ⏳ fresh Phase 2 (0/5 lanes) → ▫️ publish
Estimated from recent reviews of this tier · updated 18:10 UTC · live progress

@codecov

codecov Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.14778% with 120 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.81%. Comparing base (d020728) to head (f26c668).
⚠️ Report is 68 commits behind head on v4.3-dev.

Files with missing lines Patch % Lines
packages/rs-drive/src/drive/group/mod.rs 61.31% 53 Missing ⚠️
packages/rs-drive/src/fees/op.rs 86.99% 32 Missing ⚠️
...dit_storage_refunds_to_owners_operations/v0/mod.rs 98.07% 11 Missing ⚠️
...ration/strip_unknown_document_schema_properties.rs 94.44% 7 Missing ⚠️
packages/rs-drive/src/fees/calculate_fee/v1/mod.rs 75.86% 7 Missing ⚠️
...credit_storage_refunds_to_owners_operations/mod.rs 83.33% 5 Missing ⚠️
packages/rs-drive/src/fees/calculate_fee/mod.rs 94.02% 4 Missing ⚠️
packages/rs-drive/src/drive/document/update/mod.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.3-dev    #4706      +/-   ##
============================================
- Coverage     84.10%   82.81%   -1.29%     
============================================
  Files          2797     2801       +4     
  Lines        379933   386062    +6129     
============================================
+ Hits         319541   319727     +186     
- Misses        60392    66335    +5943     
Components Coverage Δ
dpp 84.72% <ø> (-0.01%) ⬇️
drive 81.74% <90.14%> (-0.21%) ⬇️
drive-abci 88.12% <ø> (-0.01%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 66.85% <ø> (-26.08%) ⬇️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 43.67% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (queue backlog)

Verified the Phase-2 findings against head 0b8d9c2. The new refund primitive misreports credits consumed by identity debt, violating its documented settlement contract; this is an in-scope API defect even though production lifecycle integration is deferred. The book also describes that deferred integration as already implemented. Verification was source-based; tests were not rerun.

🔴 1 blocking | 🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: critical by gpt-6-astra (effort low) — This large, intricate diff changes consensus-versioned fee calculation and storage-refund crediting, directly affecting funds movement through functions such as Drive::calculate_fee_v1 and credit_storage_refunds_to_owners_operations.
  • Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 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/drive/identity/update/methods/credit_storage_refunds_to_owners_operations/v0/mod.rs`:
- [BLOCKING] packages/rs-drive/src/drive/identity/update/methods/credit_storage_refunds_to_owners_operations/v0/mod.rs:59-67: Account for refund credits consumed by identity debt
  `add_to_identity_balance_operations` does not necessarily add the requested amount to the owner's balance: when the existing balance is zero, `add_to_previous_balance_v0` first repays negative-credit debt. The new primitive nevertheless reports the entire refund as `credited` and exposes no amount for settling that debt repayment. For an owner with balance 0 and debt 100, a refund of 150 generates balance 50 and debt 0, but reports `credited = 150` and `routed_to_processing_pool = 0`. Negative credit is stored as an ordinary `Item`, outside the conservation sum trees, while recording the full pending refund contributes -150 to the pools. Following the documented caller contract therefore leaves accounted credits short by 100. The existing conservation test uses a positive owner balance and misses this branch. Although lifecycle callers are explicitly deferred to part 2, correct settlement reporting is a deliverable of this PR's new API; fixing this does not require activating those callers or changing the frozen helper. Account for and expose the debt-repayment portion so the caller can include it in its single processing-pool write, and add conservation tests for refunds below, equal to, and above outstanding debt.

In `book/src/fees/overview.md`:
- [SUGGESTION] book/src/fees/overview.md:244-245: Distinguish the refund primitive from pending lifecycle integration
  This sentence describes lifecycle refund settlement as implemented, but the new primitive has no production callers at this head. In particular, `clean_up_after_contested_resources_vote_polls_end_v1` applies its cleanup operations with a discarded cost vector and never calculates or settles storage refunds. The PR explicitly reserves that integration for part 2. Describe settlement as the responsibility of future lifecycle callers, or state that the primitive is available but lifecycle integration is pending; no expansion of this PR's implementation scope is needed.
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.

  • Make refund settlement debt-aware before activating lifecycle callers — Already covered by the canonical in-scope API finding rather than retained as a separate follow-up. The absence of production callers confirms there is no newly reachable lifecycle exploit at this head, but the new outcome explicitly promises credits added to balances and the amount callers must settle into the pool. Its failure to account for debt repayment directly violates this PR's primitive contract. Broader changes to the pre-existing state-transition settlement path remain outside this review.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

Comment thread book/src/fees/overview.md Resolved
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

The red policy / reconcile check on this head is a base-branch gap, not something this PR changes.

The re-pinned review engine from #4713 looks the caller workflow up on the pull request's base branch (WORKFLOW_BRANCH = base.ref), and the job fails with gh api repos/dashpay/platform/contents/.github/workflows/pr-review-policy.yml?ref=v4.3-dev failed: gh: Not Found (HTTP 404). v4.3-dev does not carry pr-review-policy.yml: #4449 and #4713 are among the four commits it lacks from v4.2-dev. The earlier green runs on this PR (and on #4707) predate the re-pin, which read the default branch instead. Every PR against v4.3-dev will hit this until v4.2-dev is merged forward, so I am not rerunning it. The check is not in the v4.3-dev ruleset; the rest of CI is running on the new head.


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (queue backlog)

At head 8b9e5aa, both prior findings are fixed: the refund outcome accounts separately for debt repayment, and the documentation explicitly identifies lifecycle settlement as pending. One non-blocking documentation inconsistency remains between the introductory payer-based description and the recorded-owner semantics. Verification used source and regression-test inspection; tests were not rerun.

🟡 1 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Describe refunds as belonging to the recorded storage owner
book/src/fees/overview.md:51-53

The introduction says storage refunds return to the identity that paid the fee, but the new subsection at lines 236–245 identifies the owner recorded in storage flags as the refund recipient. The new settlement primitive likewise uses the owner identifiers in FeeRefunds, not an original-payer lookup. Align this introductory description with the recorded-owner rule so readers do not infer that paying for storage determines refund entitlement; retain the later qualification that lifecycle integration is pending.

Storage fees are **refundable**: when data is deleted, a portion of the original
storage fee becomes a refund attributed to the recorded owner of the stored bytes
(see [Refunds](#refunds) below).

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

Review provenance

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: critical by gpt-6-astra (effort low) — The diff introduces intricate protocol-versioned refund accounting that changes consensus fee calculation in consume_to_fees_v1 and funds movement in credit_storage_refunds_to_owners_operations_v0, including historical pricing, recorded-owner balance credits, debt repayment, and missing-owner pool allocation reporting.
  • Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 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 `book/src/fees/overview.md`:
- [SUGGESTION] book/src/fees/overview.md:51-53: Describe refunds as belonging to the recorded storage owner
  The introduction says storage refunds return to the identity that paid the fee, but the new subsection at lines 236–245 identifies the owner recorded in storage flags as the refund recipient. The new settlement primitive likewise uses the owner identifiers in FeeRefunds, not an original-payer lookup. Align this introductory description with the recorded-owner rule so readers do not infer that paying for storage determines refund entitlement; retain the later qualification that lifecycle integration is pending.

@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Good catch; the introduction still had the pre-storage-flags wording. Fixed in 43b587e: the sentence now says the refund goes to the owner recorded in the stored bytes' storage flags, which is not always the identity that paid the fee, and points at the Refunds section as before. I did not take the suggestion's exact text only because "attributed to" hides that payer and owner can differ, which is the point of the recorded-owner rule.


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (queue backlog)

The recorded-owner documentation, lifecycle-integration clarification, and debt-repayment accounting address all three prior findings. The proposed fee-history blocker is not supported by the current history representation and refund resolver; one non-blocking duplicate-read improvement remains. Verification was source-based at the exact head; no runtime tests were executed.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: critical by gpt-6-astra (effort low) — The diff introduces intricate, protocol-versioned changes to consensus fee calculation in consume_to_fees_v1 and funds movement in credit_storage_refunds_to_owners_operations_v0, including historical refund pricing, recorded-owner balance credits, debt repayment, and missing-owner processing-pool accounting.
  • Phase 1 reviewers: not run (skipped for throughput: 12 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 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/drive/identity/update/methods/credit_storage_refunds_to_owners_operations/v0/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/drive/identity/update/methods/credit_storage_refunds_to_owners_operations/v0/mod.rs:78-87: Avoid duplicate state reads when constructing refund credits
  Each existing owner’s balance is read at line 49 and then read again inside `add_to_identity_balance_operations_v0`. For a zero-balance owner, the negative-credit element is also read here and again inside `add_to_previous_balance_v0`, producing four stateful reads for one owner’s update. These reads also flow through the cost accumulator, so batches with many owners accumulate unnecessary read work and processing costs. Share the fetched balance and debt results with the update construction, or derive debt repayment from the balance-update outcome, while preserving the shipped helper implementations and the new conservation accounting.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

The protocol version 15 fee-history enforcement and recorded-owner refund primitive are correctly versioned, preserve shipped behavior, and are supported by targeted conservation and read-count tests. All four prior findings were independently revalidated as fixed at the exact head, and no new in-scope defects were found.

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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: security-auditor); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: critical by gpt-6-astra (effort low) — This large, intricate diff changes consensus-versioned fee calculation and identity balance crediting for storage refunds, directly affecting funds movement and owner attribution in files such as consume_to_fees_v1 and credit_storage_refunds_to_owners_operations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 11% left, 5h 100% left), glm-5.3-flash (zai below 15% reserve: 5h 99% left, weekly 13% left)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer

@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

policy / reconcile is green now. v4.3-dev picked up pr-review-policy.yml (#4765), so I reran the failed job on this head and it passed; the earlier note about the base branch gap no longer applies.


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Sep 20, 2026
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

/self-reviewed f26c668

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-self-review Waiting for the author to post /self-reviewed labels Sep 20, 2026
@github-actions
github-actions Bot requested a review from shumkov September 20, 2026 18:43
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Rebased onto the current v4.3-dev (force-push f26c668722 to dd8516c353, range-diff: 12 of 13 commits byte-identical, one rebuilt).

What changed in the rebuild of the first commit (the protocol version 15 scaffolding), because upstream reworked the tables it copies from:

  • v15.rs and drive_versions/v10.rs are regenerated from upstream's current v14.rs and v9.rs instead of the older copies this branch started from. PLATFORM_V15 therefore inherits everything v14 gained since (contract groups, moderation, key budgets, the recent platform state entries, the v3 fee schedule) and still differs from v14 only in drive: DRIVE_VERSION_V10. DRIVE_VERSION_V10 still differs from v9 only in fees.calculate_fee: 1 and the v3 identity table.
  • The identity method tables gained keys.budget, update.update_identity_key_limits and cost_estimation.for_token_once_per_identity_distribution upstream. v1.rs and v2.rs keep upstream's values and add credit_storage_refunds_to_owners: None; v3.rs is a fresh copy of the resolved v2.rs with that slot Some(0).

The one context-only difference in the group closing test is upstream's rename of the trusted deserialize trait import next to the hunk. Local gate: fmt, clippy on drive and platform-version with warnings as errors, workspace check with all targets, and the fee history, refund credit, group, migration and ranked index tests all pass.


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Sep 22, 2026
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

The Rust workspace failure on dd8516c was this branch meeting the contract moderation work that landed on v4.3-dev after it was cut (#4830, #4849). Seven tests in drive/contract/moderation/tests.rs unban, unsuspend or replace a suspension through the bare fee-returning wrappers, which pass no fee history; those removals free moderator-flagged bytes, and from protocol version 15 calculate_fee v1 refuses to price that without the history. The production path (ContractModerationOperationType through apply_drive_operations) already forwards the block's history, so 7add6b5 routes those test calls through the same funnel; calls that only insert keep the wrappers. No production code changed. The audit table in the description gained the row.


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions github-actions Bot added this to the v4.3.0 milestone Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🌳 GroveDB structure

This pull request changes the described GroveDB structure. Open it in the structure viewer: new nodes glow, removed ones stay as ghosts, and the tour walks through each change.

Changed (31 nodes)

  • root
  • tokens
  • tokens.distributions
  • tokens.distributions.perpetual.token
  • tokens.distributions.timed
  • identities.identity
  • identities.identity.contract_info.bound
  • identities.identity.key_references
  • identities.identity.key_references.authentication
  • saved_block_transactions
  • prefunded_balances
  • pools.epoch
  • shielded_balances.main_pool
  • contracts.contract
  • contracts.contract.other
  • contracts.contract.other.team_actions
  • contracts.contract.other.team_actions.active.team_action
  • contracts.contract.other.team_actions.closed.team_action
  • withdrawals
  • group_actions.contract.group
  • group_actions.contract.group.active.action
  • group_actions.contract.group.closed.action
  • misc
  • votes
  • votes.contested_resource
  • votes.contested_resource.active_polls.contract.document_type
  • votes.contested_resource.active_polls.contract.document_type.indexes.value.contender
  • versions
  • contract_groups
  • contract_groups.groups.group
  • and 1 more

Compared 1ebcedb028 with 42531b1815. Updated at 2026-10-03T04:49:29.034Z

@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Second rebase fallout on 7add6b5, one test this time: ttl_index_bytes_bill_to_processing_without_refunds from the time-range TTL work (#4581), which added an ephemeral cost arm to consume_to_fees_v0 after this branch was cut. The rebase kept consume_to_fees_v1 without that arm, so at protocol version 15 a TTL'd index write was billed to storage. That was a real gap in v1, not just a test to reroute.

2dacc92 gives v1 the same arm as v0 (ephemeral bytes to processing at the ephemeral rate, zero storage, basic removal with no history needed, sectioned removal rejected as corrupted state) and pins v0 == v1 on ephemeral operations with a new test; the twin test's delete of owner-flagged standing bytes now passes a history like its neighbours. 10cd829 routes the structure fixture's group-action close through apply_drive_operations with a history (it is not in the PR-CI filter but runs on push) and regenerates grovedb-structure.json, whose only change is the fixture labels moving from @14 to @15.

Local: cargo test -p drive --lib 3839 passed, 0 failed; fmt and clippy (-p drive --all-features --all-targets --no-deps -D warnings) clean.


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Rust workspace tests on 10cd829: 10063 passed, 2 failed, and the two are the base-branch regression, not this PR: data_contract_create::state::v0::tests::transform_into_action_v0::should_return_invalid_result_if_data_contract_is_not_valid and validate_state_v0::should_return_invalid_result_when_transform_into_action_failed_latest (a non-object document schema now surfaces ValueError("value is not a map") instead of InvalidContractStructure). The same two fail on the v4.3-dev tip 9f7ed16 itself (run 35724218351): #4864 landed on v4.3-dev without its v4.2-dev follow-up #4870, whose reader returns Ok(None) when the schema is not a map. Deterministic, so no rerun; it clears once v4.2-dev is merged forward. Everything this PR touches (fee history tests, the refund primitive, the moderation and TTL tests fixed after the rebase) passed in the same run.


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · rs-drive-abci: QuantumExplorer or shumkov · rs-drive: QuantumExplorer or shumkov.
Full checklist in the description.

Brings in #5768, under which protocol version 15 re-enables the voter key
of the address a masternode returns to. In the PLATFORM_V15 notes that
change takes item 22, so this branch's fee history, recorded-owner credit
and pricing items move to 23, 24 and 25, and their references in the
notes and in the drive slot comment move with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Merged v5.1-dev (9766bab) into the branch as 796c051, a fast-forward on top of 3d896d9 with no force-push.

#5768 (a masternode returning to a voting address keeps its vote) adds item 22 to the PLATFORM_V15 notes. This branch's items move to 23 (fee history), 24 (recorded-owner credits) and 25 (pricing before commit, which now refers to note 23). The drive slot comment's references to them move the same way. Upstream's own note 22 reference is unchanged.

Compared file by file, the branch's net diff against v5.1-dev is the same as before the merge in all 80 files except v15.rs, which differs only by that renumbering.

Local gates:

  • fmt clean.
  • Workspace cargo check --all-targets passes.
  • clippy on drive, drive-abci and platform-version with warnings as errors passes.
  • Targeted drive tests: 851 passed, 6 ignored.
  • Targeted drive-abci tests: 481 passed, 1 ignored. They cover masternode votes and voter keys, moderation and fee distribution. They ran with CI's RUST_MIN_STACK, skipping the shorthand $ref test that also fails on v5.1-dev itself.

🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Static verification of 9766bab..796c051 found no remaining actionable in-scope issues: the new behavior is protocol-15-selected, owned transactions remain uncommitted until pricing succeeds, and refund outcomes account separately for balance credits, debt repayment, and missing owners. All 24 prior findings were revalidated against this exact head: 23 are fixed and one remains withdrawn. No local builds or tests were run; current CI shows passing Rust workspace, wasm32, JavaScript, Kotlin, and Swift checks, with PR Hygiene still pending.

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

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.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: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-cutting diff changes consensus-versioned fee calculation in LowLevelDriveOperation::consume_to_fees_v1 and funds crediting in Drive::credit_storage_refunds_to_owners_operations, directly affecting refund amounts and recipients.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · rs-drive-abci: QuantumExplorer or shumkov · rs-drive: QuantumExplorer or shumkov.
Full checklist in the description.

Brings in #5770, under which protocol version 15 checks an IdentityCreate's
identity id in basic structure, and the rust-dashcore update. In the
PLATFORM_V15 notes the identity create change takes item 23, so this
branch's fee history, recorded-owner credit and pricing items move to 24,
25 and 26, and their references in the notes and in the drive slot
comment move with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Merged v5.1-dev (a7def39) into the branch as 3451a35, a fast-forward on top of 796c051 with no force-push.

#5770 (the IdentityCreate identity id checked in basic structure) adds item 23 to the PLATFORM_V15 notes. This branch's items move to 24 (fee history), 25 (recorded-owner credits) and 26 (pricing before commit, which now refers to note 24). The drive slot comment's references to them move the same way. Upstream's own note 22 and 23 references are unchanged. The rust-dashcore update (#5729) merged without touching this branch's files.

Compared file by file, the branch's net diff against v5.1-dev is the same as before the merge in all 80 files except v15.rs, which differs only by that renumbering.

Local gates:

  • fmt clean.
  • Workspace cargo check --all-targets passes.
  • clippy on drive, drive-abci and platform-version with warnings as errors passes.
  • Targeted drive tests: 851 passed, 6 ignored.
  • Targeted drive-abci tests: 495 passed. They cover identity create, moderation and fee distribution. They ran with CI's RUST_MIN_STACK, skipping the shorthand $ref test that also fails on v5.1-dev itself.

🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Verified the complete diff at head 3451a35 and independently reconciled all 24 prior findings: 23 are fixed and one remains withdrawn. No remaining actionable in-scope defects were substantiated; the new generations preserve historical behavior, price before committing owned transactions, and expose the refund shares needed for conservation. Review was static-only; current code checks, including Rust workspace tests and SDK checks, pass, with PR Hygiene still pending.

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

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.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: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-cutting diff changes consensus-versioned fee calculation in consume_to_fees_v1 and funds movement in credit_storage_refunds_to_owners_operations, including historical refund pricing and credits to recorded owners.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · rs-drive-abci: QuantumExplorer or shumkov · rs-drive: QuantumExplorer or shumkov.
Full checklist in the description.

Brings in #4933, under which protocol version 15's DashPay contract v3
declares the checks of its data triggers. In the PLATFORM_V15 notes that
change takes item 24, so this branch's fee history, recorded-owner credit
and pricing items move to 25, 26 and 27, and their references in the
notes and in the drive slot comment move with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Merged v5.1-dev (de80f86) into the branch as e58c9b1, a fast-forward on top of 3451a35 with no force-push.

#4933 (DashPay contract v3 declares its data triggers' checks) adds item 24 to the PLATFORM_V15 notes. This branch's items move to 25 (fee history), 26 (recorded-owner credits) and 27 (pricing before commit, which now refers to note 25). The drive slot comment's references to them move the same way. Upstream's own note 24 references are unchanged.

Compared file by file, the branch's net diff against v5.1-dev is the same as before the merge in all 80 files except v15.rs, which differs only by that renumbering and the placement of one separator line.

Local gates:

  • fmt clean.
  • Workspace cargo check --all-targets passes.
  • clippy on drive, drive-abci and platform-version with warnings as errors passes.
  • Targeted drive tests: 851 passed, 6 ignored.
  • Targeted drive-abci tests: 257 passed. They cover DashPay, data triggers, moderation and fee distribution. They ran with CI's RUST_MIN_STACK, skipping the shorthand $ref test that also fails on v5.1-dev itself.

🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Static verification of e58c9b1 found no outstanding in-scope defects, and all 24 prior findings have been independently reconciled. Current CI reports successful Rust workspace and wasm32 tests, JavaScript builds and test suites, Swift checks, and Kotlin checks; PR Hygiene remains pending. No local builds or tests were run.

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

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.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: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-cutting diff changes consensus-visible fee calculation in consume_to_fees_v1, moves funds through credit_storage_refunds_to_owners_operations, and introduces storage migration logic in strip_unknown_document_schema_properties.rs.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · rs-drive-abci: QuantumExplorer or shumkov · rs-drive: QuantumExplorer or shumkov.
Full checklist in the description.

Brings in #5799, under which protocol version 15 appends private document
entries paid from the shielded pool and selects GroveDB V5. Protocol 15's
drive and document tables keep both sides' slots. In the PLATFORM_V15
notes those changes take items 25 and 26, so this branch's fee history,
recorded-owner credit and pricing items move to 27, 28 and 29, and their
references in the notes and in the drive slot comment move with them; the
drive slot comment also gains upstream's two new clauses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Merged v5.1-dev (e108530) into the branch as 0351b3b, a fast-forward on top of e58c9b1 with no force-push.

#5799 (private document entries paid from the shielded pool, and GroveDB V5) adds items 25 and 26 to the PLATFORM_V15 notes.

  • Version tables: DRIVE_VERSION_V10 (GROVE_V5) and DRIVE_DOCUMENT_METHOD_VERSIONS_V5 (append_private_document_entries_operations) merged cleanly beside this branch's slots.
  • Notes: this branch's items move to 27 (fee history), 28 (recorded-owner credits) and 29 (pricing before commit, which now refers to note 27).
  • Drive slot comment: its references to those items move the same way, and it gains upstream's two new clauses.
  • Pricing order: the new private-entry append runs through the batch path, and no new upstream Drive code prices after committing.

Compared file by file, the branch's net diff against v5.1-dev is the same as before the merge in all 80 files except v15.rs, which differs only by that renumbering and the two upstream clauses.

Local gates:

  • fmt clean.
  • Workspace cargo check --all-targets passes.
  • clippy on drive, drive-abci and platform-version with warnings as errors passes.
  • Targeted drive tests: 1160 passed, 6 ignored. They include fees, documents, private stores and structure under GROVE_V5.
  • Targeted drive-abci tests: 535 passed, 3 ignored. They cover private documents, shielded transitions, moderation and fee distribution. They ran with CI's RUST_MIN_STACK, skipping the shorthand $ref test that also fails on v5.1-dev itself.

🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Static verification of e108530..0351b3b found no remaining actionable in-scope defects; the 24 prior findings reconcile to 23 fixed and one previously withdrawn. The source confirms protocol-15 isolation, pricing before owned-transaction commits, and separate accounting for balance credits, debt repayment, and missing-owner refunds. Exact-head CI reports successful Rust workspace, wasm32, JavaScript, Swift, and Kotlin checks, with review and PR Hygiene pending in the supplied snapshot; no local builds or tests were run.

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

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-cutting diff changes consensus-versioned refund pricing in Drive::calculate_fee_v1 and consume_to_fees_v1 and funds crediting in credit_storage_refunds_to_owners_operations, meeting both the intricacy and critical-surface requirements.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · rs-drive-abci: QuantumExplorer or shumkov · rs-drive: QuantumExplorer or shumkov.
Full checklist in the description.

@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

I did not update this branch against v5.1-dev this time. #5798 replaces the seam most of this PR is built on, as its description notes under "Open PRs affected".

  • v5.1-dev now has its own calculate_fee 1 (protocol version 15, note 27). It prices each refund at the storing epoch's rate and removes the fee history map from Drive::calculate_fee, apply_drive_operations and the 45 functions that forwarded it.
  • This PR's calculate_fee v1 (a refund requires the fee history) therefore has nothing left to check.
  • Its price-before-commit generations existed so that the missing-history error could not leave a write committed, so they lose their reason too: apply_drive_operations 3, the document, contract, moderation and group wrappers, and apply_contract_with_serialization 2.
  • Merging would mean either re-adding the removed map or dropping those parts. That is a scope decision rather than a conflict resolution.

What still applies on top of #5798 is the recorded-owner refund credit primitive: credit_storage_refunds_to_owners in DRIVE_IDENTITY_METHOD_VERSIONS_V3, StorageRefundCreditOutcome, the repaid-debt routing to the processing pool, and their tests.

The branch is unchanged at 0351b3b. Two options:

Which do you prefer?


🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

… refund credits

#5798 prices storage refunds at the storing epoch's rate, takes
calculate_fee 1 for that, and removes the fee history map from the fee
path. This branch's rule that a refund requires the fee history, its
calculate_fee v1 and consume_to_fees changes, and the price-before-commit
generations that kept a missing-history error from leaving a write
committed no longer have anything to act on, so the merge takes
v5.1-dev's version of every file they touched and drops the generations
this branch added for them.

What remains is the recorded-owner refund credit primitive:
Drive::credit_storage_refunds_to_owners_operations, StorageRefundCreditOutcome
and the credit_storage_refunds_to_owners slot, Some(0) in
DRIVE_IDENTITY_METHOD_VERSIONS_V3, which DRIVE_VERSION_V10's identity
block now builds on. PLATFORM_V15 note 28 describes it, the fee overview
keeps its refund ownership section, and the changelog entry is narrowed
to it. Its tests drop the removed fee history argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DCG-Claude

Copy link
Copy Markdown
Collaborator Author

Merged v5.1-dev (9b36712) into the branch as 6c62f8a, a fast-forward with no force-push, and narrowed the PR to what #5798 leaves it.

#5798 prices refunds at the storing epoch's rate (calculate_fee 1, note 27) and removes the fee history map. Its description notes that this PR's required-history rule, calculate_fee v1 and price-before-commit generations no longer have a purpose. With no reply to my earlier question, I followed that.

  • Dropped:

    • this PR's calculate_fee v1 and consume_to_fees changes;
    • apply_drive_operations 3;
    • the price-first document, contract, moderation and group wrapper generations;
    • apply_contract_with_serialization 2 and update_contract 3;
    • their version slots, tests and PLATFORM_V15 notes;
    • the fee-history test plumbing.

    The merge takes v5.1-dev's version of every file they touched.

  • Kept:

    • Drive::credit_storage_refunds_to_owners_operations and StorageRefundCreditOutcome;
    • the credit_storage_refunds_to_owners slot (Some(0) in identity table V3, which DRIVE_VERSION_V10's identity block now builds on);
    • the primitive's tests, ported to the new apply_drive_operations signature;
    • PLATFORM_V15 note 28, the fee overview's refund ownership section, and a narrowed changelog entry.

The PR is now 13 files against v5.1-dev. I updated the title (no !, since nothing calls the primitive yet and no consensus result changes) and the description. The pre-narrowing branch is kept locally as backup/r12-02-pre-narrow-20261109 if any of the dropped parts should come back.

Local gates:

  • fmt clean.
  • Workspace cargo check --all-targets passes.
  • clippy on drive, drive-abci and platform-version with warnings as errors passes.
  • Targeted drive tests: 154 passed, including the primitive's 11.
  • platform-version tests: 31 passed.
  • Targeted drive-abci tests: 145 passed.

🤖 Posted autonomously by DashVM (Claude Fable 5.1) on behalf of pasta.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@QuantumExplorer

Copy link
Copy Markdown
Member

Closing: #5798 removed the fee history map from Drive::calculate_fee, so the required-history rule and the price-before-commit generations here no longer have a purpose.

The remaining piece, credit_storage_refunds_to_owners_operations, has no caller in this PR, and refunds to recorded owners are already credited on v5.1-dev. If vote poll cleanup refunds or routing for an owner without a balance are wanted later, that helper is better built on current code in the PR that uses it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants