I've copied Kulupu's difficulty
pallet and tried to build my node after connecting the pallet. The decl_storage!
macro in that pallet looks like this:
decl_storage! {
trait Store for Module<T: Config> as Difficulty {
/// Past difficulties and timestamps, from earliest to latest.
// TODO Bug here
PastDifficultiesAndTimestamps: [Option<DifficultyAndTimestamp<T::Moment>>; 60] = [None; DIFFICULTY_ADJUST_WINDOW as usize];
/// Current difficulty.
pub CurrentDifficulty get(fn difficulty) build(|config: &GenesisConfig| {
config.initial_difficulty
}): Difficulty;
/// Initial difficulty.
pub InitialDifficulty config(initial_difficulty): Difficulty;
}
}
And the error I get is:
error[E0277]: the trait bound `[std::option::Option<DifficultyAndTimestamp<<T as pallet_timestamp::Config>::Moment>>; 60]: sp_core::Encode` is not satisfied
--> pallets/difficulty/src/lib.rs:40:1
|
40 | / decl_storage! {
41 | | trait Store for Module<T: Config> as Difficulty {
42 | | /// Past difficulties and timestamps, from earliest to latest.
43 | | // TODO Implement sp_core::Encode, Decode for
... |
51 | | }
52 | | }
| |_^ the trait `sp_core::Encode` is not implemented for `[std::option::Option<DifficultyAndTimestamp<<T as pallet_timestamp::Config>::Moment>>; 60]`
|
= help: the following implementations were found:
<[T; N] as sp_core::Encode>
<[T] as sp_core::Encode>
note: required by a bound in `hidden_include::storage::generator::StorageValue`
--> /home/creestl/.cargo/git/checkouts/substrate-7e08433d4c370a21/1b57cff/frame/support/src/storage/generator/value.rs:30:27
|
30 | pub trait StorageValue<T: FullCodec> {
| ^^^^^^^^^ required by this bound in `hidden_include::storage::generator::StorageValue`
= note: this error originates in the macro `decl_storage` (in Nightly builds, run with -Z macro-backtrace for more info)
It says that sp_core:Encode
(and Decode and some others...) is not implemented for Option<DifficultyAndTimestamp<...>>
even though there is such Derive
in difficulty
pallet:
#[derive(Encode, Decode, TypeInfo, Clone, Copy, Eq, PartialEq, Debug)]
pub struct DifficultyAndTimestamp<M> {
pub difficulty: Difficulty,
pub timestamp: M,
}
ALSO if I just clone whole Kulupu's repo and cd
to difficulty
crate and run cargo build --release
it builds no problem. But if I do the same in my crate (with the same code) it won't build.
How do I fix this?
Should I provide a whole error massage?