Skip to content

Commit

Permalink
Update to RUST-1.81.0 (#2814)
Browse files Browse the repository at this point in the history
* Update to RUST-1.81.0

* update orml

* update TARPAULIN_VERSION

* update
  • Loading branch information
zjb0807 authored Oct 8, 2024
1 parent d89054f commit 65f2e01
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions modules/aggregated-dex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,8 @@ impl<T: Config> Pallet<T> {
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;
}
Expand Down
4 changes: 1 addition & 3 deletions modules/dex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,10 @@ impl<T: Config> Pallet<T> {
LiquidityPool::<T>::try_mutate(trading_pair, |(pool_0, pool_1)| -> sp_std::result::Result<R, E> {
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
})
})
}
Expand Down
9 changes: 3 additions & 6 deletions modules/evm/src/runner/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion modules/evm/src/runner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
3 changes: 1 addition & 2 deletions modules/homa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<T>::mutate(|staking_balance| {
*staking_balance = staking_balance.saturating_sub(old_bonded_amount)
Expand All @@ -728,7 +728,6 @@ pub mod module {
});
Some(ledger)
};
result
})
})
}
Expand Down
4 changes: 2 additions & 2 deletions modules/incentives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
5 changes: 4 additions & 1 deletion modules/loans/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
3 changes: 0 additions & 3 deletions modules/loans/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ impl orml_oracle::Config<AcalaDataProvider> for Runtime {
type RootOperatorAccountId = RootOperatorAccountId;
type Members = OperatorMembershipAcala;
type MaxHasDispatchedSize = ConstU32<20>;
type WeightInfo = ();
type WeightInfo = weights::orml_oracle::WeightInfo<Runtime>;
type MaxFeedValues = MaxFeedValues;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = BenchmarkHelper;
Expand Down Expand Up @@ -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();
Expand All @@ -817,20 +817,20 @@ parameter_type_with_key! {
} else if let CurrencyId::Erc20(address) = currency_id_0 {
// LP token with erc20
AssetIdMaps::<Runtime>::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(&currency_id_0)
}
},
CurrencyId::Erc20(address) => AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance),
CurrencyId::Erc20(address) => AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance),
CurrencyId::StableAssetPoolToken(stable_asset_id) => {
AssetIdMaps::<Runtime>::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::<Runtime>::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)
},
}
};
Expand Down
4 changes: 2 additions & 2 deletions runtime/common/src/xcm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FixedRate: Get<u128>, R: TakeRevenue, M: BuyWeightRate> {
Expand Down
12 changes: 6 additions & 6 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ impl orml_oracle::Config<AcalaDataProvider> for Runtime {
type RootOperatorAccountId = RootOperatorAccountId;
type Members = OperatorMembershipAcala;
type MaxHasDispatchedSize = ConstU32<20>;
type WeightInfo = ();
type WeightInfo = weights::orml_oracle::WeightInfo<Runtime>;
type MaxFeedValues = MaxFeedValues;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = BenchmarkHelper;
Expand Down Expand Up @@ -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();
Expand All @@ -826,20 +826,20 @@ parameter_type_with_key! {
} else if let CurrencyId::Erc20(address) = currency_id_0 {
// LP token with erc20
AssetIdMaps::<Runtime>::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(&currency_id_0)
}
},
CurrencyId::Erc20(address) => AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance),
CurrencyId::Erc20(address) => AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance),
CurrencyId::StableAssetPoolToken(stable_asset_id) => {
AssetIdMaps::<Runtime>::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::<Runtime>::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)
},
}
};
Expand Down
11 changes: 5 additions & 6 deletions runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -873,20 +873,20 @@ parameter_type_with_key! {
} else if let CurrencyId::Erc20(address) = currency_id_0 {
// LP token with erc20
AssetIdMaps::<Runtime>::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(&currency_id_0)
}
},
CurrencyId::Erc20(address) => AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::max_value(), |metatata| metatata.minimal_balance),
CurrencyId::Erc20(address) => AssetIdMaps::<Runtime>::get_asset_metadata(AssetIds::Erc20(*address)).map_or(Balance::MAX, |metatata| metatata.minimal_balance),
CurrencyId::StableAssetPoolToken(stable_asset_id) => {
AssetIdMaps::<Runtime>::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::<Runtime>::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)
},
}
};
Expand Down Expand Up @@ -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::<Runtime, Executive>,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.77.0"
channel = "1.81.0"
components = ["rust-src", "rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]

0 comments on commit 65f2e01

Please sign in to comment.