[pallet-xcm] Adjust benchmarks (teleport_assets/reserve_transfer_assets) not relying on ED (#3464)
## Problem
During the bumping of the `polkadot-fellows` repository to
`polkadot-sdk@1.6.0`, I encountered a situation where the benchmarks
`teleport_assets` and `reserve_transfer_assets` in AssetHubKusama
started to fail. This issue arose due to a decreased ED balance for
AssetHubs introduced
[here](https://github.com/polkadot-fellows/runtimes/pull/158/files#diff-80668ff8e793b64f36a9a3ec512df5cbca4ad448c157a5d81abda1b15f35f1daR213),
and also because of a [missing CI
pipeline](https://github.com/polkadot-fellows/runtimes/issues/197) to
check the benchmarks, which went unnoticed.
These benchmarks expect the `caller` to have enough:
1. balance to transfer (BTT)
2. balance for paying delivery (BFPD).
So the initial balance was calculated as `ED * 100`, which seems
reasonable:
```
const ED_MULTIPLIER: u32 = 100;
let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into());`
```
The problem arises when the price for delivery is 100 times higher than
the existential deposit. In other words, when `ED * 100` does not cover
`BTT` + `BFPD`.
I check AHR/AHW/AHK/AHP and this problem has only AssetHubKusama
```
ED: 3333333
calculated price to parent delivery: 1031666634 (from xcm logs from the benchmark)
---
3333333 * 100 - BTT(3333333) - BFPD(1031666634) = −701666667
```
which results in the error;
```
2024-02-23 09:19:42 Unable to charge fee with error Module(ModuleError { index: 31, error: [17, 0, 0, 0], message: Some("FeesNotMet") })
Error: Input("Benchmark pallet_xcm::reserve_transfer_assets failed: FeesNotMet")
```
## Solution
The benchmarks `teleport_assets` and `reserve_transfer_assets` were
fixed by removing `ED * 100` and replacing it with `DeliveryHelper`
logic, which calculates the (almost real) price for delivery and sets it
along with the existential deposit as the initial balance for the
account used in the benchmark.
## TODO
- [ ] patch for 1.6 -
https://github.com/paritytech/polkadot-sdk/pull/3466
- [ ] patch for 1.7 -
https://github.com/paritytech/polkadot-sdk/pull/3465
- [ ] patch for 1.8 - TODO: PR
---------
Co-authored-by:
Francisco Aguirre <franciscoaguirreperez@gmail.com>
parent
b9c792a4
Showing
- Cargo.lock 1 addition, 2 deletionsCargo.lock
- cumulus/pallets/parachain-system/Cargo.toml 4 additions, 0 deletionscumulus/pallets/parachain-system/Cargo.toml
- cumulus/pallets/parachain-system/src/lib.rs 9 additions, 0 deletionscumulus/pallets/parachain-system/src/lib.rs
- cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs 27 additions, 15 deletions...us/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
- cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs 27 additions, 15 deletions...s/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
- cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs 7 additions, 1 deletion...achains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
- cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs 7 additions, 1 deletion...chains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs
- cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs 14 additions, 1 deletion...hains/runtimes/collectives/collectives-westend/src/lib.rs
- cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs 20 additions, 3 deletions...parachains/runtimes/contracts/contracts-rococo/src/lib.rs
- cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs 7 additions, 1 deletion...s/parachains/runtimes/coretime/coretime-rococo/src/lib.rs
- cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs 7 additions, 1 deletion.../parachains/runtimes/coretime/coretime-westend/src/lib.rs
- cumulus/parachains/runtimes/people/people-rococo/src/lib.rs 7 additions, 1 deletioncumulus/parachains/runtimes/people/people-rococo/src/lib.rs
- cumulus/parachains/runtimes/people/people-westend/src/lib.rs 7 additions, 1 deletioncumulus/parachains/runtimes/people/people-westend/src/lib.rs
- cumulus/primitives/utility/Cargo.toml 0 additions, 3 deletionscumulus/primitives/utility/Cargo.toml
- cumulus/primitives/utility/src/lib.rs 8 additions, 3 deletionscumulus/primitives/utility/src/lib.rs
- polkadot/runtime/common/Cargo.toml 0 additions, 4 deletionspolkadot/runtime/common/Cargo.toml
- polkadot/runtime/common/src/xcm_sender.rs 12 additions, 3 deletionspolkadot/runtime/common/src/xcm_sender.rs
- polkadot/runtime/rococo/src/lib.rs 23 additions, 5 deletionspolkadot/runtime/rococo/src/lib.rs
- polkadot/runtime/westend/src/lib.rs 33 additions, 13 deletionspolkadot/runtime/westend/src/lib.rs
- polkadot/runtime/westend/src/xcm_config.rs 1 addition, 1 deletionpolkadot/runtime/westend/src/xcm_config.rs
Please register or sign in to comment