2

When building my parachain, I run into the error:

error[E0277]: the trait bound `parity_scale_codec::Compact<sp_runtime::Perbill>: parity_scale_codec::MaxEncodedLen` is not satisfied
   --> /Users/ganesholi/.cargo/git/checkouts/substrate-7e08433d4c370a21/948fbd2/frame/staking/src/lib.rs:412:18
    |
412 |     pub commission: Perbill,
    |                     ^^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `parity_scale_codec::Compact<sp_runtime::Perbill>`
    |
    = help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
              parity_scale_codec::Compact<u8>
              parity_scale_codec::Compact<u16>
              parity_scale_codec::Compact<u32>
              parity_scale_codec::Compact<u64>
              parity_scale_codec::Compact<u128>

error[E0277]: the trait bound `parity_scale_codec::Compact<Balance>: parity_scale_codec::MaxEncodedLen` is not satisfied
   --> /Users/ganesholi/.cargo/git/checkouts/substrate-7e08433d4c370a21/948fbd2/frame/staking/src/lib.rs:424:9
    |
424 |     value: Balance,
    |            ^^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `parity_scale_codec::Compact<Balance>`
    |
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
    |
420 | #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen, parity_scale_codec::Compact<Balance>: parity_scale_codec::MaxEncodedLen)]
    |                                                                                     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `parity_scale_codec::Compact<<T as pallet::pallet::Config>::CurrencyBalance>: parity_scale_codec::MaxEncodedLen` is not satisfied
   --> /Users/ganesholi/.cargo/git/checkouts/substrate-7e08433d4c370a21/948fbd2/frame/staking/src/lib.rs:448:13
    |
448 |     pub total: BalanceOf<T>,
    |                ^^^^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `parity_scale_codec::Compact<<T as pallet::pallet::Config>::CurrencyBalance>`
    |
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
    |
439 |     MaxEncodedLen, parity_scale_codec::Compact<<T as pallet::pallet::Config>::CurrencyBalance>: parity_scale_codec::MaxEncodedLen,
    |                  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `parity_scale_codec::Compact<<T as pallet::pallet::Config>::CurrencyBalance>: parity_scale_codec::MaxEncodedLen` is not satisfied
   --> /Users/ganesholi/.cargo/git/checkouts/substrate-7e08433d4c370a21/948fbd2/frame/staking/src/lib.rs:452:14
    |
452 |     pub active: BalanceOf<T>,
    |                 ^^^^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `parity_scale_codec::Compact<<T as pallet::pallet::Config>::CurrencyBalance>`
    |
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
    |
439 |     MaxEncodedLen, parity_scale_codec::Compact<<T as pallet::pallet::Config>::CurrencyBalance>: parity_scale_codec::MaxEncodedLen,
    |                  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

For more information about this error, try `rustc --explain E0277`.
error: could not compile `pallet-staking` (lib) due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
ganesholi@Ganeshs-MacBook-Air xcav-parachain % 

How do I resolve this issue? This is github code repo.

2
  • What version of parity-scale-codec are you using? There was a recent bug, 3.6.5 should work. Sep 7 at 10:49
  • 3.0.0 I am using
    – Ganesh11
    Sep 7 at 11:46

2 Answers 2

1

There has be a bug in the recently released SCALE version 3.6.6 and it has been yanked since.
Please fix the version to one earlier like this: =3.6.5. Just using 3.0.0 could have pulled in the faulty version.

1

Workaround: Patching the dependency in the root Cargo.toml should solve the issue for now:

[patch.crates-io]
parity-scale-codec = { git = "https://github.com/paritytech/parity-scale-codec.git", tag = "v3.6.5" }
2
  • should I comment from runtime and node?
    – Ganesh11
    Sep 8 at 8:06
  • No, you should put it in the base Cargo.toml file, where you define the workspace members. Sep 8 at 10:46

Your Answer

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

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