mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
TryDecodeEntireState check for storage types and pallets (#1805)
### This PR is a port of this [PR for substrate](https://github.com/paritytech/substrate/pull/13013) by @kianenigma Add infrastructure needed to have a Pallet::decode_entire_state(), which makes sure all "typed" storage items defined in the pallet are decode-able. This is not enforced in any way at the moment. Teams who wish to integrate/use this in the try-runtime feature flag should add frame_support::storage::migration::EnsureStateDecodes as the LAST ITEM of the runtime's custom migrations, and pass it to frame-executive. This will make it usable in try-runtime on-runtime-upgrade. This now catches cases like https://github.com/paritytech/polkadot-sdk/pull/1969: ```pre ERROR runtime::executive] failed to decode the value at key: Failed to decode value at key: 0x94eadf0156a8ad5156507773d0471e4ab8ebad86f546c7e0b135a4212aace339. Storage info StorageInfo { pallet_name: Ok("ParaScheduler"), storage_name: Ok("AvailabilityCores"), prefix: Err(Utf8Error { valid_up_to: 0, error_len: Some(1) }), max_values: Some(1), max_size: None }. Raw value: Some("0x0c010101010101") ``` ... or:  Closes #241 --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
This commit is contained in:
+59
@@ -128,3 +128,62 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `StorageEntryMetadataBuilder`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
--> tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `Bar`
|
||||
|
|
||||
= help: the following other types implement trait `WrapperTypeDecode`:
|
||||
Box<T>
|
||||
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
|
||||
Rc<T>
|
||||
Arc<T>
|
||||
= note: required for `Bar` to implement `Decode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `TryDecodeEntireStorage`
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
--> tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `EncodeLike` is not implemented for `Bar`
|
||||
|
|
||||
= help: the following other types implement trait `EncodeLike<T>`:
|
||||
<bool as EncodeLike>
|
||||
<i8 as EncodeLike>
|
||||
<i16 as EncodeLike>
|
||||
<i32 as EncodeLike>
|
||||
<i64 as EncodeLike>
|
||||
<i128 as EncodeLike>
|
||||
<u8 as EncodeLike>
|
||||
<u16 as EncodeLike>
|
||||
and $N others
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `TryDecodeEntireStorage`
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
--> tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `Bar`
|
||||
|
|
||||
= help: the following other types implement trait `WrapperTypeEncode`:
|
||||
Box<T>
|
||||
bytes::bytes::Bytes
|
||||
Cow<'a, T>
|
||||
parity_scale_codec::Ref<'a, T, U>
|
||||
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
|
||||
Rc<T>
|
||||
Arc<T>
|
||||
Vec<T>
|
||||
and $N others
|
||||
= note: required for `Bar` to implement `Encode`
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `TryDecodeEntireStorage`
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
+59
@@ -128,3 +128,62 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `StorageEntryMetadataBuilder`
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
||||
--> tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `Bar`
|
||||
|
|
||||
= help: the following other types implement trait `WrapperTypeDecode`:
|
||||
Box<T>
|
||||
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
|
||||
Rc<T>
|
||||
Arc<T>
|
||||
= note: required for `Bar` to implement `Decode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `TryDecodeEntireStorage`
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: the trait bound `Bar: EncodeLike` is not satisfied
|
||||
--> tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `EncodeLike` is not implemented for `Bar`
|
||||
|
|
||||
= help: the following other types implement trait `EncodeLike<T>`:
|
||||
<bool as EncodeLike>
|
||||
<i8 as EncodeLike>
|
||||
<i16 as EncodeLike>
|
||||
<i32 as EncodeLike>
|
||||
<i64 as EncodeLike>
|
||||
<i128 as EncodeLike>
|
||||
<u8 as EncodeLike>
|
||||
<u16 as EncodeLike>
|
||||
and $N others
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `TryDecodeEntireStorage`
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
|
||||
--> tests/pallet_ui/storage_ensure_span_are_ok_on_wrong_gen_unnamed.rs:18:1
|
||||
|
|
||||
18 | #[frame_support::pallet]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `Bar`
|
||||
|
|
||||
= help: the following other types implement trait `WrapperTypeEncode`:
|
||||
Box<T>
|
||||
bytes::bytes::Bytes
|
||||
Cow<'a, T>
|
||||
parity_scale_codec::Ref<'a, T, U>
|
||||
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
|
||||
Rc<T>
|
||||
Arc<T>
|
||||
Vec<T>
|
||||
and $N others
|
||||
= note: required for `Bar` to implement `Encode`
|
||||
= note: required for `Bar` to implement `FullEncode`
|
||||
= note: required for `Bar` to implement `FullCodec`
|
||||
= note: required for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageFoo<T>, Bar>` to implement `TryDecodeEntireStorage`
|
||||
= note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
Reference in New Issue
Block a user