Skip to content

Commit

Permalink
development runtime failing because of serde
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Mar 21, 2024
1 parent 97901b8 commit f61e302
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 57 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions runtime/development/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
93 changes: 40 additions & 53 deletions runtime/development/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand All @@ -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,
},
};
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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},
Expand Down Expand Up @@ -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,
Expand All @@ -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::*;

Expand Down Expand Up @@ -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<AccountId, ()>;
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.
Expand Down Expand Up @@ -355,14 +353,14 @@ 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;
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
/// The overarching event type.
type RuntimeEvent = RuntimeEvent;
type RuntimeHoldReason = ();
type WeightInfo = weights::pallet_balances::WeightInfo<Self>;
}

Expand Down Expand Up @@ -400,6 +398,7 @@ parameter_types! {
}

impl pallet_aura::Config for Runtime {
type AllowMultipleBlocksPerSlot = ConstBool<false>;
type AuthorityId = AuraId;
type DisabledValidators = ();
type MaxAuthorities = MaxAuthorities;
Expand Down Expand Up @@ -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;
Expand All @@ -1070,6 +1067,7 @@ impl pallet_pool_system::Config for Runtime {
type Rate = Rate;
type RuntimeChange = runtime_common::changes::RuntimeChange<Runtime, FastDelay>;
type RuntimeEvent = RuntimeEvent;
type StringLimit = AssetStringLimit;
type Time = Timestamp;
type Tokens = Tokens;
type TrancheCurrency = TrancheCurrency;
Expand All @@ -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<Self>;
type ModifyWriteOffPolicy = pallet_loans::Pallet<Self>;
Expand Down Expand Up @@ -1151,12 +1147,7 @@ impl PoolUpdateGuard for UpdateGuard {
PoolId,
MaxTranches,
>;
type ScheduledUpdateDetails = ScheduledUpdateDetails<
Rate,
MaxTrancheNameLengthBytes,
MaxTrancheSymbolLengthBytes,
MaxTranches,
>;
type ScheduledUpdateDetails = ScheduledUpdateDetails<Rate, AssetStringLimit, MaxTranches>;

fn released(
pool: &Self::PoolDetails,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -1281,9 +1272,8 @@ impl pallet_xcm_transactor::Config for Runtime {
type CurrencyId = CurrencyId;
type CurrencyIdToMultiLocation = CurrencyIdConvert;
type DerivativeAddressRegistrationOrigin = EnsureRoot<AccountId>;
type HrmpEncoder = moonbeam_relay_encoder::westend::WestendEncoder;
type HrmpManipulatorOrigin = EnsureRootOr<HalfOfCouncil>;
type MaxHrmpFee = xcm_builder::Case<MaxHrmpRelayFee>;
type MaxHrmpFee = staging_xcm_builder::Case<MaxHrmpRelayFee>;
type ReserveProvider = xcm_primitives::AbsoluteAndRelativeReserve<SelfLocation>;
type RuntimeEvent = RuntimeEvent;
type SelfLocation = SelfLocation;
Expand All @@ -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::<Runtime>()));
//

#[derive(Clone, PartialEq, Eq, Debug, TypeInfo, Encode, Decode, MaxEncodedLen)]
pub const MaxWriteOffPolicySize: u32 = 10;

Expand Down Expand Up @@ -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 = ();
}

Expand Down Expand Up @@ -1925,7 +1916,8 @@ parameter_types! {
}

/// Xcm Weigher shared between multiple Xcm-related configs.
pub type XcmWeigher = xcm_builder::FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
pub type XcmWeigher =
staging_xcm_builder::FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;

/// XCMP Queue is responsible to handle XCM messages coming directly from
/// sibling parachains.
Expand Down Expand Up @@ -1960,7 +1952,6 @@ impl pallet_evm::Config for Runtime {
type FeeCalculator = BaseFee;
type FindAuthor = FindAuthorTruncated<Self>;
type GasLimitPovSizeRatio = ConstU64<GAS_LIMIT_POV_SIZE_RATIO>;
type GasLimitStorageGrowthRatio = ConstU64<GAS_LIMIT_STORAGE_GROWTH_RATIO>;
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type OnChargeTransaction = ();
type OnCreate = ();
Expand Down Expand Up @@ -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<T>} = 0,
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>} = 1,
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>} = 0,
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config<T>, Storage, Inherent, Event<T>} = 1,
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3,
ParachainInfo: parachain_info::{Pallet, Storage, Config} = 4,
ParachainInfo: parachain_info::{Pallet, Storage, Config<T>} = 4,

// money stuff
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 20,
Expand All @@ -2068,7 +2055,7 @@ construct_runtime!(
Authorship: pallet_authorship::{Pallet, Storage} = 30,
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>} = 31,
Aura: pallet_aura::{Pallet, Storage, Config<T>} = 32,
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 33,
AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config<T>} = 33,

// substrate pallets
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 60,
Expand All @@ -2080,7 +2067,7 @@ construct_runtime!(
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 66,
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 67,
Vesting: pallet_vesting::{Pallet, Call, Storage, Event<T>, Config<T>} = 68,
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 69,
Treasury: pallet_treasury::{Pallet, Call, Storage, Config<T>, Event<T>} = 69,
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 70,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 72,

Expand Down Expand Up @@ -2117,7 +2104,7 @@ construct_runtime!(

// XCM
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 120,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Config, Event<T>, Origin} = 121,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Config<T>, Event<T>, Origin} = 121,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 122,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 123,
XTokens: pallet_restricted_xtokens::{Pallet, Call} = 124,
Expand All @@ -2131,10 +2118,10 @@ construct_runtime!(
OrmlXcm: orml_xcm::{Pallet, Storage, Call, Event<T>} = 153,

// EVM pallets
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 160,
EVMChainId: pallet_evm_chain_id::{Pallet, Config, Storage} = 161,
EVM: pallet_evm::{Pallet, Config<T>, Call, Storage, Event<T>} = 160,
EVMChainId: pallet_evm_chain_id::{Pallet, Config<T>, Storage} = 161,
BaseFee: pallet_base_fee::{Pallet, Call, Config<T>, Storage, Event} = 162,
Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 163,
Ethereum: pallet_ethereum::{Pallet, Config<T>, Call, Storage, Event, Origin} = 163,
EthereumTransaction: pallet_ethereum_transaction::{Pallet, Storage} = 164,
LiquidityPoolsAxelarGateway: axelar_gateway_precompile::{Pallet, Call, Storage, Event<T>} = 165,

Expand Down Expand Up @@ -2326,8 +2313,8 @@ impl_runtime_apis! {
}
}

impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
fn account_nonce(account: AccountId) -> Index {
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
fn account_nonce(account: AccountId) -> Nonce {
System::account_nonce(account)
}
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/development/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -82,7 +82,7 @@ impl frame_support::traits::Contains<RuntimeCall> 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 = ();
Expand Down

0 comments on commit f61e302

Please sign in to comment.