mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
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 <andre.beat@gmail.com>
This commit is contained in:
Generated
+127
-142
File diff suppressed because it is too large
Load Diff
@@ -140,11 +140,15 @@ where
|
||||
service::new_light::<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(),
|
||||
),
|
||||
_ => {
|
||||
service::kusama_chain_hotfix::<R, D>(&config);
|
||||
|
||||
run_until_exit(
|
||||
runtime,
|
||||
service::new_full::<R, D, E>(config).map_err(|e| format!("{:?}", e))?,
|
||||
exit.into_exit(),
|
||||
)
|
||||
},
|
||||
}.map_err(|e| format!("{:?}", e))
|
||||
}),
|
||||
cli::ParseAndPrepare::BuildSpec(cmd) => cmd.run::<NoCustom, _, _, _>(&load_spec),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "polkadot-runtime-common"
|
||||
version = "0.7.10"
|
||||
version = "0.7.11"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
@@ -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" }
|
||||
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" }
|
||||
trie-db = "0.16.0"
|
||||
trie-db = "0.18.0"
|
||||
serde_json = "1.0.41"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -68,7 +68,7 @@ libsecp256k1 = "0.3.2"
|
||||
tiny-keccak = "1.5.0"
|
||||
keyring = { package = "sp-keyring", 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"
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
@@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
impl_name: create_runtime_str!("parity-kusama"),
|
||||
authoring_version: 2,
|
||||
spec_version: 1034,
|
||||
impl_version: 0,
|
||||
impl_version: 1,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ libsecp256k1 = "0.3.2"
|
||||
tiny-keccak = "1.5.0"
|
||||
keyring = { package = "sp-keyring", 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"
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
@@ -273,11 +273,8 @@ pallet_staking_reward_curve::build! {
|
||||
|
||||
parameter_types! {
|
||||
// Six sessions in an era (24 hours).
|
||||
// pub const SessionsPerEra: SessionIndex = 6;
|
||||
pub const SessionsPerEra: SessionIndex = 6;
|
||||
// 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 SlashDeferDuration: staking::EraIndex = 28;
|
||||
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
|
||||
|
||||
@@ -29,8 +29,8 @@ github_label () {
|
||||
}
|
||||
|
||||
|
||||
|
||||
for VERSIONS_FILE in runtime/kusama/src/lib.rs runtime/polkadot/src/lib.rs
|
||||
# Introduce runtime/polkadot/src/lib.rs once Polkadot mainnet is live.
|
||||
for VERSIONS_FILE in runtime/kusama/src/lib.rs
|
||||
do
|
||||
# check if the wasm sources changed
|
||||
if ! git diff --name-only origin/master...${CI_COMMIT_SHA} \
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
},
|
||||
"consensusEngine": null,
|
||||
"forkBlocks": null,
|
||||
"badBlocks": [
|
||||
"0x15b1b925b0aa5cfe43c88cd024f74258cb5cfe3af424882c901014e8acd0d241"
|
||||
],
|
||||
"genesis": {
|
||||
"raw": [
|
||||
{
|
||||
|
||||
@@ -43,6 +43,8 @@ const DEFAULT_PROTOCOL_ID: &str = "dot";
|
||||
pub struct Extensions {
|
||||
/// Block numbers with known hashes.
|
||||
pub fork_blocks: client::ForkBlocks<polkadot_primitives::Block>,
|
||||
/// Known bad block hashes.
|
||||
pub bad_blocks: client::BadBlocks<polkadot_primitives::Block>,
|
||||
}
|
||||
|
||||
/// The `ChainSpec`.
|
||||
|
||||
@@ -263,6 +263,57 @@ pub fn kusama_new_full(config: Configuration)
|
||||
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.
|
||||
pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
|
||||
-> Result<impl AbstractService<
|
||||
@@ -315,7 +366,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
|
||||
)?
|
||||
.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");
|
||||
|
||||
let client = service.client();
|
||||
@@ -411,7 +462,6 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
|
||||
let can_author_with =
|
||||
consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
|
||||
let block_import = availability_store.block_import(
|
||||
block_import,
|
||||
client.clone(),
|
||||
@@ -477,6 +527,11 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
|
||||
|
||||
let enable_grandpa = !disable_grandpa;
|
||||
if enable_grandpa {
|
||||
kusama_grandpa_hotfix(
|
||||
&client,
|
||||
&mut link_half.persistent_data,
|
||||
);
|
||||
|
||||
// start the full GRANDPA voter
|
||||
// NOTE: unlike in substrate we are currently running the full
|
||||
// GRANDPA voter protocol for all full nodes (regardless of whether
|
||||
@@ -493,6 +548,7 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(config: Configuration)
|
||||
voting_rule: grandpa::VotingRulesBuilder::default().build(),
|
||||
executor: service.spawn_task_handle(),
|
||||
};
|
||||
|
||||
service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?);
|
||||
} else {
|
||||
grandpa::setup_disabled_grandpa(
|
||||
|
||||
Reference in New Issue
Block a user