From f61e30238abf164896c85266ec6e864063b420c2 Mon Sep 17 00:00:00 2001 From: lemunozm Date: Thu, 21 Mar 2024 11:48:25 +0100 Subject: [PATCH] development runtime failing because of serde --- Cargo.lock | 1 + runtime/development/Cargo.toml | 3 ++ runtime/development/src/lib.rs | 93 +++++++++++++++------------------- runtime/development/src/xcm.rs | 8 +-- 4 files changed, 48 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fbd68a316..d5f1092472 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2114,6 +2114,7 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", + "sp-staking", "sp-std", "sp-transaction-pool", "sp-version", diff --git a/runtime/development/Cargo.toml b/runtime/development/Cargo.toml index 52348c90d4..62f82a6595 100644 --- a/runtime/development/Cargo.toml +++ b/runtime/development/Cargo.toml @@ -30,6 +30,7 @@ sp-session = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } +sp-staking = { workspace = true } frame-benchmarking = { workspace = true, optional = true } # For benchmarking frame-executive = { workspace = true } @@ -163,6 +164,7 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", + "sp-staking/std", "frame-support/std", "frame-system/std", "frame-system-rpc-runtime-api/std", @@ -274,6 +276,7 @@ runtime-benchmarks = [ # Substrate related "sp-runtime/runtime-benchmarks", + "sp-staking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "staging-xcm-builder/runtime-benchmarks", diff --git a/runtime/development/src/lib.rs b/runtime/development/src/lib.rs index 304a9549af..9370ac84db 100644 --- a/runtime/development/src/lib.rs +++ b/runtime/development/src/lib.rs @@ -15,7 +15,7 @@ #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. -#![recursion_limit = "256"] +#![recursion_limit = "512"] // Allow things like `1 * CFG` #![allow(clippy::identity_op)] @@ -24,8 +24,8 @@ use cfg_primitives::{ liquidity_pools::GeneralCurrencyPrefix, types::{ AccountId, Address, AllOfCouncil, AuraId, Balance, BlockNumber, CollectionId, - CouncilCollective, EnsureRootOr, HalfOfCouncil, Hash, Hashing, Header, IBalance, Index, - ItemId, LoanId, OrderId, OutboundMessageNonce, PalletIndex, PoolEpochId, PoolFeeId, PoolId, + CouncilCollective, EnsureRootOr, HalfOfCouncil, Hash, Hashing, Header, IBalance, ItemId, + LoanId, Nonce, OrderId, OutboundMessageNonce, PalletIndex, PoolEpochId, PoolFeeId, PoolId, Signature, TrancheId, TrancheWeight, TwoThirdOfCouncil, }, }; @@ -35,7 +35,6 @@ use cfg_traits::{ TryConvert as _, }; use cfg_types::{ - consts::pools::{MaxTrancheNameLengthBytes, MaxTrancheSymbolLengthBytes}, fee_keys::{Fee, FeeKey}, fixed_point::{Quantity, Rate, Ratio}, investments::InvestmentPortfolio, @@ -46,8 +45,8 @@ use cfg_types::{ }, time::TimeProvider, tokens::{ - CurrencyId, CustomMetadata, StakingCurrency::BlockRewards as BlockRewardsCurrency, - TrancheCurrency, + AssetStringLimit, CurrencyId, CustomMetadata, + StakingCurrency::BlockRewards as BlockRewardsCurrency, TrancheCurrency, }, }; use chainbridge::constants::DEFAULT_RELAYER_VOTE_THRESHOLD; @@ -56,19 +55,18 @@ use fp_rpc::TransactionStatus; use frame_support::{ construct_runtime, dispatch::DispatchClass, - pallet_prelude::{DispatchError, DispatchResult}, + pallet_prelude::{DispatchError, DispatchResult, RuntimeDebug}, parameter_types, - sp_std::marker::PhantomData, traits::{ - AsEnsureOriginWithArg, ConstU32, ConstU64, Contains, EitherOfDiverse, EqualPrivilegeOnly, - Get, InstanceFilter, LockIdentifier, OnFinalize, PalletInfoAccess, U128CurrencyToVote, + AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, Contains, EitherOfDiverse, + EqualPrivilegeOnly, Get, InstanceFilter, LockIdentifier, OnFinalize, PalletInfoAccess, UnixTime, WithdrawReasons, }, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, ConstantMultiplier, Weight, }, - PalletId, RuntimeDebug, + PalletId, }; use frame_system::{ limits::{BlockLength, BlockWeights}, @@ -103,7 +101,7 @@ use runtime_common::{ changes::FastDelay, evm::{ precompile::Precompiles, BaseFeeThreshold, FindAuthorTruncated, GAS_LIMIT_POV_SIZE_RATIO, - GAS_LIMIT_STORAGE_GROWTH_RATIO, WEIGHT_PER_GAS, + WEIGHT_PER_GAS, }, fees::{DealWithFees, FeeToTreasury, WeightToFee}, gateway::GatewayAccountProvider, @@ -129,10 +127,11 @@ use sp_runtime::{ transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedI128, Perbill, Permill, Perquintill, }; -use sp_std::prelude::*; +use sp_staking::currency_to_vote::U128CurrencyToVote; +use sp_std::{marker::PhantomData, prelude::*}; use sp_version::RuntimeVersion; +use staging_xcm_executor::XcmExecutor; use static_assertions::const_assert; -use xcm_executor::XcmExecutor; use crate::xcm::*; @@ -211,26 +210,25 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; type BaseCallFilter = BaseCallFilter; + /// The block type. + type Block = Block; /// Maximum number of block number to block hash mappings to keep (oldest /// pruned first). type BlockHashCount = BlockHashCount; type BlockLength = RuntimeBlockLength; /// The index type for blocks. - type BlockNumber = BlockNumber; type BlockWeights = RuntimeBlockWeights; type DbWeight = RocksDbWeight; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = Hashing; - /// The header type. - type Header = Header; - /// The index type for storing how many extrinsics an account has signed. - type Index = Index; /// The lookup mechanism to get account ID from whatever is passed in /// dispatchers. type Lookup = sp_runtime::traits::AccountIdLookup; type MaxConsumers = frame_support::traits::ConstU32<16>; + /// The nonce type for storing how many extrinsics an account has signed. + type Nonce = Nonce; /// A function that is invoked when an account has been determined to be /// dead. All resources should be cleaned up associated with the given /// account. @@ -355,7 +353,6 @@ impl pallet_balances::Config for Runtime { /// The minimum amount required to keep an account open. type ExistentialDeposit = ExistentialDeposit; type FreezeIdentifier = (); - type HoldIdentifier = (); type MaxFreezes = ConstU32<10>; type MaxHolds = ConstU32<10>; type MaxLocks = MaxLocks; @@ -363,6 +360,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; /// The overarching event type. type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = (); type WeightInfo = weights::pallet_balances::WeightInfo; } @@ -400,6 +398,7 @@ parameter_types! { } impl pallet_aura::Config for Runtime { + type AllowMultipleBlocksPerSlot = ConstBool; type AuthorityId = AuraId; type DisabledValidators = (); type MaxAuthorities = MaxAuthorities; @@ -1051,8 +1050,6 @@ impl pallet_pool_system::Config for Runtime { type EpochId = PoolEpochId; type Investments = Investments; type MaxNAVAgeUpperBound = MaxNAVAgeUpperBound; - type MaxTokenNameLength = MaxTrancheNameLengthBytes; - type MaxTokenSymbolLength = MaxTrancheSymbolLengthBytes; type MaxTranches = MaxTranches; type MinEpochTimeLowerBound = MinEpochTimeLowerBound; type MinEpochTimeUpperBound = MinEpochTimeUpperBound; @@ -1070,6 +1067,7 @@ impl pallet_pool_system::Config for Runtime { type Rate = Rate; type RuntimeChange = runtime_common::changes::RuntimeChange; type RuntimeEvent = RuntimeEvent; + type StringLimit = AssetStringLimit; type Time = Timestamp; type Tokens = Tokens; type TrancheCurrency = TrancheCurrency; @@ -1085,8 +1083,6 @@ impl pallet_pool_registry::Config for Runtime { type CurrencyId = CurrencyId; type InterestRate = Rate; type MaxSizeMetadata = MaxSizeMetadata; - type MaxTokenNameLength = MaxTrancheNameLengthBytes; - type MaxTokenSymbolLength = MaxTrancheSymbolLengthBytes; type MaxTranches = MaxTranches; type ModifyPool = pallet_pool_system::Pallet; type ModifyWriteOffPolicy = pallet_loans::Pallet; @@ -1151,12 +1147,7 @@ impl PoolUpdateGuard for UpdateGuard { PoolId, MaxTranches, >; - type ScheduledUpdateDetails = ScheduledUpdateDetails< - Rate, - MaxTrancheNameLengthBytes, - MaxTrancheSymbolLengthBytes, - MaxTranches, - >; + type ScheduledUpdateDetails = ScheduledUpdateDetails; fn released( pool: &Self::PoolDetails, @@ -1240,7 +1231,7 @@ parameter_types! { #[derive(scale_info::TypeInfo, Debug, PartialEq, Eq, Clone)] pub const MaxCandidates: u32 = 20; - pub const MinCandidates: u32 = 5; + pub const MinEligibleCollators: u32 = 5; pub const MaxVoters: u32 = 100; pub const SessionLength: BlockNumber = 6 * HOURS; pub const MaxInvulnerables: u32 = 100; @@ -1258,7 +1249,7 @@ impl pallet_collator_selection::Config for Runtime { type KickThreshold = Period; type MaxCandidates = MaxCandidates; type MaxInvulnerables = MaxInvulnerables; - type MinCandidates = MinCandidates; + type MinEligibleCollators = MinEligibleCollators; type PotId = PotId; type RuntimeEvent = RuntimeEvent; type UpdateOrigin = CollatorSelectionUpdateOrigin; @@ -1281,9 +1272,8 @@ impl pallet_xcm_transactor::Config for Runtime { type CurrencyId = CurrencyId; type CurrencyIdToMultiLocation = CurrencyIdConvert; type DerivativeAddressRegistrationOrigin = EnsureRoot; - type HrmpEncoder = moonbeam_relay_encoder::westend::WestendEncoder; type HrmpManipulatorOrigin = EnsureRootOr; - type MaxHrmpFee = xcm_builder::Case; + type MaxHrmpFee = staging_xcm_builder::Case; type ReserveProvider = xcm_primitives::AbsoluteAndRelativeReserve; type RuntimeEvent = RuntimeEvent; type SelfLocation = SelfLocation; @@ -1299,7 +1289,7 @@ parameter_types! { pub const MaxActiveLoansPerPool: u32 = 1000; pub const MaxRateCount: u32 = 1000; // See #1024 pub const FirstValueFee: Fee = Fee::Balance(deposit(1, pallet_oracle_feed::util::size_of_feed::())); - // + #[derive(Clone, PartialEq, Eq, Debug, TypeInfo, Encode, Decode, MaxEncodedLen)] pub const MaxWriteOffPolicySize: u32 = 10; @@ -1539,6 +1529,7 @@ impl orml_asset_registry::Config for Runtime { type Balance = Balance; type CustomMetadata = CustomMetadata; type RuntimeEvent = RuntimeEvent; + type StringLimit = AssetStringLimit; type WeightInfo = (); } @@ -1925,7 +1916,8 @@ parameter_types! { } /// Xcm Weigher shared between multiple Xcm-related configs. -pub type XcmWeigher = xcm_builder::FixedWeightBounds; +pub type XcmWeigher = + staging_xcm_builder::FixedWeightBounds; /// XCMP Queue is responsible to handle XCM messages coming directly from /// sibling parachains. @@ -1960,7 +1952,6 @@ impl pallet_evm::Config for Runtime { type FeeCalculator = BaseFee; type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = ConstU64; - type GasLimitStorageGrowthRatio = ConstU64; type GasWeightMapping = pallet_evm::FixedGasWeightMapping; type OnChargeTransaction = (); type OnCreate = (); @@ -2047,16 +2038,12 @@ pub type Executive = frame_executive::Executive< // Any addition should be done at the bottom // Any deletion affects the following frames during runtime upgrades construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = cfg_primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { + pub enum Runtime { // basic system stuff - System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, - ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event} = 1, + System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, + ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event} = 1, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3, - ParachainInfo: parachain_info::{Pallet, Storage, Config} = 4, + ParachainInfo: parachain_info::{Pallet, Storage, Config} = 4, // money stuff Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 20, @@ -2068,7 +2055,7 @@ construct_runtime!( Authorship: pallet_authorship::{Pallet, Storage} = 30, Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 31, Aura: pallet_aura::{Pallet, Storage, Config} = 32, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 33, + AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 33, // substrate pallets Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 60, @@ -2080,7 +2067,7 @@ construct_runtime!( Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event} = 66, Identity: pallet_identity::{Pallet, Call, Storage, Event} = 67, Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 68, - Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 69, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 69, Uniques: pallet_uniques::{Pallet, Call, Storage, Event} = 70, Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 72, @@ -2117,7 +2104,7 @@ construct_runtime!( // XCM XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 120, - PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Config, Event, Origin} = 121, + PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Config, Event, Origin} = 121, CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 122, DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 123, XTokens: pallet_restricted_xtokens::{Pallet, Call} = 124, @@ -2131,10 +2118,10 @@ construct_runtime!( OrmlXcm: orml_xcm::{Pallet, Storage, Call, Event} = 153, // EVM pallets - EVM: pallet_evm::{Pallet, Config, Call, Storage, Event} = 160, - EVMChainId: pallet_evm_chain_id::{Pallet, Config, Storage} = 161, + EVM: pallet_evm::{Pallet, Config, Call, Storage, Event} = 160, + EVMChainId: pallet_evm_chain_id::{Pallet, Config, Storage} = 161, BaseFee: pallet_base_fee::{Pallet, Call, Config, Storage, Event} = 162, - Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 163, + Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 163, EthereumTransaction: pallet_ethereum_transaction::{Pallet, Storage} = 164, LiquidityPoolsAxelarGateway: axelar_gateway_precompile::{Pallet, Call, Storage, Event} = 165, @@ -2326,8 +2313,8 @@ impl_runtime_apis! { } } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Index { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) } } diff --git a/runtime/development/src/xcm.rs b/runtime/development/src/xcm.rs index 1e8313b57f..f895394554 100644 --- a/runtime/development/src/xcm.rs +++ b/runtime/development/src/xcm.rs @@ -33,13 +33,13 @@ use runtime_common::{ xcm_fees::native_per_second, }; use sp_core::ConstU32; -use xcm::{latest::Weight as XcmWeight, prelude::*, v3::MultiLocation}; -use xcm_builder::{ +use staging_xcm::{latest::Weight as XcmWeight, prelude::*, v3::MultiLocation}; +use staging_xcm_builder::{ ConvertedConcreteId, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, NoChecking, RelayChainAsNative, SiblingParachainAsNative, SignedAccountId32AsNative, SovereignSignedViaLocation, }; -use xcm_executor::{traits::JustTry, XcmExecutor}; +use staging_xcm_executor::{traits::JustTry, XcmExecutor}; use super::{ AccountId, Balance, OrmlAssetRegistry, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, @@ -82,7 +82,7 @@ impl frame_support::traits::Contains for SafeCallFilter { /// transferred, how fees are calculated, what barriers we impose on incoming /// XCM messages, etc. pub struct XcmConfig; -impl xcm_executor::Config for XcmConfig { +impl staging_xcm_executor::Config for XcmConfig { type AssetClaims = PolkadotXcm; type AssetExchanger = (); type AssetLocker = ();