Commit 255697f2 authored by André Silva's avatar André Silva Committed by Gavin Wood
Browse files

service: reset grandpa into a future round (not past) (#726)



* service: reset grandpa into a future round (not past)

* update substrate version

* service: create grandpa reset round variable

* service: fine grained grandpa reset on startup
Co-authored-by: default avatarGavin Wood <github@gavwood.com>
parent 96f95bdf
Pipeline #73565 canceled with stages
in 6 minutes and 43 seconds
......@@ -5046,6 +5046,8 @@ dependencies = [
]
[[package]]
name = "sc-peerset"
version = "2.0.0"
source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#2223fed56a3729ea1ff7e9d6cf6189ecceaf581c"
......
......@@ -294,20 +294,50 @@ pub fn kusama_grandpa_hotfix<Runtime, Dispatch>(
Dispatch: NativeExecutionDispatch,
Runtime: Send + Sync,
{
use std::str::FromStr;
use sp_blockchain::HeaderBackend;
let authority_set = &persistent_data.authority_set;
let last_completed_round = persistent_data.set_state
.read()
.last_completed_round()
.number;
let canon_finalized_block = 516509;
let canon_finalized_hash = primitives::H256::from_str(
"f432b7655a848094e6c67f8064ea642bd18f5cf184e1cf9f05a1a9886dd8b9cc",
).unwrap();
let finalized = {
use sp_blockchain::HeaderBackend;
let info = client.info();
(info.finalized_hash, info.finalized_number)
};
let canon_finalized_height = 516509;
if authority_set.set_id() == 235 && finalized.1 == canon_finalized_height {
let set_state = grandpa::VoterSetState::<Block>::live(
// our finalized block is lower than the fork block, nothing to do
if finalized.1 < canon_finalized_block {
return;
}
// we have finalized past the fork block, we need to make sure we're on the
// correct fork (should be guaranteed by the previous chain revert)
if finalized.1 >= canon_finalized_block {
assert_eq!(
client.hash(canon_finalized_block).unwrap().unwrap(),
canon_finalized_hash,
);
}
// assuming the previous preconditions, if we are in any previous grandpa
// round then we restart at the given reset round.
let grandpa_reset_round = 999999;
if authority_set.set_id() == 235 &&
last_completed_round < grandpa_reset_round
{
let set_state = grandpa::VoterSetState::<Block>::live_at(
authority_set.set_id(),
grandpa_reset_round,
&authority_set.inner().read(),
finalized,
(canon_finalized_hash, canon_finalized_block),
);
persistent_data.set_state = set_state.into();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment