Skip to content

fix(drive-abci): a failed identity create from addresses pays a flat penalty - #4966

Merged
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/icfa-failure-flat-penalty
Sep 24, 2026
Merged

QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/icfa-failure-flat-penalty

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Follow-up to #4961, from its review.

  • The penalty of a failed IdentityCreateFromAddresses was added to the execution context as a precalculated processing fee, so the user fee increase multiplied it: doubled at a fee increase of 100, about 656 times at the maximum. The penalties of the asset-lock identity create and of the identity create from the shielded pool are flat. At a high fee increase the penalty could also exceed what the inputs hold, and the transition was then dropped instead of charged.
  • Giving a failed transition's inputs their spend back was written twice (identity create from addresses and address funding from asset lock). Both copies added 0 for an input missing from either map and saturated on overflow, where a mismatch is a code error.
  • The other BumpAddressInputNoncesAction constructors (top-up, transfer, from_inputs_with_remaining_balance) had no callers and subtracted a penalty from the balances without booking it.

What was done?

  • BumpAddressInputNoncesActionV0 gains penalty_credits. Its execution event books it as additional_fixed_fee_cost, which is taken from the inputs with the fee and added after the user fee increase. bump_input_nonces_with_penalty passes the penalty to the action instead of adding an operation to the execution context.
  • New address_funds::restore_input_spends_for_failed_transition (rs-drive). It returns an error when the remaining balances and the inputs differ, or when a sum overflows. BumpAddressInputNoncesActionV0::from_failed_identity_create_from_addresses_transition and AddressFundingFromAssetLockTransitionAction::restore_input_spends_for_failed_transition both call it. The constructor now returns a Result.
  • The unused constructors and their helpers new_with_penalty / deduct_penalty_from_inputs are removed, with their tests.
  • The comment in identity_create_from_shielded_pool state v0/v1 no longer describes its penalty as working like this transition's.
  • Test helper process_state_transitions_with_results takes its protocol version from the platform state, so validation, execution and block fees run at the same version. Every existing caller builds its platform at the latest version.

Example: a transition failing the key proof-of-possession check (penalty 50,000,000), metered processing 376,540.

Before:

user fee increase 0:    processing fee  50,376,540
user fee increase 100:  processing fee 100,753,080   (the penalty doubled with the rest)

After:

user fee increase 0:    processing fee  50,376,540
user fee increase 100:  processing fee  50,753,080   (376,540 doubled, penalty unchanged)

In-place changes to shipped generations

  • advanced_structure v0 and state v0 of IdentityCreateFromAddresses: the penalty is booked flat instead of scaled. The scaled booking came with fix(drive-abci): a failed identity create from addresses keeps its input balances and books its penalty #4961, which is not in any release. No recorded chain holds a failed transition of this kind, so replaying any recorded chain gives the same state.
  • advanced_structure v0 of AddressFundingFromAssetLock: restoring the input spends can now return an error. Its remaining balances and its inputs both come from the transition's inputs through the same balance check, so they always match and the sums cannot overflow. Every outcome is unchanged.

How Has This Been Tested?

  • New should_charge_the_penalty_unscaled_by_the_user_fee_increase (identity_create_from_addresses/tests.rs, protocol versions 13 and latest): the same failing transition at a fee increase of 0 and of 100 on fresh platforms. Twice the first processing fee minus the second must equal the penalty exactly. A doubled penalty makes it fail.
  • should_charge_the_inputs_when_the_fee_strategy_only_reduces_the_output now also runs at protocol version 13 and checks the penalty. The block tests share their transition builders and a single penalty and balance assertion.
  • rs-drive unit tests: the fee order with three inputs (the strategy's steps, then the unnamed inputs in input order), and errors for balances that do not match the inputs and for an overflowing sum.
  • cargo test -p drive-abci --lib -- identity_create_from_addresses address_funding_from_asset_lock execution_event advanced_structure_with_state block_processing_end_events: 346 passed. cargo test -p drive --lib -- bump_address_input_nonces address_funding_from_asset_lock: 42 passed.
  • cargo fmt --all -- --check and cargo clippy -p drive -p drive-abci --tests are clean.

Breaking Changes

None. See the in-place section above: no recorded state changes.

Checklist:

  • I have performed a self-review of my own code
  • 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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 87ce471

  • Bots — coderabbitai not yet · thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed once the bots are done
  • Within your 5 open PRs
  • Build running
  • Approvals — you own every area touched; none needed

When every box is checked the PR Hygiene check passes and this can merge.

…penalty

The penalty of a failed IdentityCreateFromAddresses was added as a
precalculated operation, so the user fee increase scaled it. It now rides
on the BumpAddressInputNoncesAction and is booked as the event's
additional_fixed_fee_cost, which the user fee increase does not scale.

Restoring a failed transition's input spends is one shared function,
restore_input_spends_for_failed_transition, used by IdentityCreateFromAddresses
and AddressFundingFromAssetLock. It errors when the remaining balances and the
inputs differ or the sum overflows, instead of adding 0 or saturating.

The unused BumpAddressInputNoncesAction constructors, which subtracted a
penalty without booking it, are removed. The block test helper takes its
protocol version from the platform state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: dashpay/platform/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: d0c93d44-e7a2-4dbc-89f6-98cb0b896e77

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc89b9 and 87ce471.

📒 Files selected for processing (17)
  • packages/rs-drive-abci/src/execution/types/execution_event/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/address_funding_from_asset_lock/advanced_structure/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_addresses/advanced_structure/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_addresses/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_addresses/state/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_addresses/state/v1/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_addresses/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_shielded_pool/state/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_shielded_pool/state/v1/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/system/bump_address_input_nonces.rs
  • packages/rs-drive/src/state_transition_action/address_funds/address_funding_from_asset_lock/mod.rs
  • packages/rs-drive/src/state_transition_action/address_funds/mod.rs
  • packages/rs-drive/src/state_transition_action/system/bump_address_input_nonces_action/mod.rs
  • packages/rs-drive/src/state_transition_action/system/bump_address_input_nonces_action/transformer.rs
  • packages/rs-drive/src/state_transition_action/system/bump_address_input_nonces_action/v0/mod.rs
  • packages/rs-drive/src/state_transition_action/system/bump_address_input_nonces_action/v0/transformer.rs

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

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 24, 2026
@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Sep 24, 2026
@thepastaclaw

thepastaclaw commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 3rd in line, estimated start in ~1.0 h (commit 87ce471)
Estimated review time once started: ~40 min (two-phase automated review; median of recent runs).

  • Request priority review — click to move this review to the front of the queue.

@QuantumExplorer
QuantumExplorer merged commit b574744 into v4.2-dev Sep 24, 2026
19 of 20 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/icfa-failure-flat-penalty branch September 24, 2026 05:35
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.

2 participants