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

Companion for substrate#8724 #2994

Merged
15 commits merged into from
May 26, 2021
Merged

Companion for substrate#8724 #2994

15 commits merged into from
May 26, 2021

Conversation

octol
Copy link
Contributor

@octol octol commented May 7, 2021

Companion for paritytech/substrate#8724

Migrate grandpa pallet to the new storage prefix to support converting the pallet to the new macros

@octol octol added B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. labels May 7, 2021
@github-actions github-actions bot added the A0-please_review Pull request needs code review. label May 7, 2021
@octol octol added E1-database_migration PR introduces code that does a one-way migration of the database. E0-runtime_migration PR introduces code that might require downstream chains to run a runtime upgrade. and removed E1-database_migration PR introduces code that does a one-way migration of the database. labels May 7, 2021
Copy link
Contributor

@thiolliere thiolliere left a comment

Choose a reason for hiding this comment

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

looks good to me

impl frame_support::traits::OnRuntimeUpgrade for GrandpaStoragePrefixMigration {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
use frame_support::traits::PalletInfo;
if let Some(name) = <Runtime as frame_system::Config>::PalletInfo::name::<Grandpa>() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could use expect here as Grandpa is part of pallets in construct_runtime, thus it has been given a name.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could use expect here as Grandpa is part of pallets in construct_runtime, thus it has been given a name.

But this will break the chain if there is something wrong. IMO panic in on_initialize is unrecoverable. Very dangerous code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the proof given is correct, GrandPa is declared in construct_runtime, construct_runtime will implement the PalletInfo and give a name to every pallet, so GrandPa must have a name.
This code path should also have been tested at least one time before going to production.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, that code is correct.
But why not if let Some. Any specific reason?

This is a runtime level custom migration instead #[pallet::hook]. And many other projects will follow this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know, for me the proof makes sense so both are fine.

@octol octol added the D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. label May 20, 2021
Cargo.lock Outdated
Comment on lines 4649 to 4650
version = "3.1.0"
source = "git+https://github.com/paritytech/substrate?branch=jon/migrate-grandpa-pallet-framev2#32ba95b6eac24b79de07bc0e2b64e1f5786c028c"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this to make the substrate PR companion check go green. I hoping here that the cargo update that processbot does when merging will reset this. Otherwise I'll have to revert this before merging the companion

@ghost
Copy link

ghost commented May 26, 2021

Error: Companion update failed: Command 'Command { std: "git" "merge" "origin/master" "--no-ff" "--no-edit", kill_on_drop: false }' failed with status Some(1); output: no output

@andresilva
Copy link
Member

bot merge

@ghost
Copy link

ghost commented May 26, 2021

Waiting for commit status.

@ghost
Copy link

ghost commented May 26, 2021

Merge aborted: Checks failed for 0ccd4b0

@andresilva
Copy link
Member

bot merge

@ghost
Copy link

ghost commented May 26, 2021

Trying merge.

@andresilva
Copy link
Member

bot merge

@ghost
Copy link

ghost commented May 26, 2021

Trying merge.

This pull request was closed.
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. C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. E0-runtime_migration PR introduces code that might require downstream chains to run a runtime upgrade.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants