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

Events from on_runtime_upgrade are unavailable #10603

Closed
xlc opened this issue Jan 7, 2022 · 1 comment · Fixed by #10620
Closed

Events from on_runtime_upgrade are unavailable #10603

xlc opened this issue Jan 7, 2022 · 1 comment · Fixed by #10620
Labels
I7-refactor Code needs refactoring.

Comments

@xlc
Copy link
Contributor

xlc commented Jan 7, 2022

on_runtime_upgrade hook is executed before initialize and which initialize fields like block number as well as kill all the events from previous block. This means events from on_runtime_upgrade are also removed by initialize.

This makes debugging harder as well as make events incomplete. It will not be possible to observe changes by only look at events.

I can see reason why it is executed before initialize but most of the time, the reason doesn't apply and that means code from on_runtime_upgrade will have no event, read old block number, read bad execution phase, etc.

@bkchr
Copy link
Member

bkchr commented Jan 7, 2022

The idea would be to move these lines of code:
https://github.com/paritytech/substrate/blob/master/frame/system/src/lib.rs#L1323-L1327

That is currently being called here:
https://github.com/paritytech/substrate/blob/master/frame/executive/src/lib.rs#L301-L306

Above these lines here:
https://github.com/paritytech/substrate/blob/master/frame/executive/src/lib.rs#L298-L300

I think the best would probably be to create a special clear_events functions this would then be called inside Executive. We should then also be able to drop the InitKind enum because we can control from the outside when the events are being cleared.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I7-refactor Code needs refactoring.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants