Skip to content

fix(drive-abci): a failed identity create from addresses keeps its input balances and books its penalty - #4961

Merged
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/fix-first-item-629c01
Sep 24, 2026
Merged

QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/fix-first-item-629c01

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

An IdentityCreateFromAddresses that fails after its inputs were checked (invalid key structure, invalid key signature, or a key that is already registered) still bumps its input nonces and pays a penalty, through a BumpAddressInputNoncesAction. That action was built with the wrong balances:

  • the key checks (advanced_structure v0) set each input to the amount the transition asked to spend;
  • the state checks (state v0 and v1) set each input to the balance left after that spend.

The penalty, plus a second copy of the processing fee, was then subtracted from those balances without being booked to the fee pools.

What was done?

  • BumpAddressInputNoncesAction::from_failed_identity_create_from_addresses_transition (rs-drive) builds the action from the transition and the action it was transformed into: each input keeps its whole balance, the balance left after the spend plus the amount it would have spent. It replaces the four identity create from addresses constructors.
  • The penalty is added to the execution context as a precalculated processing fee, as ShieldFromIdentity already does. The address fee path then takes it from the inputs and books it with the rest of the fee. The processing fee is counted once. Like any processing fee, the penalty follows the user fee increase.
  • The fee is taken in the order of the transition's fee strategy, then from the inputs the strategy does not name, the order the penalty was already taken in. A failed transition has no output, so a strategy that only reduces the output could not otherwise pay.
  • All three failure paths go through one helper, bump_input_nonces_with_penalty (identity_create_from_addresses/mod.rs). The advanced structure dispatcher now passes the action to validate_advanced_structure_from_state_for_identity_create_from_addresses_transition.
  • Test helper process_state_transitions_with_results runs transitions through a whole block, block fee processing included, and accepts failed ones. process_state_transitions now wraps it.

Example: an input holding 1.1 Dash (110,000,000,000 credits) asks to spend 1 Dash, and one key signature is invalid (penalty 50,000,000).

Before:

input balance:      99,949,551,260   (the 1 Dash it asked to spend, minus 50,072,200, minus the 376,540 fee)
fee pools receive:         376,540

After:

input balance:     109,949,623,460   (1.1 Dash minus the 50,376,540 fee)
fee pools receive:      50,376,540   (the 50,000,000 penalty and 376,540 of processing)

In-place changes to shipped generations

advanced_structure v0 and state v0 of IdentityCreateFromAddresses are selected by every released protocol version and are edited in place. state v1 is selected only by protocol version 14, which is unreleased.

  • The outcome changes only for a transition that fails after its inputs were checked. Before this change, a block holding such a transition did not balance its credits at block end, or the transition was left out of the block when its fee could not be taken, so no recorded chain holds one. Replaying any recorded chain gives the same state.
  • The new tests run the failure paths at protocol version 13 as well as the latest.

How Has This Been Tested?

  • New module failed_transition_credit_conservation in identity_create_from_addresses/tests.rs: invalid key signature, duplicated key ids, key already registered (with a change output), and a fee strategy that only reduces the output. Each runs a whole block, at protocol versions 13 and latest for the first three. Each checks the paid consensus error, that the booked fee includes the penalty, and that the input holds its balance minus exactly the booked fee with its nonce bumped. Without the fix the first three fail, and without the fee strategy fallback the fourth does.
  • Unit tests for the new constructor in bump_address_input_nonces_action/transformer.rs and v0/transformer.rs.
  • cargo test -p drive-abci --lib -- identity_create_from_addresses advanced_structure_with_state: 209 passed. cargo test -p drive --lib bump_address_input_nonces: 45 passed.
  • cargo fmt --all -- --check and cargo clippy -p drive -p drive-abci --tests are clean. Strategy tests were not run locally.

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 · 477e5f4

  • 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.

…put balances and books its penalty

A failed IdentityCreateFromAddresses (invalid key structure, invalid key
signature, key already registered) now bumps its input nonces with each
input's whole balance and charges its penalty as part of its fee, so the
penalty is taken from the inputs and booked to the fee pools together.
The fee is taken in the order of the fee strategy, then from the inputs it
does not name.

advanced_structure v0 and state v0 are edited in place: no recorded chain
holds a transition that took those paths.

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 23 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: 779fdd01-7d33-4a9d-819c-fa0e004a7a40

📥 Commits

Reviewing files that changed from the base of the PR and between dd93756 and 477e5f4.

📒 Files selected for processing (9)
  • packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/advanced_structure_with_state.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/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/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 ~50 min (commit 477e5f4)
Estimated review time once started: ~35 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 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Approved

@QuantumExplorer
QuantumExplorer merged commit 7fc89b9 into v4.2-dev Sep 24, 2026
20 of 21 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/fix-first-item-629c01 branch September 24, 2026 04:42
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