Implement validator sessions pallets #233
Merged
+1,620
−25
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.
Pull Request
Checklist
PR Type
Please delete options that are irrelevant.
Linked tickets
https://digicatapult.atlassian.net/browse/SQNC-95
High level description
Adds
pallet_session
andpallet_validator_set
to runtimeDetailed description
We need to be able to modify the validator set of a live chain and rotate keys for existing validators. This change is the first step in that journey.
First this PR adds
pallet_session
to the runtime andpallet_validator_set
(forked from https://github.com/gautamdhameja/substrate-validator-set) to the runtime. Note however that we cannot for the live chain configure this with a new genesis as the prod chain is already live. To work around this we need to add the pallets and then run transactions to ensure that the validator set and and keys are set correctly.As we cannot guarentee that this happens before a session change we need to ensure that the existing validator set is maintained even though the session currently has no validators. We do this by hijacking the
SessionHandler
implementation to always use the existing keys as fetched fromBabe
andGrandpa
. See the structSessionHandlerBaitAndSwitch
.A future PR will remove
SessionHandlerBaitAndSwitch
and replace theSessionHandler
with<opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders
which then correctly passes through the new validators toBabe
andGrandpa
.To test this I've performed the following procedure in a local chain in a docker compose running
Alice
,Bob
,Charlie
andEve
:3e6bd7d3cec7139f5f2bc362ddddac5261326a4a
1132
d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee
with proof0x00
d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
d17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69
with proof0x00
90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22
439660b36c6c03afafca027b910b4fecf99801834c62a5e6006f27d978de234f
with proof0x00
e659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e
1dfe3e22cc0d45c70779c1095f7489a8ef3cf52d62fbd8c2fa38c9f1723502b5
with proof0x00
1133
which removesSessionHandlerBaitAndSwitch
and setstype SessionHandler = <opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
Describe alternatives you've considered
The
SessionHandlerBaitAndSwitch
is obviously a bit of a hack. I considered several alternatives but all would have required further changes down the line. The main issue is the way Babe interacts with session.Operational impact
As with all node upgrades this needs to be applied incrementally. First we should upgrade the nodes. Once done we can then safely upgrade the runtime in prod to this runtime and finally add in the validator identities. This will require a procedure to be written.
Additional context
N/A