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

Add assignment keys to session keys, no separate approvals key #2092

Merged
merged 17 commits into from
Dec 11, 2020

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Dec 9, 2020

For Polkadot, Kusama, and Westend, sets up a runtime upgrade to migrate the keys that uses paritytech/substrate#7688.

For Rococo and Test-runtime, we still need to wire it up to the SessionInfo module somehow. That's beyond the scope of this issue in particular.

Unlike we previously thought, we don't need a separate key just for approvals. We can reuse the parachain validation key for this purpose. We'll also use the same key for disputes.

I'll test the migration on a local Westend before marking this ready for review.

@rphmeier rphmeier added A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Dec 9, 2020
@rphmeier rphmeier changed the title Add assignment keys to session keys Add assignment keys to session keys, no separate approvals key Dec 9, 2020
@rphmeier rphmeier marked this pull request as ready for review December 9, 2020 03:14
@github-actions github-actions bot added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Dec 9, 2020
@rphmeier
Copy link
Contributor Author

rphmeier commented Dec 9, 2020

I tested this on a local westend with no issues. I made sure it continued authoring & finalizing beyond the next session change.

@@ -38,7 +38,7 @@ We need two separate keys for the approval subsystem:

- **Approval assignment keys** are sr25519/schnorrkel keys used only for the assignment criteria VRFs. We implicitly sign assignment notices with approval assignment keys by including their relay chain context and additional data in the VRF's extra message, but exclude these from its VRF input.

- **Approval vote keys** would only sign off on candidate parablock validity and has no natural key type restrictions. We could reuse the ed25519 grandpa keys for this purpose since these signatures control access to grandpa, although distant future node configurations might favor separate roles.
- **Approval vote keys** would only sign off on candidate parablock validity and has no natural key type restrictions. There's no need for this to actualy embody a new session key type. We just want to make a distinction between assignments and approvals, although distant future node configurations might favor separate roles. We re-use the same keys as are used for parachain backing in practice.
Copy link
Contributor

Choose a reason for hiding this comment

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

Assignments and approvals need separate keys so that assignments keys can stay on the machine while approvals keys might live on a remote signer.

We employ the same keys for all candidate validity and invalidity statements (approvals, backing, and disputes) because logically these incur similar risks.

Copy link
Contributor Author

@rphmeier rphmeier Dec 9, 2020

Choose a reason for hiding this comment

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

Is there a change in the text you want me to make? I agree with everything you just said

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine I guess. It just confused me on a first reading. What should we actually call them? (candidate) validation keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I called them para_validation keys in the runtime description.

@@ -8,12 +8,13 @@ Helper structs:

```rust
struct SessionInfo {
// validators in canonical ordering.
// validators in canonical ordering. These are the public keys used for backing,
// dispute participation, and approvals.
validators: Vec<ValidatorId>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes exactly.

@rphmeier
Copy link
Contributor Author

rphmeier commented Dec 9, 2020

I've tested a local rococo testnet with adder-collator; parachain consensus functions as expected.

@@ -90,7 +90,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2,
spec_version: 2027,
spec_version: 2028,
Copy link
Member

Choose a reason for hiding this comment

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

the latest released version is on 2026, right?
https://github.com/paritytech/polkadot/blob/v0.8.26-1/runtime/kusama/src/lib.rs#L91
is the assumption that this will be merged after 0.8.27 branches off?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @s3krit - I believe there's a release queued up currently and we want this to go into the next one. Let me know what I should be doing with the version numbers here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct. We have already branched off for v0.8.27, so if your intent is for this change to go into v0.8.28 (i.e., the release after v0.8.27, barring any security releases), this looks right

let mut id = AssignmentId::default();
let id_raw: &mut [u8] = id.as_mut();
id_raw.copy_from_slice(v.as_ref());
id_raw[0..5].copy_from_slice(b"assgn");
Copy link
Member

Choose a reason for hiding this comment

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

where does assgn come from? KeyTypeId is defined as asgn:

pub const ASSIGNMENT_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"asgn");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only goal of this section is uniqueness per validator and independence from other session keys, which we achieve by combining the (unique) ValidatorId with the text 'assgn'`. I've now changed this to 'asgn' for consistency, although it will not affect observed behavior in any meaningful way.

@@ -158,6 +158,35 @@ impl<T: pallet_session::Config>
fn on_disabled(_: usize) { }
}

/// A placeholder since there is currently no provided session key handler for parachain validator
Copy link
Member

Choose a reason for hiding this comment

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

can be replaced by SessionInfo I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet everywhere, but in the long term. This struct is used in the polkadot, kusama, westend runtimes where we don't yet enable parachain runtime modules.

@rphmeier rphmeier merged commit 6701f77 into master Dec 11, 2020
@rphmeier rphmeier deleted the rh-add-assignments-keys branch December 11, 2020 02:30
Copy link
Member

@bkchr bkchr 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, just one question.

Sorry for being late.

im_online: old.im_online,
para_validator: old.para_validator,
para_assignment: {
// We need to produce a dummy value that's unique for the validator.
Copy link
Member

Choose a reason for hiding this comment

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

DQ: Why does that needs to be unique?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The underlying reason is that frame-session has a KeyOwner: map (KeyTypeId, [u8]) -> ValidatorId. This map requires validators to have unique session keys. From the perspective of this PR, the reason is that upgrade_keys has documented that validators' keys must be unique after the upgrade.

@@ -1208,7 +1247,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
FixCouncilHistoricalVotes,
Copy link
Contributor

@kianenigma kianenigma Dec 17, 2020

Choose a reason for hiding this comment

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

This PR has mistakenly removed this migration from the next release, while it has not be applied yet. Should have used a tuple of both.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh or we already have branched v27? then it is okay.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay -- sorry, it is in the 27 release. Then there are two questions:

  1. is there a way to make it possible for this to also be noted in the release note? I first checked there and didn't find it, and then I checked the branch and it was there. cc @s3krit

  2. Why is the struct definition not removed? :p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let's add it to the v28 release notes.

"Includes a runtime migration to update session key types to be used for parachain validation and approval. All validators are encouraged to rotate their session keys following the upgrade."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants