Skip to content
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

Fix post dispatch weight #851

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.

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 <[email protected]>
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 <[email protected]>
(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