Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
updated kitchensink runtime
Browse files Browse the repository at this point in the history
Signed-off-by: muraca <[email protected]>
  • Loading branch information
muraca committed Jun 15, 2023
1 parent abbb9ee commit 3bed795
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 41 deletions.
27 changes: 18 additions & 9 deletions bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ use frame_support::{
pallet_prelude::*,
traits::{
fungibles::{Balanced, Credit},
Currency, OnUnbalanced,
Bounded, Currency, OnUnbalanced, StorePreimage,
},
};
use pallet_alliance::{IdentityVerifier, ProposalIndex, ProposalProvider};
use pallet_asset_tx_payment::HandleCredit;
use sp_std::prelude::*;

use crate::{
AccountId, AllianceMotion, Assets, Authorship, Balances, Hash, NegativeImbalance, Runtime,
AccountId, AllianceMotion, Assets, Authorship, Balances, NegativeImbalance, Preimage, Runtime,
RuntimeCall,
};

Expand Down Expand Up @@ -77,7 +77,7 @@ impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
}

pub struct AllianceProposalProvider;
impl ProposalProvider<AccountId, Hash, RuntimeCall> for AllianceProposalProvider {
impl ProposalProvider<AccountId, RuntimeCall> for AllianceProposalProvider {
fn propose_proposal(
who: AccountId,
threshold: u32,
Expand All @@ -89,24 +89,33 @@ impl ProposalProvider<AccountId, Hash, RuntimeCall> for AllianceProposalProvider

fn vote_proposal(
who: AccountId,
proposal: Hash,
proposal_bounded: Bounded<RuntimeCall>,
index: ProposalIndex,
approve: bool,
) -> Result<bool, DispatchError> {
AllianceMotion::do_vote(who, proposal, index, approve)
AllianceMotion::do_vote(who, proposal_bounded, index, approve)
}

fn close_proposal(
proposal_hash: Hash,
proposal_bounded: Bounded<RuntimeCall>,
proposal_index: ProposalIndex,
proposal_weight_bound: Weight,
length_bound: u32,
) -> DispatchResultWithPostInfo {
AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound)
AllianceMotion::do_close(
proposal_bounded,
proposal_index,
proposal_weight_bound,
length_bound,
)
}

fn proposal_of(proposal_hash: Hash) -> Option<RuntimeCall> {
AllianceMotion::proposal_of(proposal_hash)
fn proposal_of(proposal_bounded: Bounded<RuntimeCall>) -> Option<RuntimeCall> {
AllianceMotion::proposal_of(proposal_bounded)
}

fn bound_proposal(proposal: RuntimeCall) -> Result<Bounded<RuntimeCall>, DispatchError> {
Preimage::bound(proposal)
}
}

Expand Down
3 changes: 3 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type Preimages = Preimage;
}

parameter_types! {
Expand Down Expand Up @@ -1072,6 +1073,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type Preimages = Preimage;
}

type EnsureRootOrHalfCouncil = EitherOfDiverse<
Expand Down Expand Up @@ -1792,6 +1794,7 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type Preimages = Preimage;
}

parameter_types! {
Expand Down
15 changes: 6 additions & 9 deletions frame/alliance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ use sp_std::{
};

use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError};
use frame_support::{
bounded_vec,
traits::{EnsureOrigin, Get, UnfilteredDispatchable},
};
use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};
use frame_system::{Pallet as System, RawOrigin as SystemOrigin};

use super::{Call as AllianceCall, Pallet as Alliance, *};
Expand Down Expand Up @@ -164,7 +161,7 @@ benchmarks_instance_pallet! {
let threshold = m - 1;

// Add previous proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = AllianceCall::<T, I>::set_rule {
Expand Down Expand Up @@ -236,7 +233,7 @@ benchmarks_instance_pallet! {
let threshold = m;

// Add previous proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = AllianceCall::<T, I>::set_rule {
Expand Down Expand Up @@ -314,7 +311,7 @@ benchmarks_instance_pallet! {
let threshold = 2;

// Add previous proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = AllianceCall::<T, I>::set_rule {
Expand Down Expand Up @@ -397,7 +394,7 @@ benchmarks_instance_pallet! {
let threshold = m - 1;

// Add proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = AllianceCall::<T, I>::set_rule {
Expand Down Expand Up @@ -466,7 +463,7 @@ benchmarks_instance_pallet! {
let threshold = 2;

// Add proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = AllianceCall::<T, I>::set_rule {
Expand Down
13 changes: 6 additions & 7 deletions frame/collective/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use super::*;
use crate::Pallet as Collective;

use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller};
use frame_support::bounded_vec;
use frame_system::{Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin};
use sp_runtime::traits::Bounded;
use sp_std::mem::size_of;
Expand Down Expand Up @@ -235,7 +234,7 @@ benchmarks_instance_pallet! {
let threshold = m - 1;

// Add previous proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = SystemCall::<T>::remark { remark: id_to_remark_data(i, b as usize) }.into();
Expand Down Expand Up @@ -310,7 +309,7 @@ benchmarks_instance_pallet! {
let threshold = m;

// Add previous proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = SystemCall::<T>::remark { remark: id_to_remark_data(i, bytes as usize) }.into();
Expand Down Expand Up @@ -387,7 +386,7 @@ benchmarks_instance_pallet! {
let threshold = 2;

// Add previous proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = SystemCall::<T>::remark { remark: id_to_remark_data(i, b as usize) }.into();
Expand Down Expand Up @@ -473,7 +472,7 @@ benchmarks_instance_pallet! {
let threshold = m - 1;

// Add proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = SystemCall::<T>::remark { remark: id_to_remark_data(i, bytes as usize) }.into();
Expand Down Expand Up @@ -555,7 +554,7 @@ benchmarks_instance_pallet! {
let threshold = 2;

// Add proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = SystemCall::<T>::remark { remark: id_to_remark_data(i, b as usize) }.into();
Expand Down Expand Up @@ -626,7 +625,7 @@ benchmarks_instance_pallet! {
let threshold = m - 1;

// Add proposals
let mut last_bound = frame_support::traits::Bounded::Inline(bounded_vec![]);
let mut last_bound = frame_support::traits::Bounded::Inline(vec![].try_into().unwrap());
for i in 0 .. p {
// Proposals should be different
let proposal: T::Proposal = SystemCall::<T>::remark { remark: id_to_remark_data(i, b as usize) }.into();
Expand Down
4 changes: 2 additions & 2 deletions frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Votes {
index,
threshold,
ayes: frame_support::bounded_vec![],
nays: frame_support::bounded_vec![],
ayes: vec![].try_into().expect("empty vec is always bounded; qed"),
nays: vec![].try_into().expect("empty vec is always bounded; qed"),
end,
}
};
Expand Down
22 changes: 8 additions & 14 deletions frame/collective/src/migrations/v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,14 @@ pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
let vote = crate::Votes::<T::AccountId, T::BlockNumber, <T as Config<I>>::MaxMembers> {
index: vote.index,
threshold: vote.threshold,
ayes: vote.ayes.try_into().expect(
format!(
"runtime::collective migration failed, ayes for vote {:?} should not overflow; qed",
vote.index
)
.as_str(),
),
nays: vote.nays.try_into().expect(
format!(
"runtime::collective migration failed, nays for vote {:?} should not overflow; qed",
vote.index,
)
.as_str(),
),
ayes: vote
.ayes
.try_into()
.expect("runtime::collective migration failed, ayes overflow"),
nays: vote
.nays
.try_into()
.expect("runtime::collective migration failed, nays overflow"),
end: vote.end,
};

Expand Down

0 comments on commit 3bed795

Please sign in to comment.