-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NoOp Impl Polling Trait #5311
NoOp Impl Polling Trait #5311
Conversation
@Doordashcon do you have any reasoning for this? |
@bkchr just a follow up on this? |
The comment is saying that this no-op should be implemented on |
Implemented |
@Doordashcon can you please fix it as done in this pr #3049? |
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.
Generally looking good, just some nitpicks
@@ -139,7 +139,7 @@ pub struct TrackInfo<Balance, Moment> { | |||
/// Information on the voting tracks. | |||
pub trait TracksInfo<Balance, Moment> { | |||
/// The identifier for a track. | |||
type Id: Copy + Parameter + Ord + PartialOrd + Send + Sync + 'static + MaxEncodedLen; | |||
type Id: Copy + Parameter + Ord + PartialOrd + Send + Sync + 'static + MaxEncodedLen + Default; |
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.
Why do we need Default
?
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.
Id
-----> tracks, tracks -----> classes in pallet_referenda
's implementation of the Polling
trait.
polkadot-sdk/substrate/frame/referenda/src/lib.rs
Lines 750 to 752 in c987da3
fn classes() -> Vec<Self::Class> { | |
T::Tracks::tracks().iter().map(|x| x.0).collect() | |
} |
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 a breaking change (major bump in the prdoc), since it can break existing code.
If it is something that is only needed for benchmarking, then the benchmark can use a where clause to only work if the Id is Default, but not requiring it on the trait itself. (the trait does not care about benchmarks).
For example like here:
<T as Config>::MaxMessagePayloadSize: Get<u32>, |
It is known that both extrinsics each involve a single read operation. This can be manually accounted for, rather than relying on the default value for a non existent class. Would you agree with this approach @bkchr? let class_exists = T::Polls::classes().into_iter().next().is_some();
let class = if class_exists {
T::Polls::classes().into_iter().next().unwrap() // Assuming there's at least one class here
} else {
return Err(BenchmarkError::Override(BenchmarkResult::from_weight(
T::DbWeight::get().reads(1),
)));
}; |
See this. |
please review @bkchr I saw no other way to create an invalid poll for a NoOp Poll than adding |
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.
Going to approve since am async, but could still be worth to try and remove the additional added requirements in the traits.
Thanks for the benchmarking tip @ggwpez should be ready to merge now! |
9f603b1
Adds NoOp implementation for the
Polling
trait and updates benchmarks inpallet-ranked-collective
.