I am implementing the MaxEncodedLen trait for my pallet. I have this struct in a separate crate. I use this struct as my GenesisConfig, which is why it derives serde::Serialize and serde::Deserialize :

#[derive(Encode, Decode, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct InitialSync<SyncCommitteeSize: Get<u32>, ProofSize: Get<u32>> {
    pub current_sync_committee_branch: BoundedVec<H256, ProofSize>

In my pallet, I declared a constant for the vector bound:

pub trait Config: frame_system::Config {
    type MaxProofBranchSize: Get<u32>;

Here is my GenesisConfig:

pub struct GenesisConfig<T: Config> {
    pub initial_sync: InitialSync<T::MaxProofBranchSize>,

When I compile my pallet, the compiler complains that

^^^ the trait frame_support::Deserialize<'_>is not implemented for<T as pallet::Config>::MaxProofBranchSize

It doesn't make sense to implement the Deserialize for my constant, since it's just a size bound.

The same thing happened with TypeInfo, where the compiler said that the trait is not implemented for MaxProofBranchSize. Macro #[scale_info(skip_type_params(ProofSize))] fixed that error.

I'm looking for something to tell the compiler to ignore my parameter ProofSize for traits Deserialize and Serialize.

1 Answer 1


To make your life easier, you can use the expansions that genesis_config already provides. It does solve your problem and makes the code easier.
So you could opt for deleting the InitialSync struct, or just not using it in the Genesis config.

pub struct GenesisConfig<T: Config> {
    pub initial_sync: BoundedVec<sp_core::H256, T::MaxProofBranchSize>,

Otherwise you have to re-do what the genesis_config macro does for you.
The struct then becomes:

#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
    feature = "std",
        rename_all = "camelCase",
        bound(serialize = ""),
        bound(deserialize = "")
// Dont know if the other derives that you added here are actually
// needed for a genesis config.
pub struct InitialSync<ProofSize: Get<u32>> {
    pub current_sync_committee_branch: BoundedVec<H256, ProofSize>

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.