mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 02:11:01 +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:
@@ -29,8 +29,8 @@ use frame_election_provider_support::{bounds::ElectionBoundsBuilder, onchain, Se
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{
|
||||
ConstU32, InstanceFilter, KeyOwnerProofSystem, ProcessMessage, ProcessMessageError,
|
||||
WithdrawReasons,
|
||||
fungible::HoldConsideration, ConstU32, InstanceFilter, KeyOwnerProofSystem,
|
||||
LinearStoragePrice, ProcessMessage, ProcessMessageError, WithdrawReasons,
|
||||
},
|
||||
weights::{ConstantMultiplier, WeightMeter},
|
||||
PalletId,
|
||||
@@ -193,9 +193,9 @@ impl pallet_scheduler::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const PreimageMaxSize: u32 = 4096 * 1024;
|
||||
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 {
|
||||
@@ -203,8 +203,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>,
|
||||
>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -268,7 +272,7 @@ impl pallet_balances::Config for Runtime {
|
||||
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
|
||||
type RuntimeHoldReason = RuntimeHoldReason;
|
||||
type FreezeIdentifier = ();
|
||||
type MaxHolds = ConstU32<0>;
|
||||
type MaxHolds = ConstU32<1>;
|
||||
type MaxFreezes = ConstU32<0>;
|
||||
}
|
||||
|
||||
@@ -1311,7 +1315,7 @@ construct_runtime! {
|
||||
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 20,
|
||||
|
||||
// Preimage registrar.
|
||||
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 28,
|
||||
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>, HoldReason} = 28,
|
||||
|
||||
// Sudo.
|
||||
Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>} = 21,
|
||||
|
||||
@@ -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