Repository navigation
fix(drive-abci): a failed identity create from addresses keeps its input balances and books its penalty - #4961
Conversation
…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]>
|
Warning Review limit reachedNext included review available in 23 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
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. Comment |
|
🕓 Queued for automated review — 3rd in line, estimated start in ~50 min (commit 477e5f4)
|
Issue being fixed or feature implemented
An
IdentityCreateFromAddressesthat 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 aBumpAddressInputNoncesAction. That action was built with the wrong balances:advanced_structurev0) set each input to the amount the transition asked to spend;statev0 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.ShieldFromIdentityalready 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.bump_input_nonces_with_penalty(identity_create_from_addresses/mod.rs). The advanced structure dispatcher now passes the action tovalidate_advanced_structure_from_state_for_identity_create_from_addresses_transition.process_state_transitions_with_resultsruns transitions through a whole block, block fee processing included, and accepts failed ones.process_state_transitionsnow 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:
After:
In-place changes to shipped generations
advanced_structurev0 andstatev0 ofIdentityCreateFromAddressesare selected by every released protocol version and are edited in place.statev1 is selected only by protocol version 14, which is unreleased.How Has This Been Tested?
failed_transition_credit_conservationinidentity_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.bump_address_input_nonces_action/transformer.rsandv0/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 -- --checkandcargo clippy -p drive -p drive-abci --testsare clean. Strategy tests were not run locally.Breaking Changes
None. See the in-place section above: no recorded state changes.
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
PR Hygiene ·
477e5f4/skip-botsproceeds without the ones not yet reported/self-reviewedonce the bots are doneWhen every box is checked the
PR Hygienecheck passes and this can merge.