mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Remove in-tree max-encoded-len and use the new SCALE codec crate instead (#9163)
* Update impl-codec to use new upstream MaxEncodedLen trait * Adapt crates to use the updated codec crate for `MaxEncodedLen` * Remove max-encoded-len crate altogether * Fix test compilation in `pallet-proxy` * reorganize import (#9186) * Fix remaining `MaxEncodedLen` imports * Fix remaining old usages of max-encoded-len crate * Fix UI test * Manually depend on new impl-codec to fix Polkadot companion build * Use newly released primitive-types v0.9.1 that has new codec impls * Make sure codec deps are up-to-date in crates that use them Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -14,9 +14,8 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "2.1.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] }
|
||||
frame-metadata = { version = "13.0.0", default-features = false, path = "../metadata" }
|
||||
max-encoded-len = { version = "3.0.0", default-features = false, path = "../../max-encoded-len", features = [ "derive" ] }
|
||||
sp-std = { version = "3.0.0", default-features = false, path = "../../primitives/std" }
|
||||
sp-io = { version = "3.0.0", default-features = false, path = "../../primitives/io" }
|
||||
sp-runtime = { version = "3.0.0", default-features = false, path = "../../primitives/runtime" }
|
||||
@@ -56,7 +55,6 @@ std = [
|
||||
"sp-state-machine",
|
||||
"frame-support-procedural/std",
|
||||
"log/std",
|
||||
"max-encoded-len/std",
|
||||
]
|
||||
runtime-benchmarks = []
|
||||
try-runtime = []
|
||||
|
||||
@@ -267,7 +267,7 @@ pub fn decl_and_impl(def: &DeclStorageDefExt) -> TokenStream {
|
||||
use #scrate::sp_runtime::SaturatedConversion;
|
||||
|
||||
let max_size = <
|
||||
#value_type as #scrate::traits::MaxEncodedLen
|
||||
#value_type as #scrate::codec::MaxEncodedLen
|
||||
>::max_encoded_len()
|
||||
.saturated_into();
|
||||
|
||||
@@ -301,7 +301,7 @@ pub fn decl_and_impl(def: &DeclStorageDefExt) -> TokenStream {
|
||||
>::Hasher::max_len::<#key>();
|
||||
|
||||
let max_size = <
|
||||
#value_type as #scrate::traits::MaxEncodedLen
|
||||
#value_type as #scrate::codec::MaxEncodedLen
|
||||
>::max_encoded_len()
|
||||
.saturating_add(key_max_size)
|
||||
.saturated_into();
|
||||
@@ -342,7 +342,7 @@ pub fn decl_and_impl(def: &DeclStorageDefExt) -> TokenStream {
|
||||
>::Hasher2::max_len::<#key2>();
|
||||
|
||||
let max_size = <
|
||||
#value_type as #scrate::traits::MaxEncodedLen
|
||||
#value_type as #scrate::codec::MaxEncodedLen
|
||||
>::max_encoded_len()
|
||||
.saturating_add(key1_max_size)
|
||||
.saturating_add(key2_max_size)
|
||||
@@ -378,7 +378,7 @@ pub fn decl_and_impl(def: &DeclStorageDefExt) -> TokenStream {
|
||||
>::key_max_encoded_len();
|
||||
|
||||
let max_size = <
|
||||
#value_type as #scrate::traits::MaxEncodedLen
|
||||
#value_type as #scrate::codec::MaxEncodedLen
|
||||
>::max_encoded_len()
|
||||
.saturating_add(key_max_size)
|
||||
.saturated_into();
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
|
||||
//! Hash utilities.
|
||||
|
||||
use codec::Codec;
|
||||
use codec::{Codec, MaxEncodedLen};
|
||||
use sp_std::prelude::Vec;
|
||||
use sp_io::hashing::{blake2_128, blake2_256, twox_64, twox_128, twox_256};
|
||||
use crate::traits::MaxEncodedLen;
|
||||
|
||||
// This trait must be kept coherent with frame-support-procedural HasherKind usage
|
||||
pub trait Hashable: Sized {
|
||||
|
||||
@@ -1274,7 +1274,7 @@ pub mod pallet_prelude {
|
||||
RuntimeDebug, storage,
|
||||
traits::{
|
||||
Get, Hooks, IsType, GetPalletVersion, EnsureOrigin, PalletInfoAccess, StorageInfoTrait,
|
||||
ConstU32, GetDefault, MaxEncodedLen,
|
||||
ConstU32, GetDefault,
|
||||
},
|
||||
dispatch::{DispatchResultWithPostInfo, Parameter, DispatchError, DispatchResult},
|
||||
weights::{DispatchClass, Pays, Weight},
|
||||
@@ -1284,7 +1284,7 @@ pub mod pallet_prelude {
|
||||
},
|
||||
storage::bounded_vec::BoundedVec,
|
||||
};
|
||||
pub use codec::{Encode, Decode};
|
||||
pub use codec::{Encode, Decode, MaxEncodedLen};
|
||||
pub use crate::inherent::{InherentData, InherentIdentifier, ProvideInherent};
|
||||
pub use sp_runtime::{
|
||||
traits::{MaybeSerializeDeserialize, Member, ValidateUnsigned},
|
||||
@@ -2376,7 +2376,3 @@ pub mod pallet_prelude {
|
||||
/// * use the newest nightly possible.
|
||||
///
|
||||
pub use frame_support_procedural::pallet;
|
||||
|
||||
/// The `max_encoded_len` module contains the `MaxEncodedLen` trait and derive macro, which is
|
||||
/// useful for computing upper bounds on storage size.
|
||||
pub use max_encoded_len;
|
||||
|
||||
@@ -23,9 +23,9 @@ use sp_std::{
|
||||
};
|
||||
use crate::{
|
||||
storage::StorageDecodeLength,
|
||||
traits::{Get, MaxEncodedLen},
|
||||
traits::Get,
|
||||
};
|
||||
use codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode, MaxEncodedLen};
|
||||
|
||||
/// A bounded map based on a B-Tree.
|
||||
///
|
||||
|
||||
@@ -23,9 +23,9 @@ use sp_std::{
|
||||
};
|
||||
use crate::{
|
||||
storage::StorageDecodeLength,
|
||||
traits::{Get, MaxEncodedLen},
|
||||
traits::Get,
|
||||
};
|
||||
use codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode, MaxEncodedLen};
|
||||
|
||||
/// A bounded set based on a B-Tree.
|
||||
///
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::{convert::TryFrom, fmt, marker::PhantomData};
|
||||
use codec::{Encode, Decode, EncodeLike};
|
||||
use codec::{Encode, Decode, EncodeLike, MaxEncodedLen};
|
||||
use core::{
|
||||
ops::{Deref, Index, IndexMut},
|
||||
slice::SliceIndex,
|
||||
};
|
||||
use crate::{
|
||||
traits::{Get, MaxEncodedLen},
|
||||
traits::Get,
|
||||
storage::{StorageDecodeLength, StorageTryAppend},
|
||||
};
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
//! Storage map type. Implements StorageDoubleMap, StorageIterableDoubleMap,
|
||||
//! StoragePrefixedDoubleMap traits and their methods directly.
|
||||
|
||||
use codec::{Decode, Encode, EncodeLike, FullCodec};
|
||||
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen};
|
||||
use crate::{
|
||||
storage::{
|
||||
StorageAppend, StorageTryAppend, StorageDecodeLength, StoragePrefixedMap,
|
||||
types::{OptionQuery, QueryKindTrait, OnEmptyGetter},
|
||||
},
|
||||
traits::{GetDefault, StorageInstance, Get, MaxEncodedLen, StorageInfo},
|
||||
traits::{GetDefault, StorageInstance, Get, StorageInfo},
|
||||
};
|
||||
use frame_metadata::{DefaultByteGetter, StorageEntryModifier};
|
||||
use sp_arithmetic::traits::SaturatedConversion;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
//! Storage key type.
|
||||
|
||||
use crate::{hash::{ReversibleStorageHasher, StorageHasher}, traits::MaxEncodedLen};
|
||||
use codec::{Encode, EncodeLike, FullCodec};
|
||||
use crate::hash::{ReversibleStorageHasher, StorageHasher};
|
||||
use codec::{Encode, EncodeLike, FullCodec, MaxEncodedLen};
|
||||
use paste::paste;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
//! Storage map type. Implements StorageMap, StorageIterableMap, StoragePrefixedMap traits and their
|
||||
//! methods directly.
|
||||
|
||||
use codec::{FullCodec, Decode, EncodeLike, Encode};
|
||||
use codec::{FullCodec, Decode, EncodeLike, Encode, MaxEncodedLen};
|
||||
use crate::{
|
||||
storage::{
|
||||
StorageAppend, StorageTryAppend, StorageDecodeLength, StoragePrefixedMap,
|
||||
types::{OptionQuery, QueryKindTrait, OnEmptyGetter},
|
||||
},
|
||||
traits::{GetDefault, StorageInstance, Get, MaxEncodedLen, StorageInfo},
|
||||
traits::{GetDefault, StorageInstance, Get, StorageInfo},
|
||||
};
|
||||
use frame_metadata::{DefaultByteGetter, StorageEntryModifier};
|
||||
use sp_arithmetic::traits::SaturatedConversion;
|
||||
|
||||
@@ -26,9 +26,9 @@ use crate::{
|
||||
},
|
||||
KeyGenerator, PrefixIterator, StorageAppend, StorageDecodeLength, StoragePrefixedMap,
|
||||
},
|
||||
traits::{Get, GetDefault, StorageInstance, StorageInfo, MaxEncodedLen},
|
||||
traits::{Get, GetDefault, StorageInstance, StorageInfo},
|
||||
};
|
||||
use codec::{Decode, Encode, EncodeLike, FullCodec};
|
||||
use codec::{Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen};
|
||||
use frame_metadata::{DefaultByteGetter, StorageEntryModifier};
|
||||
use sp_runtime::SaturatedConversion;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
//! Storage value type. Implements StorageValue trait and its method directly.
|
||||
|
||||
use codec::{FullCodec, Decode, EncodeLike, Encode};
|
||||
use codec::{FullCodec, Decode, EncodeLike, Encode, MaxEncodedLen};
|
||||
use crate::{
|
||||
storage::{
|
||||
StorageAppend, StorageTryAppend, StorageDecodeLength,
|
||||
types::{OptionQuery, QueryKindTrait, OnEmptyGetter},
|
||||
},
|
||||
traits::{GetDefault, StorageInstance, MaxEncodedLen, StorageInfo},
|
||||
traits::{GetDefault, StorageInstance, StorageInfo},
|
||||
};
|
||||
use frame_metadata::{DefaultByteGetter, StorageEntryModifier};
|
||||
use sp_arithmetic::traits::SaturatedConversion;
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::{convert::TryFrom, fmt, marker::PhantomData};
|
||||
use codec::{Encode, Decode};
|
||||
use codec::{Encode, Decode, MaxEncodedLen};
|
||||
use core::{
|
||||
ops::{Deref, Index, IndexMut},
|
||||
slice::SliceIndex,
|
||||
};
|
||||
use crate::{
|
||||
traits::{Get, MaxEncodedLen},
|
||||
traits::Get,
|
||||
storage::{StorageDecodeLength, StorageTryAppend},
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +81,3 @@ pub use dispatch::{EnsureOrigin, OriginTrait, UnfilteredDispatchable};
|
||||
|
||||
mod voting;
|
||||
pub use voting::{CurrencyToVote, SaturatingCurrencyToVote, U128CurrencyToVote};
|
||||
|
||||
// for backwards-compatibility with existing imports
|
||||
pub use max_encoded_len::MaxEncodedLen;
|
||||
|
||||
@@ -22,7 +22,7 @@ use sp_runtime::traits::MaybeSerializeDeserialize;
|
||||
use crate::dispatch::{DispatchResult, DispatchError};
|
||||
use super::misc::{Balance, WithdrawReasons, ExistenceRequirement};
|
||||
use super::imbalance::{Imbalance, SignedImbalance};
|
||||
use frame_support::traits::MaxEncodedLen;
|
||||
use codec::MaxEncodedLen;
|
||||
|
||||
mod reservable;
|
||||
pub use reservable::{ReservableCurrency, NamedReservableCurrency};
|
||||
|
||||
@@ -29,7 +29,7 @@ mod tests {
|
||||
|
||||
pub trait Config: frame_support_test::Config {
|
||||
type Origin2: codec::Codec + codec::EncodeLike + Default
|
||||
+ frame_support::traits::MaxEncodedLen;
|
||||
+ codec::MaxEncodedLen;
|
||||
}
|
||||
|
||||
frame_support::decl_storage! {
|
||||
|
||||
@@ -19,7 +19,6 @@ use frame_support::{
|
||||
weights::{DispatchInfo, DispatchClass, Pays, GetDispatchInfo},
|
||||
traits::{
|
||||
GetCallName, OnInitialize, OnFinalize, OnRuntimeUpgrade, GetPalletVersion, OnGenesis,
|
||||
MaxEncodedLen,
|
||||
},
|
||||
dispatch::{UnfilteredDispatchable, Parameter},
|
||||
storage::unhashed,
|
||||
@@ -48,10 +47,10 @@ impl From<SomeType6> for u64 { fn from(_t: SomeType6) -> Self { 0u64 } }
|
||||
pub struct SomeType7;
|
||||
impl From<SomeType7> for u64 { fn from(_t: SomeType7) -> Self { 0u64 } }
|
||||
|
||||
pub trait SomeAssociation1 { type _1: Parameter + MaxEncodedLen; }
|
||||
pub trait SomeAssociation1 { type _1: Parameter + codec::MaxEncodedLen; }
|
||||
impl SomeAssociation1 for u64 { type _1 = u64; }
|
||||
|
||||
pub trait SomeAssociation2 { type _2: Parameter + MaxEncodedLen; }
|
||||
pub trait SomeAssociation2 { type _2: Parameter + codec::MaxEncodedLen; }
|
||||
impl SomeAssociation2 for u64 { type _2 = u64; }
|
||||
|
||||
#[frame_support::pallet]
|
||||
|
||||
@@ -33,9 +33,9 @@ error[E0277]: the trait bound `<T as pallet::Config>::Bar: WrapperTypeEncode` is
|
||||
20 | pub fn foo(origin: OriginFor<T>, bar: T::Bar) -> DispatchResultWithPostInfo {
|
||||
| ^ the trait `WrapperTypeEncode` is not implemented for `<T as pallet::Config>::Bar`
|
||||
|
|
||||
::: /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/parity-scale-codec-2.1.1/src/codec.rs:216:21
|
||||
::: /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/parity-scale-codec-2.2.0/src/codec.rs:223:21
|
||||
|
|
||||
216 | fn encode_to<T: Output + ?Sized>(&self, dest: &mut T) {
|
||||
223 | fn encode_to<T: Output + ?Sized>(&self, dest: &mut T) {
|
||||
| ------ required by this bound in `encode_to`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `pallet::_::_parity_scale_codec::Encode` for `<T as pallet::Config>::Bar`
|
||||
@@ -46,9 +46,9 @@ error[E0277]: the trait bound `<T as pallet::Config>::Bar: WrapperTypeDecode` is
|
||||
20 | pub fn foo(origin: OriginFor<T>, bar: T::Bar) -> DispatchResultWithPostInfo {
|
||||
| ^ the trait `WrapperTypeDecode` is not implemented for `<T as pallet::Config>::Bar`
|
||||
|
|
||||
::: /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/parity-scale-codec-2.1.1/src/codec.rs:277:18
|
||||
::: /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/parity-scale-codec-2.2.0/src/codec.rs:284:18
|
||||
|
|
||||
277 | fn decode<I: Input>(input: &mut I) -> Result<Self, Error>;
|
||||
284 | fn decode<I: Input>(input: &mut I) -> Result<Self, Error>;
|
||||
| ----- required by this bound in `pallet::_::_parity_scale_codec::Decode::decode`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Decode` for `<T as pallet::Config>::Bar`
|
||||
|
||||
Reference in New Issue
Block a user