sc-consensus-beefy: graceful support for pallet-beefy reset (#14217)

BEEFY consensus can be restarted by resetting "genesisBlock" in
pallet-beefy, but we don't want to also reset authority set IDs so
that they are uniquely identified across the entire chain history
regardless of how many times BEEFY consensus has been reset/restarted.

This is why the client now also accepts initial authority_set_id != 0.

BEEFY client now detects pallet-beefy reset/reinit and errors-out and
asks for a restart.
BEEFY client persisted state should be discarded on client restarts
following pallet-beefy reset/reinit.

End result is BEEFY client/voter can now completely reinitialize using
"new" on-chain info following pallet-beefy reset/reinit, discarding old state.

Fixes #14203
Fixes #14204

Signed-off-by: acatangiu <adrian@parity.io>
This commit is contained in:
Adrian Catangiu
2023-05-25 15:16:37 +03:00
committed by GitHub
parent 4185a213ac
commit b907f52066
7 changed files with 141 additions and 59 deletions
@@ -18,7 +18,7 @@
//! BEEFY gadget specific errors
//!
//! Used for BEEFY gadget interal error handling only
//! Used for BEEFY gadget internal error handling only
use std::fmt::Debug;
@@ -34,6 +34,8 @@ pub enum Error {
Signature(String),
#[error("Session uninitialized")]
UninitSession,
#[error("pallet-beefy was reset, please restart voter")]
ConsensusReset,
}
#[cfg(test)]
@@ -45,6 +47,7 @@ impl PartialEq for Error {
(Error::RuntimeApi(_), Error::RuntimeApi(_)) => true,
(Error::Signature(s1), Error::Signature(s2)) => s1 == s2,
(Error::UninitSession, Error::UninitSession) => true,
(Error::ConsensusReset, Error::ConsensusReset) => true,
_ => false,
}
}