mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
Updating GRANDPA to v0.10.0 (#4174)
* update finality-grandpa to v0.10.0 rev * add concluded implementation to environment * also update state when concluding * switch to the cargo version * address comment grumbles
This commit is contained in:
committed by
Gavin Wood
parent
1735683cc9
commit
5a8146d64e
Generated
+3
-4
@@ -1132,11 +1132,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "finality-grandpa"
|
name = "finality-grandpa"
|
||||||
version = "0.9.1"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -5809,7 +5808,7 @@ name = "substrate-finality-grandpa"
|
|||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"finality-grandpa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"finality-grandpa 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fork-tree 2.0.0",
|
"fork-tree 2.0.0",
|
||||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -7796,7 +7795,7 @@ dependencies = [
|
|||||||
"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
|
"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
|
||||||
"checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa"
|
"checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa"
|
||||||
"checksum file-per-thread-logger 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8505b75b31ef7285168dd237c4a7db3c1f3e0927e7d314e670bc98e854272fe9"
|
"checksum file-per-thread-logger 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8505b75b31ef7285168dd237c4a7db3c1f3e0927e7d314e670bc98e854272fe9"
|
||||||
"checksum finality-grandpa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34754852da8d86bc509715292c73140a5b678656d0b16132acd6737bdb5fd5f8"
|
"checksum finality-grandpa 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b36ece7dc398ce17438d815f3202d2cdba8fd930452a68b616965662742b7e10"
|
||||||
"checksum fixed-hash 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72fe7539e2c5692c6989f2f9c0457e42f1e5768f96b85c87d273574670ae459f"
|
"checksum fixed-hash 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72fe7539e2c5692c6989f2f9c0457e42f1e5768f96b85c87d273574670ae459f"
|
||||||
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
|
"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
|
||||||
"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f"
|
"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f"
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ inherents = { package = "substrate-inherents", path = "../../primitives/inherent
|
|||||||
network = { package = "substrate-network", path = "../network" }
|
network = { package = "substrate-network", path = "../network" }
|
||||||
sp-finality-tracker = { path = "../../primitives/finality-tracker" }
|
sp-finality-tracker = { path = "../../primitives/finality-tracker" }
|
||||||
fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" }
|
fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" }
|
||||||
grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] }
|
grandpa = { package = "finality-grandpa", version = "0.10.0", features = ["derive-codec"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec", "test-helpers"] }
|
grandpa = { package = "finality-grandpa", version = "0.10.0", features = ["derive-codec", "test-helpers"] }
|
||||||
network = { package = "substrate-network", path = "../network", features = ["test-helpers"] }
|
network = { package = "substrate-network", path = "../network", features = ["test-helpers"] }
|
||||||
keyring = { package = "substrate-keyring", path = "../../primitives/keyring" }
|
keyring = { package = "substrate-keyring", path = "../../primitives/keyring" }
|
||||||
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client"}
|
test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client"}
|
||||||
|
|||||||
@@ -798,7 +798,7 @@ where
|
|||||||
let mut completed_rounds = completed_rounds.clone();
|
let mut completed_rounds = completed_rounds.clone();
|
||||||
|
|
||||||
// TODO: Future integration will store the prevote and precommit index. See #2611.
|
// TODO: Future integration will store the prevote and precommit index. See #2611.
|
||||||
let votes = historical_votes.seen().clone();
|
let votes = historical_votes.seen().to_vec();
|
||||||
|
|
||||||
completed_rounds.push(CompletedRound {
|
completed_rounds.push(CompletedRound {
|
||||||
number: round,
|
number: round,
|
||||||
@@ -825,6 +825,61 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn concluded(
|
||||||
|
&self,
|
||||||
|
round: RoundNumber,
|
||||||
|
state: RoundState<Block::Hash, NumberFor<Block>>,
|
||||||
|
_base: (Block::Hash, NumberFor<Block>),
|
||||||
|
historical_votes: &HistoricalVotes<Block>,
|
||||||
|
) -> Result<(), Self::Error> {
|
||||||
|
debug!(
|
||||||
|
target: "afg", "Voter {} concluded round {} in set {}. Estimate = {:?}, Finalized in round = {:?}",
|
||||||
|
self.config.name(),
|
||||||
|
round,
|
||||||
|
self.set_id,
|
||||||
|
state.estimate.as_ref().map(|e| e.1),
|
||||||
|
state.finalized.as_ref().map(|e| e.1),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.update_voter_set_state(|voter_set_state| {
|
||||||
|
// NOTE: we don't use `with_current_round` here, because a concluded
|
||||||
|
// round is completed and cannot be current.
|
||||||
|
let (completed_rounds, current_rounds) =
|
||||||
|
if let VoterSetState::Live { completed_rounds, current_rounds } = voter_set_state {
|
||||||
|
(completed_rounds, current_rounds)
|
||||||
|
} else {
|
||||||
|
let msg = "Voter acting while in paused state.";
|
||||||
|
return Err(Error::Safety(msg.to_string()));
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut completed_rounds = completed_rounds.clone();
|
||||||
|
|
||||||
|
if let Some(already_completed) = completed_rounds.rounds
|
||||||
|
.iter_mut().find(|r| r.number == round)
|
||||||
|
{
|
||||||
|
let n_existing_votes = already_completed.votes.len();
|
||||||
|
|
||||||
|
// the interface of Environment guarantees that the previous `historical_votes`
|
||||||
|
// from `completable` is a prefix of what is passed to `concluded`.
|
||||||
|
already_completed.votes.extend(
|
||||||
|
historical_votes.seen().iter().skip(n_existing_votes).cloned()
|
||||||
|
);
|
||||||
|
already_completed.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
let set_state = VoterSetState::<Block>::Live {
|
||||||
|
completed_rounds,
|
||||||
|
current_rounds: current_rounds.clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
crate::aux_schema::write_voter_set_state(&*self.client, &set_state)?;
|
||||||
|
|
||||||
|
Ok(Some(set_state))
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn finalize_block(
|
fn finalize_block(
|
||||||
&self,
|
&self,
|
||||||
hash: Block::Hash,
|
hash: Block::Hash,
|
||||||
|
|||||||
@@ -746,7 +746,8 @@ where
|
|||||||
(*self.env.voters).clone(),
|
(*self.env.voters).clone(),
|
||||||
global_comms,
|
global_comms,
|
||||||
last_completed_round.number,
|
last_completed_round.number,
|
||||||
last_completed_round.state.clone(),
|
last_completed_round.votes.clone(),
|
||||||
|
last_completed_round.base.clone(),
|
||||||
last_finalized,
|
last_finalized,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user