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

remove without_storage_info from pallet-collective #14355

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,007 changes: 536 additions & 471 deletions Cargo.lock

Large diffs are not rendered by default.

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>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually asked Gav whether this is the intended usage of Bounded; turns out it is not. He said it does not make sense to pass the proposal itself, but rather the hash. So we need a map again for Hash -> Bounded<Proposal>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Hash -> Bounded<Proposal> map with a Bounded<Proposal> -> Proposal given by pallet preimages doesn't make any sense, I'll revert to a Hash -> Proposal inside pallet collective

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 @@ -1018,6 +1018,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 @@ -1079,6 +1080,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 @@ -1797,6 +1799,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
1 change: 1 addition & 0 deletions frame/alliance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ array-bytes = "6.1"
sp-core-hashing = { version = "9.0.0", default-features = false, path = "../../primitives/core/hashing" }
pallet-balances = { version = "4.0.0-dev", path = "../balances" }
pallet-collective = { version = "4.0.0-dev", path = "../collective" }
pallet-preimage = { version = "4.0.0-dev", path = "../preimage" }

[features]
default = ["std"]
Expand Down
Loading
Loading