mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
FRAME: Revamp Preimage pallet to use Consideration (#1363)
Make Preimage pallet use Consideration instead of handling deposits directly. Other half of paritytech/substrate#13666. Depends/based on #1361. Script for the lazy migration that should be run manually once: [migrate-preimage-lazy.py](https://github.com/ggwpez/substrate-scripts/blob/master/migrate-preimage-lazy.py). ## TODO - [x] Migration code. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -67,7 +67,10 @@ use frame_support::{
|
||||
construct_runtime,
|
||||
dispatch::DispatchClass,
|
||||
parameter_types,
|
||||
traits::{ConstBool, ConstU16, ConstU32, ConstU64, ConstU8, EitherOfDiverse, InstanceFilter},
|
||||
traits::{
|
||||
fungible::HoldConsideration, ConstBool, ConstU16, ConstU32, ConstU64, ConstU8,
|
||||
EitherOfDiverse, InstanceFilter, LinearStoragePrice,
|
||||
},
|
||||
weights::{ConstantMultiplier, Weight},
|
||||
PalletId,
|
||||
};
|
||||
@@ -209,7 +212,7 @@ impl pallet_balances::Config for Runtime {
|
||||
type ReserveIdentifier = [u8; 8];
|
||||
type RuntimeHoldReason = RuntimeHoldReason;
|
||||
type FreezeIdentifier = ();
|
||||
type MaxHolds = ConstU32<0>;
|
||||
type MaxHolds = ConstU32<1>;
|
||||
type MaxFreezes = ConstU32<0>;
|
||||
}
|
||||
|
||||
@@ -545,6 +548,7 @@ impl pallet_scheduler::Config for Runtime {
|
||||
parameter_types! {
|
||||
pub const PreimageBaseDeposit: Balance = deposit(2, 64);
|
||||
pub const PreimageByteDeposit: Balance = deposit(0, 1);
|
||||
pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
|
||||
}
|
||||
|
||||
impl pallet_preimage::Config for Runtime {
|
||||
@@ -552,8 +556,12 @@ impl pallet_preimage::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type ManagerOrigin = EnsureRoot<AccountId>;
|
||||
type BaseDeposit = PreimageBaseDeposit;
|
||||
type ByteDeposit = PreimageByteDeposit;
|
||||
type Consideration = HoldConsideration<
|
||||
AccountId,
|
||||
Balances,
|
||||
PreimageHoldReason,
|
||||
LinearStoragePrice<PreimageBaseDeposit, PreimageByteDeposit, Balance>,
|
||||
>;
|
||||
}
|
||||
|
||||
// Create the runtime by composing the FRAME pallets that were previously configured.
|
||||
@@ -589,7 +597,7 @@ construct_runtime!(
|
||||
Utility: pallet_utility::{Pallet, Call, Event} = 40,
|
||||
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 41,
|
||||
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 42,
|
||||
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 43,
|
||||
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>, HoldReason} = 43,
|
||||
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 44,
|
||||
|
||||
// The main stage.
|
||||
|
||||
+15
@@ -50,6 +50,21 @@ use core::marker::PhantomData;
|
||||
/// Weight functions for `pallet_preimage`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_preimage::WeightInfo for WeightInfo<T> {
|
||||
fn ensure_updated(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `193 + n * (91 ±0)`
|
||||
// Estimated: `3593 + n * (2566 ±0)`
|
||||
// Minimum execution time: 2_000_000 picoseconds.
|
||||
Weight::from_parts(2_000_000, 3593)
|
||||
// Standard Error: 13_720
|
||||
.saturating_add(Weight::from_parts(17_309_199, 0).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into())))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into())))
|
||||
.saturating_add(Weight::from_parts(0, 2566).saturating_mul(n.into()))
|
||||
}
|
||||
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
|
||||
|
||||
Reference in New Issue
Block a user