5

I am trying to implement the prebuilt pallet-staking using 4.0.0-dev and tag devhub/latest. I am getting a compilation error on npos-elections. Should I be able to add the staking pallet into the runtime and it would use the correct dependency? Any recommendation?

error: cannot find macro `vec` in this scope
   --> /home/max/.cargo/git/checkouts/substrate-7e08433d4c370a21/22d40c7/primitives/npos-elections/src/lib.rs:367:45
    |
367 |         Self { total: Default::default(), voters: vec![] }
    |                                                   ^^^
    |
    = note: consider importing one of these items:
            codec::alloc::vec
            crate::sp_std::vec
            scale_info::prelude::vec
            sp_std::vec

Here is the implementation of the pallet in the runtime:

impl pallet_staking::Config for Runtime {
  type MaxNominations = ConstU32<16>;
  type Currency = Balances;
  type UnixTime = pallet_timestamp::Pallet<Self>;
  type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
  type RewardRemainder = ();
  type Event = Event;
  type Slash = ();
  type Reward = ();
  type SessionsPerEra = ();
  type SlashDeferDuration = ();
  type SlashCancelOrigin = frame_system::EnsureRoot<AccountId>;
  type BondingDuration = ();
  type SessionInterface = Self;
  type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
  type NextNewSession = Session;
  type MaxNominatorRewardedPerValidator = ConstU32<64>;
  type OffendingValidatorsThreshold = ();
  type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
  type GenesisElectionProvider = Self::ElectionProvider;
  type MaxUnlockingChunks = ConstU32<32>;
  type SortedListProvider = pallet_staking::UseNominatorsMap<Self>;
  type BenchmarkingConfig = pallet_staking::TestBenchmarkingConfig;
  type WeightInfo = ();
}

And here is my dependency in runtime/Cargo.toml

pallet-staking = {version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", tag = "devhub/latest"}

1 Answer 1

7

Looks like you didn't put pallet-staking/std into the list of enabled features of std of your runtime.

1
  • Doh! That's it, ty
    – Max
    Commented Mar 9, 2022 at 0:24

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.