Skip to content

Commit

Permalink
Merge branch 'rb-payee-in-rewarded' of https://github.com/paritytech/…
Browse files Browse the repository at this point in the history
…polkadot-sdk into rb-payee-in-rewarded
  • Loading branch information
Ross Bulat committed Sep 18, 2023
2 parents 6825049 + 4b95e9f commit bddf18c
Show file tree
Hide file tree
Showing 35 changed files with 882 additions and 411 deletions.
9 changes: 3 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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>;
}

Expand Down Expand Up @@ -545,15 +548,20 @@ 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 {
type WeightInfo = weights::pallet_preimage::WeightInfo<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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cumulus/polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-parachain-bin"
version = "1.0.0"
version = "1.1.0"
authors.workspace = true
build = "build.rs"
edition.workspace = true
Expand Down
52 changes: 44 additions & 8 deletions cumulus/polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl SubstrateCli for RelayChainCli {
}

/// Creates partial components for the runtimes that are supported by the benchmarks.
macro_rules! construct_benchmark_partials {
macro_rules! construct_partials {
($config:expr, |$partials:ident| $code:expr) => {
match $config.chain_spec.runtime() {
Runtime::AssetHubKusama => {
Expand Down Expand Up @@ -456,7 +456,41 @@ macro_rules! construct_benchmark_partials {
)?;
$code
},
_ => Err("The chain is not supported".into()),
Runtime::Shell => {
let $partials = new_partial::<shell_runtime::RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
)?;
$code
},
Runtime::Seedling => {
let $partials = new_partial::<seedling_runtime::RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
)?;
$code
},
Runtime::ContractsRococo => {
let $partials = new_partial::<contracts_rococo_runtime::RuntimeApi, _>(
&$config,
crate::service::contracts_rococo_build_import_queue,
)?;
$code
},
Runtime::Penpal(_) | Runtime::Default => {
let $partials = new_partial::<rococo_parachain_runtime::RuntimeApi, _>(
&$config,
crate::service::rococo_parachain_build_import_queue,
)?;
$code
},
Runtime::Glutton => {
let $partials = new_partial::<glutton_runtime::RuntimeApi, _>(
&$config,
crate::service::shell_build_import_queue,
)?;
$code
},
}
};
}
Expand Down Expand Up @@ -679,10 +713,12 @@ pub fn run() -> Result<()> {
cmd.run(config, polkadot_config)
})
},
Some(Subcommand::ExportGenesisState(cmd)) =>
construct_async_run!(|components, cli, cmd, config| {
Ok(async move { cmd.run(&*config.chain_spec, &*components.client) })
}),
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| {
construct_partials!(config, |partials| cmd.run(&*config.chain_spec, &*partials.client))
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|_config| {
Expand All @@ -704,7 +740,7 @@ pub fn run() -> Result<()> {
.into())
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| cmd.run(partials.client))
construct_partials!(config, |partials| cmd.run(partials.client))
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) =>
Expand All @@ -716,7 +752,7 @@ pub fn run() -> Result<()> {
.into()),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| {
construct_partials!(config, |partials| {
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();

Expand Down
2 changes: 1 addition & 1 deletion polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rust-version = "1.64.0"
readme = "README.md"
authors.workspace = true
edition.workspace = true
version = "1.0.0"
version = "1.1.0"
default-run = "polkadot"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion polkadot/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "polkadot-cli"
description = "Polkadot Relay-chain Client Node"
version = "1.0.0"
version = "1.1.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
16 changes: 11 additions & 5 deletions polkadot/runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ use frame_election_provider_support::{
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim, WithdrawReasons,
fungible::HoldConsideration, ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter,
KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage, ProcessMessageError,
StorageMapShim, WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId,
Expand Down Expand Up @@ -239,15 +240,20 @@ 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 {
type WeightInfo = weights::pallet_preimage::WeightInfo<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! {
Expand Down Expand Up @@ -1560,7 +1566,7 @@ construct_runtime! {
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 31,

// Preimage registrar.
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 32,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>, HoldReason} = 32,

// Bounties modules.
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>} = 35,
Expand Down
15 changes: 15 additions & 0 deletions polkadot/runtime/kusama/src/weights/pallet_preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 12 additions & 7 deletions polkadot/runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ use frame_election_provider_support::{
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
PrivilegeCmp, ProcessMessage, ProcessMessageError, WithdrawReasons,
fungible::HoldConsideration, ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter,
KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage, ProcessMessageError,
WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId,
Expand Down Expand Up @@ -221,18 +222,22 @@ 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 {
type WeightInfo = weights::pallet_preimage::WeightInfo<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! {
Expand Down Expand Up @@ -297,7 +302,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>;
}

Expand Down Expand Up @@ -1326,7 +1331,7 @@ construct_runtime! {
// Basic stuff; balances is uncallable initially.
System: frame_system::{Pallet, Call, Storage, Config<T>, Event<T>} = 0,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 10,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>, HoldReason} = 10,

// Babe must be before session.
Babe: pallet_babe::{Pallet, Call, Storage, Config<T>, ValidateUnsigned} = 2,
Expand Down
15 changes: 15 additions & 0 deletions polkadot/runtime/polkadot/src/weights/pallet_preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit bddf18c

Please sign in to comment.