From e4783a60d392b86fb6380db25fd21eeaf893db08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 7 Oct 2020 14:07:42 +0200 Subject: [PATCH] Backport paritytech/substrate#7381 --- Cargo.lock | 48 +++++++++---------- client/cli/Cargo.toml | 2 +- client/cli/src/commands/export_blocks_cmd.rs | 2 +- client/finality-grandpa/Cargo.toml | 2 +- client/finality-grandpa/src/voting_rule.rs | 2 +- client/informant/Cargo.toml | 2 +- client/informant/src/display.rs | 2 +- client/network/Cargo.toml | 2 +- client/network/src/light_client_handler.rs | 2 +- client/service/Cargo.toml | 2 +- client/service/src/chain_ops/export_blocks.rs | 2 +- client/service/src/chain_ops/import_blocks.rs | 4 +- client/service/src/client/client.rs | 4 +- client/service/src/metrics.rs | 4 +- client/transaction-pool/Cargo.toml | 2 +- client/transaction-pool/src/lib.rs | 2 +- frame/aura/Cargo.toml | 2 +- frame/aura/src/lib.rs | 4 +- frame/babe/Cargo.toml | 2 +- frame/babe/src/lib.rs | 2 +- frame/benchmarking/Cargo.toml | 2 +- frame/benchmarking/src/lib.rs | 4 +- frame/example-offchain-worker/Cargo.toml | 2 +- frame/example-offchain-worker/src/lib.rs | 8 ++-- frame/executive/Cargo.toml | 2 +- frame/executive/src/lib.rs | 2 +- frame/grandpa/Cargo.toml | 2 +- frame/grandpa/src/benchmarking.rs | 4 +- frame/grandpa/src/lib.rs | 2 +- frame/im-online/Cargo.toml | 2 +- frame/im-online/src/lib.rs | 6 +-- frame/offences/Cargo.toml | 2 +- frame/offences/benchmarking/src/lib.rs | 9 ++-- frame/randomness-collective-flip/Cargo.toml | 2 +- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/staking/Cargo.toml | 2 +- frame/staking/src/benchmarking.rs | 22 ++++----- frame/system/Cargo.toml | 2 +- frame/system/benchmarking/Cargo.toml | 2 +- frame/system/benchmarking/src/lib.rs | 6 +-- frame/system/src/offchain.rs | 2 +- frame/timestamp/Cargo.toml | 2 +- frame/timestamp/src/lib.rs | 2 +- frame/treasury/Cargo.toml | 2 +- frame/treasury/src/lib.rs | 7 ++- primitives/arithmetic/Cargo.toml | 2 +- primitives/arithmetic/src/fixed_point.rs | 6 +-- primitives/externalities/Cargo.toml | 2 +- primitives/npos-elections/Cargo.toml | 2 +- primitives/npos-elections/src/mock.rs | 4 +- test-utils/client/Cargo.toml | 2 +- test-utils/client/src/client_ext.rs | 2 +- 52 files changed, 110 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a661ed15d242..aa9e143be58a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1512,7 +1512,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-support", "frame-system", @@ -1547,7 +1547,7 @@ dependencies = [ [[package]] name = "frame-executive" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-support", "frame-system", @@ -1653,7 +1653,7 @@ dependencies = [ [[package]] name = "frame-system" -version = "2.0.0" +version = "2.0.1" dependencies = [ "criterion", "frame-support", @@ -1671,7 +1671,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -4220,7 +4220,7 @@ dependencies = [ [[package]] name = "pallet-aura" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-support", "frame-system", @@ -4276,7 +4276,7 @@ dependencies = [ [[package]] name = "pallet-babe" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -4498,7 +4498,7 @@ dependencies = [ [[package]] name = "pallet-example-offchain-worker" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-support", "frame-system", @@ -4530,7 +4530,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" -version = "2.0.0" +version = "2.0.1" dependencies = [ "finality-grandpa", "frame-benchmarking", @@ -4576,7 +4576,7 @@ dependencies = [ [[package]] name = "pallet-im-online" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -4671,7 +4671,7 @@ dependencies = [ [[package]] name = "pallet-offences" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-support", "frame-system", @@ -4729,7 +4729,7 @@ dependencies = [ [[package]] name = "pallet-randomness-collective-flip" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-support", "frame-system", @@ -4849,7 +4849,7 @@ dependencies = [ [[package]] name = "pallet-staking" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -4937,7 +4937,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -5003,7 +5003,7 @@ dependencies = [ [[package]] name = "pallet-treasury" -version = "2.0.0" +version = "2.0.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -6310,7 +6310,7 @@ dependencies = [ [[package]] name = "sc-cli" -version = "0.8.0" +version = "0.8.1" dependencies = [ "ansi_term 0.12.1", "atty", @@ -6755,7 +6755,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" -version = "0.8.0" +version = "0.8.1" dependencies = [ "assert_matches", "derive_more", @@ -6830,7 +6830,7 @@ dependencies = [ [[package]] name = "sc-informant" -version = "0.8.0" +version = "0.8.1" dependencies = [ "ansi_term 0.12.1", "futures 0.3.5", @@ -6881,7 +6881,7 @@ dependencies = [ [[package]] name = "sc-network" -version = "0.8.0" +version = "0.8.1" dependencies = [ "assert_matches", "async-std", @@ -7132,7 +7132,7 @@ dependencies = [ [[package]] name = "sc-service" -version = "0.8.0" +version = "0.8.1" dependencies = [ "async-std", "derive_more", @@ -7310,7 +7310,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" -version = "2.0.0" +version = "2.0.1" dependencies = [ "assert_matches", "derive_more", @@ -7834,7 +7834,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" -version = "2.0.0" +version = "2.0.1" dependencies = [ "criterion", "integer-sqrt", @@ -8070,7 +8070,7 @@ dependencies = [ [[package]] name = "sp-externalities" -version = "0.8.0" +version = "0.8.1" dependencies = [ "environmental", "parity-scale-codec", @@ -8147,7 +8147,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" -version = "2.0.0" +version = "2.0.1" dependencies = [ "parity-scale-codec", "rand 0.7.3", @@ -8714,7 +8714,7 @@ dependencies = [ [[package]] name = "substrate-test-client" -version = "2.0.0" +version = "2.0.1" dependencies = [ "futures 0.1.29", "futures 0.3.5", diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index dca91d18c3efc..8af52b5f5889a 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-cli" -version = "0.8.0" +version = "0.8.1" authors = ["Parity Technologies "] description = "Substrate CLI interface." edition = "2018" diff --git a/client/cli/src/commands/export_blocks_cmd.rs b/client/cli/src/commands/export_blocks_cmd.rs index e175d498941b8..497531ad393ba 100644 --- a/client/cli/src/commands/export_blocks_cmd.rs +++ b/client/cli/src/commands/export_blocks_cmd.rs @@ -85,7 +85,7 @@ impl ExportBlocksCmd { info!("DB path: {}", path.display()); } - let from = self.from.as_ref().and_then(|f| f.parse().ok()).unwrap_or(1); + let from = self.from.as_ref().and_then(|f| f.parse().ok()).unwrap_or(1u32); let to = self.to.as_ref().and_then(|t| t.parse().ok()); let binary = self.binary; diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index fcefa2a04162e..8d7e261c5e29a 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-finality-grandpa" -version = "0.8.0" +version = "0.8.1" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/client/finality-grandpa/src/voting_rule.rs b/client/finality-grandpa/src/voting_rule.rs index 60493867ce1f4..700b0aeb551cd 100644 --- a/client/finality-grandpa/src/voting_rule.rs +++ b/client/finality-grandpa/src/voting_rule.rs @@ -241,7 +241,7 @@ impl Default for VotingRulesBuilder where { fn default() -> Self { VotingRulesBuilder::new() - .add(BeforeBestBlockBy(2.into())) + .add(BeforeBestBlockBy(2u32.into())) .add(ThreeQuartersOfTheUnfinalizedChain) } } diff --git a/client/informant/Cargo.toml b/client/informant/Cargo.toml index 871cc3ef426ec..78b2ec75ca2ef 100644 --- a/client/informant/Cargo.toml +++ b/client/informant/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-informant" -version = "0.8.0" +version = "0.8.1" authors = ["Parity Technologies "] description = "Substrate informant." edition = "2018" diff --git a/client/informant/src/display.rs b/client/informant/src/display.rs index ce7fb4fc4b12b..8bc3a4548c4a0 100644 --- a/client/informant/src/display.rs +++ b/client/informant/src/display.rs @@ -168,7 +168,7 @@ fn speed( } else { // If the number of blocks can't be converted to a regular integer, then we need a more // algebraic approach and we stay within the realm of integers. - let one_thousand = NumberFor::::from(1_000); + let one_thousand = NumberFor::::from(1_000u32); let elapsed = NumberFor::::from( >::try_from(elapsed_ms).unwrap_or(u32::max_value()) ); diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 76d8f0a23eda2..eb7780a658d75 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Substrate network protocol" name = "sc-network" -version = "0.8.0" +version = "0.8.1" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/client/network/src/light_client_handler.rs b/client/network/src/light_client_handler.rs index c1ff14fc82a22..d1c407c99695b 100644 --- a/client/network/src/light_client_handler.rs +++ b/client/network/src/light_client_handler.rs @@ -1429,7 +1429,7 @@ mod tests { _: ChangesProof ) -> Result, u32)>, ClientError> { match self.ok { - true => Ok(vec![(100.into(), 2)]), + true => Ok(vec![(100u32.into(), 2)]), false => Err(ClientError::Backend("Test error".into())), } } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index f57a145422c8c..a360ebc8f8c0a 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-service" -version = "0.8.0" +version = "0.8.1" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/client/service/src/chain_ops/export_blocks.rs b/client/service/src/chain_ops/export_blocks.rs index 2f32cbf7fbdb7..3d2dbcbb9d00f 100644 --- a/client/service/src/chain_ops/export_blocks.rs +++ b/client/service/src/chain_ops/export_blocks.rs @@ -87,7 +87,7 @@ where // Reached end of the chain. None => return Poll::Ready(Ok(())), } - if (block % 10000.into()).is_zero() { + if (block % 10000u32.into()).is_zero() { info!("#{}", block); } if block == last { diff --git a/client/service/src/chain_ops/import_blocks.rs b/client/service/src/chain_ops/import_blocks.rs index 46ad0d0501d93..74a33c6557c9a 100644 --- a/client/service/src/chain_ops/import_blocks.rs +++ b/client/service/src/chain_ops/import_blocks.rs @@ -200,7 +200,7 @@ impl Speedometer { /// Creates a fresh Speedometer. fn new() -> Self { Self { - best_number: NumberFor::::from(0), + best_number: NumberFor::::from(0u32), last_number: None, last_update: Instant::now(), } @@ -232,7 +232,7 @@ impl Speedometer { } else { // If the number of blocks can't be converted to a regular integer, then we need a more // algebraic approach and we stay within the realm of integers. - let one_thousand = NumberFor::::from(1_000); + let one_thousand = NumberFor::::from(1_000u32); let elapsed = NumberFor::::from( >::try_from(elapsed_ms).unwrap_or(u32::max_value()) ); diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index fd76084988dbc..93a6a9320922b 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -38,7 +38,7 @@ use sp_runtime::{ generic::{BlockId, SignedBlock, DigestItem}, traits::{ Block as BlockT, Header as HeaderT, Zero, NumberFor, - HashFor, SaturatedConversion, One, DigestFor, + HashFor, SaturatedConversion, One, DigestFor, UniqueSaturatedInto, }, }; use sp_state_machine::{ @@ -1139,7 +1139,7 @@ impl Client where let mut ancestor = load_header(ancestor_hash)?; let mut uncles = Vec::new(); - for _generation in 0..max_generation.saturated_into() { + for _generation in 0u32..UniqueSaturatedInto::::unique_saturated_into(max_generation) { let children = self.backend.blockchain().children(ancestor_hash)?; uncles.extend(children.into_iter().filter(|h| h != ¤t_hash)); current_hash = ancestor_hash; diff --git a/client/service/src/metrics.rs b/client/service/src/metrics.rs index 0af393b53f517..d3ad780b5be62 100644 --- a/client/service/src/metrics.rs +++ b/client/service/src/metrics.rs @@ -316,9 +316,9 @@ impl MetricsService { ); if let Some(metrics) = self.metrics.as_ref() { - let best_seen_block = net_status + let best_seen_block: Option = net_status .best_seen_block - .map(|num: NumberFor| num.unique_saturated_into() as u64); + .map(|num: NumberFor| UniqueSaturatedInto::::unique_saturated_into(num)); if let Some(best_seen_block) = best_seen_block { metrics.block_height.with_label_values(&["sync_target"]).set(best_seen_block); diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 5db37f5368387..28dad85f6d58a 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-transaction-pool" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 0b6a1e935b9d0..e03c01bd1d816 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -569,7 +569,7 @@ impl MaintainedTransactionPool for BasicPool let next_action = self.revalidation_strategy.lock().next( block_number, Some(std::time::Duration::from_secs(60)), - Some(20.into()), + Some(20u32.into()), ); let revalidation_strategy = self.revalidation_strategy.clone(); let revalidation_queue = self.revalidation_queue.clone(); diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 27a579e0f9f8b..88132cfffe4a8 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-aura" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index ca3d1f15f421b..e8e0e616bc0dc 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -74,7 +74,7 @@ pub trait Trait: pallet_timestamp::Trait { decl_storage! { trait Store for Module as Aura { /// The last timestamp. - LastTimestamp get(fn last) build(|_| 0.into()): T::Moment; + LastTimestamp get(fn last): T::Moment; /// The current authorities pub Authorities get(fn authorities): Vec; @@ -196,7 +196,7 @@ impl Module { pub fn slot_duration() -> T::Moment { // we double the minimum block-period so each author can always propose within // the majority of its slot. - ::MinimumPeriod::get().saturating_mul(2.into()) + ::MinimumPeriod::get().saturating_mul(2u32.into()) } fn on_timestamp_set(now: T::Moment, slot_duration: T::Moment) { diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index a210a2a8ef06a..e1b4590d5bf72 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-babe" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 3f13fe7e03002..51fc77b0e8d25 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -371,7 +371,7 @@ impl Module { pub fn slot_duration() -> T::Moment { // we double the minimum block-period so each author can always propose within // the majority of their slot. - ::MinimumPeriod::get().saturating_mul(2.into()) + ::MinimumPeriod::get().saturating_mul(2u32.into()) } /// Determine whether an epoch change should take place at this block. diff --git a/frame/benchmarking/Cargo.toml b/frame/benchmarking/Cargo.toml index 924ffc8627abc..87e16c5d772a4 100644 --- a/frame/benchmarking/Cargo.toml +++ b/frame/benchmarking/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-benchmarking" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index b189cdb6e705e..284b0545d03a5 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -820,7 +820,7 @@ macro_rules! impl_benchmark { // Set the block number to at least 1 so events are deposited. if $crate::Zero::is_zero(&frame_system::Module::::block_number()) { - frame_system::Module::::set_block_number(1.into()); + frame_system::Module::::set_block_number(1u32.into()); } // Commit the externalities to the database, flushing the DB cache. @@ -966,7 +966,7 @@ macro_rules! impl_benchmark_test { // Set the block number to at least 1 so events are deposited. if $crate::Zero::is_zero(&frame_system::Module::::block_number()) { - frame_system::Module::::set_block_number(1.into()); + frame_system::Module::::set_block_number(1u32.into()); } // Run execution + verification diff --git a/frame/example-offchain-worker/Cargo.toml b/frame/example-offchain-worker/Cargo.toml index 8478ddec29053..b445cd8461721 100644 --- a/frame/example-offchain-worker/Cargo.toml +++ b/frame/example-offchain-worker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-example-offchain-worker" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Unlicense" diff --git a/frame/example-offchain-worker/src/lib.rs b/frame/example-offchain-worker/src/lib.rs index 8e02a09484ef5..5fd5eff19bd73 100644 --- a/frame/example-offchain-worker/src/lib.rs +++ b/frame/example-offchain-worker/src/lib.rs @@ -269,7 +269,7 @@ decl_module! { // to the storage and other included pallets. // // We can easily import `frame_system` and retrieve a block hash of the parent block. - let parent_hash = >::block_hash(block_number - 1.into()); + let parent_hash = >::block_hash(block_number - 1u32.into()); debug::debug!("Current block: {:?} (parent hash: {:?})", block_number, parent_hash); // It's a good practice to keep `fn offchain_worker()` function minimal, and move most @@ -364,10 +364,10 @@ impl Module { // transactions in a row. If a strict order is desired, it's better to use // the storage entry for that. (for instance store both block number and a flag // indicating the type of next transaction to send). - let transaction_type = block_number % 3.into(); + let transaction_type = block_number % 3u32.into(); if transaction_type == Zero::zero() { TransactionType::Signed } - else if transaction_type == T::BlockNumber::from(1) { TransactionType::UnsignedForAny } - else if transaction_type == T::BlockNumber::from(2) { TransactionType::UnsignedForAll } + else if transaction_type == T::BlockNumber::from(1u32) { TransactionType::UnsignedForAny } + else if transaction_type == T::BlockNumber::from(2u32) { TransactionType::UnsignedForAll } else { TransactionType::Raw } }, // We are in the grace period, we should not send a transaction this time. diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index 3bd8da04e6cf1..7cd1601189707 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-executive" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 7a5f39ccd8f48..1e3fc68cf6871 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -468,7 +468,7 @@ where >::offchain_worker( // to maintain backward compatibility we call module offchain workers // with parent block number. - header.number().saturating_sub(1.into()) + header.number().saturating_sub(1u32.into()) ) } } diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index 6147458b0dbd7..f1f1941eb34b1 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-grandpa" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/grandpa/src/benchmarking.rs b/frame/grandpa/src/benchmarking.rs index 048f99fff7a9b..bac2c24584464 100644 --- a/frame/grandpa/src/benchmarking.rs +++ b/frame/grandpa/src/benchmarking.rs @@ -65,8 +65,8 @@ benchmarks! { } note_stalled { - let delay = 1000.into(); - let best_finalized_block_number = 1.into(); + let delay = 1000u32.into(); + let best_finalized_block_number = 1u32.into(); }: _(RawOrigin::Root, delay, best_finalized_block_number) verify { diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 9a592ab9266f1..5b2bd50bb6a20 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -447,7 +447,7 @@ impl Module { // only allow the next forced change when twice the window has passed since // this one. - >::put(scheduled_at + in_blocks * 2.into()); + >::put(scheduled_at + in_blocks * 2u32.into()); } >::put(StoredPendingChange { diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index ef22d67688732..69cf402a12f3f 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-im-online" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index ef9c6b9182af6..716a2cbcb786c 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -594,7 +594,7 @@ impl Module { // clear the lock in case we have failed to send transaction. if res.is_err() { - new_status.sent_at = 0.into(); + new_status.sent_at = 0u32.into(); storage.set(&new_status); } @@ -635,7 +635,7 @@ impl pallet_session::OneSessionHandler for Module { // Since we consider producing blocks as being online, // the heartbeat is deferred a bit to prevent spamming. let block_number = >::block_number(); - let half_session = T::SessionDuration::get() / 2.into(); + let half_session = T::SessionDuration::get() / 2u32.into(); >::put(block_number + half_session); // Remember who the authorities are for the new session. @@ -723,7 +723,7 @@ impl frame_support::unsigned::ValidateUnsigned for Module { .priority(T::UnsignedPriority::get()) .and_provides((current_session, authority_id)) .longevity(TryInto::::try_into( - T::SessionDuration::get() / 2.into() + T::SessionDuration::get() / 2u32.into() ).unwrap_or(64_u64)) .propagate(true) .build() diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index c5c8881007c22..fbc8567534c67 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-offences" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index e35050992368a..47055eab73d4a 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -87,7 +87,7 @@ struct Offender { } fn bond_amount() -> BalanceOf { - T::Currency::minimum_balance().saturating_mul(10_000.into()) + T::Currency::minimum_balance().saturating_mul(10_000u32.into()) } fn create_offender(n: u32, nominators: u32) -> Result, &'static str> { @@ -97,7 +97,7 @@ fn create_offender(n: u32, nominators: u32) -> Result, &'s let reward_destination = RewardDestination::Staked; let raw_amount = bond_amount::(); // add twice as much balance to prevent the account from being killed. - let free_amount = raw_amount.saturating_mul(2.into()); + let free_amount = raw_amount.saturating_mul(2u32.into()); T::Currency::make_free_balance_be(&stash, free_amount); let amount: BalanceOf = raw_amount.into(); Staking::::bond( @@ -243,7 +243,8 @@ benchmarks! { verify { // make sure the report was not deferred assert!(Offences::::deferred_offences().is_empty()); - let slash_amount = slash_fraction * bond_amount::().unique_saturated_into() as u32; + let bond_amount: u32 = UniqueSaturatedInto::::unique_saturated_into(bond_amount::()); + let slash_amount = slash_fraction * bond_amount; let reward_amount = slash_amount * (1 + n) / 2; let mut slash_events = raw_offenders.into_iter() .flat_map(|offender| { @@ -379,7 +380,7 @@ benchmarks! { Offences::::set_deferred_offences(deferred_offences); assert!(!Offences::::deferred_offences().is_empty()); }: { - Offences::::on_initialize(0.into()); + Offences::::on_initialize(0u32.into()); } verify { // make sure that all deferred offences were reported with Ok status. diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index d35f6960af5d9..bca617e6f484b 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-randomness-collective-flip" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 6b1b9f4f37448..c1747669dab07 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -69,7 +69,7 @@ const RANDOM_MATERIAL_LEN: u32 = 81; fn block_number_to_index(block_number: T::BlockNumber) -> usize { // on_initialize is called on the first block after genesis - let index = (block_number - 1.into()) % RANDOM_MATERIAL_LEN.into(); + let index = (block_number - 1u32.into()) % RANDOM_MATERIAL_LEN.into(); index.try_into().ok().expect("Something % 81 is always smaller than usize; qed") } diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 88b8c1270a4e1..ab5534300542c 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-staking" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index afda58db4672f..8783945213851 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -103,7 +103,7 @@ pub fn create_validator_with_nominators( ErasRewardPoints::::insert(current_era, reward); // Create reward pool - let total_payout = T::Currency::minimum_balance() * 1000.into(); + let total_payout = T::Currency::minimum_balance() * 1000u32.into(); >::insert(current_era, total_payout); Ok(v_stash) @@ -119,7 +119,7 @@ benchmarks! { let controller = create_funded_user::("controller", USER_SEED, 100); let controller_lookup: ::Source = T::Lookup::unlookup(controller.clone()); let reward_destination = RewardDestination::Staked; - let amount = T::Currency::minimum_balance() * 10.into(); + let amount = T::Currency::minimum_balance() * 10u32.into(); do_whitelist!(stash); }: _(RawOrigin::Signed(stash.clone()), controller_lookup, amount, reward_destination) verify { @@ -129,7 +129,7 @@ benchmarks! { bond_extra { let (stash, controller) = create_stash_controller::(USER_SEED, 100, Default::default())?; - let max_additional = T::Currency::minimum_balance() * 10.into(); + let max_additional = T::Currency::minimum_balance() * 10u32.into(); let ledger = Ledger::::get(&controller).ok_or("ledger not created before")?; let original_bonded: BalanceOf = ledger.active; do_whitelist!(stash); @@ -142,7 +142,7 @@ benchmarks! { unbond { let (_, controller) = create_stash_controller::(USER_SEED, 100, Default::default())?; - let amount = T::Currency::minimum_balance() * 10.into(); + let amount = T::Currency::minimum_balance() * 10u32.into(); let ledger = Ledger::::get(&controller).ok_or("ledger not created before")?; let original_bonded: BalanceOf = ledger.active; do_whitelist!(controller); @@ -159,7 +159,7 @@ benchmarks! { let s in 0 .. MAX_SPANS; let (stash, controller) = create_stash_controller::(0, 100, Default::default())?; add_slashing_spans::(&stash, s); - let amount = T::Currency::minimum_balance() * 5.into(); // Half of total + let amount = T::Currency::minimum_balance() * 5u32.into(); // Half of total Staking::::unbond(RawOrigin::Signed(controller.clone()).into(), amount)?; CurrentEra::put(EraIndex::max_value()); let ledger = Ledger::::get(&controller).ok_or("ledger not created before")?; @@ -178,7 +178,7 @@ benchmarks! { let s in 0 .. MAX_SPANS; let (stash, controller) = create_stash_controller::(0, 100, Default::default())?; add_slashing_spans::(&stash, s); - let amount = T::Currency::minimum_balance() * 10.into(); + let amount = T::Currency::minimum_balance() * 10u32.into(); Staking::::unbond(RawOrigin::Signed(controller.clone()).into(), amount)?; CurrentEra::put(EraIndex::max_value()); let ledger = Ledger::::get(&controller).ok_or("ledger not created before")?; @@ -342,7 +342,7 @@ benchmarks! { let (_, controller) = create_stash_controller::(USER_SEED, 100, Default::default())?; let mut staking_ledger = Ledger::::get(controller.clone()).unwrap(); let unlock_chunk = UnlockChunk::> { - value: 1.into(), + value: 1u32.into(), era: EraIndex::zero(), }; for _ in 0 .. l { @@ -380,7 +380,7 @@ benchmarks! { let s in 1 .. MAX_SPANS; let (stash, controller) = create_stash_controller::(0, 100, Default::default())?; add_slashing_spans::(&stash, s); - T::Currency::make_free_balance_be(&stash, 0.into()); + T::Currency::make_free_balance_be(&stash, 0u32.into()); do_whitelist!(controller); }: _(RawOrigin::Signed(controller), stash.clone(), s) verify { @@ -427,7 +427,7 @@ benchmarks! { ErasRewardPoints::::insert(current_era, reward); // Create reward pool - let total_payout = T::Currency::minimum_balance() * 1000.into(); + let total_payout = T::Currency::minimum_balance() * 1000u32.into(); >::insert(current_era, total_payout); let caller: T::AccountId = whitelisted_caller(); @@ -443,14 +443,14 @@ benchmarks! { let (stash, controller) = create_stash_controller::(0, 100, Default::default())?; let mut staking_ledger = Ledger::::get(controller.clone()).unwrap(); let unlock_chunk = UnlockChunk::> { - value: 1.into(), + value: 1u32.into(), era: EraIndex::zero(), }; for _ in 0 .. l { staking_ledger.unlocking.push(unlock_chunk.clone()) } Ledger::::insert(controller, staking_ledger); - let slash_amount = T::Currency::minimum_balance() * 10.into(); + let slash_amount = T::Currency::minimum_balance() * 10u32.into(); let balance_before = T::Currency::free_balance(&stash); }: { crate::slashing::do_slash::( diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index cebf761a907c7..b8fa17b0dfc77 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-system" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/system/benchmarking/Cargo.toml b/frame/system/benchmarking/Cargo.toml index 26b9bd9230e00..39f33b033bb52 100644 --- a/frame/system/benchmarking/Cargo.toml +++ b/frame/system/benchmarking/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "frame-system-benchmarking" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/system/benchmarking/src/lib.rs b/frame/system/benchmarking/src/lib.rs index 653d9536f1797..41253b0e407f2 100644 --- a/frame/system/benchmarking/src/lib.rs +++ b/frame/system/benchmarking/src/lib.rs @@ -139,17 +139,17 @@ benchmarks! { suicide { let caller: T::AccountId = whitelisted_caller(); let account_info = AccountInfo:: { - nonce: 1337.into(), + nonce: 1337u32.into(), refcount: 0, data: T::AccountData::default() }; frame_system::Account::::insert(&caller, account_info); let new_account_info = System::::account(caller.clone()); - assert_eq!(new_account_info.nonce, 1337.into()); + assert_eq!(new_account_info.nonce, 1337u32.into()); }: _(RawOrigin::Signed(caller.clone())) verify { let account_info = System::::account(&caller); - assert_eq!(account_info.nonce, 0.into()); + assert_eq!(account_info.nonce, 0u32.into()); } } diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index 6e6284b57fdc3..ba5cfb8536f24 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -183,7 +183,7 @@ impl, X> Signer .enumerate() .map(|(index, key)| { let generic_public = C::GenericPublic::from(key); - let public = generic_public.into(); + let public: T::Public = generic_public.into(); let account_id = public.clone().into_account(); Account::new(index, account_id, public) }) diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index 5a99c5d02c5af..68a3d63dcd4d8 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-timestamp" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 959382c07b610..7f25219aeb361 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -200,7 +200,7 @@ decl_module! { decl_storage! { trait Store for Module as Timestamp { /// Current time for the current block. - pub Now get(fn now) build(|_| 0.into()): T::Moment; + pub Now get(fn now): T::Moment; /// Did the timestamp get updated in this block? DidUpdate: bool; diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index fd2d103e9f335..3b4e0a22d6b5f 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-treasury" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 4d76f2f532151..d81da40015fe5 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -1406,7 +1406,12 @@ impl, I: Instance> Module { BountyCount::::put(index + 1); let bounty = Bounty { - proposer, value, fee: 0.into(), curator_deposit: 0.into(), bond, status: BountyStatus::Proposed, + proposer, + value, + fee: 0u32.into(), + curator_deposit: 0u32.into(), + bond, + status: BountyStatus::Proposed, }; Bounties::::insert(index, &bounty); diff --git a/primitives/arithmetic/Cargo.toml b/primitives/arithmetic/Cargo.toml index b8e482491a7d4..8afed59c948c3 100644 --- a/primitives/arithmetic/Cargo.toml +++ b/primitives/arithmetic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-arithmetic" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/primitives/arithmetic/src/fixed_point.rs b/primitives/arithmetic/src/fixed_point.rs index 59c237efb6260..ba1484898c110 100644 --- a/primitives/arithmetic/src/fixed_point.rs +++ b/primitives/arithmetic/src/fixed_point.rs @@ -536,10 +536,10 @@ macro_rules! implement_fixed { } } - impl From

for $name { + impl From

for $name where P::Inner: FixedPointOperand { fn from(p: P) -> Self { - let accuracy = P::ACCURACY.saturated_into(); - let value = p.deconstruct().saturated_into(); + let accuracy = P::ACCURACY; + let value = p.deconstruct(); $name::saturating_from_rational(value, accuracy) } } diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index f7211779634d9..91f865b1a3cc8 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-externalities" -version = "0.8.0" +version = "0.8.1" license = "Apache-2.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/primitives/npos-elections/Cargo.toml b/primitives/npos-elections/Cargo.toml index 4a66743028d19..6994b50f5234e 100644 --- a/primitives/npos-elections/Cargo.toml +++ b/primitives/npos-elections/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-npos-elections" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/primitives/npos-elections/src/mock.rs b/primitives/npos-elections/src/mock.rs index 9b25f6f5f2e37..0151f5ca83a47 100644 --- a/primitives/npos-elections/src/mock.rs +++ b/primitives/npos-elections/src/mock.rs @@ -313,8 +313,8 @@ pub(crate) fn create_stake_of(stakes: &[(AccountId, VoteWeight)]) pub fn check_assignments_sum(assignments: Vec>) { for Assignment { distribution, .. } in assignments { let mut sum: u128 = Zero::zero(); - distribution.iter().for_each(|(_, p)| sum += p.deconstruct().saturated_into()); - assert_eq_error_rate!(sum, T::ACCURACY.saturated_into(), 1); + distribution.iter().for_each(|(_, p)| sum += p.deconstruct().saturated_into::()); + assert_eq_error_rate!(sum, T::ACCURACY.saturated_into::(), 1); } } diff --git a/test-utils/client/Cargo.toml b/test-utils/client/Cargo.toml index 91602b0b27c49..fdedfc3e97fc3 100644 --- a/test-utils/client/Cargo.toml +++ b/test-utils/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substrate-test-client" -version = "2.0.0" +version = "2.0.1" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/test-utils/client/src/client_ext.rs b/test-utils/client/src/client_ext.rs index a74bd3258ef0f..43e89c8f10bc1 100644 --- a/test-utils/client/src/client_ext.rs +++ b/test-utils/client/src/client_ext.rs @@ -79,7 +79,7 @@ impl ClientExt for Client } fn genesis_hash(&self) -> ::Hash { - self.block_hash(0.into()).unwrap().unwrap() + self.block_hash(0u32.into()).unwrap().unwrap() } }