diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index 266b63cb2..ede53f13b 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -9,31 +9,11 @@ on: - main jobs: - build-check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/shared - - - name: Install toolchain - # Call `rustup show` as a hack so that the toolchain defined in rust-toolchain.toml is installed - run: rustup show - - # Enable this for clippy linting. - # - name: Check and Lint Code - # run: cargo +nightly-2021-12-01 clippy -- -D warnings - - - name: Install Protoc - uses: arduino/setup-protoc@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check Code - run: cargo check - test-code: runs-on: ubuntu-latest + env: + # Make sure CI fails on all warnings, including Clippy lints + RUSTFLAGS: "-Dwarnings" steps: - uses: actions/checkout@v3 @@ -64,3 +44,27 @@ jobs: with: toolchain: nightly-2024-04-18 command: test + + - name: Clippy -- Main + uses: actions-rs/cargo@v1 + with: + toolchain: nightly-2024-04-18 + command: clippy + args: --all-features -- -W clippy::all -A clippy::style -A forgetting_copy_types -A forgetting_references + + - name: Clippy -- All Targets (except integration) + uses: actions-rs/cargo@v1 + with: + toolchain: nightly-2024-04-18 + command: clippy + # We are a bit more forgiving when it comes to the code in tests and only check for correctness + args: --workspace --all-features --all-targets --exclude runtime-integration-tests -- -A clippy::all -W clippy::correctness -A forgetting_copy_types -A forgetting_references + + - name: Clippy -- Integration + uses: actions-rs/cargo@v1 + with: + toolchain: nightly-2024-04-18 + command: clippy + # We are a bit more forgiving when it comes to the code in tests and only check for correctness + args: --package runtime-integration-tests --all-features --all-targets -- -A clippy::all -W clippy::correctness -A forgetting_copy_types -A forgetting_references + \ No newline at end of file diff --git a/chain-extensions/price/src/lib.rs b/chain-extensions/price/src/lib.rs index 766832705..411905a9f 100644 --- a/chain-extensions/price/src/lib.rs +++ b/chain-extensions/price/src/lib.rs @@ -46,7 +46,7 @@ where T: SysConfig + pallet_contracts::Config + dia_oracle::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, { - fn call(&mut self, env: Environment) -> Result + fn call(&mut self, env: Environment) -> Result where E: Ext, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, @@ -74,7 +74,7 @@ where } } -fn get_coin_info( +fn get_coin_info( env: Environment<'_, '_, E, InitState>, overhead_weight: Weight, ) -> Result diff --git a/chain-extensions/token/src/lib.rs b/chain-extensions/token/src/lib.rs index 5cc87a251..961f3d485 100644 --- a/chain-extensions/token/src/lib.rs +++ b/chain-extensions/token/src/lib.rs @@ -73,9 +73,9 @@ where + orml_currencies_allowance_extension::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, Tokens: orml_traits::MultiCurrency, - AccountId: sp_std::fmt::Debug + Decode, + AccountId: sp_std::fmt::Debug + Decode + core::clone::Clone, { - fn call(&mut self, env: Environment) -> Result + fn call(&mut self, env: Environment) -> Result where E: Ext, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, @@ -92,15 +92,14 @@ where 0, ); - let result = match func_id { + match func_id { FuncId::TotalSupply => total_supply(env, overhead_weight), FuncId::BalanceOf => balance_of(env, overhead_weight), FuncId::Transfer => transfer(env, overhead_weight), FuncId::Allowance => allowance(env, overhead_weight), FuncId::Approve => approve(env, overhead_weight), FuncId::TransferFrom => transfer_from(env, overhead_weight), - }; - result + } } fn enabled() -> bool { @@ -108,7 +107,7 @@ where } } -fn total_supply( +fn total_supply( env: Environment<'_, '_, E, InitState>, overhead_weight: Weight, ) -> Result @@ -147,7 +146,7 @@ where return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) } -fn balance_of( +fn balance_of( env: Environment<'_, '_, E, InitState>, overhead_weight: Weight, ) -> Result @@ -189,7 +188,7 @@ where return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) } -fn transfer( +fn transfer( env: Environment<'_, '_, E, InitState>, overhead_weight: Weight, ) -> Result @@ -200,7 +199,7 @@ where + orml_currencies::Config + orml_currencies_allowance_extension::Config, E: Ext, - AccountId: sp_std::fmt::Debug, + AccountId: sp_std::fmt::Debug + core::clone::Clone, Tokens: orml_traits::MultiCurrency, (CurrencyId, AccountId, >::Balance): Decode, { @@ -229,14 +228,14 @@ where as MultiCurrency>::transfer( currency_id, - &env.ext().caller(), + env.ext().caller(), &recipient, amount, )?; return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) } -fn allowance( +fn allowance( env: Environment<'_, '_, E, InitState>, overhead_weight: Weight, ) -> Result @@ -281,7 +280,7 @@ where return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) } -fn approve( +fn approve( env: Environment<'_, '_, E, InitState>, overhead_weight: Weight, ) -> Result @@ -292,7 +291,7 @@ where + orml_currencies::Config + orml_currencies_allowance_extension::Config, E: Ext, - AccountId: sp_std::fmt::Debug, + AccountId: sp_std::fmt::Debug + core::clone::Clone, Tokens: orml_traits::MultiCurrency, (CurrencyId, AccountId, >::Balance): Decode, { @@ -320,14 +319,14 @@ where orml_currencies_allowance_extension::Pallet::::do_approve_transfer( currency_id, - &env.ext().caller(), + env.ext().caller(), &spender, amount, )?; return Ok(RetVal::Converging(ChainExtensionOutcome::Success.as_u32())) } -fn transfer_from( +fn transfer_from( env: Environment<'_, '_, E, InitState>, overhead_weight: Weight, ) -> Result @@ -338,7 +337,7 @@ where + orml_currencies::Config + orml_currencies_allowance_extension::Config, E: Ext, - AccountId: sp_std::fmt::Debug, + AccountId: sp_std::fmt::Debug + core::clone::Clone, Tokens: orml_traits::MultiCurrency, (AccountId, CurrencyId, AccountId, >::Balance): Decode, { @@ -372,7 +371,7 @@ where orml_currencies_allowance_extension::Pallet::::do_transfer_approved( currency_id, &owner, - &env.ext().caller(), + env.ext().caller(), &recipient, amount, )?; diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 72ee6970d..1fbdc1c7a 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -34,7 +34,7 @@ const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; pub fn create_pendulum_multisig_account(id: &str) -> AccountId { let mut signatories: Vec<_> = pendulum::SUDO_SIGNATORIES .iter() - .chain(vec![id].iter()) + .chain([id].iter()) .map(|ss58| AccountId::from_ss58check(ss58).unwrap()) .collect(); signatories.sort(); @@ -384,7 +384,7 @@ pub fn pendulum_config() -> PendulumChainSpec { pendulum::TREASURY_ALLOCATION * 20 / 100, )); - let multisig_identifiers = vec![ + let multisig_identifiers = [ pendulum::MULTISIG_ID_GENESIS, pendulum::MULTISIG_ID_TEAM, pendulum::MULTISIG_ID_CL_RESERVES, diff --git a/node/src/command.rs b/node/src/command.rs index 7a71636f8..ec33c71e6 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -404,19 +404,19 @@ pub fn run() -> Result<()> { .map_err(|e| format!("Error: {:?}", e))?; match runner.config().chain_spec.identify() { - ChainIdentity::Amplitude => runner.async_run(|config| { + ChainIdentity::Amplitude => runner.async_run(|_config| { Ok((cmd.run::::ExtendHostFunctions, >, _>(Some(substrate_info(BLOCK_TIME_MILLIS))), task_manager)) }), - ChainIdentity::Foucoco => runner.async_run(|config| { + ChainIdentity::Foucoco => runner.async_run(|_config| { Ok((cmd.run::::ExtendHostFunctions, >, _>(Some(substrate_info(BLOCK_TIME_MILLIS))), task_manager)) }), - ChainIdentity::Pendulum => runner.async_run(|config| { + ChainIdentity::Pendulum => runner.async_run(|_config| { Ok((cmd.run::::ExtendHostFunctions, diff --git a/pallets/orml-currencies-allowance-extension/src/lib.rs b/pallets/orml-currencies-allowance-extension/src/lib.rs index 57874bece..c23f93984 100644 --- a/pallets/orml-currencies-allowance-extension/src/lib.rs +++ b/pallets/orml-currencies-allowance-extension/src/lib.rs @@ -238,7 +238,7 @@ pub mod pallet { } } -#[allow(clippy::forget_non_drop, clippy::swap_ptr_to_ref, clippy::forget_ref, clippy::forget_copy)] +#[allow(clippy::forget_non_drop, clippy::swap_ptr_to_ref, forgetting_references, forgetting_copy_types)] #[cfg_attr(test, mockable)] impl Pallet { // Check the amount approved to be spent by an owner to a delegate diff --git a/pallets/orml-tokens-management-extension/src/lib.rs b/pallets/orml-tokens-management-extension/src/lib.rs index 59f1c6e2d..d2c35e962 100644 --- a/pallets/orml-tokens-management-extension/src/lib.rs +++ b/pallets/orml-tokens-management-extension/src/lib.rs @@ -124,14 +124,14 @@ pub mod pallet { T::CurrencyIdChecker::is_valid_currency_id(¤cy_id), Error::::NotOwnableCurrency ); - ensure!(!CurrencyData::::contains_key(¤cy_id), Error::::AlreadyCreated); + ensure!(!CurrencyData::::contains_key(currency_id), Error::::AlreadyCreated); let deposit = T::AssetDeposit::get(); ext::orml_tokens::reserve::(T::DepositCurrency::get(), &creator, deposit) .map_err(|_| Error::::InsufficientBalance)?; CurrencyData::::insert( - currency_id.clone(), + currency_id, CurrencyDetails { owner: creator.clone(), issuer: creator.clone(), @@ -175,7 +175,7 @@ pub mod pallet { ensure!(origin == currency_data.issuer, Error::::NoPermission); // do mint via orml-currencies - let _ = ext::orml_tokens::mint::(currency_id, &to, amount)?; + ext::orml_tokens::mint::(currency_id, &to, amount)?; Self::deposit_event(Event::Mint { currency_id, to, amount }); Ok(()) @@ -207,7 +207,7 @@ pub mod pallet { ensure!(origin == currency_data.admin, Error::::NoPermission); // do burn via orml-currencies - let _ = ext::orml_tokens::burn::(currency_id, &from, amount)?; + ext::orml_tokens::burn::(currency_id, &from, amount)?; Self::deposit_event(Event::Burned { currency_id, from, amount }); Ok(()) @@ -231,7 +231,7 @@ pub mod pallet { ) -> DispatchResult { let origin = ensure_signed(origin)?; - CurrencyData::::try_mutate(currency_id.clone(), |maybe_details| { + CurrencyData::::try_mutate(currency_id, |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::NotCreated)?; ensure!(origin == details.owner, Error::::NoPermission); @@ -241,7 +241,7 @@ pub mod pallet { details.owner = new_owner.clone(); // move reserved balance to the new owner's account - let _ = ext::orml_tokens::repatriate_reserve::( + ext::orml_tokens::repatriate_reserve::( T::DepositCurrency::get(), &origin, &new_owner, @@ -271,13 +271,13 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; - CurrencyData::::try_mutate(currency_id.clone(), |maybe_details| { + CurrencyData::::try_mutate(currency_id, |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::NotCreated)?; if details.owner == new_owner { return Ok(()) } - let _ = ext::orml_tokens::repatriate_reserve::( + ext::orml_tokens::repatriate_reserve::( T::DepositCurrency::get(), &details.owner, &new_owner, @@ -311,7 +311,7 @@ pub mod pallet { ) -> DispatchResult { let origin = ensure_signed(origin)?; - CurrencyData::::try_mutate(currency_id.clone(), |maybe_details| { + CurrencyData::::try_mutate(currency_id, |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::NotCreated)?; ensure!(origin == details.owner, Error::::NoPermission); diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index fe74b9581..869191bad 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -36,9 +36,10 @@ frame-benchmarking = {git = "https://github.com/paritytech/substrate", branch = [features] default = ["std"] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", ] std = [ "frame-support/std", diff --git a/pallets/parachain-staking/rpc/src/lib.rs b/pallets/parachain-staking/rpc/src/lib.rs index bf60f8d1f..10d0ccbbf 100644 --- a/pallets/parachain-staking/rpc/src/lib.rs +++ b/pallets/parachain-staking/rpc/src/lib.rs @@ -72,7 +72,7 @@ where let at = at.unwrap_or_else(|| self.client.info().best_hash); api.get_unclaimed_staking_rewards(at, account) - .map_err(|_e| internal_err(format!("Unable to get unclaimed staking rewards"))) + .map_err(|_e| internal_err("Unable to get unclaimed staking rewards")) } fn get_staking_rates(&self, at: Option<::Hash>) -> RpcResult { @@ -80,6 +80,6 @@ where let at = at.unwrap_or_else(|| self.client.info().best_hash); api.get_staking_rates(at) - .map_err(|_e| internal_err(format!("Unable to get staking rates"))) + .map_err(|_e| internal_err("Unable to get staking rates")) } } diff --git a/pallets/parachain-staking/src/benchmarking.rs b/pallets/parachain-staking/src/benchmarking.rs index 9f536fc47..053003a51 100644 --- a/pallets/parachain-staking/src/benchmarking.rs +++ b/pallets/parachain-staking/src/benchmarking.rs @@ -307,7 +307,7 @@ benchmarks! { let n in (T::MinCollators::get() + 1) .. T::MaxTopCandidates::get() - 1; let m in 0 .. T::MaxDelegatorsPerCollator::get(); - let u = T::MaxUnstakeRequests::get() as u32 - 1; + let u = T::MaxUnstakeRequests::get() - 1; let candidates = setup_collator_candidates::(n, None); for (i, c) in candidates.iter().enumerate() { fill_delegators::(m, c.clone(), i.saturated_into::()); @@ -532,7 +532,7 @@ benchmarks! { } unlock_unstaked { - let u in 1 .. (T::MaxUnstakeRequests::get() as u32 - 1); + let u in 1 .. (T::MaxUnstakeRequests::get() - 1); let candidate = account("collator", 0u32, COLLATOR_ACCOUNT_SEED); let free_balance = T::CurrencyBalance::from(u128::MAX); diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs index 899b7bb9e..2deaea2ac 100644 --- a/pallets/parachain-staking/src/try_state.rs +++ b/pallets/parachain-staking/src/try_state.rs @@ -35,6 +35,7 @@ pub fn log_and_return_error_message(error_message: String) -> &'static str { "Sanity test error" } +#[allow(dead_code)] pub(crate) fn do_try_state() -> Result<(), &'static str> { validate_candiate_pool::()?; validate_delegators::()?; diff --git a/pallets/parachain-staking/src/types.rs b/pallets/parachain-staking/src/types.rs index 9b74b089e..b2a60a607 100644 --- a/pallets/parachain-staking/src/types.rs +++ b/pallets/parachain-staking/src/types.rs @@ -84,20 +84,17 @@ impl Ord for Stake } /// The activity status of the collator. -#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] +#[derive( + Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen, Default, +)] pub enum CandidateStatus { /// Committed to be online and producing valid blocks (not equivocating) + #[default] Active, /// Staked until the inner round Leaving(SessionIndex), } -impl Default for CandidateStatus { - fn default() -> CandidateStatus { - CandidateStatus::Active - } -} - #[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(MaxDelegatorsPerCandidate))] #[codec(mel_bound(AccountId: MaxEncodedLen, Balance: MaxEncodedLen))] diff --git a/pallets/treasury-buyout-extension/src/lib.rs b/pallets/treasury-buyout-extension/src/lib.rs index a19e52ede..4c8b91c72 100644 --- a/pallets/treasury-buyout-extension/src/lib.rs +++ b/pallets/treasury-buyout-extension/src/lib.rs @@ -266,7 +266,7 @@ pub mod pallet { // Update `AllowedCurrencies` storage with provided `assets` for asset in assets.clone() { // Check for duplicates - if !AllowedCurrencies::::contains_key(&asset) { + if !AllowedCurrencies::::contains_key(asset) { AllowedCurrencies::::insert(asset, ()); allowed_assets.push(asset); } @@ -291,7 +291,7 @@ impl Pallet { >::block_number().saturated_into::(); let current_period_start_number = current_block_number .checked_div(buyout_period) - .and_then(|n| Some(n.saturating_mul(buyout_period))) + .map(|n| n.saturating_mul(buyout_period)) .unwrap_or_default(); let (mut buyouts, last_buyout) = Buyouts::::get(account_id); @@ -454,12 +454,10 @@ impl Pallet { fn fetch_prices( assets: (&CurrencyIdOf, &CurrencyIdOf), ) -> Result<(FixedU128, FixedU128), DispatchError> { - let basic_asset_price: FixedU128 = T::PriceGetter::get_price::(*assets.0) - .map_err(|_| Error::::NoPrice)? - .into(); - let exchange_asset_price: FixedU128 = T::PriceGetter::get_price::(*assets.1) - .map_err(|_| Error::::NoPrice)? - .into(); + let basic_asset_price: FixedU128 = + T::PriceGetter::get_price::(*assets.0).map_err(|_| Error::::NoPrice)?; + let exchange_asset_price: FixedU128 = + T::PriceGetter::get_price::(*assets.1).map_err(|_| Error::::NoPrice)?; Ok((basic_asset_price, exchange_asset_price)) } @@ -626,32 +624,30 @@ where _info: &DispatchInfoOf, _len: usize, ) -> TransactionValidity { - if let Some(local_call) = call.is_sub_type() { - if let Call::buyout { asset, amount } = local_call { - Pallet::::ensure_asset_allowed_for_buyout(asset).map_err(|_| { - InvalidTransaction::Custom(ValidityError::WrongAssetToBuyout.into()) - })?; - - let (buyout_amount, exchange_amount) = - Pallet::::split_to_buyout_and_exchange(*asset, *amount) - .map_err(|_| InvalidTransaction::Custom(ValidityError::Math.into()))?; - - ensure!( - buyout_amount >= T::MinAmountToBuyout::get(), - InvalidTransaction::Custom(ValidityError::LessThanMinBuyoutAmount.into()) - ); - - let free_balance = T::Currency::free_balance(*asset, who); - - ensure!( - free_balance >= exchange_amount, - InvalidTransaction::Custom(ValidityError::NotEnoughToBuyout.into()) - ); - - Pallet::::ensure_buyout_limit_not_exceeded(who, buyout_amount).map_err( - |_| InvalidTransaction::Custom(ValidityError::BuyoutLimitExceeded.into()), - )?; - } + if let Some(Call::buyout { asset, amount }) = call.is_sub_type() { + Pallet::::ensure_asset_allowed_for_buyout(asset).map_err(|_| { + InvalidTransaction::Custom(ValidityError::WrongAssetToBuyout.into()) + })?; + + let (buyout_amount, exchange_amount) = + Pallet::::split_to_buyout_and_exchange(*asset, *amount) + .map_err(|_| InvalidTransaction::Custom(ValidityError::Math.into()))?; + + ensure!( + buyout_amount >= T::MinAmountToBuyout::get(), + InvalidTransaction::Custom(ValidityError::LessThanMinBuyoutAmount.into()) + ); + + let free_balance = T::Currency::free_balance(*asset, who); + + ensure!( + free_balance >= exchange_amount, + InvalidTransaction::Custom(ValidityError::NotEnoughToBuyout.into()) + ); + + Pallet::::ensure_buyout_limit_not_exceeded(who, buyout_amount).map_err(|_| { + InvalidTransaction::Custom(ValidityError::BuyoutLimitExceeded.into()) + })?; } Ok(ValidTransaction::default()) diff --git a/pallets/treasury-buyout-extension/src/tests.rs b/pallets/treasury-buyout-extension/src/tests.rs index d38119317..83d0ca525 100644 --- a/pallets/treasury-buyout-extension/src/tests.rs +++ b/pallets/treasury-buyout-extension/src/tests.rs @@ -167,7 +167,7 @@ fn root_update_buyout_amount_limit_succeeds() { let buyout_amount_limit = 200 * UNIT; assert_ok!(crate::Pallet::::update_buyout_limit( RuntimeOrigin::root(), - Some(buyout_amount_limit.into()), + Some(buyout_amount_limit), )); assert_eq!(BuyoutLimit::::get(), buyout_amount_limit.into()); @@ -191,7 +191,7 @@ fn user_update_buyout_amount_limit_fails() { assert_noop!( crate::Pallet::::update_buyout_limit( RuntimeOrigin::signed(user), - Some(buyout_amount_limit.into()), + Some(buyout_amount_limit), ), BadOrigin ); @@ -606,7 +606,7 @@ mod signed_extension { // With buyout limit BuyoutLimit::::put(100 * UNIT); // Previous buyout at current_block - Buyouts::::insert(&user, (80 * UNIT, current_block)); + Buyouts::::insert(user, (80 * UNIT, current_block)); let check = CheckBuyout::::new(); let info = info_from_weight(Weight::zero()); diff --git a/pallets/vesting-manager/Cargo.toml b/pallets/vesting-manager/Cargo.toml index 0443644ae..707011fb2 100644 --- a/pallets/vesting-manager/Cargo.toml +++ b/pallets/vesting-manager/Cargo.toml @@ -27,6 +27,7 @@ runtime-benchmarks = [ "frame-benchmarking", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks" ] std = [ "frame-support/std", diff --git a/pallets/vesting-manager/src/lib.rs b/pallets/vesting-manager/src/lib.rs index 30579255b..a732746db 100644 --- a/pallets/vesting-manager/src/lib.rs +++ b/pallets/vesting-manager/src/lib.rs @@ -30,8 +30,10 @@ pub mod pallet { #[pallet::call] impl Pallet { + // TODO to remove this manually assigned weight, we need to add benchmarks to the pallet #[pallet::call_index(0)] - #[pallet::weight(10_000_000)] + #[pallet::weight(Weight::from_parts(10_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)))] pub fn remove_vesting_schedule( origin: OriginFor, who: AccountIdLookupOf, diff --git a/runtime/amplitude/src/chain_ext.rs b/runtime/amplitude/src/chain_ext.rs index eafccdcb9..23aa0f7da 100644 --- a/runtime/amplitude/src/chain_ext.rs +++ b/runtime/amplitude/src/chain_ext.rs @@ -6,9 +6,9 @@ pub use price_chain_extension::PriceChainExtension; pub use token_chain_extension::TokensChainExtension; impl RegisteredChainExtension for TokensChainExtension { - const ID: u16 = 01; + const ID: u16 = 1; } impl RegisteredChainExtension for PriceChainExtension { - const ID: u16 = 02; + const ID: u16 = 2; } diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index d034434e6..acfb3bd13 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -1824,11 +1824,15 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use baseline::Pallet as BaselineBench; + #[allow(non_local_definitions)] impl frame_system_benchmarking::Config for Runtime {} + #[allow(non_local_definitions)] impl baseline::Config for Runtime {} + #[allow(non_local_definitions)] impl runtime_common::benchmarking::orml_asset_registry::Config for Runtime {} use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + #[allow(non_local_definitions)] impl cumulus_pallet_session_benchmarking::Config for Runtime {} let whitelist: Vec = vec![ @@ -2029,6 +2033,7 @@ impl_runtime_apis! { } +#[allow(dead_code)] struct CheckInherents; impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 28350211f..471334ab0 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -69,5 +69,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "orml-asset-registry/runtime-benchmarks", "treasury-buyout-extension/runtime-benchmarks", ] diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 3152f6b35..1ff272816 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -3,12 +3,15 @@ use asset_registry::CustomMetadata; use core::{fmt::Debug, marker::PhantomData}; -use dia_oracle::{CoinInfo, DiaOracle}; +#[cfg(feature = "runtime-benchmarks")] +use dia_oracle::CoinInfo; +use dia_oracle::DiaOracle; use orml_traits::asset_registry::Inspect; use sp_runtime::{ traits::{Convert, IdentifyAccount, One, Verify, Zero}, DispatchError, FixedPointNumber, FixedU128, MultiSignature, }; +#[cfg(feature = "runtime-benchmarks")] use sp_std::vec; use spacewalk_primitives::CurrencyId; use treasury_buyout_extension::PriceGetter; diff --git a/runtime/foucoco/src/chain_ext.rs b/runtime/foucoco/src/chain_ext.rs index eafccdcb9..23aa0f7da 100644 --- a/runtime/foucoco/src/chain_ext.rs +++ b/runtime/foucoco/src/chain_ext.rs @@ -6,9 +6,9 @@ pub use price_chain_extension::PriceChainExtension; pub use token_chain_extension::TokensChainExtension; impl RegisteredChainExtension for TokensChainExtension { - const ID: u16 = 01; + const ID: u16 = 1; } impl RegisteredChainExtension for PriceChainExtension { - const ID: u16 = 02; + const ID: u16 = 2; } diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 898c74687..039a0c3fc 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -1806,11 +1806,15 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use baseline::Pallet as BaselineBench; + #[allow(non_local_definitions)] impl frame_system_benchmarking::Config for Runtime {} + #[allow(non_local_definitions)] impl baseline::Config for Runtime {} + #[allow(non_local_definitions)] impl runtime_common::benchmarking::orml_asset_registry::Config for Runtime {} use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + #[allow(non_local_definitions)] impl cumulus_pallet_session_benchmarking::Config for Runtime {} let whitelist: Vec = vec![ @@ -2027,6 +2031,7 @@ impl_runtime_apis! { } +#[allow(dead_code)] struct CheckInherents; impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { diff --git a/runtime/foucoco/src/weights/redeem.rs b/runtime/foucoco/src/weights/redeem.rs index 973a689c8..da4c4b23e 100644 --- a/runtime/foucoco/src/weights/redeem.rs +++ b/runtime/foucoco/src/weights/redeem.rs @@ -30,6 +30,7 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] +#![allow(dead_code)] #![allow(unused_imports)] #![allow(missing_docs)] diff --git a/runtime/integration-tests/src/pendulum_tests.rs b/runtime/integration-tests/src/pendulum_tests.rs index 7a9226838..d193c05ba 100644 --- a/runtime/integration-tests/src/pendulum_tests.rs +++ b/runtime/integration-tests/src/pendulum_tests.rs @@ -13,6 +13,7 @@ use crate::{ }; use frame_support::assert_ok; +#[allow(unused_imports)] use pendulum_runtime::definitions::moonbeam::PARA_ID as MOONBEAM_PARA_ID; use statemint_runtime as polkadot_asset_hub_runtime; use xcm::latest::NetworkId; diff --git a/runtime/integration-tests/src/sibling.rs b/runtime/integration-tests/src/sibling.rs index d6063ab8e..9809a89e0 100644 --- a/runtime/integration-tests/src/sibling.rs +++ b/runtime/integration-tests/src/sibling.rs @@ -258,6 +258,8 @@ match_types! { //TODO: move DenyThenTry to polkadot's xcm module. /// Deny executing the xcm message if it matches any of the Deny filter regardless of anything else. /// If it passes the Deny, and matches one of the Allow cases then it is let through. + +#[allow(dead_code)] pub struct DenyThenTry(PhantomData, PhantomData) where Deny: ShouldExecute, @@ -280,6 +282,7 @@ where } // See issue #5233 +#[allow(dead_code)] pub struct DenyReserveTransferToRelayChain; impl ShouldExecute for DenyReserveTransferToRelayChain { fn should_execute( diff --git a/runtime/pendulum/src/chain_ext.rs b/runtime/pendulum/src/chain_ext.rs index eafccdcb9..23aa0f7da 100644 --- a/runtime/pendulum/src/chain_ext.rs +++ b/runtime/pendulum/src/chain_ext.rs @@ -6,9 +6,9 @@ pub use price_chain_extension::PriceChainExtension; pub use token_chain_extension::TokensChainExtension; impl RegisteredChainExtension for TokensChainExtension { - const ID: u16 = 01; + const ID: u16 = 1; } impl RegisteredChainExtension for PriceChainExtension { - const ID: u16 = 02; + const ID: u16 = 2; } diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index ea33c3730..79d0690a8 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -1809,11 +1809,15 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use baseline::Pallet as BaselineBench; + #[allow(non_local_definitions)] impl frame_system_benchmarking::Config for Runtime {} + #[allow(non_local_definitions)] impl baseline::Config for Runtime {} + #[allow(non_local_definitions)] impl runtime_common::benchmarking::orml_asset_registry::Config for Runtime {} use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + #[allow(non_local_definitions)] impl cumulus_pallet_session_benchmarking::Config for Runtime {} @@ -2015,6 +2019,7 @@ impl_runtime_apis! { } +#[allow(dead_code)] struct CheckInherents; impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents {