-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Conversation
/// `hrmp_max_parathread_outbound_channels` can be set to. | ||
/// | ||
/// This is used for benchmarking sanely bounding relevant storage items. | ||
type HrmpMaxOutboundChannelsBound: Get<u32>; |
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.
Long term, I don't think this patter is good. We probably will need to add a lot of bound types here, one for each field of HostConfigurations
. I don't see it within the scope of this PR, but if we go down that road, it is probably worthwhile to abstract all of these types into one new type, maybe called struct HostConfigurationBounds
and only use that to minimize the footprint in the interface.
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.
Also, note that for simplicity, for now I have combined the parachain and parathread variant. This might help us use BoundedVec
in some places as well, but that didn't work out.
runtime/kusama/src/lib.rs
Outdated
@@ -1134,6 +1134,8 @@ impl parachains_origin::Config for Runtime {} | |||
|
|||
impl parachains_configuration::Config for Runtime { | |||
type WeightInfo = weights::runtime_parachains_configuration::WeightInfo<Runtime>; | |||
type HrmpMaxOutboundChannelsBound = ConstU32<128>; | |||
type HrmpMaxInboundChannelsBound = ConstU32<128>; |
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.
rather arbitrary numbers.
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 looks fine, assuming the formatting changes will be reverted.
PS: For the future, I would really appreciate if a PR didn't include so much formatting. It complicates reviewing as it takes effort to see what actually requires attention.
Yeah, I am having some weird issues with cargo fmt: #3876 (comment). Only ones that I did fix intentionally was that your comments were sometimes were not wrapped at |
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.
Ah, actually, I also assumed that comments underwent some kind of automatic formatting.
I am really sensitive about the line width and never go over 120. The ones you wrapped looked more like they were 100, which I believe is fine to do occasionally, if that improves reading experience. In some instances it is fine and I do not feel strongly, but in others (I mentioned them below) I do.
Fixed your feedbacks, indeed my fixings (which where done with a plugin, not manually) made a few things a bit unclear. And indeed I try and enforce 100 where possible, what I said earlier about 120 was wrong. |
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.
Changes look reasonable to me, I did not do a deep dive on the parameterization logic of the actual benchmarking code.
Co-authored-by: Zeke Mostov <[email protected]>
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.
A couple of fixes and good to go
pub fn force_process_hrmp_open(origin: OriginFor<T>) -> DispatchResult { | ||
/// | ||
/// Total number of opening channels must be provided as witness data of weighing. | ||
#[pallet::weight(<T as Config>::WeightInfo::force_process_hrmp_open(*_channels))] |
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 appears to be not checked. Do you think this right? It also applies to other places above and below.
In any case, this looks weird for reviewers/auditors and as such required a comment.
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 is not checked because it is coming from root origin and it is assumed to be correct, but I could easily add that, but IMO it is just noise. It will clutter both the dispatch code and the error variant.
About the comment, if you look around Frame, this a pretty common patter, where some additional data needs to be passed to the dispatch, sometime not really used other than checked for correctness, just to measure the weight of some transaction ahead of time and have efficient pool processing. These are typically called "witness data".
@@ -1005,6 +1020,7 @@ pub mod pallet { | |||
new: u32, | |||
) -> DispatchResult { | |||
ensure_root(origin)?; | |||
ensure!(new <= T::HrmpMaxOutboundChannelsBound::get(), Error::<T>::InvalidNewValue); |
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.
ensuring the conditions in setters are now discouraged in favor of checking it centrally in fn check_consistency
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 settled this in e22a79f, LMK what you think.
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.
So, I will also change this in Ump? #3889
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 missed your comment... ༼ ༎ຶ ෴ ༎ຶ༽
But that seems to be the same cases
// ingress channels to a single leaving parachain that need to be closed. | ||
let i in 0 .. (<T as configuration::Config>::HrmpMaxInboundChannelsBound::get() - 1); | ||
// egress channels to a single leaving parachain that need to be closed. | ||
let e in 0 .. (<T as configuration::Config>::HrmpMaxOutboundChannelsBound::get() - 1); |
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.
Just out of my inexperience: why do we check it for every variable and just not once for the bound const variable?
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.
(if I have understood your question correctly:) We want the benchmarking machinery to tell us the dependency on i
and e
, for which you need to run the benchmark in a range of values for both i
and e
. The final outcome of this would be fn(i, e) -> weight
.
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.
But why do we want us to tell the dependency on those? i
and e
are constants anyway?
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.
their upper bound is constant and we happen to use that here as well, If you see where T::WeightInfo::force_clean_hrmp
is being called, these two parameters need to be provided (similar to the other comment, it is a root call and we expect root to give a proper estimate of the witness data)
let channel_id = HrmpChannelId { sender, recipient }; | ||
assert_ok!(Hrmp::<T>::hrmp_close_channel(sender_origin.clone().into(), channel_id)); | ||
if matches!(until, ParachainSetupStep::CloseRequested) { | ||
// NOTE: this is just for expressiveness, otherwise the if-statement is 100% useless. |
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.
Nit: This function has an obvious code pattern which makes this comment superfluous. It does not harm though.
from: u32, | ||
to: u32, | ||
until: ParachainSetupStep, | ||
) -> [(ParaId, crate::Origin); 2] |
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.
Nit: You probably know what I am going to say about this.
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.
In fact I don't, enlighten me please.
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.
Use a tuple instead and/or define a helper struct :)
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.
What is the rationale? an array of two is perfectly fine in my opinion and practically synonym to a tuple of two in my head.
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.
Sorry, I assumed too much.
While I think an array of two is definitely uncommon in such cases, and by default I would expect a tuple in cases like this. However, I agree it's more or less synonymous (It seems a bit novel and I even like it a bit compared to a tuple, because you use different brackets for the outer and inner items)
I, however, meant to propose to use a struct instead of the array. The inner tuples are OK since they are at least typed. That has an advantage that you fix names in one place — at the declaration side compared to the each place (which promotes consistency). Names are a bit better in this setting compared to indices:
What's more clear to refer the recipient, a field named recipient
or an element at index 1
?
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.
👍
…used for benchmarks as well.
/// Maximum number of HRMP outbound channels exceeded. | ||
MaxHrmpOutboundChannelsExceeded, | ||
/// Maximum number of HRMP inbound channels exceeded. | ||
MaxHrmpInboundChannelsExceeded, |
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.
Nit: mention the value for consistency with other similar variants?
bot merge |
Waiting for commit status. |
* wip template for hrmp benchmarks * add all of the benchmarks, first draft * File was not saved :/ * cargo +nightly fmt * Use configs * add configs * Fix rococo * Final touches * revert fmt changes, one last time * Fix wrappings * Fix a bunch of tests * cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_parachains::hrmp --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_parachains_hrmp.rs * add to westend * actually use everything * cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_parachains::hrmp --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_parachains_hrmp.rs * Update runtime/parachains/src/hrmp.rs Co-authored-by: Keith Yeung <[email protected]> * use real weight in wnd * reorg * minor cleanup * weigh some of the internal stuff as well * cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_parachains::hrmp --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_parachains_hrmp.rs * cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_parachains::hrmp --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_parachains_hrmp.rs * add files * Master.into() * add validation * fmt * fmt * final fixes * all runtimes build * undo formatting * Update runtime/parachains/src/hrmp.rs Co-authored-by: Zeke Mostov <[email protected]> * non-controversial changes * do it the parachain-way: use const instead of type configs for simplicity. * borrow assert_storage_consistency_exhaustive * move assert_storage_consistency_exhaustive to Pallet, so it can be reused for benchmarks as well. * fix typo Co-authored-by: Parity Bot <[email protected]> Co-authored-by: Keith Yeung <[email protected]> Co-authored-by: Sergey Shulepov <[email protected]> Co-authored-by: Zeke Mostov <[email protected]>
as you see, nothing is done, just opening a PR to signal that I will work on this and prevent overlap.
part of #3850