diff --git a/pallets/liquidity-pools-gateway/routers/Cargo.toml b/pallets/liquidity-pools-gateway/routers/Cargo.toml index 91523a7b76..7e5ba91264 100644 --- a/pallets/liquidity-pools-gateway/routers/Cargo.toml +++ b/pallets/liquidity-pools-gateway/routers/Cargo.toml @@ -34,13 +34,13 @@ pallet-evm = { workspace = true } # Custom crates cfg-traits = { workspace = true } -cfg-types = { workspace = true } # Local pallets pallet-ethereum-transaction = { workspace = true } pallet-liquidity-pools-gateway = { workspace = true } [dev-dependencies] +cfg-types = { workspace = true, default-features = true } lazy_static = { workspace = true } cumulus-primitives-core = { workspace = true, default-features = true } @@ -65,7 +65,6 @@ pallet-balances = { workspace = true, default-features = true } default = ["std"] std = [ "parity-scale-codec/std", - "cfg-types/std", "cfg-traits/std", "cfg-mocks/std", "hex/std", diff --git a/pallets/liquidity-pools-gateway/routers/src/lib.rs b/pallets/liquidity-pools-gateway/routers/src/lib.rs index acf465d12b..25d1fa3837 100644 --- a/pallets/liquidity-pools-gateway/routers/src/lib.rs +++ b/pallets/liquidity-pools-gateway/routers/src/lib.rs @@ -53,10 +53,7 @@ use scale_info::TypeInfo; use sp_core::{bounded::BoundedVec, ConstU32, H160, H256, U256}; use sp_runtime::traits::{BlakeTwo256, Hash}; use sp_std::{boxed::Box, marker::PhantomData, vec::Vec}; -use staging_xcm::{ - latest::{MultiLocation, OriginKind}, - VersionedMultiLocation, -}; +use staging_xcm::{latest::OriginKind, VersionedMultiLocation}; #[cfg(test)] mod mock; @@ -303,7 +300,7 @@ where /// XcmDomain gathers all the required fields to build and send remote /// calls to a specific XCM-based Domain. -#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] +#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] pub struct XcmDomain { /// The XCM multilocation of the domain. pub location: Box, @@ -346,32 +343,3 @@ pub struct XcmTransactInfo { pub max_weight: Weight, pub transact_extra_weight_signed: Option, } - -/// NOTE: Remove this custom implementation once the following underlying data -/// implements MaxEncodedLen: -/// * Polkadot Repo: xcm::VersionedMultiLocation -/// * PureStake Repo: pallet_xcm_transactor::Config::CurrencyId -impl MaxEncodedLen for XcmDomain -where - XcmDomain: Encode, -{ - fn max_encoded_len() -> usize { - // The domain's `VersionedMultiLocation` (custom bound) - MultiLocation::max_encoded_len() - // From the enum wrapping of `VersionedMultiLocation` for the XCM domain location. - .saturating_add(1) - // From the enum wrapping of `VersionedMultiLocation` for the asset fee location. - .saturating_add(1) - // The ethereum xcm call index (default bound) - .saturating_add(BoundedVec::< - u8, - ConstU32<{ xcm_primitives::MAX_ETHEREUM_XCM_INPUT_SIZE }>, - >::max_encoded_len()) - // The contract address (default bound) - .saturating_add(H160::max_encoded_len()) - // The fee currency (custom bound) - .saturating_add(cfg_types::tokens::CurrencyId::max_encoded_len()) - // The XcmTransactInfo - .saturating_add(XcmTransactInfo::max_encoded_len()) - } -} diff --git a/pallets/liquidity-pools/src/routers.rs b/pallets/liquidity-pools/src/routers.rs index 15c4006c50..29ebef06ef 100644 --- a/pallets/liquidity-pools/src/routers.rs +++ b/pallets/liquidity-pools/src/routers.rs @@ -15,7 +15,7 @@ pub enum Router { /// XcmDomain gathers all the required fields to build and send remote /// calls to a specific XCM-based Domain. -#[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] +#[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Debug))] pub struct XcmDomain { /// the xcm multilocation of the domain @@ -33,28 +33,3 @@ pub struct XcmDomain { /// The max gas_limit we want to propose for a remote evm execution pub max_gas_limit: u64, } - -// NOTE: Remove this custom implementation once the following underlying data -// implements MaxEncodedLen: -/// * Polkadot Repo: xcm::VersionedMultiLocation -/// * PureStake Repo: pallet_xcm_transactor::Config::CurrencyId -impl MaxEncodedLen for XcmDomain -where - XcmDomain: Encode, -{ - fn max_encoded_len() -> usize { - // The domain's `VersionedMultiLocation` (custom bound) - staging_xcm::latest::MultiLocation::max_encoded_len() - // From the enum wrapping of `VersionedMultiLocation` - .saturating_add(1) - // The ethereum xcm call index (default bound) - .saturating_add(BoundedVec::< - u8, - ConstU32<{ xcm_primitives::MAX_ETHEREUM_XCM_INPUT_SIZE }>, - >::max_encoded_len()) - // The contract address (default bound) - .saturating_add(H160::max_encoded_len()) - // The fee currency (custom bound) - .saturating_add(cfg_types::tokens::CurrencyId::max_encoded_len()) - } -} diff --git a/pallets/pool-system/src/pool_types.rs b/pallets/pool-system/src/pool_types.rs index 99453d6344..8eab01c58a 100644 --- a/pallets/pool-system/src/pool_types.rs +++ b/pallets/pool-system/src/pool_types.rs @@ -148,7 +148,7 @@ pub struct PoolParameters { pub max_nav_age: Seconds, } -#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)] +#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct PoolChanges where StringLimit: Get, @@ -160,31 +160,6 @@ where pub max_nav_age: Change, } -// NOTE: Can be removed once orml_traits::Change impls MaxEncodedLen -// https://github.com/open-web3-stack/open-runtime-module-library/pull/867 -impl MaxEncodedLen for PoolChanges -where - StringLimit: Get, - MaxTranches: Get, - PoolChanges: Encode, - BoundedVec, MaxTranches>: MaxEncodedLen, - BoundedVec, MaxTranches>: MaxEncodedLen, - Seconds: MaxEncodedLen, -{ - fn max_encoded_len() -> usize { - // The tranches (default bound) - BoundedVec::, MaxTranches>::max_encoded_len() - // The tranche metadata (default bound) - .saturating_add( - BoundedVec::, MaxTranches>::max_encoded_len(), - ) - // The min epoc time and max nav age (default bounds) - .saturating_add(Seconds::max_encoded_len().saturating_mul(2)) - // From the `Change` enum which wraps all four fields of Self - .saturating_add(4) - } -} - /// Information about the deposit that has been taken to create a pool #[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, Default, TypeInfo, MaxEncodedLen)] pub struct PoolDepositInfo {