Unverified Commit f1d06780 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Hotfix for Kusama (#724)



* cli: revert borked kusama chain on startup

* Docs.

* cli: fix reversal of bork kusama fork

* cli: force always can author

* Version bump

* service: support setting fork blocks in config

* service: add support for bad blocks extension

* service: add badBlocks to kusama chainspec

* Bump Substrate to hotfix version.

* service: add bad block to kusama chain spec

* cleanup kusama hotfix

* add kusama grandpa hotfix

* Bump substrate

* Bump spec_version

* Rebump

* cli: remove unnecessary dependencies

* service: revert can_author_with fix

* service: remove unnecessary method

* Don't try to track polkadot runtime verion yet

* Versions

* service: better grandpa fix detection
Co-authored-by: André Silva's avatarAndré Silva <andre.beat@gmail.com>
parent eac2ae7b
Pipeline #73528 failed with stages
in 7 minutes and 7 seconds
This diff is collapsed.
...@@ -140,11 +140,15 @@ where ...@@ -140,11 +140,15 @@ where
service::new_light::<R, D, E>(config).map_err(|e| format!("{:?}", e))?, service::new_light::<R, D, E>(config).map_err(|e| format!("{:?}", e))?,
exit.into_exit(), exit.into_exit(),
), ),
_ => run_until_exit( _ => {
runtime, service::kusama_chain_hotfix::<R, D>(&config);
service::new_full::<R, D, E>(config).map_err(|e| format!("{:?}", e))?,
exit.into_exit(), run_until_exit(
), runtime,
service::new_full::<R, D, E>(config).map_err(|e| format!("{:?}", e))?,
exit.into_exit(),
)
},
}.map_err(|e| format!("{:?}", e)) }.map_err(|e| format!("{:?}", e))
}), }),
cli::ParseAndPrepare::BuildSpec(cmd) => cmd.run::<NoCustom, _, _, _>(&load_spec), cli::ParseAndPrepare::BuildSpec(cmd) => cmd.run::<NoCustom, _, _, _>(&load_spec),
......
[package] [package]
name = "polkadot-runtime-common" name = "polkadot-runtime-common"
version = "0.7.10" version = "0.7.11"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
...@@ -41,7 +41,7 @@ babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate ...@@ -41,7 +41,7 @@ babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate
randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" } randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" } treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
trie-db = "0.16.0" trie-db = "0.18.0"
serde_json = "1.0.41" serde_json = "1.0.41"
[features] [features]
......
...@@ -68,7 +68,7 @@ libsecp256k1 = "0.3.2" ...@@ -68,7 +68,7 @@ libsecp256k1 = "0.3.2"
tiny-keccak = "1.5.0" tiny-keccak = "1.5.0"
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
trie-db = "0.16.0" trie-db = "0.18.0"
serde_json = "1.0.41" serde_json = "1.0.41"
[build-dependencies] [build-dependencies]
......
...@@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { ...@@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("parity-kusama"), impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2, authoring_version: 2,
spec_version: 1034, spec_version: 1034,
impl_version: 0, impl_version: 1,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
}; };
......
...@@ -66,7 +66,7 @@ libsecp256k1 = "0.3.2" ...@@ -66,7 +66,7 @@ libsecp256k1 = "0.3.2"
tiny-keccak = "1.5.0" tiny-keccak = "1.5.0"
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
trie-db = "0.16.0" trie-db = "0.18.0"
serde_json = "1.0.41" serde_json = "1.0.41"
[build-dependencies] [build-dependencies]
......
...@@ -273,11 +273,8 @@ pallet_staking_reward_curve::build! { ...@@ -273,11 +273,8 @@ pallet_staking_reward_curve::build! {
parameter_types! { parameter_types! {
// Six sessions in an era (24 hours). // Six sessions in an era (24 hours).
// pub const SessionsPerEra: SessionIndex = 6;
pub const SessionsPerEra: SessionIndex = 6; pub const SessionsPerEra: SessionIndex = 6;
// 28 eras for unbonding (28 days). // 28 eras for unbonding (28 days).
// KUSAMA: This value is 1/4 of what we expect for the mainnet, however session length is also
// a quarter, so the figure remains the same.
pub const BondingDuration: staking::EraIndex = 28; pub const BondingDuration: staking::EraIndex = 28;
pub const SlashDeferDuration: staking::EraIndex = 28; pub const SlashDeferDuration: staking::EraIndex = 28;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
......
...@@ -29,8 +29,8 @@ github_label () { ...@@ -29,8 +29,8 @@ github_label () {
} }
# Introduce runtime/polkadot/src/lib.rs once Polkadot mainnet is live.
for VERSIONS_FILE in runtime/kusama/src/lib.rs runtime/polkadot/src/lib.rs for VERSIONS_FILE in runtime/kusama/src/lib.rs
do do
# check if the wasm sources changed # check if the wasm sources changed
if ! git diff --name-only origin/master...${CI_COMMIT_SHA} \ if ! git diff --name-only origin/master...${CI_COMMIT_SHA} \
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
}, },
"consensusEngine": null, "consensusEngine": null,
"forkBlocks": null, "forkBlocks": null,
"badBlocks": [
"0x15b1b925b0aa5cfe43c88cd024f74258cb5cfe3af424882c901014e8acd0d241"
],
"genesis": { "genesis": {
"raw": [ "raw": [
{ {
...@@ -43,6 +43,8 @@ const DEFAULT_PROTOCOL_ID: &str = "dot"; ...@@ -43,6 +43,8 @@ const DEFAULT_PROTOCOL_ID: &str = "dot";
pub struct Extensions { pub struct Extensions {
/// Block numbers with known hashes. /// Block numbers with known hashes.
pub fork_blocks: client::ForkBlocks<polkadot_primitives::Block>, pub fork_blocks: client::ForkBlocks<polkadot_primitives::Block>,
/// Known bad block hashes.
pub bad_blocks: client::BadBlocks<polkadot_primitives::Block>,
} }
/// The `ChainSpec`. /// The `ChainSpec`.
......
...@@ -263,6 +263,57 @@ pub fn kusama_new_full(config: Configuration) ...@@ -263,6 +263,57 @@ pub fn kusama_new_full(config: Configuration)
new_full(config) new_full(config)
} }
pub fn kusama_chain_hotfix<Runtime, Dispatch>(config: &Configuration) where
Dispatch: NativeExecutionDispatch,
Runtime: Send + Sync,
{
use std::str::FromStr;
use sp_blockchain::HeaderBackend;
let client: service::TFullClient<Block, Runtime, Dispatch> =
service::new_full_client(&config).unwrap();
let fork_block = 516510; // target_block - reverted_blocks + 1;
let fork_hash = primitives::H256::from_str(
"15b1b925b0aa5cfe43c88cd024f74258cb5cfe3af424882c901014e8acd0d241",
).unwrap();
let best_number = client.info().best_number;
let target_hash = client.hash(fork_block).unwrap();
if target_hash == Some(fork_hash) {
let diff = best_number.saturating_sub(fork_block - 1);
client.unsafe_revert(diff).unwrap();
}
}
pub fn kusama_grandpa_hotfix<Runtime, Dispatch>(
client: &service::TFullClient<Block, Runtime, Dispatch>,
persistent_data: &mut grandpa::PersistentData<Block>,
) where
Dispatch: NativeExecutionDispatch,
Runtime: Send + Sync,
{
let authority_set = &persistent_data.authority_set;
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(
authority_set.set_id(),
&authority_set.inner().read(),
finalized,
);
persistent_data.set_state = set_state.into();
}
}
/// Builds a new service for a full client. /// Builds a new service for a full client.
pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration) pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
-> Result<impl AbstractService< -> Result<impl AbstractService<
...@@ -315,7 +366,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration) ...@@ -315,7 +366,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
)? )?
.build()?; .build()?;
let (block_import, link_half, babe_link) = import_setup.take() let (block_import, mut link_half, babe_link) = import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed"); .expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
let client = service.client(); let client = service.client();
...@@ -411,7 +462,6 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration) ...@@ -411,7 +462,6 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
let can_author_with = let can_author_with =
consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()); consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone());
let block_import = availability_store.block_import( let block_import = availability_store.block_import(
block_import, block_import,
client.clone(), client.clone(),
...@@ -477,6 +527,11 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration) ...@@ -477,6 +527,11 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
let enable_grandpa = !disable_grandpa; let enable_grandpa = !disable_grandpa;
if enable_grandpa { if enable_grandpa {
kusama_grandpa_hotfix(
&client,
&mut link_half.persistent_data,
);
// start the full GRANDPA voter // start the full GRANDPA voter
// NOTE: unlike in substrate we are currently running the full // NOTE: unlike in substrate we are currently running the full
// GRANDPA voter protocol for all full nodes (regardless of whether // GRANDPA voter protocol for all full nodes (regardless of whether
...@@ -493,6 +548,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration) ...@@ -493,6 +548,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
voting_rule: grandpa::VotingRulesBuilder::default().build(), voting_rule: grandpa::VotingRulesBuilder::default().build(),
executor: service.spawn_task_handle(), executor: service.spawn_task_handle(),
}; };
service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?); service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?);
} else { } else {
grandpa::setup_disabled_grandpa( grandpa::setup_disabled_grandpa(
......
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