From 65f2e01f22a961fe3a3eb907f4d425723c37cf8a Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Tue, 8 Oct 2024 13:16:11 +0800 Subject: [PATCH] Update to RUST-1.81.0 (#2814) * Update to RUST-1.81.0 * update orml * update TARPAULIN_VERSION * update --- .github/workflows/coverage.yml | 2 +- modules/aggregated-dex/src/lib.rs | 6 ++---- modules/dex/src/lib.rs | 4 +--- modules/evm/src/runner/stack.rs | 9 +++------ modules/evm/src/runner/state.rs | 2 +- modules/homa/src/lib.rs | 3 +-- modules/incentives/src/lib.rs | 4 ++-- modules/loans/src/mock.rs | 5 ++++- modules/loans/src/tests.rs | 3 --- orml | 2 +- runtime/acala/src/lib.rs | 12 ++++++------ runtime/common/src/xcm_impl.rs | 4 ++-- runtime/karura/src/lib.rs | 12 ++++++------ runtime/mandala/src/lib.rs | 11 +++++------ rust-toolchain.toml | 2 +- 15 files changed, 36 insertions(+), 45 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 893387c3d5..b47be97355 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -18,7 +18,7 @@ concurrency: cancel-in-progress: true env: - TARPAULIN_VERSION: 0.27.3 + TARPAULIN_VERSION: 0.31.2 CARGO_INCREMENTAL: 0 jobs: test: diff --git a/modules/aggregated-dex/src/lib.rs b/modules/aggregated-dex/src/lib.rs index 482a1a3a7d..f107d97d17 100644 --- a/modules/aggregated-dex/src/lib.rs +++ b/modules/aggregated-dex/src/lib.rs @@ -282,10 +282,8 @@ impl Pallet { match path { SwapPath::Dex(dex_path) => { // calculate the supply amount - let (supply_amount, _) = T::DEX::get_swap_amount( - dex_path, - SwapLimit::ExactTarget(Balance::max_value(), input_amount), - )?; + let (supply_amount, _) = + T::DEX::get_swap_amount(dex_path, SwapLimit::ExactTarget(Balance::MAX, input_amount))?; input_amount = supply_amount; } diff --git a/modules/dex/src/lib.rs b/modules/dex/src/lib.rs index 90888a1406..728dd33aac 100644 --- a/modules/dex/src/lib.rs +++ b/modules/dex/src/lib.rs @@ -818,12 +818,10 @@ impl Pallet { LiquidityPool::::try_mutate(trading_pair, |(pool_0, pool_1)| -> sp_std::result::Result { let old_pool_0 = *pool_0; let old_pool_1 = *pool_1; - f((pool_0, pool_1)).map(move |result| { + f((pool_0, pool_1)).inspect(move |_result| { if *pool_0 != old_pool_0 || *pool_1 != old_pool_1 { T::OnLiquidityPoolUpdated::happened(&(*trading_pair, *pool_0, *pool_1)); } - - result }) }) } diff --git a/modules/evm/src/runner/stack.rs b/modules/evm/src/runner/stack.rs index a31cc7ed37..e773f1eeaf 100644 --- a/modules/evm/src/runner/stack.rs +++ b/modules/evm/src/runner/stack.rs @@ -469,9 +469,8 @@ impl<'config> SubstrateStackSubstate<'config> { let target = self.metadata().target().expect("Storage target is none"); let storage = exited.metadata().storage_meter().used_storage(); - self.metadata.swallow_commit(exited.metadata).map_err(|e| { + self.metadata.swallow_commit(exited.metadata).inspect_err(|_e| { sp_io::storage::rollback_transaction(); - e })?; self.logs.append(&mut exited.logs); self.deletes.append(&mut exited.deletes); @@ -486,9 +485,8 @@ impl<'config> SubstrateStackSubstate<'config> { pub fn exit_revert(&mut self) -> Result<(), ExitError> { let mut exited = *self.parent.take().expect("Cannot discard on root substate"); mem::swap(&mut exited, self); - self.metadata.swallow_revert(exited.metadata).map_err(|e| { + self.metadata.swallow_revert(exited.metadata).inspect_err(|_e| { sp_io::storage::rollback_transaction(); - e })?; sp_io::storage::rollback_transaction(); @@ -498,9 +496,8 @@ impl<'config> SubstrateStackSubstate<'config> { pub fn exit_discard(&mut self) -> Result<(), ExitError> { let mut exited = *self.parent.take().expect("Cannot discard on root substate"); mem::swap(&mut exited, self); - self.metadata.swallow_discard(exited.metadata).map_err(|e| { + self.metadata.swallow_discard(exited.metadata).inspect_err(|_e| { sp_io::storage::rollback_transaction(); - e })?; sp_io::storage::rollback_transaction(); diff --git a/modules/evm/src/runner/state.rs b/modules/evm/src/runner/state.rs index 14c821fe19..45fdd8437a 100644 --- a/modules/evm/src/runner/state.rs +++ b/modules/evm/src/runner/state.rs @@ -811,7 +811,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet> StackExecu let mut stream = rlp::RlpStream::new_list(2); stream.append(&caller); stream.append(&nonce); - H256::from_slice(Keccak256::digest(&stream.out()).as_slice()).into() + H256::from_slice(Keccak256::digest(stream.out()).as_slice()).into() } CreateScheme::Fixed(naddress) => naddress, }; diff --git a/modules/homa/src/lib.rs b/modules/homa/src/lib.rs index 42694fc29b..4f150b1878 100644 --- a/modules/homa/src/lib.rs +++ b/modules/homa/src/lib.rs @@ -714,7 +714,7 @@ pub mod module { let mut ledger = maybe_ledger.take().unwrap_or_default(); let old_bonded_amount = ledger.bonded; - f(&mut ledger).map(move |result| { + f(&mut ledger).inspect(move |_result| { *maybe_ledger = if ledger == Default::default() { TotalStakingBonded::::mutate(|staking_balance| { *staking_balance = staking_balance.saturating_sub(old_bonded_amount) @@ -728,7 +728,6 @@ pub mod module { }); Some(ledger) }; - result }) }) } diff --git a/modules/incentives/src/lib.rs b/modules/incentives/src/lib.rs index b7a90da498..7114b2d5aa 100644 --- a/modules/incentives/src/lib.rs +++ b/modules/incentives/src/lib.rs @@ -32,8 +32,8 @@ //! //! Rewards accumulation: //! 1. Incentives: periodicly(AccumulatePeriod), accumulate fixed amount according to Incentive. -//! Rewards come from RewardsSource, please transfer enough tokens to RewardsSource before -//! start incentive plan. +//! Rewards come from RewardsSource, please transfer enough tokens to RewardsSource before start +//! incentive plan. #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] diff --git a/modules/loans/src/mock.rs b/modules/loans/src/mock.rs index a6dd7a8e3f..1f47b50294 100644 --- a/modules/loans/src/mock.rs +++ b/modules/loans/src/mock.rs @@ -277,6 +277,9 @@ impl ExtBuilder { } .assimilate_storage(&mut t) .unwrap(); - t.into() + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| System::set_block_number(1)); + ext } } diff --git a/modules/loans/src/tests.rs b/modules/loans/src/tests.rs index 7599dcbf3d..ec0baa72e0 100644 --- a/modules/loans/src/tests.rs +++ b/modules/loans/src/tests.rs @@ -57,7 +57,6 @@ fn check_update_loan_underflow_work() { #[test] fn adjust_position_should_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_eq!(Currencies::free_balance(BTC, &ALICE), 1000); // balance too low @@ -166,7 +165,6 @@ fn update_loan_should_work() { #[test] fn transfer_loan_should_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_ok!(LoansModule::update_loan(&ALICE, BTC, 400, 500)); assert_ok!(LoansModule::update_loan(&BOB, BTC, 100, 600)); assert_eq!(LoansModule::positions(BTC, &ALICE).debit, 500); @@ -190,7 +188,6 @@ fn transfer_loan_should_work() { #[test] fn confiscate_collateral_and_debit_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_ok!(LoansModule::update_loan(&BOB, BTC, 5000, 1000)); assert_eq!(Currencies::free_balance(BTC, &LoansModule::account_id()), 0); diff --git a/orml b/orml index 144a9625bc..7d608999cb 160000 --- a/orml +++ b/orml @@ -1 +1 @@ -Subproject commit 144a9625bc0cbd1afb81088f4d8a79a931811b49 +Subproject commit 7d608999cbcf79dbb1eb40de4b04a7366e2a8352 diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 822db4ef5a..11b2ae9f39 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -766,7 +766,7 @@ impl orml_oracle::Config for Runtime { type RootOperatorAccountId = RootOperatorAccountId; type Members = OperatorMembershipAcala; type MaxHasDispatchedSize = ConstU32<20>; - type WeightInfo = (); + type WeightInfo = weights::orml_oracle::WeightInfo; type MaxFeedValues = MaxFeedValues; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = BenchmarkHelper; @@ -805,7 +805,7 @@ parameter_type_with_key! { TokenSymbol::ACA | TokenSymbol::KBTC | TokenSymbol::KINT | - TokenSymbol::TAI => Balance::max_value() // unsupported + TokenSymbol::TAI => Balance::MAX // unsupported }, CurrencyId::DexShare(dex_share_0, _) => { let currency_id_0: CurrencyId = (*dex_share_0).into(); @@ -817,20 +817,20 @@ parameter_type_with_key! { } else if let CurrencyId::Erc20(address) = currency_id_0 { // LP token with erc20 AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(address)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) } else { Self::get(¤cy_id_0) } }, - CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance), + CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance), CurrencyId::StableAssetPoolToken(stable_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::StableAssetId(*stable_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, CurrencyId::LiquidCrowdloan(_) => ExistentialDeposits::get(&CurrencyId::Token(TokenSymbol::DOT)), // the same as DOT CurrencyId::ForeignAsset(foreign_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::ForeignAssetId(*foreign_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, } }; diff --git a/runtime/common/src/xcm_impl.rs b/runtime/common/src/xcm_impl.rs index cfde56f8bf..502e261356 100644 --- a/runtime/common/src/xcm_impl.rs +++ b/runtime/common/src/xcm_impl.rs @@ -117,8 +117,8 @@ where /// Simple fee calculator that requires payment in a single fungible at a fixed rate. /// -/// - The `FixedRate` constant should be the concrete fungible ID and the amount of it -/// required for one second of weight. +/// - The `FixedRate` constant should be the concrete fungible ID and the amount of it required for +/// one second of weight. /// - The `TakeRevenue` trait is used to collecting xcm execution fee. /// - The `BuyWeightRate` trait is used to calculate ratio by location. pub struct FixedRateOfAsset, R: TakeRevenue, M: BuyWeightRate> { diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index af2b110964..88304685c8 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -775,7 +775,7 @@ impl orml_oracle::Config for Runtime { type RootOperatorAccountId = RootOperatorAccountId; type Members = OperatorMembershipAcala; type MaxHasDispatchedSize = ConstU32<20>; - type WeightInfo = (); + type WeightInfo = weights::orml_oracle::WeightInfo; type MaxFeedValues = MaxFeedValues; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = BenchmarkHelper; @@ -814,7 +814,7 @@ parameter_type_with_key! { TokenSymbol::DOT | TokenSymbol::LDOT | TokenSymbol::KAR | - TokenSymbol::TAP => Balance::max_value() // unsupported + TokenSymbol::TAP => Balance::MAX // unsupported }, CurrencyId::DexShare(dex_share_0, _) => { let currency_id_0: CurrencyId = (*dex_share_0).into(); @@ -826,20 +826,20 @@ parameter_type_with_key! { } else if let CurrencyId::Erc20(address) = currency_id_0 { // LP token with erc20 AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(address)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) } else { Self::get(¤cy_id_0) } }, - CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance), + CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance), CurrencyId::StableAssetPoolToken(stable_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::StableAssetId(*stable_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, CurrencyId::LiquidCrowdloan(_) => ExistentialDeposits::get(&CurrencyId::Token(TokenSymbol::KSM)), // the same as KSM CurrencyId::ForeignAsset(foreign_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::ForeignAssetId(*foreign_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, } }; diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index 95fc2e9213..f8ae36b0cc 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -861,7 +861,7 @@ parameter_type_with_key! { TokenSymbol::TAI => 10 * millicent(*currency_id), TokenSymbol::TAP => 10 * millicent(*currency_id), TokenSymbol::ACA | - TokenSymbol::KAR => Balance::max_value() // unsupported + TokenSymbol::KAR => Balance::MAX // unsupported }, CurrencyId::DexShare(dex_share_0, _) => { let currency_id_0: CurrencyId = (*dex_share_0).into(); @@ -873,20 +873,20 @@ parameter_type_with_key! { } else if let CurrencyId::Erc20(address) = currency_id_0 { // LP token with erc20 AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(address)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) } else { Self::get(¤cy_id_0) } }, - CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance), + CurrencyId::Erc20(address) => AssetIdMaps::::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance), CurrencyId::StableAssetPoolToken(stable_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::StableAssetId(*stable_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, CurrencyId::LiquidCrowdloan(_) => ExistentialDeposits::get(&CurrencyId::Token(TokenSymbol::DOT)), // the same as DOT CurrencyId::ForeignAsset(foreign_asset_id) => { AssetIdMaps::::get_asset_metadata(AssetIds::ForeignAssetId(*foreign_asset_id)). - map_or(Balance::max_value(), |metatata| metatata.minimal_balance) + map_or(Balance::MAX, |metatata| metatata.minimal_balance) }, } }; @@ -2682,7 +2682,6 @@ impl_runtime_apis! { } } -#[cfg(not(feature = "standalone"))] cumulus_pallet_parachain_system::register_validate_block!( Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b365e13a84..6d985f163a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.77.0" +channel = "1.81.0" components = ["rust-src", "rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"]