2

When attempting to build the Democracy pallet (pallet_democracy) within a runtime based on the polkadot-v0.9.15-1 branch, built native using Rust stable 1.57 and WASM using Rust nightly 2021-11-29, this build error appears with little assisting information.

error[E0107]: missing generics for struct `pallet_democracy::GenesisConfig`
    --> runtime/alpha/src/lib.rs:1177:1
     |
1177 | / construct_runtime! {
1178 | |     pub enum Runtime where
1179 | |         Block = Block,
1180 | |         NodeBlock = primitives::Block,
...    |
1247 | |     }
1248 | | }
     | |_^ expected 1 generic argument
     |
note: struct defined here, with 1 generic parameter: `T`
    --> /usr/local/cargo/git/checkouts/substrate-7e08433d4c370a21/e6fbbd5/frame/democracy/src/lib.rs:479:13
     |
479  |     pub struct GenesisConfig<T: Config> {
     |                ^^^^^^^^^^^^^ -
     = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: add missing generic argument
     |
1177 | GenesisConfig<T>
     |

For more information about this error, try `rustc --explain E0107`.
error: could not compile `native-runtime-alpha` due to previous error

Contents of runtime/alpha/src/lib.rs

#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "256"]
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
[...]
impl pallet_democracy::Config for Runtime {
    type Proposal = Call;
    type Event = Event;
    type Currency = Balances;
[...]
    type ExternalOrigin = pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
    type ExternalMajorityOrigin = pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
    type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>;
    type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>;
    type InstantOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>;
    type InstantAllowed = InstantAllowed;
    type FastTrackVotingPeriod = FastTrackVotingPeriod;
    type CancellationOrigin = EnsureOneOf<
        AccountId,
        EnsureRoot<AccountId>,
        pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>,
    >;
    type CancelProposalOrigin = EnsureOneOf<
        AccountId,
        EnsureRoot<AccountId>,
        pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>,
    >;
    type BlacklistOrigin = EnsureRoot<AccountId>;
    type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
[...]
    type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
    type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
    type MaxProposals = MaxProposals;
}

[...]

/// The type used to represent the kinds of proxying allowed.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, scale_info::TypeInfo)]
pub enum ProxyType {
    Any,
    NonTransfer,
    Governance,
    Staking,
    IdentityJudgement,
    CancelProxy,
}
impl Default for ProxyType { fn default() -> Self { Self::Any } }
impl InstanceFilter<Call> for ProxyType {
    fn filter(&self, c: &Call) -> bool {
        match self {
            ProxyType::Any => true,
            ProxyType::NonTransfer => matches!(c,
[...]
                Call::Democracy(..) |
[...]
            ProxyType::Governance => matches!(c,
[...]
                Call::Democracy(..) |
[...]
            )
        }
    }
}
[...]
construct_runtime!(
    pub enum Runtime where
        Block = Block,
        NodeBlock = primitives::Block,
        UncheckedExtrinsic = UncheckedExtrinsic
    {
[...]
        Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},
[...]
    }
);

Contents of node/src/lib.rs

use sc_service::ChainType;
use sp_core::{ed25519, Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
use native_alpha::{
    AccountId, AuthorityDiscoveryId, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, BabeId,
    CouncilConfig, ImOnlineId, IndicesConfig, GenesisConfig, GrandpaId, GrandpaConfig, SessionConfig,
    StakingConfig, Signature, SystemConfig, TechnicalCommitteeConfig,
    BABE_GENESIS_EPOCH_CONFIG, WASM_BINARY
};
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
[...]
fn testnet_genesis(
    wasm_binary: &[u8],
    initial_authorities: Vec<(
        AccountId,
        AccountId,
        BabeId,
        GrandpaId,
        ImOnlineId,
        AuthorityDiscoveryId,
    )>,
    root_key: AccountId,
    endowed_accounts: Vec<AccountId>,
    _enable_println: bool,
) -> GenesisConfig {
    GenesisConfig {
[...]
        democracy: Default::default(),
[...]
    }
}

Now, it seems that the construct_runtime macro generates GenesisConfig which is then extended with sc_service::GenericChainSpec to give us the ChainSpec type, which is then used by the node.

We are using other pallets that do require a GenesisConfig (such as pallet_grandpa) but don't have similar errors as merely uncommenting calls to pallet_democracy bypasses the problem altogether.

1 Answer 1

4

Rather than:

Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event<T>},

Add in <T> to the Config here:

Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>},

or if you're ok having all of the exports of that pallet you can just say:

Democracy: pallet_democracy,

(This second syntax is fairly new which is why it's not as prevalent)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.