-
Notifications
You must be signed in to change notification settings - Fork 732
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
Include extrinsics len in PoV size #193
Comments
We only need to take this into account when building the block and when calculating the resulting weight i think. |
Yeah that should be enough! Could probably be done as part of |
Actually I think for standalone chains like the relay chain we even have to only track extrinsic.encoded_len() and no storage proof size. Otherwise if we take the size/storage proof weight into account we would underutilize the available block length. |
The DotSama relay chains have |
Yeah and the block size is already tracked independently here: https://github.com/paritytech/substrate/blob/2bf16d831b777d3c44445d869689a66f0c0e64c6/frame/system/src/extensions/check_weight.rs#L73-L86 |
That does not help at all. If we are still accounting proof size in the proof size weight, then we cannot use it for tracking block size - and would not know when a block becomes overweight with regards to size/length. |
Copying over my response from the other ticket: To me this does not look like it would apply to inherents? But even if it did (does it?) it would actually make matters worse, because if would drop all of paras inherent at a hard boundary. So we would need to check size internally even more precisely then. |
Inherents are just normal (unsigned) extrinsics and this also applies to them: https://github.com/paritytech/substrate/blob/057f2afd686dceb48c08d8a31f35b338bb5992d3/frame/system/src/extensions/check_weight.rs#L206-L212
Not sure what you mean by "internally", but yes. I mean you could do these checks inside |
To me it sounds like, if we do the "proof size weight" proper (name should probably be adjusted then), then we already pretty much have the mechanism in place I was suggesting, but actually better. Because we already do filtering on weight, so in theory if I get benchmarks to work correctly for candidate receipts and we have proof size weights which take into account block size (and only that for standalone chains), then the code that is already there would already have the desired effect: Perfect, just seems to be the right solution to me! The code we have, queries what is the remaining available weight and then filters out stuff to fit things in. With weights also taking into account size, that code already does all we need. Shouldn't be to hard to ignore actual proof size for standalone chains? |
I think I proposed this at some point, by making the size an option and set it to |
Let's see whether I understand this correctly:
Did I get this correctly? If so, I am still unsure why we would want to use u64::Max and not 0? Sounds more correct and safer to me. E.g. if we had a bug in benchmarking and used block size was 0, then we would always be overweight. So I think, I am absolutely not getting what you actually mean. 😬 |
Tried this a while back, but it resulted in a large breaking change where all downstream chains would have to change how they construct their
The limit is set to |
Ok, that was my initial understanding - that you are talking about the limit, but given @bkchr comment I wasn't so sure anymore. The problem is for our use case, just setting the limit to If we keep tracking the size for the non existing proof for standalone chains, then the second weight component is totally useless here. While if we tracked correctly, it would be very valuable and useful in maintaining the security of the chain. |
I also quite don't get how not adding the proof size in benchmarks (but only counting extrinisic length) for standalone chains should break any parachain. I am specifically talking about benchmarks. If we benchmark a call for a parachain runtime we get for the second weight component:
While for the relay chain we would get:
The limits for a parachain would be the PoV size limit. For the relay chain it would be the maximum block size. |
Does this make sense? At least for parachain consensus we do have a couple of things which can be large in size and we need a proper way to ensure we are not producing blocks exceeding the block size limit. |
With "things" do you mean dispatchables? So you have a point in the code where you have The |
Yes it would not be benchmarked, the generated code would just call |
Okay that makes more sense, thanks.
I dont think there is a good way around this though. Even if we include it in the |
Oh shoot, I remembered wrongly. Indeed we are already using a wrapper function that takes the actual argument and not the u32 parameters. Indeed since all we have is the u32 values in the WeightInfo functions, we would need to benchmark, which is kinda stupid. I think I will just override the second weight component in the wrapper function, since we don't care about proof size anyway. Feels a bit hacky, but let's see how it goes. |
I found this issue while thinking about how to manage Weight v2 in frontier and moonbeam. I think the optimal solution is to have two different CheckWeight implementations for the sovereign chain and for the parachains. The solution which would consist in integrating the size of the tx in the benchmarks does not suit us for frontier, because in frontier we not have benchmarks (we accounting resources usage dynamically). |
Seem's to be fixed by #4326 |
Yes! :D Ty @librelois for reminding me. |
With WeightsV2 and storage proof tracking we will also need to take the encoded extrinsics length into account. The point being that the actual PoV size is the size of the block header, the extrinsics and the storage proof.
As we also should include the header, we could use the length of an empty encoded header plus the the size of the digests.
CC @ggwpez
The text was updated successfully, but these errors were encountered: