From 1f0a1cc0e534604bbc461af35e532f7f3dc475ef Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi <shawntabrizi@gmail.com> Date: Tue, 16 Aug 2022 21:33:09 +0100 Subject: [PATCH] Governance 2 (Part 1, Non-Controversial Changes) (#5892) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial stuff * make copy data from kusama * Update runtime/kusama/src/governance/old.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update runtime/kusama/src/governance/mod.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> --- polkadot/runtime/common/src/auctions.rs | 11 +- polkadot/runtime/common/src/slots/mod.rs | 13 +- polkadot/runtime/kusama/src/governance/mod.rs | 20 ++ polkadot/runtime/kusama/src/governance/old.rs | 172 ++++++++++++++++++ polkadot/runtime/kusama/src/lib.rs | 156 +--------------- polkadot/runtime/kusama/src/tests.rs | 7 +- polkadot/xcm/pallet-xcm/src/lib.rs | 8 +- .../xcm/xcm-builder/src/origin_conversion.rs | 4 +- .../xcm/xcm-executor/src/traits/weight.rs | 6 +- 9 files changed, 221 insertions(+), 176 deletions(-) create mode 100644 polkadot/runtime/kusama/src/governance/mod.rs create mode 100644 polkadot/runtime/kusama/src/governance/old.rs diff --git a/polkadot/runtime/common/src/auctions.rs b/polkadot/runtime/common/src/auctions.rs index 71f9c2182d9..b937a26d567 100644 --- a/polkadot/runtime/common/src/auctions.rs +++ b/polkadot/runtime/common/src/auctions.rs @@ -1784,7 +1784,7 @@ mod benchmarking { let duration = T::BlockNumber::max_value(); let lease_period_index = LeasePeriodOf::<T>::max_value(); let origin = T::InitiateOrigin::successful_origin(); - }: _(RawOrigin::Root, duration, lease_period_index) + }: _<T::Origin>(origin, duration, lease_period_index) verify { assert_last_event::<T>(Event::<T>::AuctionStarted { auction_index: AuctionCounter::<T>::get(), @@ -1802,7 +1802,8 @@ mod benchmarking { // Create a new auction let duration = T::BlockNumber::max_value(); let lease_period_index = LeasePeriodOf::<T>::zero(); - Auctions::<T>::new_auction(RawOrigin::Root.into(), duration, lease_period_index)?; + let origin = T::InitiateOrigin::successful_origin(); + Auctions::<T>::new_auction(origin, duration, lease_period_index)?; let para = ParaId::from(0); let new_para = ParaId::from(1_u32); @@ -1853,7 +1854,8 @@ mod benchmarking { let duration: T::BlockNumber = lease_length / 2u32.into(); let lease_period_index = LeasePeriodOf::<T>::zero(); let now = frame_system::Pallet::<T>::block_number(); - Auctions::<T>::new_auction(RawOrigin::Root.into(), duration, lease_period_index)?; + let origin = T::InitiateOrigin::successful_origin(); + Auctions::<T>::new_auction(origin, duration, lease_period_index)?; fill_winners::<T>(lease_period_index); @@ -1896,7 +1898,8 @@ mod benchmarking { let duration: T::BlockNumber = lease_length / 2u32.into(); let lease_period_index = LeasePeriodOf::<T>::zero(); let now = frame_system::Pallet::<T>::block_number(); - Auctions::<T>::new_auction(RawOrigin::Root.into(), duration, lease_period_index)?; + let origin = T::InitiateOrigin::successful_origin(); + Auctions::<T>::new_auction(origin, duration, lease_period_index)?; fill_winners::<T>(lease_period_index); diff --git a/polkadot/runtime/common/src/slots/mod.rs b/polkadot/runtime/common/src/slots/mod.rs index 1b76e508dad..76054ac989f 100644 --- a/polkadot/runtime/common/src/slots/mod.rs +++ b/polkadot/runtime/common/src/slots/mod.rs @@ -1024,7 +1024,8 @@ mod benchmarking { let amount = T::Currency::minimum_balance(); let period_begin = 69u32.into(); let period_count = 3u32.into(); - }: _(RawOrigin::Root, para, leaser.clone(), amount, period_begin, period_count) + let origin = T::ForceOrigin::successful_origin(); + }: _<T::Origin>(origin, para, leaser.clone(), amount, period_begin, period_count) verify { assert_last_event::<T>(Event::<T>::Leased { para_id: para, @@ -1057,8 +1058,8 @@ mod benchmarking { // T parathread are upgrading to parachains for (para, leaser) in paras_info { let amount = T::Currency::minimum_balance(); - - Slots::<T>::force_lease(RawOrigin::Root.into(), para, leaser, amount, period_begin, period_count)?; + let origin = T::ForceOrigin::successful_origin(); + Slots::<T>::force_lease(origin, para, leaser, amount, period_begin, period_count)?; } T::Registrar::execute_pending_transitions(); @@ -1108,7 +1109,8 @@ mod benchmarking { // Average slot has 4 lease periods. let period_count: LeasePeriodOf<T> = 4u32.into(); let period_begin = period_count * i.into(); - Slots::<T>::force_lease(RawOrigin::Root.into(), para, leaser, amount, period_begin, period_count)?; + let origin = T::ForceOrigin::successful_origin(); + Slots::<T>::force_lease(origin, para, leaser, amount, period_begin, period_count)?; } for i in 0 .. max_people { @@ -1116,7 +1118,8 @@ mod benchmarking { assert_eq!(T::Currency::reserved_balance(&leaser), T::Currency::minimum_balance()); } - }: _(RawOrigin::Root, para) + let origin = T::ForceOrigin::successful_origin(); + }: _<T::Origin>(origin, para) verify { for i in 0 .. max_people { let leaser = account("lease_deposit", i, 0); diff --git a/polkadot/runtime/kusama/src/governance/mod.rs b/polkadot/runtime/kusama/src/governance/mod.rs new file mode 100644 index 00000000000..27aa07a4795 --- /dev/null +++ b/polkadot/runtime/kusama/src/governance/mod.rs @@ -0,0 +1,20 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. + +//! Governance configurations for the Kusama runtime. + +// Old governance configurations. +pub mod old; diff --git a/polkadot/runtime/kusama/src/governance/old.rs b/polkadot/runtime/kusama/src/governance/old.rs new file mode 100644 index 00000000000..a87ddf6ec1f --- /dev/null +++ b/polkadot/runtime/kusama/src/governance/old.rs @@ -0,0 +1,172 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. + +//! Old governance configurations for the Kusama runtime. + +use crate::*; +use frame_support::{parameter_types, traits::EitherOfDiverse}; + +parameter_types! { + pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "KSM_LAUNCH_PERIOD"); + pub VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "KSM_VOTING_PERIOD"); + pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 1 * MINUTES, "KSM_FAST_TRACK_VOTING_PERIOD"); + pub const MinimumDeposit: Balance = 100 * CENTS; + pub EnactmentPeriod: BlockNumber = prod_or_fast!(8 * DAYS, 1, "KSM_ENACTMENT_PERIOD"); + pub CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "KSM_COOLOFF_PERIOD"); + pub const InstantAllowed: bool = true; + pub const MaxVotes: u32 = 100; + pub const MaxProposals: u32 = 100; +} + +impl pallet_democracy::Config for Runtime { + type Proposal = Call; + type Event = Event; + type Currency = Balances; + type EnactmentPeriod = EnactmentPeriod; + type VoteLockingPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = + pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>; + /// A majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = + pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = + pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>; + /// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = + pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>; + type InstantOrigin = + pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = EitherOfDiverse< + EnsureRoot<AccountId>, + pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>, + >; + type BlacklistOrigin = EnsureRoot<AccountId>; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EitherOfDiverse< + EnsureRoot<AccountId>, + pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>, + >; + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cooloff period. + type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>; + type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; + type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>; + type MaxProposals = MaxProposals; +} + +parameter_types! { + pub CouncilMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "KSM_MOTION_DURATION"); + pub const CouncilMaxProposals: u32 = 100; + pub const CouncilMaxMembers: u32 = 100; +} + +pub type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Config<CouncilCollective> for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = weights::pallet_collective_council::WeightInfo<Runtime>; +} + +parameter_types! { + pub const CandidacyBond: Balance = 100 * CENTS; + // 1 storage item created, key size is 32 bytes, value size is 16+16. + pub const VotingBondBase: Balance = deposit(1, 64); + // additional data per vote is 32 bytes (account id). + pub const VotingBondFactor: Balance = deposit(0, 32); + /// Daily council elections + pub TermDuration: BlockNumber = prod_or_fast!(24 * HOURS, 2 * MINUTES, "KSM_TERM_DURATION"); + pub const DesiredMembers: u32 = 19; + pub const DesiredRunnersUp: u32 = 19; + pub const MaxVoters: u32 = 10 * 1000; + pub const MaxCandidates: u32 = 1000; + pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect"; +} + +// Make sure that there are no more than `MaxMembers` members elected via Phragmen. +const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); + +impl pallet_elections_phragmen::Config for Runtime { + type Event = Event; + type Currency = Balances; + type ChangeMembers = Council; + type InitializeMembers = Council; + type CurrencyToVote = frame_support::traits::U128CurrencyToVote; + type CandidacyBond = CandidacyBond; + type VotingBondBase = VotingBondBase; + type VotingBondFactor = VotingBondFactor; + type LoserCandidate = Treasury; + type KickedMember = Treasury; + type DesiredMembers = DesiredMembers; + type DesiredRunnersUp = DesiredRunnersUp; + type TermDuration = TermDuration; + type MaxVoters = MaxVoters; + type MaxCandidates = MaxCandidates; + type PalletId = PhragmenElectionPalletId; + type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>; +} + +parameter_types! { + pub TechnicalMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "KSM_MOTION_DURATION"); + pub const TechnicalMaxProposals: u32 = 100; + pub const TechnicalMaxMembers: u32 = 100; +} + +pub type TechnicalCollective = pallet_collective::Instance2; +impl pallet_collective::Config<TechnicalCollective> for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = TechnicalMotionDuration; + type MaxProposals = TechnicalMaxProposals; + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo<Runtime>; +} + +impl pallet_membership::Config<pallet_membership::Instance1> for Runtime { + type Event = Event; + type AddOrigin = MoreThanHalfCouncil; + type RemoveOrigin = MoreThanHalfCouncil; + type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = TechnicalCommittee; + type MembershipChanged = TechnicalCommittee; + type MaxMembers = TechnicalMaxMembers; + type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>; +} diff --git a/polkadot/runtime/kusama/src/lib.rs b/polkadot/runtime/kusama/src/lib.rs index 511e7d1e69a..12b9554c5cf 100644 --- a/polkadot/runtime/kusama/src/lib.rs +++ b/polkadot/runtime/kusama/src/lib.rs @@ -102,6 +102,10 @@ mod bag_thresholds; // XCM configurations. pub mod xcm_config; +// Governance configurations. +pub mod governance; +use governance::old::CouncilCollective; + #[cfg(test)] mod tests; @@ -623,158 +627,6 @@ impl pallet_staking::Config for Runtime { type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>; } -parameter_types! { - pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "KSM_LAUNCH_PERIOD"); - pub VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "KSM_VOTING_PERIOD"); - pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 1 * MINUTES, "KSM_FAST_TRACK_VOTING_PERIOD"); - pub const MinimumDeposit: Balance = 100 * CENTS; - pub EnactmentPeriod: BlockNumber = prod_or_fast!(8 * DAYS, 1, "KSM_ENACTMENT_PERIOD"); - pub CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "KSM_COOLOFF_PERIOD"); - pub const InstantAllowed: bool = true; - pub const MaxVotes: u32 = 100; - pub const MaxProposals: u32 = 100; -} - -impl pallet_democracy::Config for Runtime { - type Proposal = Call; - type Event = Event; - type Currency = Balances; - type EnactmentPeriod = EnactmentPeriod; - type VoteLockingPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type MinimumDeposit = MinimumDeposit; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = - pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>; - /// A majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = - pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>; - /// A unanimous council can have the next scheduled referendum be a straight default-carries - /// (NTB) vote. - type ExternalDefaultOrigin = - pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>; - /// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote - /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = - pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>; - type InstantOrigin = - pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>; - type InstantAllowed = InstantAllowed; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = EitherOfDiverse< - EnsureRoot<AccountId>, - pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>, - >; - type BlacklistOrigin = EnsureRoot<AccountId>; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EitherOfDiverse< - EnsureRoot<AccountId>, - pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>, - >; - // Any single technical committee member may veto a coming council proposal, however they can - // only do it once and it lasts only for the cooloff period. - type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>; - type CooloffPeriod = CooloffPeriod; - type PreimageByteDeposit = PreimageByteDeposit; - type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>; - type Slash = Treasury; - type Scheduler = Scheduler; - type PalletsOrigin = OriginCaller; - type MaxVotes = MaxVotes; - type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>; - type MaxProposals = MaxProposals; -} - -parameter_types! { - pub CouncilMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "KSM_MOTION_DURATION"); - pub const CouncilMaxProposals: u32 = 100; - pub const CouncilMaxMembers: u32 = 100; -} - -type CouncilCollective = pallet_collective::Instance1; -impl pallet_collective::Config<CouncilCollective> for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = CouncilMaxProposals; - type MaxMembers = CouncilMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = weights::pallet_collective_council::WeightInfo<Runtime>; -} - -parameter_types! { - pub const CandidacyBond: Balance = 100 * CENTS; - // 1 storage item created, key size is 32 bytes, value size is 16+16. - pub const VotingBondBase: Balance = deposit(1, 64); - // additional data per vote is 32 bytes (account id). - pub const VotingBondFactor: Balance = deposit(0, 32); - /// Daily council elections - pub TermDuration: BlockNumber = prod_or_fast!(24 * HOURS, 2 * MINUTES, "KSM_TERM_DURATION"); - pub const DesiredMembers: u32 = 19; - pub const DesiredRunnersUp: u32 = 19; - pub const MaxVoters: u32 = 10 * 1000; - pub const MaxCandidates: u32 = 1000; - pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect"; -} - -// Make sure that there are no more than MaxMembers members elected via phragmen. -const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); - -impl pallet_elections_phragmen::Config for Runtime { - type Event = Event; - type Currency = Balances; - type ChangeMembers = Council; - type InitializeMembers = Council; - type CurrencyToVote = frame_support::traits::U128CurrencyToVote; - type CandidacyBond = CandidacyBond; - type VotingBondBase = VotingBondBase; - type VotingBondFactor = VotingBondFactor; - type LoserCandidate = Treasury; - type KickedMember = Treasury; - type DesiredMembers = DesiredMembers; - type DesiredRunnersUp = DesiredRunnersUp; - type TermDuration = TermDuration; - type MaxVoters = MaxVoters; - type MaxCandidates = MaxCandidates; - type PalletId = PhragmenElectionPalletId; - type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>; -} - -parameter_types! { - pub TechnicalMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "KSM_MOTION_DURATION"); - pub const TechnicalMaxProposals: u32 = 100; - pub const TechnicalMaxMembers: u32 = 100; -} - -type TechnicalCollective = pallet_collective::Instance2; -impl pallet_collective::Config<TechnicalCollective> for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; - type MotionDuration = TechnicalMotionDuration; - type MaxProposals = TechnicalMaxProposals; - type MaxMembers = TechnicalMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo<Runtime>; -} - -impl pallet_membership::Config<pallet_membership::Instance1> for Runtime { - type Event = Event; - type AddOrigin = MoreThanHalfCouncil; - type RemoveOrigin = MoreThanHalfCouncil; - type SwapOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; - type PrimeOrigin = MoreThanHalfCouncil; - type MembershipInitialized = TechnicalCommittee; - type MembershipChanged = TechnicalCommittee; - type MaxMembers = TechnicalMaxMembers; - type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>; -} - parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); pub const ProposalBondMinimum: Balance = 2000 * CENTS; diff --git a/polkadot/runtime/kusama/src/tests.rs b/polkadot/runtime/kusama/src/tests.rs index 6c53cf8beb3..891aebe060b 100644 --- a/polkadot/runtime/kusama/src/tests.rs +++ b/polkadot/runtime/kusama/src/tests.rs @@ -173,10 +173,5 @@ fn era_payout_should_give_sensible_results() { #[test] fn call_size() { - assert!( - core::mem::size_of::<Call>() <= 230, - "size of Call is more than 230 bytes: some calls have too big arguments, use Box to reduce \ - the size of Call. - If the limit is too strong, maybe consider increase the limit to 300.", - ); + Call::assert_size_under(230); } diff --git a/polkadot/xcm/pallet-xcm/src/lib.rs b/polkadot/xcm/pallet-xcm/src/lib.rs index 6fc6285a600..c237fc702a4 100644 --- a/polkadot/xcm/pallet-xcm/src/lib.rs +++ b/polkadot/xcm/pallet-xcm/src/lib.rs @@ -1517,8 +1517,8 @@ where } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> O { - O::from(Origin::Xcm(Here.into())) + fn try_successful_origin() -> Result<O, ()> { + Ok(O::from(Origin::Xcm(Here.into()))) } } @@ -1542,8 +1542,8 @@ where } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> O { - O::from(Origin::Response(Here.into())) + fn try_successful_origin() -> Result<O, ()> { + Ok(O::from(Origin::Response(Here.into()))) } } diff --git a/polkadot/xcm/xcm-builder/src/origin_conversion.rs b/polkadot/xcm/xcm-builder/src/origin_conversion.rs index 4d9a882464d..5df56f1ed5d 100644 --- a/polkadot/xcm/xcm-builder/src/origin_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/origin_conversion.rs @@ -253,8 +253,8 @@ where } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> Origin { - Origin::root() + fn try_successful_origin() -> Result<Origin, ()> { + Ok(Origin::root()) } } diff --git a/polkadot/xcm/xcm-executor/src/traits/weight.rs b/polkadot/xcm/xcm-executor/src/traits/weight.rs index d3da75e0c29..a3c7d2a2f64 100644 --- a/polkadot/xcm/xcm-executor/src/traits/weight.rs +++ b/polkadot/xcm/xcm-executor/src/traits/weight.rs @@ -47,9 +47,9 @@ pub trait WeightTrader: Sized { /// Create a new trader instance. fn new() -> Self; - /// Purchase execution weight credit in return for up to a given `fee`. If less of the fee is required - /// then the surplus is returned. If the `fee` cannot be used to pay for the `weight`, then an error is - /// returned. + /// Purchase execution weight credit in return for up to a given `payment`. If less of the + /// payment is required then the surplus is returned. If the `payment` cannot be used to pay + /// for the `weight`, then an error is returned. fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError>; /// Attempt a refund of `weight` into some asset. The caller does not guarantee that the weight was -- GitLab