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

Benchmarks for offences pallet. #5851

Merged
merged 23 commits into from
May 6, 2020
Merged

Conversation

tomusdrw
Copy link
Contributor

An attempt to benchmark offences with the same kind of reports that are most likely going to be used in the final runtime (like im-online, grandpa and babe).

Even though we don't report babe (see #5752) nor grandpa (see #3868) yet, the final report is not likely to change that much (or at all).

@tomusdrw tomusdrw added A0-please_review Pull request needs code review. M4-core labels Apr 30, 2020
@tomusdrw tomusdrw requested review from marcio-diaz and shawntabrizi and removed request for andresilva and Demi-Marie April 30, 2020 13:45
Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks overall very good to me.

@@ -458,7 +458,7 @@ decl_module! {
/// - Contains a limited number of reads and writes.
/// # </weight>
#[weight = T::DbWeight::get().reads_writes(1, 1) + 100_000_000]
fn set_balance(
pub fn set_balance(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just started reviewing, but you shouldn't need to make this pub. You can instead call make_free_balance_be which is part of the currency trait.

Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the balance/event stuff

@@ -18,7 +18,7 @@
//! from VRF outputs and manages epoch transitions.

#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(unused_must_use, unsafe_code, unused_variables, unused_must_use)]
#![warn(unused_must_use, unsafe_code, unused_variables, unused_must_use)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentional (or a result of debugging)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional. Using forbid may cause issues with:

  • Quick development cycle
  • Build randomly breaking on rustc upgrades

We did try that in the past, but it was doing more harm than good.

@shawntabrizi
Copy link
Member

bot merge

@tomusdrw tomusdrw added A8-mergeoncegreen and removed A0-please_review Pull request needs code review. labels May 6, 2020
let raw_amount = bond_amount::<T>();
// add twice as much balance to prevent the account from being killed.
let free_amount = raw_amount.saturating_mul(2.into());
T::Currency::make_free_balance_be(&stash, free_amount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note for whoever might read this in the future and want to work on benchmarks: we use this function quite a lot, and it does not change T::Currency::issuance. And we use total issuance in staking's phragmen, and it can cause some very hard to track bugs... so keep that in mind.

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had another brief look and looks okay to me!

@tomusdrw tomusdrw merged commit 80e4417 into master May 6, 2020
@tomusdrw tomusdrw deleted the shawntabrizi-fix-offences-benchmarks branch May 6, 2020 12:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants