Skip to content

Fix post dispatch weight#851

Merged
sorpaas merged 3 commits intopolkadot-evm:masterfrom
moonbeam-foundation:notlesh-fix-post-dispatch-weight
Sep 20, 2022
Merged

Fix post dispatch weight#851
sorpaas merged 3 commits intopolkadot-evm:masterfrom
moonbeam-foundation:notlesh-fix-post-dispatch-weight

Conversation

@notlesh
Copy link
Contributor

@notlesh notlesh commented Sep 12, 2022

This fixes a bug where weight was not refunded after execution, which meant that the worst-case weight (based on gas_limit) was accounted for in all cases. This change calls Extra::post_dispatch which can invoke CheckWeight::post_dispatch, which will properly refund any extra weight.

Note that this only applies to weight accounting, the currency used for fees was already working as designed.

Thanks to @nbaztec for adding tests.

@notlesh notlesh requested a review from sorpaas as a code owner September 12, 2022 13:13
Copy link
Contributor

@tgmichel tgmichel left a comment

Choose a reason for hiding this comment

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

lgtm, thank you :)

.actual_weight
.unwrap();

let expected_weight = base_extrinsic_weight.saturating_add(post_dispatch_weight);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This implies that we are adding Substrate`s notion of base weight and Ethereum's. I don't believe these should be added in this way, as they both account for the same things (signature verification and basic accounting of fees).

It would be great if we could convince substrate not to include the extrinsic_base_weight...

@sorpaas sorpaas merged commit d3beddc into polkadot-evm:master Sep 20, 2022
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
* Call post_dispatch for CheckedSignature::SelfContained

* add tests

* rename tests

Co-authored-by: Nisheeth Barthwal <nbaztec@gmail.com>
icodezjb pushed a commit to chainx-org/frontier that referenced this pull request Dec 27, 2023
* Call post_dispatch for CheckedSignature::SelfContained

* add tests

* rename tests

Co-authored-by: Nisheeth Barthwal <nbaztec@gmail.com>
(cherry picked from commit d3beddc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants