Repository navigation
fix(drive-abci): a failed identity create from addresses pays a flat penalty - #4966
Conversation
…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]>
|
Warning Review limit reachedNext included review available in 22 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 (17)
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 ~1.0 h (commit 87ce471)
|
Issue being fixed or feature implemented
Follow-up to #4961, from its review.
IdentityCreateFromAddresseswas 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.BumpAddressInputNoncesActionconstructors (top-up, transfer,from_inputs_with_remaining_balance) had no callers and subtracted a penalty from the balances without booking it.What was done?
BumpAddressInputNoncesActionV0gainspenalty_credits. Its execution event books it asadditional_fixed_fee_cost, which is taken from the inputs with the fee and added after the user fee increase.bump_input_nonces_with_penaltypasses the penalty to the action instead of adding an operation to the execution context.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_transitionandAddressFundingFromAssetLockTransitionAction::restore_input_spends_for_failed_transitionboth call it. The constructor now returns aResult.new_with_penalty/deduct_penalty_from_inputsare removed, with their tests.identity_create_from_shielded_poolstate v0/v1 no longer describes its penalty as working like this transition's.process_state_transitions_with_resultstakes 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:
After:
In-place changes to shipped generations
advanced_structurev0 andstatev0 ofIdentityCreateFromAddresses: 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_structurev0 ofAddressFundingFromAssetLock: 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?
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_outputnow also runs at protocol version 13 and checks the penalty. The block tests share their transition builders and a single penalty and balance assertion.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 -- --checkandcargo clippy -p drive -p drive-abci --testsare clean.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 ·
87ce471/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.