Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix on_runtime_upgrade weight recording #7480

Merged
merged 5 commits into from
Nov 3, 2020

Conversation

shawntabrizi
Copy link
Member

@shawntabrizi shawntabrizi commented Nov 2, 2020

This fixes a bug in frame_executive/frame_system where the weight of runtime upgrade logic was not represented in the block.

The issue arises from the following steps:

  • Perform on_runtime_upgrade logic (which updates weight)
  • Initialize block (which clears weight)
  • Process extrinsics and other stuff (starting from weight 0)

This both fixes the bug and optimizes the code such that the weight is locally tracked during the entirety of the initialize_block_impl, and only one storage write is used to update that weight at the end of the function.

This also takes into account the weight of frame_system on_initialize weight, which does not exist right now, but could later.

A test has been added that verifies all weights being tracked in the initialize_block_impl are being recorded correctly.

@shawntabrizi shawntabrizi added A0-please_review Pull request needs code review. B7-runtimenoteworthy C3-medium PR touches the given topic and has a medium impact on builders. labels Nov 2, 2020
frame/executive/src/lib.rs Outdated Show resolved Hide resolved
frame/executive/src/lib.rs Outdated Show resolved Hide resolved
frame/executive/src/lib.rs Show resolved Hide resolved
Copy link
Contributor

@apopiak apopiak left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@shawntabrizi shawntabrizi merged commit b7712fe into master Nov 3, 2020
@shawntabrizi shawntabrizi deleted the shawntabrizi-upgrade-weight branch November 3, 2020 13:11
@apopiak
Copy link
Contributor

apopiak commented Nov 4, 2020

resolves #7427

darkfriend77 pushed a commit to mogwaicoin/substrate that referenced this pull request Jan 11, 2021
* Fix on_runtime_upgrade weight recording

* fix naming

* Update lib.rs

* fix line width

* fix line width again
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C3-medium PR touches the given topic and has a medium impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants