Contracts: Remove ED from base deposit (#3536)

- Update internal logic so that the storage_base_deposit does not
include ED
- add v16 migration to update ContractInfo struct with this change

Before:
<img width="820" alt="Screenshot 2024-03-21 at 11 23 29"
src="https://github.com/paritytech/polkadot-sdk/assets/521091/a0a8df0d-e743-42c5-9e16-cf2ec1aa949c">

After:
![Screenshot 2024-03-21 at 11 23
42](https://github.com/paritytech/polkadot-sdk/assets/521091/593235b0-b866-4915-b653-2071d793228b)

---------

Co-authored-by: Cyrill Leutwiler <cyrill@parity.io>
Co-authored-by: command-bot <>
This commit is contained in:
PG Herveou
2024-04-10 22:32:53 +02:00
committed by GitHub
parent d21a41f238
commit 643aa2be2a
8 changed files with 174 additions and 42 deletions
@@ -32,7 +32,7 @@ use self::{
use crate::{
exec::Key,
migration::{
codegen::LATEST_MIGRATION_VERSION, v09, v10, v11, v12, v13, v14, v15, MigrationStep,
codegen::LATEST_MIGRATION_VERSION, v09, v10, v11, v12, v13, v14, v15, v16, MigrationStep,
},
Pallet as Contracts, *,
};
@@ -331,6 +331,26 @@ mod benchmarks {
Ok(())
}
// This benchmarks the v16 migration step (Remove ED from base_deposit).
#[benchmark(pov_mode = Measured)]
fn v16_migration_step() -> Result<(), BenchmarkError> {
let contract =
<Contract<T>>::with_caller(whitelisted_caller(), WasmModule::dummy(), vec![])?;
let info = contract.info()?;
let base_deposit = v16::store_old_contract_info::<T>(contract.account_id.clone(), &info);
let mut m = v16::Migration::<T>::default();
#[block]
{
m.step(&mut WeightMeter::new());
}
let ed = Pallet::<T>::min_balance();
let info = v16::ContractInfoOf::<T>::get(&contract.account_id).unwrap();
assert_eq!(info.storage_base_deposit, base_deposit - ed);
Ok(())
}
// This benchmarks the weight of executing Migration::migrate to execute a noop migration.
#[benchmark(pov_mode = Measured)]
fn migration_noop() {