Aura: Adds some compatibility mode to support old chains (#12492)

* Aura: Adds some compatibility mode to support old chains

In https://github.com/paritytech/substrate/pull/9132 we changed the way how we get the authorities
from the runtime. Before this mentioned pr we would call `initialize_block` before calling the
authorities runtime function. The problem with this was that when you have a block X that would
switch the authority set, it would already be signed by an authority of the new set. This was wrong,
as a block should only be signed by the current authority set. As this change is a hard fork, this
pr brings back the possibility for users that have a chain running with this old logic to upgrade.

They will need to use:
```
CompatibilityMode::UseInitializeBlock { until: some_block_in_the_future }
```

Using this compatibility mode will make the node behave like the old nodes, aka calling
`initialize_block` before doing the actual runtime call to `authorities`. Then when the given
`until` block is being build/imported the node switches to the new behaviour of not calling
`initialize_block` before. This is a hard fork, so the `until` block should be chosen wisely as a
point where all nodes in the network have upgraded.

* Fixes

* Make docs ready

* Update client/consensus/aura/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update client/consensus/aura/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Update client/consensus/aura/src/lib.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* FMT

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Bastian Köcher
2022-10-28 15:25:49 +02:00
committed by GitHub
parent ca779b36da
commit 33b61f0e03
5 changed files with 147 additions and 58 deletions
@@ -641,7 +641,7 @@ where
if state_root != *import_headers.post().state_root() {
// State root mismatch when importing state. This should not happen in
// safe fast sync mode, but may happen in unsafe mode.
warn!("Error imporing state: State root mismatch.");
warn!("Error importing state: State root mismatch.");
return Err(Error::InvalidStateRoot)
}
None