Repository navigation
fix(platform)!: charge a sponsored batch's fee increase to its signer (PV14) - #5398
Conversation
… (PV14) The signer of a document batch chooses its user_fee_increase. When the contract owner pays the batch's gas, fee validation v1 judged and execute_event v1 charged that owner the processing fee raised by it. Now the sponsor is judged on and charged the fee without the increase, and the signer pays the processing fee the increase adds, as a fee of its own: its balance and a budgeted key's budget must cover the principal plus the increase (refused unpaid otherwise, 40210 / 40218). The reported actual fee is the sum of both charges. A batch with no increase, or paid by its signer, is judged and charged as before. Both generations are selected only by protocol version 14, which has not shipped, so they are edited in place; v14 note 11 and the book describe the rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
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-13T07:43:34.388Z |
|
🔍 Review in progress — actively reviewing now (commit 57eb03c) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification at head 83a98ba found no blocking defects: sponsorship excludes the signer's fee increase in both validation and execution, and the changed implementations are confined to unreleased PV14. One targeted admission-boundary test would strengthen coverage of the new sponsor-selection rule. No local builds or tests were run; the supplied CI snapshot reports successful Rust workspace tests, with PR Hygiene pending.
🟡 1 suggestion(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); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The diff changes consensus fee allocation in settle_fees_of_event_v1 and execute_event_v1, but the surcharge split and associated balance and budget checks are contained rather than large or intricate enough to meet the critical tier. - 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) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort high); 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/validation/state_transition/state_transitions/batch/tests/document/gas_sponsorship.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/gas_sponsorship.rs:1068-1073: Cover sponsor admission when only the unincreased fee fits
The successful fee-split test fixes the sponsor balance at 0.1 Dash without establishing that it covers the estimated base gas but cannot cover the gas including the increase. Its payment assertions verify execution, but do not explicitly pin the changed admission boundary in `settle_fees_of_event_v1`, which now subtracts the increase before selecting the sponsor. Add a deterministic case that establishes the sponsor's balance is between those two estimated requirements and gives the signer enough credits for the increase. Exercise both `ContractOwner` and `PreferContractOwner`, asserting check-tx admission and sponsor payment at execution, so charging the increased estimate cannot regress into an unpaid refusal or a signer-pays fallback.
|
Bots are done — your move: post |
… fits A contract owner whose balance holds exactly the gas estimated without the signer's fee increase still sponsors a creation asking for a 100% increase, under ContractOwner and PreferContractOwner: check tx admits it, the owner pays the gas and the signer the increase. Before the fix an insisting batch was refused with 40222 and a preferring one fell back to the signer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Basic explanation
What this does: Every state transition can carry a
user_fee_increase: a percentage the sender adds to the processing fee to get picked sooner. When a contract owner pays the gas of a document action (gas sponsorship, protocol version 14), that extra percentage was billed to the contract owner, although the signer chose it. Now the contract owner pays the fee as if no increase was chosen, and the signer pays the extra amount themselves.Value: A contract owner who sponsors gas pays a predictable fee per action, whatever the signer puts in the transition. A signer who wants priority still gets it and pays for it, as on an unsponsored transition.
Risks: Low. Consensus change at protocol version 14 only, which has not shipped to mainnet; the two methods edited are selected by no released version. A sponsored batch with
user_fee_increase: 0is judged and charged exactly as before. A signer with a nonzero increase who cannot pay it is now refused (unpaid) instead of having the contract owner pay it.Issue being fixed or feature implemented
With gas sponsorship (
gasFeesPaidBy: ContractOwner/PreferContractOwner),validate_fees_of_eventv1 judged andexecute_eventv1 charged the contract owner the processing fee raised by the signer'suser_fee_increase. The signer chose the increase, so the signer should pay it.What was done?
Before, a sponsored creation with
user_fee_increase: 100:After:
validate_fees_of_eventv1 (settle_fees_of_event_v1): the sponsor is judged on the estimated gas less the increase. When the sponsor pays, the signer's balance has to cover the principal plus the increase (IdentityInsufficientBalanceError, 40210, unpaid otherwise), and a budgeted signing key has to cover the same (IdentityPublicKeyBudgetExceededError, 40218).execute_eventv1: when a sponsor pays, the increase is taken off the sponsor's fee and charged to the signer as a processing fee of its own (a secondapply_balance_change_from_fee_to_identity). The reported actual fee is the sum of both, and the signer's key budget is charged the increase.PreferContractOwnerfallback, or a failed batch) nothing changes.ResolvedGasSponsor,ExecutionEvent::Paid.gas_sponsor, the book's fee overview andtokenCostchapter.In-place changes to shipped generations
None.
execute_event1 andvalidate_fees_of_event1 are selected only byDRIVE_ABCI_METHOD_VERSIONS_V10(protocol version 14, unreleased), so they are edited in place.How Has This Been Tested?
New tests in
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/gas_sponsorship.rs:user_fee_increase0 andu16::MAX: the contract owner pays the same, the signer pays exactlyprocessing × 65535 / 100, and the result reports both;ContractOwnerandPreferContractOwner): refused in check tx and at execution, unpaid, the contract owner untouched;cargo test -p drive-abci --lib -- gas_sponsorship key_limits action_fees token_cost_policy validate_fees_of_event execute_eventBreaking Changes
Consensus change at protocol version 14 (unreleased): a sponsored document batch with a nonzero
user_fee_increasecharges the increase to its signer.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
IdentityInsufficientBalanceError(40210).PR Hygiene ·
57eb03c/skip-botsproceeds without the ones not yet reported/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.