This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Fix author-inherent, update weight #47
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -117,7 +117,7 @@ pub mod pallet { | |||||
/// but before transactions are executed. | ||||||
// This should go into on_post_inherents when it is ready https://github.com/paritytech/substrate/pull/10128 | ||||||
// TODO better weight. For now we just set a somewhat conservative fudge factor | ||||||
#[pallet::weight((10 * T::DbWeight::get().write, DispatchClass::Mandatory))] | ||||||
#[pallet::weight((3 * T::DbWeight::get().read + 11 * T::DbWeight::get().write, DispatchClass::Mandatory))] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'll revert the weight change so the objective optimization can get in. |
||||||
pub fn kick_off_authorship_validation(origin: OriginFor<T>) -> DispatchResultWithPostInfo { | ||||||
ensure_none(origin)?; | ||||||
|
||||||
|
@@ -132,7 +132,7 @@ pub mod pallet { | |||||
let author = <Author<T>>::get() | ||||||
.expect("Block invalid, no authorship information supplied in preruntime digest."); | ||||||
assert!( | ||||||
T::CanAuthor::can_author(&author, &T::SlotBeacon::slot()), | ||||||
T::CanAuthor::can_author(&author, &slot), | ||||||
"Block invalid, supplied author is not eligible." | ||||||
); | ||||||
|
||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this is a fudge factor, but it seems extremely high. What's the rationale for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was 10 writes before and now it is 11 writes. The
HighestSlotSeen
added 1 more write.I do not know why the fudge factor was 7 writes, it isn't benchmarked so the author (probably @JoshOrndorff ) was presumably being conservative (and just estimating all reads + writes + computation as 10 writes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was me that added that fudge factor, and it was exactly as Amar says. I just wanted something quick and safe that was better than
0
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tricky because it calls the
SlotBeacon
which can have any implementation it wants. I think this problem has been solved in substrate land. It's the problem of weighing functionality that is abstracted behind a trait. How do they do it for all the pallets that depend onCurrency
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true I was assuming T::SlotBeacon::slot() was 1 read. I think this is what most implementations will be in practice.
@girazoki told me it's best to return (ReturnValue, WeightConsumed) in that case for the trait that is getting the value. So we'd need to change the SlotBeacon trait to return this tuple and change the impl to return the weight consumed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am in the process of benchmarking this, I think I have almost everything set except for paritytech/cumulus#1187.