Skip to content

add poke_deposit extrinsic to pallet-recovery#7882

Merged
UtkarshBhardwaj007 merged 21 commits into
paritytech:masterfrom
UtkarshBhardwaj007:poke-recovery
Apr 22, 2025
Merged

add poke_deposit extrinsic to pallet-recovery#7882
UtkarshBhardwaj007 merged 21 commits into
paritytech:masterfrom
UtkarshBhardwaj007:poke-recovery

Conversation

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member

@UtkarshBhardwaj007 UtkarshBhardwaj007 commented Mar 11, 2025

Description

Review Notes

  • Added a new extrinsic poke_deposit in pallet-recovery.
  • Added a new event DepositPoked to be emitted upon a successful call of the extrinsic.
  • Added a new enum DepositKind to differentiate between the 2 kinds of deposits in the pallet.
  • Although the immediate use of the extrinsic will be to give back some of the deposit after the AH-migration, the extrinsic is written such that it can work if the deposit decreases or increases (both).
  • The call to the extrinsic would be free if an actual adjustment is made to the deposit and paid otherwise.
  • Added tests to test all scenarios.
  • Added benchmark
  • Fixed bug in benchmark helper function insert_recovery_config where funds were being reserved from the wrong account.
  • Minor refactoring to avoid code duplication.
  • Had to re-organise imports to make the code more readable and modular. In the process, I removed unnecessary dependencies and imported everything from the frame umbrella crate. So this PR also solves: [tracking] Migrate pallets to FRAME umbrella crate #6504 for pallet-recovery

TO-DOs

  • Run CI cmd bot to benchmark

@UtkarshBhardwaj007 UtkarshBhardwaj007 added T1-FRAME This PR/Issue is related to core FRAME, the framework. T2-pallets This PR/Issue is related to a particular pallet. labels Mar 11, 2025
@UtkarshBhardwaj007 UtkarshBhardwaj007 requested a review from a team as a code owner March 11, 2025 11:59
@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd fmt

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd prdoc

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd bench --pallet pallet_recovery

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_recovery" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_recovery" has finished ✅ See logs here

Details

Subweight results:
File Extrinsic Old New Change [%]
substrate/frame/recovery/src/weights.rs poke_deposit 2.73ms Added
polkadot/runtime/westend/src/weights/pallet_recovery.rs poke_deposit 2.74ms Added
polkadot/runtime/rococo/src/weights/pallet_recovery.rs poke_deposit 2.75ms Added
Command output:

❌ Failed benchmarks of runtimes/pallets:
-- dev: ['pallet_recovery']
-- westend: ['pallet_recovery']
-- rococo: ['pallet_recovery']

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd bench --pallet pallet_recovery

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_recovery" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_recovery" has finished ✅ See logs here

Details

Subweight results:
File Extrinsic Old New Change [%]
substrate/frame/recovery/src/weights.rs as_recovered 84.51us 94.70us +12.06
substrate/frame/recovery/src/weights.rs poke_deposit 330.79us Added
polkadot/runtime/westend/src/weights/pallet_recovery.rs poke_deposit 329.98us Added
polkadot/runtime/rococo/src/weights/pallet_recovery.rs poke_deposit 329.55us Added
Command output:

✅ Successful benchmarks of runtimes/pallets:
-- dev: ['pallet_recovery']
-- westend: ['pallet_recovery']
-- rococo: ['pallet_recovery']

Comment thread substrate/frame/recovery/src/lib.rs
Comment thread substrate/frame/recovery/src/lib.rs Outdated
Comment thread substrate/frame/recovery/src/lib.rs Outdated
Comment thread substrate/frame/recovery/src/lib.rs Outdated
@paritytech-review-bot paritytech-review-bot Bot requested a review from a team March 24, 2025 12:41
@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd --help

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd fmt

@github-actions
Copy link
Copy Markdown
Contributor

Command help:
usage: /cmd  [--help] [--quiet] [--clean] [--image IMAGE]
             {bench,bench-omni,fmt,update-ui,prdoc} ...

A command runner for polkadot-sdk repo

positional arguments:
  {bench,bench-omni,fmt,update-ui,prdoc}
                        a command to run
    bench (bench-omni)  Runs benchmarks (frame omni bencher)
    fmt                 Formats code (cargo +nightly-VERSION fmt) and configs
                        (taplo format)
    update-ui           Updates UI tests
    prdoc               Generates PR documentation

options:
  --help                help for help if you need some help
  --quiet               Won't print start/end/failed messages in PR
  --clean               Clean up the previous bot's & author's comments in PR
  --image IMAGE         Override docker image '--image
                        docker.io/paritytech/ci-unified:latest'

### Command 'bench'
usage: /cmd bench [-h] [--quiet] [--clean] [--image IMAGE]
                  [--runtime [{dev,westend,rococo,asset-hub-westend,asset-hub-rococo,bridge-hub-rococo,bridge-hub-westend,collectives-westend,coretime-rococo,coretime-westend,glutton-westend,people-rococo,people-westend} ...]]
                  [--pallet [PALLET ...]] [--fail-fast]

options:
  -h, --help            show this help message and exit
  --quiet               Won't print start/end/failed messages in PR
  --clean               Clean up the previous bot's & author's comments in PR
  --image IMAGE         Override docker image '--image
                        docker.io/paritytech/ci-unified:latest'
  --runtime [{dev,westend,rococo,asset-hub-westend,asset-hub-rococo,bridge-hub-rococo,bridge-hub-westend,collectives-westend,coretime-rococo,coretime-westend,glutton-westend,people-rococo,people-westend} ...]
                        Runtime(s) space separated
  --pallet [PALLET ...]
                        Pallet(s) space separated
  --fail-fast           Fail fast on first failed benchmark

**Examples**:
 Runs all benchmarks 
 /cmd bench

 Runs benchmarks for pallet_balances and pallet_multisig for all runtimes which have these pallets. **--quiet** makes it to output nothing to PR but reactions
 /cmd bench --pallet pallet_balances pallet_xcm_benchmarks::generic --quiet
 
 Runs bench for all pallets for westend runtime and fails fast on first failed benchmark
 /cmd bench --runtime westend --fail-fast
 
 Does not output anything and cleans up the previous bot's & author command triggering comments in PR 
 /cmd bench --runtime westend rococo --pallet pallet_balances pallet_multisig --quiet --clean


### Command 'bench-omni'
usage: /cmd bench [-h] [--quiet] [--clean] [--image IMAGE]
                  [--runtime [{dev,westend,rococo,asset-hub-westend,asset-hub-rococo,bridge-hub-rococo,bridge-hub-westend,collectives-westend,coretime-rococo,coretime-westend,glutton-westend,people-rococo,people-westend} ...]]
                  [--pallet [PALLET ...]] [--fail-fast]

options:
  -h, --help            show this help message and exit
  --quiet               Won't print start/end/failed messages in PR
  --clean               Clean up the previous bot's & author's comments in PR
  --image IMAGE         Override docker image '--image
                        docker.io/paritytech/ci-unified:latest'
  --runtime [{dev,westend,rococo,asset-hub-westend,asset-hub-rococo,bridge-hub-rococo,bridge-hub-westend,collectives-westend,coretime-rococo,coretime-westend,glutton-westend,people-rococo,people-westend} ...]
                        Runtime(s) space separated
  --pallet [PALLET ...]
                        Pallet(s) space separated
  --fail-fast           Fail fast on first failed benchmark

**Examples**:
 Runs all benchmarks 
 /cmd bench

 Runs benchmarks for pallet_balances and pallet_multisig for all runtimes which have these pallets. **--quiet** makes it to output nothing to PR but reactions
 /cmd bench --pallet pallet_balances pallet_xcm_benchmarks::generic --quiet
 
 Runs bench for all pallets for westend runtime and fails fast on first failed benchmark
 /cmd bench --runtime westend --fail-fast
 
 Does not output anything and cleans up the previous bot's & author command triggering comments in PR 
 /cmd bench --runtime westend rococo --pallet pallet_balances pallet_multisig --quiet --clean


### Command 'fmt'
usage: /cmd fmt [-h] [--quiet] [--clean] [--image IMAGE]

options:
  -h, --help     show this help message and exit
  --quiet        Won't print start/end/failed messages in PR
  --clean        Clean up the previous bot's & author's comments in PR
  --image IMAGE  Override docker image '--image docker.io/paritytech/ci-
                 unified:latest'


### Command 'update-ui'
usage: /cmd update-ui [-h] [--quiet] [--clean] [--image IMAGE]

options:
  -h, --help     show this help message and exit
  --quiet        Won't print start/end/failed messages in PR
  --clean        Clean up the previous bot's & author's comments in PR
  --image IMAGE  Override docker image '--image docker.io/paritytech/ci-
                 unified:latest'


### Command 'prdoc'
usage: /cmd prdoc [-h] [--pr PR]
                  [--audience [{runtime_dev,runtime_user,node_dev,node_operator,todo} ...]]
                  [--bump {patch,minor,major,silent,ignore,none}] [--force]

options:
  -h, --help            show this help message and exit
  --pr PR               The PR number to generate the PrDoc for.
  --audience [{runtime_dev,runtime_user,node_dev,node_operator,todo} ...]
                        The audience of whom the changes may concern. Example:
                        --audience runtime_dev node_dev
  --bump {patch,minor,major,silent,ignore,none}
                        A default bump level for all crates. Example: --bump
                        patch
  --force               Whether to overwrite any existing PrDoc.

Comment thread substrate/frame/recovery/Cargo.toml Outdated
@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd fmt

Comment thread substrate/frame/recovery/src/benchmarking.rs
@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd fmt

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member Author

/cmd bench --pallet pallet_recovery

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_recovery" has started 🚀 See logs here

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_recovery" has finished ✅ See logs here

Details

Subweight results:
File Extrinsic Old New Change [%]
substrate/frame/recovery/src/weights.rs as_recovered 84.51us 94.50us +11.82
substrate/frame/recovery/src/weights.rs initiate_recovery 174.93us 184.08us +5.23
substrate/frame/recovery/src/weights.rs create_recovery 146.65us 154.09us +5.08
substrate/frame/recovery/src/weights.rs poke_deposit 299.33us Added
polkadot/runtime/westend/src/weights/pallet_recovery.rs poke_deposit 298.76us Added
polkadot/runtime/rococo/src/weights/pallet_recovery.rs poke_deposit 298.26us Added
Command output:

✅ Successful benchmarks of runtimes/pallets:
-- dev: ['pallet_recovery']
-- westend: ['pallet_recovery']
-- rococo: ['pallet_recovery']

@UtkarshBhardwaj007 UtkarshBhardwaj007 added this pull request to the merge queue Apr 18, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 18, 2025
@UtkarshBhardwaj007 UtkarshBhardwaj007 added this pull request to the merge queue Apr 20, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 20, 2025
@UtkarshBhardwaj007 UtkarshBhardwaj007 added this pull request to the merge queue Apr 22, 2025
Merged via the queue into paritytech:master with commit 79b28b3 Apr 22, 2025
1 check passed
@UtkarshBhardwaj007 UtkarshBhardwaj007 deleted the poke-recovery branch April 22, 2025 17:00
ordian added a commit that referenced this pull request Apr 28, 2025
* master: (120 commits)
  [CI] Improve GH build status checking (#8331)
  [CI/CD] Use original PR name in prdoc check for the backport PR's to the stable branches (#8329)
  Add new host APIs set_storage_or_clear and get_storage_or_zero (#7857)
  push to dockerhub (#8322)
  Snowbridge - V1 - Adds 2 hop transfer to Rococo (#7956)
  [AHM] Prepare `election-provider-multi-block` for full lazy data deletion (#8304)
  Check umbrella version (#8250)
  [AHM] Fully bound staking async (#8303)
  migrate parachain-templates tests to `gha` (#8226)
  staking-async: add missing new_session_genesis (#8310)
  New NFT traits: granular and abstract interface (#5620)
  Extract create_pool_with_native_on macro to common crate (#8289)
  XCMP: use batching when enqueuing inbound messages (#8021)
  Snowbridge - Tests refactor (#8014)
  Allow configuration of worst case buy execution weight (#7944)
  Fix faulty pre-upgrade migration check in pallet-session (#8294)
  [pallet-revive] add get_storage_var_key for variable-sized keys (#8274)
  add poke_deposit extrinsic to pallet-recovery (#7882)
  `txpool`: use tracing for structured logging (#8001)
  [revive] eth-rpc refactoring (#8148)
  ...
castillax pushed a commit that referenced this pull request May 12, 2025
# Description

* This PR adds a new extrinsic `poke_deposit` to `pallet-recovery`. This
extrinsic will be used to re-adjust the deposits made in the pallet
after AHM.
* Part of #5591 

## Review Notes

* Added a new extrinsic `poke_deposit` in `pallet-recovery`.
* Added a new event `DepositPoked` to be emitted upon a successful call
of the extrinsic.
* Added a new enum `DepositKind` to differentiate between the 2 kinds of
deposits in the pallet.
* Although the immediate use of the extrinsic will be to give back some
of the deposit after the AH-migration, the extrinsic is written such
that it can work if the deposit decreases or increases (both).
* The call to the extrinsic would be `free` if an actual adjustment is
made to the deposit and `paid` otherwise.
* Added tests to test all scenarios.
* Added benchmark
* **Fixed bug** in benchmark helper function `insert_recovery_config`
where funds were being reserved from the wrong account.
* Minor refactoring to avoid code duplication.
* Had to re-organise imports to make the code more readable and modular.
In the process, I removed unnecessary dependencies and imported
everything from the frame umbrella crate. So this PR also solves: #6504
for `pallet-recovery`

## TO-DOs
* [x] Run CI cmd bot to benchmark

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T1-FRAME This PR/Issue is related to core FRAME, the framework. T2-pallets This PR/Issue is related to a particular pallet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants