mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 21:21:03 +00:00
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: Gavin Wood <github@gavwood.com>
This commit is contained in:
Generated
+2
@@ -5046,6 +5046,8 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
||||||
|
|
||||||
name = "sc-peerset"
|
name = "sc-peerset"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#2223fed56a3729ea1ff7e9d6cf6189ecceaf581c"
|
source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#2223fed56a3729ea1ff7e9d6cf6189ecceaf581c"
|
||||||
|
|||||||
@@ -294,20 +294,50 @@ pub fn kusama_grandpa_hotfix<Runtime, Dispatch>(
|
|||||||
Dispatch: NativeExecutionDispatch,
|
Dispatch: NativeExecutionDispatch,
|
||||||
Runtime: Send + Sync,
|
Runtime: Send + Sync,
|
||||||
{
|
{
|
||||||
|
use std::str::FromStr;
|
||||||
|
use sp_blockchain::HeaderBackend;
|
||||||
|
|
||||||
let authority_set = &persistent_data.authority_set;
|
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 = {
|
let finalized = {
|
||||||
use sp_blockchain::HeaderBackend;
|
|
||||||
let info = client.info();
|
let info = client.info();
|
||||||
(info.finalized_hash, info.finalized_number)
|
(info.finalized_hash, info.finalized_number)
|
||||||
};
|
};
|
||||||
|
|
||||||
let canon_finalized_height = 516509;
|
// our finalized block is lower than the fork block, nothing to do
|
||||||
if authority_set.set_id() == 235 && finalized.1 == canon_finalized_height {
|
if finalized.1 < canon_finalized_block {
|
||||||
let set_state = grandpa::VoterSetState::<Block>::live(
|
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(),
|
authority_set.set_id(),
|
||||||
|
grandpa_reset_round,
|
||||||
&authority_set.inner().read(),
|
&authority_set.inner().read(),
|
||||||
finalized,
|
(canon_finalized_hash, canon_finalized_block),
|
||||||
);
|
);
|
||||||
|
|
||||||
persistent_data.set_state = set_state.into();
|
persistent_data.set_state = set_state.into();
|
||||||
|
|||||||
Reference in New Issue
Block a user