Make benchmarks compile with latest nightly (#7395)

This commit is contained in:
Alexander Theißen
2020-10-26 13:02:10 +01:00
committed by GitHub
parent 653868c01e
commit cfd834be41
6 changed files with 113 additions and 113 deletions
+2 -2
View File
@@ -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: <T::Lookup as StaticLookup>::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::<T>::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: <T::Lookup as StaticLookup>::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::<T>::free_balance(&source), Zero::zero());
@@ -107,11 +107,11 @@ impl<T: Trait> Contract<T> {
// 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::<T>()),
Endow::Max => (0u32.into(), Endow::max::<T>()),
};
T::Currency::make_free_balance_be(&caller, caller_funding::<T>());
let addr = T::DetermineContractAddress::contract_address_for(&module.hash, &data, &caller);
@@ -202,7 +202,7 @@ impl<T: Trait> Tombstone<T> {
let storage_items = create_storage::<T>(stor_num, stor_size)?;
contract.store(&storage_items)?;
System::<T>::set_block_number(
contract.eviction_at()? + T::SignedClaimHandicap::get() + 5.into()
contract.eviction_at()? + T::SignedClaimHandicap::get() + 5u32.into()
);
crate::rent::collect_rent::<T>(&contract.account_id);
contract.ensure_tombstone()?;
@@ -230,7 +230,7 @@ fn create_storage<T: Trait>(
/// The funding that each account that either calls or instantiates contracts is funded with.
fn caller_funding<T: Trait>() -> BalanceOf<T> {
BalanceOf::<T>::max_value() / 2.into()
BalanceOf::<T>::max_value() / 2u32.into()
}
/// Set the block number to one.
@@ -241,7 +241,7 @@ fn caller_funding<T: Trait>() -> BalanceOf<T> {
/// in the setup closure so that both the instantiate and subsequent call are run with the
/// same block number.
fn init_block_number<T: Trait>() {
System::<T>::set_block_number(1.into());
System::<T>::set_block_number(1u32.into());
}
benchmarks! {
@@ -301,12 +301,12 @@ benchmarks! {
let instance = Contract::<T>::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::<T>::set_block_number(instance.eviction_at()? - 5.into());
System::<T>::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::<T>::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::<T>::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::<T>::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::<T>::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::<T>() * 64;
@@ -535,7 +535,7 @@ benchmarks! {
let instance = Contract::<T>::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::<T>::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::<T>() * 64;
@@ -579,7 +579,7 @@ benchmarks! {
});
let instance = Contract::<T>::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::<T>::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::<T>());
}: 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::<T>());
}
}
@@ -686,10 +686,10 @@ benchmarks! {
account("origin", 0, 0), code, vec![], Endow::Max
)?;
instance.store(&tombstone.storage)?;
System::<T>::set_block_number(System::<T>::block_number() + 1.into());
System::<T>::set_block_number(System::<T>::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::<T>::set_block_number(System::<T>::block_number() + 1.into());
System::<T>::set_block_number(System::<T>::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::<T>::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::<T>::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::<T>::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::<T>::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::<T>::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::<T>::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::<T>::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::<T>::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::<Result<Vec<_>, _>>()?;
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<T> = 0.into();
let value: BalanceOf<T> = 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::<T>::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::<T>::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::<Vec<_>>();
let hashes_len = hashes_bytes.len();
let value = Config::<T>::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::<T::AccountId>();
@@ -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::<Vec<_>>();
let inputs_len = input_bytes.len();
let value = Config::<T>::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::<T::AccountId>();
@@ -1509,7 +1509,7 @@ benchmarks! {
});
let instance = Contract::<T>::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)]
+19 -19
View File
@@ -70,12 +70,12 @@ fn add_referendum<T: Trait>(n: u32) -> Result<ReferendumIndex, &'static str> {
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::<T>("caller", 0);
let account_vote = account_vote::<T>(100.into());
let account_vote = account_vote::<T>(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::<T>("caller", 0);
let account_vote = account_vote::<T>(100.into());
let account_vote = account_vote::<T>(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::<T>::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::<T>::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::<T>::iter() {
if let ReferendumInfo::Ongoing(ref mut status) = info {
status.end += 100.into();
status.end += 100u32.into();
}
ReferendumInfoOf::<T>::insert(key, info);
}
@@ -437,7 +437,7 @@ benchmarks! {
assert_eq!(Democracy::<T>::referendum_count(), r, "referenda not created");
assert_eq!(Democracy::<T>::lowest_unbaked(), 0, "invalid referenda init");
}: { Democracy::<T>::on_initialize(0.into()) }
}: { Democracy::<T>::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<T> = 100.into();
let delegated_balance: BalanceOf<T> = 1000.into();
let initial_balance: BalanceOf<T> = 100u32.into();
let delegated_balance: BalanceOf<T> = 1000u32.into();
let caller = funded_account::<T>("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<T> = 100.into();
let delegated_balance: BalanceOf<T> = 1000.into();
let initial_balance: BalanceOf<T> = 100u32.into();
let delegated_balance: BalanceOf<T> = 1000u32.into();
let caller = funded_account::<T>("caller", 0);
// Caller will delegate
@@ -619,7 +619,7 @@ benchmarks! {
let locker = funded_account::<T>("locker", 0);
// Populate votes so things are locked
let base_balance: BalanceOf<T> = 100.into();
let base_balance: BalanceOf<T> = 100u32.into();
let small_vote = account_vote::<T>(base_balance);
// Vote and immediately unvote
for i in 0 .. r {
@@ -643,7 +643,7 @@ benchmarks! {
let locker = funded_account::<T>("locker", 0);
// Populate votes so things are locked
let base_balance: BalanceOf<T> = 100.into();
let base_balance: BalanceOf<T> = 100u32.into();
let small_vote = account_vote::<T>(base_balance);
for i in 0 .. r {
let ref_idx = add_referendum::<T>(i)?;
@@ -651,7 +651,7 @@ benchmarks! {
}
// Create a big vote so lock increases
let big_vote = account_vote::<T>(base_balance * 10.into());
let big_vote = account_vote::<T>(base_balance * 10u32.into());
let referendum_index = add_referendum::<T>(r)?;
Democracy::<T>::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::<T>::get(&locker);
assert_eq!(voting.locked_balance(), base_balance * 10.into());
assert_eq!(voting.locked_balance(), base_balance * 10u32.into());
Democracy::<T>::remove_vote(RawOrigin::Signed(locker.clone()).into(), referendum_index)?;
@@ -685,7 +685,7 @@ benchmarks! {
let r in 1 .. MAX_REFERENDUMS;
let caller = funded_account::<T>("caller", 0);
let account_vote = account_vote::<T>(100.into());
let account_vote = account_vote::<T>(100u32.into());
for i in 0 .. r {
let ref_idx = add_referendum::<T>(i)?;
@@ -714,7 +714,7 @@ benchmarks! {
let r in 1 .. MAX_REFERENDUMS;
let caller = funded_account::<T>("caller", r);
let account_vote = account_vote::<T>(100.into());
let account_vote = account_vote::<T>(100u32.into());
for i in 0 .. r {
let ref_idx = add_referendum::<T>(i)?;
+10 -10
View File
@@ -43,7 +43,7 @@ fn add_registrars<T: Trait>(r: u32) -> Result<(), &'static str> {
let registrar: T::AccountId = account("registrar", i, SEED);
let _ = T::Currency::make_free_balance_be(&registrar, BalanceOf::<T>::max_value());
Identity::<T>::add_registrar(RawOrigin::Root.into(), registrar.clone())?;
Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), i.into(), 10.into())?;
Identity::<T>::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::<T>::request_judgement(caller_origin.clone(), i, 10.into())?;
Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;
Identity::<T>::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::<T>::request_judgement(caller_origin.clone(), i, 10.into())?;
Identity::<T>::request_judgement(caller_origin.clone(), i, 10u32.into())?;
Identity::<T>::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::<T>(Event::<T>::JudgementRequested(caller, r-1).into());
}
@@ -243,7 +243,7 @@ benchmarks! {
let r in ...;
let x in ...;
Identity::<T>::request_judgement(caller_origin, r - 1, 10.into())?;
Identity::<T>::request_judgement(caller_origin, r - 1, 10u32.into())?;
}: _(RawOrigin::Signed(caller.clone()), r - 1)
verify {
assert_last_event::<T>(Event::<T>::JudgementUnrequested(caller, r-1).into());
@@ -256,11 +256,11 @@ benchmarks! {
Identity::<T>::add_registrar(RawOrigin::Root.into(), caller.clone())?;
let registrars = Registrars::<T>::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::<T>::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::<T>::add_registrar(RawOrigin::Root.into(), caller.clone())?;
Identity::<T>::request_judgement(user_origin.clone(), r, 10.into())?;
Identity::<T>::request_judgement(user_origin.clone(), r, 10u32.into())?;
}: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable)
verify {
assert_last_event::<T>(Event::<T>::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::<T>::request_judgement(target_origin.clone(), i, 10.into())?;
Identity::<T>::request_judgement(target_origin.clone(), i, 10u32.into())?;
Identity::<T>::provide_judgement(
RawOrigin::Signed(account("registrar", i, SEED)).into(),
i,
+9 -9
View File
@@ -36,7 +36,7 @@ fn setup_proposal<T: Trait<I>, I: Instance>(u: u32) -> (
<T::Lookup as StaticLookup>::Source,
) {
let caller = account("caller", u, SEED);
let value: BalanceOf<T, I> = T::ProposalBondMinimum::get().saturating_mul(100.into());
let value: BalanceOf<T, I> = 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<T: Trait<I>, 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<T: Trait<I>, I: Instance>(u: u32, d: u32) -> (
Vec<u8>,
) {
let caller = account("caller", u, SEED);
let value: BalanceOf<T, I> = T::BountyValueMinimum::get().saturating_mul(100.into());
let fee = value / 2.into();
let value: BalanceOf<T, I> = 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<T: Trait<I>, I: Instance>() -> Result<(
fn setup_pod_account<T: Trait<I>, I: Instance>() {
let pot_account = Treasury::<T, I>::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::<T, _>(0, t)?;
let value = T::Currency::minimum_balance().saturating_mul(100.into());
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
Treasury::<T, _>::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::<T, _>(0, t)?;
let value = T::Currency::minimum_balance().saturating_mul(100.into());
let value = T::Currency::minimum_balance().saturating_mul(100u32.into());
Treasury::<T, _>::tip_new(
RawOrigin::Signed(member).into(),
reason.clone(),
@@ -303,7 +303,7 @@ benchmarks_instance! {
let (curator_lookup, bounty_id) = create_bounty::<T, _>()?;
Treasury::<T, _>::on_initialize(T::BlockNumber::zero());
let bounty_id = BountyCount::<I>::get() - 1;
frame_system::Module::<T>::set_block_number(T::BountyUpdatePeriod::get() + 1.into());
frame_system::Module::<T>::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into());
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), bounty_id)
+15 -15
View File
@@ -34,18 +34,18 @@ type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trai
fn add_locks<T: Trait>(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<T: Trait>(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::<T>::set_block_number(0.into());
System::<T>::set_block_number(0u32.into());
// Add schedule to avoid `NotVesting` error.
Vesting::<T>::add_vesting_schedule(
@@ -71,7 +71,7 @@ benchmarks! {
System::<T>::set_block_number(T::BlockNumber::zero());
assert_eq!(
Vesting::<T>::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::<T>::vesting_balance(&caller),
Some(100.into()),
Some(100u32.into()),
"Vesting schedule was removed",
);
}
@@ -92,7 +92,7 @@ benchmarks! {
add_locks::<T>(&caller, l as u8);
add_vesting_schedule::<T>(&caller)?;
// At block 20, everything is unvested.
System::<T>::set_block_number(20.into());
System::<T>::set_block_number(20u32.into());
assert_eq!(
Vesting::<T>::vesting_balance(&caller),
Some(BalanceOf::<T>::zero()),
@@ -120,7 +120,7 @@ benchmarks! {
System::<T>::set_block_number(T::BlockNumber::zero());
assert_eq!(
Vesting::<T>::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::<T>::vesting_balance(&other),
Some(100.into()),
Some(100u32.into()),
"Vesting schedule was removed",
);
}
@@ -144,7 +144,7 @@ benchmarks! {
add_locks::<T>(&other, l as u8);
add_vesting_schedule::<T>(&other)?;
// At block 20, everything is unvested.
System::<T>::set_block_number(20.into());
System::<T>::set_block_number(20u32.into());
assert_eq!(
Vesting::<T>::vesting_balance(&other),
Some(BalanceOf::<T>::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 {