Repository navigation
fix(drive-abci)!: return missing proposer payouts to processing pool - #5399
Conversation
Preserve valid reward shares and the final proposer remainder when an owner balance is absent. Return the checked allocation after ordinary pool writes and debt routing in the same transaction before commit; old apply and generic lowering refuse the internal transfer. Test would have caught this in CI: ✖ before fix, real epoch distribution failed with there should always be a balance; ✔ after fix, the unchanged regression passes and exact credits remain conserved. Validation: native library payout suite 23 passed and Drive operation batch suite 40 passed. This is an authorized in-place development PV14 consensus amendment; PV1–13 implementations and tables are unchanged.
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
⛔ Final review complete — 1 blocking finding(s) (commit ae62c0b) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification at 3bbf64f confirms one blocking issue: the payout and application changes redefine existing generation-1 consensus behavior without a new versioned activation boundary. Three suggestions remain concerning allocation overhead, Rust API compatibility documentation, and protocol documentation. The supplied CI snapshot reports successful Rust workspace tests; Swift SDK build/tests and PR Hygiene were pending, and no local builds or tests were run.
🔴 1 blocking | 🟡 3 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Document the missing-proposer pool return in the activating protocol specification
packages/rs-platform-version/src/version/v14.rs:1310-1314
The protocol prose describes reward-share skipping and capping, debt routing, and payout application, but omits the new absent-proposer behavior introduced here. It does not explain that valid shares are paid first, the missing proposer's leftover and final rounding remainder return to the applying block's processing pool, and an existing zero balance remains a valid recipient. The payout and application table comments omit the return as well. Document this behavior in whichever protocol snapshot activates the new generations, including the deferred, transactional, unbilled pool write and the fact that estimates and zero returns do not modify the pool. Updating prose alone does not justify keeping the existing leaf generations at 1.
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)
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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The payout-generation v1 and apply_drive_operations/v1 changes intricately alter consensus-critical funds movement through reward-share allocation, rounding conservation, and transaction-ordered processing-pool returns. - 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 14% 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
🤖 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-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_epoch_pool_to_proposers_payout_operations/v1/mod.rs`:
- [BLOCKING] packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_epoch_pool_to_proposers_payout_operations/v1/mod.rs:182-201: Preserve shipped generation 1 and version the new payout behavior
This changes reachable consensus behavior in an existing generation. The previous implementation always emitted AddToIdentityBalance for the proposer; application fails when its balance is absent. This implementation instead returns the allocation to the processing pool and succeeds through the accompanying apply_drive_operations/v1 change. An absent owner is structurally reachable: create_owner_identity_v2 returns None when owner_address is absent, and PV14 selects that method.
Both payout and application slots still select generation 1. I also checked release commit 371a3b3961c: it contains the previous payout implementation and those same selections. Consequently, old and new binaries selecting PV14 can disagree on the affected block's validity. Preserving protocols 1–13 and disclosing the incompatibility do not preserve generation 1. The repository's coding conventions explicitly distinguish amendable unreleased tables from leaf implementations, for which each behavior change requires a new generation.
Restore both v1 implementations, introduce v2 implementations and dispatcher arms, and select them only at an appropriate unreleased protocol boundary. If existing PV14 history or mixed-binary operation must remain supported, that boundary must distinguish the existing PV14 rules. Add preservation coverage for the previous v1 behavior; the historical tests currently cover v0/protocols 1–13.
In `packages/rs-drive/src/util/batch/drive_op_batch/system.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/system.rs:26-31: Document the public Rust enum expansion as source-breaking
SystemOperationType is publicly re-exported as drive::util::batch::SystemOperationType under the server feature and is not marked non_exhaustive. Adding AddToCurrentEpochProcessingPool therefore breaks downstream exhaustive matches. The PR's statement that public APIs remain compatible is inaccurate, even though this enum is not serialized and wire formats remain unchanged. Update the breaking-change description and release notes to distinguish the Rust source-compatibility change from the consensus change; this does not require a serialization or storage-format bump.
In `packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v1/mod.rs`:
- [SUGGESTION] packages/rs-drive/src/util/batch/drive_op_batch/drive_methods/apply_drive_operations/v1/mod.rs:93-111: Extract pool returns without reallocating every ordinary batch
For every nonempty batch, this partition allocates another Vec with capacity for the entire batch and moves all ordinary operations into it, even when no processing-pool return exists. Both validate_fees_of_event/v1 and execute_event/v1 call this method, so the extra allocation and element movement affect ordinary transition estimation and execution, not just epoch payouts. merge_balance_writes explicitly preserves the input allocation when no merge is required, but this step discards that benefit. Extract the return operations in place, for example with Vec::extract_if, retaining ordinary-operation order and the checked accumulation.
In `packages/rs-platform-version/src/version/v14.rs`:
- [SUGGESTION] packages/rs-platform-version/src/version/v14.rs:1310-1314: Document the missing-proposer pool return in the activating protocol specification
The protocol prose describes reward-share skipping and capping, debt routing, and payout application, but omits the new absent-proposer behavior introduced here. It does not explain that valid shares are paid first, the missing proposer's leftover and final rounding remainder return to the applying block's processing pool, and an existing zero balance remains a valid recipient. The payout and application table comments omit the return as well. Document this behavior in whichever protocol snapshot activates the new generations, including the deferred, transactional, unbilled pool write and the fact that estimates and zero returns do not modify the pool. Updating prose alone does not justify keeping the existing leaf generations at 1.
| if self | ||
| .drive | ||
| .fetch_identity_balance( | ||
| proposer_tx_hash.to_buffer(), | ||
| Some(transaction), | ||
| platform_version, | ||
| )? | ||
| .is_some() | ||
| { | ||
| drive_operations.push(IdentityOperation(AddToIdentityBalance { | ||
| identity_id: proposer_tx_hash.to_buffer(), | ||
| added_balance: proposer_payout, | ||
| })); | ||
| } else { | ||
| unallocated_payouts = | ||
| unallocated_payouts | ||
| .checked_add(proposer_payout) | ||
| .ok_or(Error::Execution(ExecutionError::Overflow( | ||
| "overflow when accumulating unallocated proposer payouts", | ||
| )))?; |
There was a problem hiding this comment.
🔴 Blocking: Preserve shipped generation 1 and version the new payout behavior
This changes reachable consensus behavior in an existing generation. The previous implementation always emitted AddToIdentityBalance for the proposer; application fails when its balance is absent. This implementation instead returns the allocation to the processing pool and succeeds through the accompanying apply_drive_operations/v1 change. An absent owner is structurally reachable: create_owner_identity_v2 returns None when owner_address is absent, and PV14 selects that method.
Both payout and application slots still select generation 1. I also checked release commit 371a3b3: it contains the previous payout implementation and those same selections. Consequently, old and new binaries selecting PV14 can disagree on the affected block's validity. Preserving protocols 1–13 and disclosing the incompatibility do not preserve generation 1. The repository's coding conventions explicitly distinguish amendable unreleased tables from leaf implementations, for which each behavior change requires a new generation.
Restore both v1 implementations, introduce v2 implementations and dispatcher arms, and select them only at an appropriate unreleased protocol boundary. If existing PV14 history or mixed-binary operation must remain supported, that boundary must distinguish the existing PV14 rules. Add preservation coverage for the previous v1 behavior; the historical tests currently cover v0/protocols 1–13.
source: gpt-6.1-sol (phase2-reviewer: general)
There was a problem hiding this comment.
p14 us not released and activated neither testnet or mainnet
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
Extract processing pool returns in place, retaining ordinary operation order and checked accumulation before writes. Document development protocol 14 payout routing without changing version selections. No payout behavior delta in this follow-up. The original missing-balance regression was RED before the preceding fix and remains GREEN. Validation: Drive batch lib 40 passed; ABCI payout lib 23 passed; scoped rustfmt and diff checks clean. No held integration targets compiled.
|
Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The pool-return implementation conserves missing-proposer allocations and applies them after ordinary writes and debt repayment within the same transaction. The documentation, allocation, and public-API disclosure concerns are fixed, but the in-place consensus change to beta-distributed generation 1 remains blocking. This verification was static; the supplied CI snapshot at 2026-10-13T06:25:13Z still showed Rust workspace tests and the JS build running.
🔴 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: 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 payout logic in add_epoch_pool_to_proposers_payout_operations/v1/mod.rs and transaction routing in apply_drive_operations/v1/mod.rs intricately change consensus-critical credit allocation, rounding conservation, and processing-pool updates across debt repayment and transaction boundaries. - 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 14% 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
🤖 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-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_epoch_pool_to_proposers_payout_operations/v1/mod.rs`:
- [BLOCKING] packages/rs-drive-abci/src/execution/platform_events/fee_pool_outwards_distribution/add_epoch_pool_to_proposers_payout_operations/v1/mod.rs:182-201: Preserve shipped generation 1 and version the new payout behavior
(existing thread: https://github.com/dashpay/platform/pull/5399#discussion_r4255235021)
Although protocol 14 is still described as in development, the local `v5.0.0-beta.3` release snapshot already contains both generation-1 implementations and selects them through `DRIVE_ABCI_METHOD_VERSIONS_V10` and `DRIVE_VERSION_V9`. That snapshot also selects `create_owner_identity` generation 2, which returns `None` when the owner address is absent, so the missing-owner condition is not excluded by the beta's construction. Its payout implementation unconditionally emits `AddToIdentityBalance`; lowering that credit requires an existing balance and otherwise fails with `there should always be a balance`. This head instead returns the allocation to the processing pool and allows distribution to complete, while retaining both generation-1 selectors.
The new disclosure correctly acknowledges this difference, but does not establish the consensus-inertness required by `book/src/contributing/coding-conventions.md`. Preserving protocols 1–13 protects generation 0, not the beta-distributed generation 1. The block compatibility check in `run_block_proposal_v0` compares the advertised application protocol number, so older and newer binaries selecting protocol 14 do not have a boundary that distinguishes these payout semantics.
Restore the prior payout/apply `v1` bodies, introduce separately dispatched generations for the new behavior, and activate them through the eligible unreleased protocol tables. If beta-PV14 chains are retained, preserve their old selection and activate the changed semantics at a distinct protocol boundary. Add coverage for the original generation-1 behavior as well as the new generations.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
Basic explanation
What this does: When a proposer has no identity balance, pays its valid reward shares and returns its remaining allocation, including rounding remainder, to the applying block's processing pool.
Value: Epoch payout can finish without losing credits when an owner identity is absent.
Risks: Changes development protocol 14 consensus behavior for affected payouts. Protocols 1–13 are unchanged. Verified with deterministic native tests; no live network reproduction or rollout compatibility claim.
Issue being fixed or feature implemented
Owner creation can omit an identity when its address is absent. Payout generation 1 nevertheless credited its missing balance, failing batch application with
there should always be a balance.What was done?
SystemOperationType::AddToCurrentEpochProcessingPool, with checked addition and refusal by generic lowering.How Has This Been Tested?
Actual regression RED before the fix: real distribution/application failed on a missing proposer balance. The unchanged regression passed afterward.
cargo test -p drive-abci --lib fee_pool_outwards_distribution -j 2: 23 passed. Includes exact credit conservation, finalized records, missing proposers/shares, remainder, debt, corruption, transaction visibility and historical dispatch.cargo test -p drive --lib util::batch::drive_op_batch -j 2: 40 passed. Includes pool-write ordering, estimates, overflow, owned rollback, caller transaction behavior and legacy refusal.Breaking Changes
Affected development protocol 14 consensus results change: a missing proposer's allocation now reaches the applying block's processing pool instead of failing distribution. Adding
SystemOperationType::AddToCurrentEpochProcessingPoolexpands a public Rust enum under theserverfeature, so downstream exhaustive matches must add the new variant. Wire formats and stored structures are unchanged.In-place changes to shipped generations
Payout/apply generation 1 is amended in place for development protocol 14. These generations already appeared in devnet betas; affected payout results change. Historical protocol 1–13 implementations and version tables are untouched. There is no stored structure migration or mixed-binary rollout guarantee.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
Summary by CodeRabbit