Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Backport #7395
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Jan 6, 2021
1 parent dac9477 commit e2861b5
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 69 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frame/balances/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-balances"
version = "2.0.0"
version = "2.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions frame/balances/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-contracts"
version = "2.0.0"
version = "2.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
8 changes: 4 additions & 4 deletions frame/contracts/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn compile_module<T: Trait>(code: &[u8]) -> (Vec<u8>, <T::Hashing as Hash>::Outp
}

fn funding<T: Trait>() -> BalanceOf<T> {
T::Currency::minimum_balance() * 10_000.into()
T::Currency::minimum_balance() * 10_000u32.into()
}

fn create_funded_user<T: Trait>(string: &'static str, n: u32) -> T::AccountId {
Expand Down Expand Up @@ -160,7 +160,7 @@ benchmarks! {
call {
let data = vec![0u8; 128];
let endowment = Config::<T>::subsistence_threshold_uncached();
let value = T::Currency::minimum_balance() * 100.into();
let value = T::Currency::minimum_balance() * 100u32.into();
let caller = create_funded_user::<T>("caller", 0);
let (binary, hash) = load_module!("dummy");
let addr = T::DetermineContractAddress::contract_address_for(&hash, &[], &caller);
Expand Down Expand Up @@ -195,7 +195,7 @@ benchmarks! {
// the reward for removing them.
claim_surcharge {
let endowment = Config::<T>::subsistence_threshold_uncached();
let value = T::Currency::minimum_balance() * 100.into();
let value = T::Currency::minimum_balance() * 100u32.into();
let caller = create_funded_user::<T>("caller", 0);
let (binary, hash) = load_module!("dummy");
let addr = T::DetermineContractAddress::contract_address_for(&hash, &[], &caller);
Expand All @@ -213,7 +213,7 @@ benchmarks! {
ContractInfoOf::<T>::get(addr.clone()).unwrap().get_alive().unwrap();

// generate some rent
advance_block::<T>(<T as Trait>::SignedClaimHandicap::get() + 1.into());
advance_block::<T>(<T as Trait>::SignedClaimHandicap::get() + 1u32.into());

}: _(RawOrigin::Signed(caller.clone()), addr.clone(), None)
verify {
Expand Down
2 changes: 1 addition & 1 deletion frame/democracy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-democracy"
version = "2.0.0"
version = "2.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
38 changes: 19 additions & 19 deletions frame/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -132,7 +132,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 {
Expand Down Expand Up @@ -160,7 +160,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 {
Expand All @@ -175,7 +175,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
Expand All @@ -192,7 +192,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 {
Expand Down Expand Up @@ -253,7 +253,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)? }
Expand Down Expand Up @@ -382,15 +382,15 @@ 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);
}

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 {
Expand All @@ -406,8 +406,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`
Expand Down Expand Up @@ -455,8 +455,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
Expand Down Expand Up @@ -567,7 +567,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 {
Expand All @@ -590,15 +590,15 @@ 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)?;
Democracy::<T>::vote(RawOrigin::Signed(locker.clone()).into(), ref_idx, small_vote.clone())?;
}

// 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)?;

Expand All @@ -609,7 +609,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)?;

Expand All @@ -631,7 +631,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)?;
Expand Down Expand Up @@ -660,7 +660,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)?;
Expand Down
2 changes: 1 addition & 1 deletion frame/identity/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-identity"
version = "2.0.0"
version = "2.0.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
20 changes: 10 additions & 10 deletions frame/identity/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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());
}
Expand All @@ -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());
Expand All @@ -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 {
Expand Down Expand Up @@ -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())
Expand All @@ -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,
Expand Down

0 comments on commit e2861b5

Please sign in to comment.