From dac12988dee5d0949c0fff33276e7e3c25f41ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Mon, 26 Oct 2020 13:02:10 +0100 Subject: [PATCH] Make benchmarks compile with latest nightly (#7395) --- frame/balances/src/benchmarking.rs | 4 +- frame/contracts/src/benchmarking/mod.rs | 116 ++++++++++++------------ frame/democracy/src/benchmarking.rs | 38 ++++---- frame/identity/src/benchmarking.rs | 20 ++-- frame/treasury/src/benchmarking.rs | 18 ++-- frame/vesting/src/benchmarking.rs | 30 +++--- 6 files changed, 113 insertions(+), 113 deletions(-) diff --git a/frame/balances/src/benchmarking.rs b/frame/balances/src/benchmarking.rs index 21f43c7c63640..078d74006ba2f 100644 --- a/frame/balances/src/benchmarking.rs +++ b/frame/balances/src/benchmarking.rs @@ -49,7 +49,7 @@ benchmarks! { // Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user. let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup: ::Source = T::Lookup::unlookup(recipient.clone()); - let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1.into(); + let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); }: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount) verify { assert_eq!(Balances::::free_balance(&caller), Zero::zero()); @@ -138,7 +138,7 @@ benchmarks! { // Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user. let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup: ::Source = T::Lookup::unlookup(recipient.clone()); - let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1.into(); + let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); }: force_transfer(RawOrigin::Root, source_lookup, recipient_lookup, transfer_amount) verify { assert_eq!(Balances::::free_balance(&source), Zero::zero()); diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 22bcc3bc4e860..7c084a222a641 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -107,11 +107,11 @@ impl Contract { // Endowment should be large but not as large to inhibit rent payments. let endowment = T::RentDepositOffset::get() .saturating_mul(storage_size + T::StorageSizeOffset::get().into()) - .saturating_sub(1.into()); + .saturating_sub(1u32.into()); (storage_size, endowment) }, - Endow::Max => (0.into(), Endow::max::()), + Endow::Max => (0u32.into(), Endow::max::()), }; T::Currency::make_free_balance_be(&caller, caller_funding::()); let addr = T::DetermineContractAddress::contract_address_for(&module.hash, &data, &caller); @@ -202,7 +202,7 @@ impl Tombstone { let storage_items = create_storage::(stor_num, stor_size)?; contract.store(&storage_items)?; System::::set_block_number( - contract.eviction_at()? + T::SignedClaimHandicap::get() + 5.into() + contract.eviction_at()? + T::SignedClaimHandicap::get() + 5u32.into() ); crate::rent::collect_rent::(&contract.account_id); contract.ensure_tombstone()?; @@ -230,7 +230,7 @@ fn create_storage( /// The funding that each account that either calls or instantiates contracts is funded with. fn caller_funding() -> BalanceOf { - BalanceOf::::max_value() / 2.into() + BalanceOf::::max_value() / 2u32.into() } /// Set the block number to one. @@ -241,7 +241,7 @@ fn caller_funding() -> BalanceOf { /// in the setup closure so that both the instantiate and subsequent call are run with the /// same block number. fn init_block_number() { - System::::set_block_number(1.into()); + System::::set_block_number(1u32.into()); } benchmarks! { @@ -301,12 +301,12 @@ benchmarks! { let instance = Contract::::with_caller( whitelisted_caller(), WasmModule::dummy(), vec![], Endow::CollectRent )?; - let value = T::Currency::minimum_balance() * 100.into(); + let value = T::Currency::minimum_balance() * 100u32.into(); let origin = RawOrigin::Signed(instance.caller.clone()); let callee = instance.addr.clone(); // trigger rent collection for worst case performance of call - System::::set_block_number(instance.eviction_at()? - 5.into()); + System::::set_block_number(instance.eviction_at()? - 5u32.into()); let before = T::Currency::free_balance(&instance.account_id); }: _(origin, callee, value, Weight::max_value(), data) verify { @@ -339,7 +339,7 @@ benchmarks! { // generate enough rent so that the contract is evicted System::::set_block_number( - instance.eviction_at()? + T::SignedClaimHandicap::get() + 5.into() + instance.eviction_at()? + T::SignedClaimHandicap::get() + 5u32.into() ); }: _(origin, account_id, None) verify { @@ -359,7 +359,7 @@ benchmarks! { "seal_caller", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_address { let r in 0 .. API_BENCHMARK_BATCHES; @@ -367,7 +367,7 @@ benchmarks! { "seal_address", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_gas_left { let r in 0 .. API_BENCHMARK_BATCHES; @@ -375,7 +375,7 @@ benchmarks! { "seal_gas_left", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_balance { let r in 0 .. API_BENCHMARK_BATCHES; @@ -383,7 +383,7 @@ benchmarks! { "seal_balance", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_value_transferred { let r in 0 .. API_BENCHMARK_BATCHES; @@ -391,7 +391,7 @@ benchmarks! { "seal_value_transferred", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_minimum_balance { let r in 0 .. API_BENCHMARK_BATCHES; @@ -399,7 +399,7 @@ benchmarks! { "seal_minimum_balance", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_tombstone_deposit { let r in 0 .. API_BENCHMARK_BATCHES; @@ -407,7 +407,7 @@ benchmarks! { "seal_tombstone_deposit", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_rent_allowance { let r in 0 .. API_BENCHMARK_BATCHES; @@ -415,7 +415,7 @@ benchmarks! { "seal_rent_allowance", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_block_number { let r in 0 .. API_BENCHMARK_BATCHES; @@ -423,7 +423,7 @@ benchmarks! { "seal_block_number", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_now { let r in 0 .. API_BENCHMARK_BATCHES; @@ -431,7 +431,7 @@ benchmarks! { "seal_now", r * API_BENCHMARK_BATCH_SIZE ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_weight_to_fee { let r in 0 .. API_BENCHMARK_BATCHES; @@ -457,7 +457,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_gas { let r in 0 .. API_BENCHMARK_BATCHES; @@ -476,7 +476,7 @@ benchmarks! { let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // We cannot call seal_input multiple times. Therefore our weight determination is not // as precise as with other APIs. Because this function can only be called once per @@ -505,7 +505,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_input_per_kb { let n in 0 .. code::max_pages::() * 64; @@ -535,7 +535,7 @@ benchmarks! { let instance = Contract::::new(code, vec![], Endow::Max)?; let data = vec![42u8; (n * 1024).min(buffer_size) as usize]; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), data) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), data) // The same argument as for `seal_input` is true here. seal_return { @@ -557,7 +557,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_return_per_kb { let n in 0 .. code::max_pages::() * 64; @@ -579,7 +579,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // The same argument as for `seal_input` is true here. seal_terminate { @@ -609,12 +609,12 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - assert_eq!(T::Currency::total_balance(&beneficiary), 0.into()); + assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into()); assert_eq!(T::Currency::total_balance(&instance.account_id), Endow::max::()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) verify { if r > 0 { - assert_eq!(T::Currency::total_balance(&instance.account_id), 0.into()); + assert_eq!(T::Currency::total_balance(&instance.account_id), 0u32.into()); assert_eq!(T::Currency::total_balance(&beneficiary), Endow::max::()); } } @@ -686,10 +686,10 @@ benchmarks! { account("origin", 0, 0), code, vec![], Endow::Max )?; instance.store(&tombstone.storage)?; - System::::set_block_number(System::::block_number() + 1.into()); + System::::set_block_number(System::::block_number() + 1u32.into()); let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) verify { if r > 0 { tombstone.contract.alive_info()?; @@ -768,10 +768,10 @@ benchmarks! { )?; instance.store(&tombstone.storage)?; instance.store(&delta)?; - System::::set_block_number(System::::block_number() + 1.into()); + System::::set_block_number(System::::block_number() + 1u32.into()); let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) verify { tombstone.contract.alive_info()?; } @@ -808,7 +808,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Overhead of calling the function without any topic. // We benchmark for the worst case (largest event). @@ -832,7 +832,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Benchmark the overhead that topics generate. // `t`: Number of topics @@ -870,7 +870,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_set_rent_allowance { let r in 0 .. API_BENCHMARK_BATCHES; @@ -898,7 +898,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Only the overhead of calling the function itself with minimal arguments. // The contract is a bit more complex because I needs to use different keys in order @@ -934,7 +934,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_set_storage_per_kb { let n in 0 .. T::MaxValueSize::get() / 1024; @@ -963,7 +963,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Similar to seal_set_storage. However, we store all the keys that we are about to // delete beforehand in order to prevent any optimizations that could occur when @@ -1007,7 +1007,7 @@ benchmarks! { .map_err(|_| "Failed to write to storage during setup.")?; } let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // We make sure that all storage accesses are to unique keys. seal_get_storage { @@ -1053,7 +1053,7 @@ benchmarks! { .map_err(|_| "Failed to write to storage during setup.")?; } let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_get_storage_per_kb { let n in 0 .. T::MaxValueSize::get() / 1024; @@ -1096,7 +1096,7 @@ benchmarks! { ) .map_err(|_| "Failed to write to storage during setup.")?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // We transfer to unique accounts. seal_transfer { @@ -1107,7 +1107,7 @@ benchmarks! { let account_len = accounts.get(0).map(|i| i.encode().len()).unwrap_or(0); let account_bytes = accounts.iter().flat_map(|x| x.encode()).collect(); let value = Config::::subsistence_threshold_uncached(); - assert!(value > 0.into()); + assert!(value > 0u32.into()); let value_bytes = value.encode(); let value_len = value_bytes.len(); use body::CountedInstruction::{Counter, Regular}; @@ -1141,9 +1141,9 @@ benchmarks! { let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); for account in &accounts { - assert_eq!(T::Currency::total_balance(account), 0.into()); + assert_eq!(T::Currency::total_balance(account), 0u32.into()); } - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) verify { for account in &accounts { assert_eq!(T::Currency::total_balance(account), value); @@ -1159,7 +1159,7 @@ benchmarks! { .collect::, _>>()?; let callee_len = callees.get(0).map(|i| i.account_id.encode().len()).unwrap_or(0); let callee_bytes = callees.iter().flat_map(|x| x.account_id.encode()).collect(); - let value: BalanceOf = 0.into(); + let value: BalanceOf = 0u32.into(); let value_bytes = value.encode(); let value_len = value_bytes.len(); use body::CountedInstruction::{Counter, Regular}; @@ -1207,7 +1207,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) seal_call_per_transfer_input_output_kb { let t in 0 .. 1; @@ -1291,7 +1291,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // We assume that every instantiate sends at least the subsistence amount. seal_instantiate { @@ -1314,7 +1314,7 @@ benchmarks! { let hashes_bytes = hashes.iter().flat_map(|x| x.encode()).collect::>(); let hashes_len = hashes_bytes.len(); let value = Config::::subsistence_threshold_uncached(); - assert!(value > 0.into()); + assert!(value > 0u32.into()); let value_bytes = value.encode(); let value_len = value_bytes.len(); let addr_len = sp_std::mem::size_of::(); @@ -1391,7 +1391,7 @@ benchmarks! { return Err("Expected that contract does not exist at this point."); } } - }: call(origin, callee, 0.into(), Weight::max_value(), vec![]) + }: call(origin, callee, 0u32.into(), Weight::max_value(), vec![]) verify { for addr in &addresses { instance.alive_info()?; @@ -1430,7 +1430,7 @@ benchmarks! { let input_bytes = inputs.iter().cloned().flatten().collect::>(); let inputs_len = input_bytes.len(); let value = Config::::subsistence_threshold_uncached(); - assert!(value > 0.into()); + assert!(value > 0u32.into()); let value_bytes = value.encode(); let value_len = value_bytes.len(); let addr_len = sp_std::mem::size_of::(); @@ -1509,7 +1509,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Only the overhead of calling the function itself with minimal arguments. seal_hash_sha2_256 { @@ -1518,7 +1518,7 @@ benchmarks! { "seal_hash_sha2_256", r * API_BENCHMARK_BATCH_SIZE, 0, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // `n`: Input to hash in kilobytes seal_hash_sha2_256_per_kb { @@ -1527,7 +1527,7 @@ benchmarks! { "seal_hash_sha2_256", API_BENCHMARK_BATCH_SIZE, n * 1024, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Only the overhead of calling the function itself with minimal arguments. seal_hash_keccak_256 { @@ -1536,7 +1536,7 @@ benchmarks! { "seal_hash_keccak_256", r * API_BENCHMARK_BATCH_SIZE, 0, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // `n`: Input to hash in kilobytes seal_hash_keccak_256_per_kb { @@ -1545,7 +1545,7 @@ benchmarks! { "seal_hash_keccak_256", API_BENCHMARK_BATCH_SIZE, n * 1024, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Only the overhead of calling the function itself with minimal arguments. seal_hash_blake2_256 { @@ -1554,7 +1554,7 @@ benchmarks! { "seal_hash_blake2_256", r * API_BENCHMARK_BATCH_SIZE, 0, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // `n`: Input to hash in kilobytes seal_hash_blake2_256_per_kb { @@ -1563,7 +1563,7 @@ benchmarks! { "seal_hash_blake2_256", API_BENCHMARK_BATCH_SIZE, n * 1024, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // Only the overhead of calling the function itself with minimal arguments. seal_hash_blake2_128 { @@ -1572,7 +1572,7 @@ benchmarks! { "seal_hash_blake2_128", r * API_BENCHMARK_BATCH_SIZE, 0, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) // `n`: Input to hash in kilobytes seal_hash_blake2_128_per_kb { @@ -1581,7 +1581,7 @@ benchmarks! { "seal_hash_blake2_128", API_BENCHMARK_BATCH_SIZE, n * 1024, ), vec![], Endow::Max)?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0.into(), Weight::max_value(), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::max_value(), vec![]) } #[cfg(test)] diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 0b822e885989e..b5de1a91c17ad 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -70,12 +70,12 @@ fn add_referendum(n: u32) -> Result { T::LaunchPeriod::get(), proposal_hash, vote_threshold, - 0.into(), + 0u32.into(), ); let referendum_index: ReferendumIndex = ReferendumCount::get() - 1; T::Scheduler::schedule_named( (DEMOCRACY_ID, referendum_index).encode(), - DispatchTime::At(1.into()), + DispatchTime::At(1u32.into()), None, 63, system::RawOrigin::Root.into(), @@ -140,7 +140,7 @@ benchmarks! { let r in 1 .. MAX_REFERENDUMS; let caller = funded_account::("caller", 0); - let account_vote = account_vote::(100.into()); + let account_vote = account_vote::(100u32.into()); // We need to create existing direct votes for i in 0 .. r { @@ -168,7 +168,7 @@ benchmarks! { let r in 1 .. MAX_REFERENDUMS; let caller = funded_account::("caller", 0); - let account_vote = account_vote::(100.into()); + let account_vote = account_vote::(100u32.into()); // We need to create existing direct votes for i in 0 ..=r { @@ -183,7 +183,7 @@ benchmarks! { // Change vote from aye to nay let nay = Vote { aye: false, conviction: Conviction::Locked1x }; - let new_vote = AccountVote::Standard { vote: nay, balance: 1000.into() }; + let new_vote = AccountVote::Standard { vote: nay, balance: 1000u32.into() }; let referendum_index = Democracy::::referendum_count() - 1; // This tests when a user changes a vote @@ -201,7 +201,7 @@ benchmarks! { ReferendumInfo::Ongoing(r) => r.tally, _ => return Err("referendum not ongoing"), }; - assert_eq!(tally.nays, 1000.into(), "changed vote was not recorded"); + assert_eq!(tally.nays, 1000u32.into(), "changed vote was not recorded"); } emergency_cancel { @@ -287,7 +287,7 @@ benchmarks! { // NOTE: Instant origin may invoke a little bit more logic, but may not always succeed. let origin_fast_track = T::FastTrackOrigin::successful_origin(); let voting_period = T::FastTrackVotingPeriod::get(); - let delay = 0; + let delay = 0u32; let call = Call::::fast_track(proposal_hash, voting_period.into(), delay.into()); }: { call.dispatch_bypass_filter(origin_fast_track)? } @@ -429,7 +429,7 @@ benchmarks! { for (key, mut info) in ReferendumInfoOf::::iter() { if let ReferendumInfo::Ongoing(ref mut status) = info { - status.end += 100.into(); + status.end += 100u32.into(); } ReferendumInfoOf::::insert(key, info); } @@ -437,7 +437,7 @@ benchmarks! { assert_eq!(Democracy::::referendum_count(), r, "referenda not created"); assert_eq!(Democracy::::lowest_unbaked(), 0, "invalid referenda init"); - }: { Democracy::::on_initialize(0.into()) } + }: { Democracy::::on_initialize(0u32.into()) } verify { // All should be on going for i in 0 .. r { @@ -453,8 +453,8 @@ benchmarks! { delegate { let r in 1 .. MAX_REFERENDUMS; - let initial_balance: BalanceOf = 100.into(); - let delegated_balance: BalanceOf = 1000.into(); + let initial_balance: BalanceOf = 100u32.into(); + let delegated_balance: BalanceOf = 1000u32.into(); let caller = funded_account::("caller", 0); // Caller will initially delegate to `old_delegate` @@ -503,8 +503,8 @@ benchmarks! { undelegate { let r in 1 .. MAX_REFERENDUMS; - let initial_balance: BalanceOf = 100.into(); - let delegated_balance: BalanceOf = 1000.into(); + let initial_balance: BalanceOf = 100u32.into(); + let delegated_balance: BalanceOf = 1000u32.into(); let caller = funded_account::("caller", 0); // Caller will delegate @@ -619,7 +619,7 @@ benchmarks! { let locker = funded_account::("locker", 0); // Populate votes so things are locked - let base_balance: BalanceOf = 100.into(); + let base_balance: BalanceOf = 100u32.into(); let small_vote = account_vote::(base_balance); // Vote and immediately unvote for i in 0 .. r { @@ -643,7 +643,7 @@ benchmarks! { let locker = funded_account::("locker", 0); // Populate votes so things are locked - let base_balance: BalanceOf = 100.into(); + let base_balance: BalanceOf = 100u32.into(); let small_vote = account_vote::(base_balance); for i in 0 .. r { let ref_idx = add_referendum::(i)?; @@ -651,7 +651,7 @@ benchmarks! { } // Create a big vote so lock increases - let big_vote = account_vote::(base_balance * 10.into()); + let big_vote = account_vote::(base_balance * 10u32.into()); let referendum_index = add_referendum::(r)?; Democracy::::vote(RawOrigin::Signed(locker.clone()).into(), referendum_index, big_vote)?; @@ -662,7 +662,7 @@ benchmarks! { assert_eq!(votes.len(), (r + 1) as usize, "Votes were not recorded."); let voting = VotingOf::::get(&locker); - assert_eq!(voting.locked_balance(), base_balance * 10.into()); + assert_eq!(voting.locked_balance(), base_balance * 10u32.into()); Democracy::::remove_vote(RawOrigin::Signed(locker.clone()).into(), referendum_index)?; @@ -685,7 +685,7 @@ benchmarks! { let r in 1 .. MAX_REFERENDUMS; let caller = funded_account::("caller", 0); - let account_vote = account_vote::(100.into()); + let account_vote = account_vote::(100u32.into()); for i in 0 .. r { let ref_idx = add_referendum::(i)?; @@ -714,7 +714,7 @@ benchmarks! { let r in 1 .. MAX_REFERENDUMS; let caller = funded_account::("caller", r); - let account_vote = account_vote::(100.into()); + let account_vote = account_vote::(100u32.into()); for i in 0 .. r { let ref_idx = add_referendum::(i)?; diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index d39df27017b71..d7876514452e2 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -43,7 +43,7 @@ fn add_registrars(r: u32) -> Result<(), &'static str> { let registrar: T::AccountId = account("registrar", i, SEED); let _ = T::Currency::make_free_balance_be(®istrar, BalanceOf::::max_value()); Identity::::add_registrar(RawOrigin::Root.into(), registrar.clone())?; - Identity::::set_fee(RawOrigin::Signed(registrar.clone()).into(), i.into(), 10.into())?; + Identity::::set_fee(RawOrigin::Signed(registrar.clone()).into(), i.into(), 10u32.into())?; let fields = IdentityFields( IdentityField::Display | IdentityField::Legal | IdentityField::Web | IdentityField::Riot | IdentityField::Email | IdentityField::PgpFingerprint | IdentityField::Image | IdentityField::Twitter @@ -152,7 +152,7 @@ benchmarks! { // User requests judgement from all the registrars, and they approve for i in 0..r { - Identity::::request_judgement(caller_origin.clone(), i, 10.into())?; + Identity::::request_judgement(caller_origin.clone(), i, 10u32.into())?; Identity::::provide_judgement( RawOrigin::Signed(account("registrar", i, SEED)).into(), i, @@ -210,7 +210,7 @@ benchmarks! { // User requests judgement from all the registrars, and they approve for i in 0..r { - Identity::::request_judgement(caller_origin.clone(), i, 10.into())?; + Identity::::request_judgement(caller_origin.clone(), i, 10u32.into())?; Identity::::provide_judgement( RawOrigin::Signed(account("registrar", i, SEED)).into(), i, @@ -230,7 +230,7 @@ benchmarks! { let r in ...; let x in ...; - }: _(RawOrigin::Signed(caller.clone()), r - 1, 10.into()) + }: _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into()) verify { assert_last_event::(Event::::JudgementRequested(caller, r-1).into()); } @@ -243,7 +243,7 @@ benchmarks! { let r in ...; let x in ...; - Identity::::request_judgement(caller_origin, r - 1, 10.into())?; + Identity::::request_judgement(caller_origin, r - 1, 10u32.into())?; }: _(RawOrigin::Signed(caller.clone()), r - 1) verify { assert_last_event::(Event::::JudgementUnrequested(caller, r-1).into()); @@ -256,11 +256,11 @@ benchmarks! { Identity::::add_registrar(RawOrigin::Root.into(), caller.clone())?; let registrars = Registrars::::get(); - ensure!(registrars[r as usize].as_ref().unwrap().fee == 0.into(), "Fee already set."); - }: _(RawOrigin::Signed(caller), r, 100.into()) + ensure!(registrars[r as usize].as_ref().unwrap().fee == 0u32.into(), "Fee already set."); + }: _(RawOrigin::Signed(caller), r, 100u32.into()) verify { let registrars = Registrars::::get(); - ensure!(registrars[r as usize].as_ref().unwrap().fee == 100.into(), "Fee not changed."); + ensure!(registrars[r as usize].as_ref().unwrap().fee == 100u32.into(), "Fee not changed."); } set_account_id { @@ -315,7 +315,7 @@ benchmarks! { }; Identity::::add_registrar(RawOrigin::Root.into(), caller.clone())?; - Identity::::request_judgement(user_origin.clone(), r, 10.into())?; + Identity::::request_judgement(user_origin.clone(), r, 10u32.into())?; }: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable) verify { assert_last_event::(Event::::JudgementGiven(user, r).into()) @@ -338,7 +338,7 @@ benchmarks! { // User requests judgement from all the registrars, and they approve for i in 0..r { - Identity::::request_judgement(target_origin.clone(), i, 10.into())?; + Identity::::request_judgement(target_origin.clone(), i, 10u32.into())?; Identity::::provide_judgement( RawOrigin::Signed(account("registrar", i, SEED)).into(), i, diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index 1d6d7c6afceb7..2794e6cc43203 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -36,7 +36,7 @@ fn setup_proposal, I: Instance>(u: u32) -> ( ::Source, ) { let caller = account("caller", u, SEED); - let value: BalanceOf = T::ProposalBondMinimum::get().saturating_mul(100.into()); + let value: BalanceOf = T::ProposalBondMinimum::get().saturating_mul(100u32.into()); let _ = T::Currency::make_free_balance_be(&caller, value); let beneficiary = account("beneficiary", u, SEED); let beneficiary_lookup = T::Lookup::unlookup(beneficiary); @@ -71,7 +71,7 @@ fn setup_tip, I: Instance>(r: u32, t: u32) -> let caller = account("member", t - 1, SEED); let reason = vec![0; r as usize]; let beneficiary = account("beneficiary", t, SEED); - let value = T::Currency::minimum_balance().saturating_mul(100.into()); + let value = T::Currency::minimum_balance().saturating_mul(100u32.into()); Ok((caller, reason, beneficiary, value)) } @@ -130,12 +130,12 @@ fn setup_bounty, I: Instance>(u: u32, d: u32) -> ( Vec, ) { let caller = account("caller", u, SEED); - let value: BalanceOf = T::BountyValueMinimum::get().saturating_mul(100.into()); - let fee = value / 2.into(); + let value: BalanceOf = T::BountyValueMinimum::get().saturating_mul(100u32.into()); + let fee = value / 2u32.into(); let deposit = T::BountyDepositBase::get() + T::DataDepositPerByte::get() * MAX_BYTES.into(); let _ = T::Currency::make_free_balance_be(&caller, deposit); let curator = account("curator", u, SEED); - let _ = T::Currency::make_free_balance_be(&curator, fee / 2.into()); + let _ = T::Currency::make_free_balance_be(&curator, fee / 2u32.into()); let reason = vec![0; d as usize]; (caller, curator, fee, value, reason) } @@ -157,7 +157,7 @@ fn create_bounty, I: Instance>() -> Result<( fn setup_pod_account, I: Instance>() { let pot_account = Treasury::::account_id(); - let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000.into()); + let value = T::Currency::minimum_balance().saturating_mul(1_000_000_000u32.into()); let _ = T::Currency::make_free_balance_be(&pot_account, value); } @@ -230,7 +230,7 @@ benchmarks_instance! { tip { let t in 1 .. MAX_TIPPERS; let (member, reason, beneficiary, value) = setup_tip::(0, t)?; - let value = T::Currency::minimum_balance().saturating_mul(100.into()); + let value = T::Currency::minimum_balance().saturating_mul(100u32.into()); Treasury::::tip_new( RawOrigin::Signed(member).into(), reason.clone(), @@ -255,7 +255,7 @@ benchmarks_instance! { // Set up a new tip proposal let (member, reason, beneficiary, value) = setup_tip::(0, t)?; - let value = T::Currency::minimum_balance().saturating_mul(100.into()); + let value = T::Currency::minimum_balance().saturating_mul(100u32.into()); Treasury::::tip_new( RawOrigin::Signed(member).into(), reason.clone(), @@ -303,7 +303,7 @@ benchmarks_instance! { let (curator_lookup, bounty_id) = create_bounty::()?; Treasury::::on_initialize(T::BlockNumber::zero()); let bounty_id = BountyCount::::get() - 1; - frame_system::Module::::set_block_number(T::BountyUpdatePeriod::get() + 1.into()); + frame_system::Module::::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into()); let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), bounty_id) diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index 7c5478472f8ab..69dc7abaa7038 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -34,18 +34,18 @@ type BalanceOf = <::Currency as Currency<(who: &T::AccountId, n: u8) { for id in 0..n { let lock_id = [id; 8]; - let locked = 100; + let locked = 100u32; let reasons = WithdrawReason::Transfer | WithdrawReason::Reserve; T::Currency::set_lock(lock_id, who, locked.into(), reasons); } } fn add_vesting_schedule(who: &T::AccountId) -> Result<(), &'static str> { - let locked = 100; - let per_block = 10; - let starting_block = 1; + let locked = 100u32; + let per_block = 10u32; + let starting_block = 1u32; - System::::set_block_number(0.into()); + System::::set_block_number(0u32.into()); // Add schedule to avoid `NotVesting` error. Vesting::::add_vesting_schedule( @@ -71,7 +71,7 @@ benchmarks! { System::::set_block_number(T::BlockNumber::zero()); assert_eq!( Vesting::::vesting_balance(&caller), - Some(100.into()), + Some(100u32.into()), "Vesting schedule not added", ); }: vest(RawOrigin::Signed(caller.clone())) @@ -79,7 +79,7 @@ benchmarks! { // Nothing happened since everything is still vested. assert_eq!( Vesting::::vesting_balance(&caller), - Some(100.into()), + Some(100u32.into()), "Vesting schedule was removed", ); } @@ -92,7 +92,7 @@ benchmarks! { add_locks::(&caller, l as u8); add_vesting_schedule::(&caller)?; // At block 20, everything is unvested. - System::::set_block_number(20.into()); + System::::set_block_number(20u32.into()); assert_eq!( Vesting::::vesting_balance(&caller), Some(BalanceOf::::zero()), @@ -120,7 +120,7 @@ benchmarks! { System::::set_block_number(T::BlockNumber::zero()); assert_eq!( Vesting::::vesting_balance(&other), - Some(100.into()), + Some(100u32.into()), "Vesting schedule not added", ); @@ -130,7 +130,7 @@ benchmarks! { // Nothing happened since everything is still vested. assert_eq!( Vesting::::vesting_balance(&other), - Some(100.into()), + Some(100u32.into()), "Vesting schedule was removed", ); } @@ -144,7 +144,7 @@ benchmarks! { add_locks::(&other, l as u8); add_vesting_schedule::(&other)?; // At block 20, everything is unvested. - System::::set_block_number(20.into()); + System::::set_block_number(20u32.into()); assert_eq!( Vesting::::vesting_balance(&other), Some(BalanceOf::::zero()), @@ -176,8 +176,8 @@ benchmarks! { let vesting_schedule = VestingInfo { locked: transfer_amount, - per_block: 10.into(), - starting_block: 1.into(), + per_block: 10u32.into(), + starting_block: 1u32.into(), }; }: _(RawOrigin::Signed(caller), target_lookup, vesting_schedule) verify { @@ -208,8 +208,8 @@ benchmarks! { let vesting_schedule = VestingInfo { locked: transfer_amount, - per_block: 10.into(), - starting_block: 1.into(), + per_block: 10u32.into(), + starting_block: 1u32.into(), }; }: _(RawOrigin::Root, source_lookup, target_lookup, vesting_schedule) verify {