This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Emit log on Runtime Code change. #9580
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
467aa71
Emit digest item on Runtime Code changes.
tomusdrw 7d89a5b
Merge branch 'master' into td-runtime-digest
tomusdrw 38abfa5
Add tests.
tomusdrw 7123eec
cargo +nightly fmt --all
tomusdrw 947ed2c
Rename.
tomusdrw 33e440e
Add comment.
tomusdrw 717a680
Move generic parameter to the trait.
tomusdrw ed0943d
cargo +nightly fmt --all
tomusdrw 8c03efa
Merge branch 'master' into td-runtime-digest
tomusdrw 6e99b76
Elaborate in doc.
tomusdrw 3897dac
Merge branch 'master' into td-runtime-digest
tomusdrw 4803778
Revert to RuntimeUpdated name
tomusdrw b3df42a
cargo +nightly fmt --all
tomusdrw dadea43
Merge branch 'master' into td-runtime-digest
tomusdrw b403705
Rename to RuntimeEnvironmentUpdated
tomusdrw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,14 @@ pub enum DigestItem<Hash> { | |
|
||
/// Some other thing. Unsupported and experimental. | ||
Other(Vec<u8>), | ||
|
||
/// An indication for the light clients that the runtime execution | ||
/// environment is updated. | ||
/// | ||
/// Currently this is triggered when: | ||
/// 1. Runtime code blob is changed or | ||
/// 2. `heap_pages` value is changed. | ||
RuntimeUpdated, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally wouldn't mind the more accurate name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
/// Available changes trie signals. | ||
|
@@ -184,6 +192,8 @@ pub enum DigestItemRef<'a, Hash: 'a> { | |
ChangesTrieSignal(&'a ChangesTrieSignal), | ||
/// Any 'non-system' digest item, opaque to the native code. | ||
Other(&'a Vec<u8>), | ||
/// Runtime code or heap pages updated. | ||
RuntimeUpdated, | ||
} | ||
|
||
/// Type of the digest item. Used to gain explicit control over `DigestItem` encoding | ||
|
@@ -199,6 +209,7 @@ pub enum DigestItemType { | |
Seal = 5, | ||
PreRuntime = 6, | ||
ChangesTrieSignal = 7, | ||
RuntimeUpdated = 8, | ||
} | ||
|
||
/// Type of a digest item that contains raw data; this also names the consensus engine ID where | ||
|
@@ -225,6 +236,7 @@ impl<Hash> DigestItem<Hash> { | |
Self::Seal(ref v, ref s) => DigestItemRef::Seal(v, s), | ||
Self::ChangesTrieSignal(ref s) => DigestItemRef::ChangesTrieSignal(s), | ||
Self::Other(ref v) => DigestItemRef::Other(v), | ||
Self::RuntimeUpdated => DigestItemRef::RuntimeUpdated, | ||
} | ||
} | ||
|
||
|
@@ -322,6 +334,7 @@ impl<Hash: Decode> Decode for DigestItem<Hash> { | |
DigestItemType::ChangesTrieSignal => | ||
Ok(Self::ChangesTrieSignal(Decode::decode(input)?)), | ||
DigestItemType::Other => Ok(Self::Other(Decode::decode(input)?)), | ||
DigestItemType::RuntimeUpdated => Ok(Self::RuntimeUpdated), | ||
} | ||
} | ||
} | ||
|
@@ -457,6 +470,9 @@ impl<'a, Hash: Encode> Encode for DigestItemRef<'a, Hash> { | |
DigestItemType::Other.encode_to(&mut v); | ||
val.encode_to(&mut v); | ||
}, | ||
Self::RuntimeUpdated => { | ||
DigestItemType::RuntimeUpdated.encode_to(&mut v); | ||
}, | ||
} | ||
|
||
v | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work for Parachains.
Parachains have a special
set_code
implementation that will not update:code
here directly. It will first queue the update and update it when it is allowed by the relay chain.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can I find the queue implementation? Any chance the actual storage write can go through some function that would emit the log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can do this.
https://github.com/paritytech/cumulus/blob/master/pallets/parachain-system/src/lib.rs#L943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've exposed a helper function to update the storage and emit event + log. The idea is that this function will be used by parachain code implementation and is used by the default implementation of
OnSetCode
for unit type.