Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,12 @@ pub mod pallet {
vfp.relay_parent_number,
));

Ok(PostDispatchInfo { actual_weight: Some(total_weight), pays_fee: Pays::No })
frame_system::Pallet::<T>::register_extra_weight_unchecked(
total_weight,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume we don't know an upper bound for this value pre-dispatch because it is calculated ad-hoc?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes but it's once per block and we register the weight, meaning it will be correctly accounted for in the following transactions.

If we go with the worst case weight here before dispatching, we might greatly underestimate the block space we have since those stuctures in ParachainInherentData can grow a lot as far as I'm aware. This model works best IMO.

DispatchClass::Mandatory,
);

Ok(Pays::No.into())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: You can change the return type of the dispatchable to just DispatchResult.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done in e988d2b

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it make a difference here if we just return this vs Ok(PostDispatchInfo { actual_weight: Some(total_weight), pays_fee: Pays::No })? It would look more correct to me

Copy link
Copy Markdown
Member

@athei athei Jan 24, 2025

Choose a reason for hiding this comment

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

That is what we were doing before (this PR removes this line) and it was incorrect. This is because you cant (or should not) return a post dispatch weight that is higher than the pre dispatch weight. It will not be charged. Hence the error that was emitted by try runtime.

}

#[pallet::call_index(1)]
Expand Down
11 changes: 11 additions & 0 deletions prdoc/pr_7327.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Correctly register the weight n `set_validation_data` in `cumulus-pallet-parachain-system`

doc:
- audience: Runtime Dev
description: |
The actual weight of the call was register as a refund, but the pre-dispatch weight is 0,
and we can't refund from 0. Now the actual weight is registered manually instead of ignored.

crates:
- name: cumulus-pallet-parachain-system
bump: patch