From 6e55812704444a99cf0134eff847210c769d17af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Fri, 25 Jan 2019 14:05:39 +0000 Subject: [PATCH] core: restrict grandpa voter on authority set change (#1564) --- substrate/core/finality-grandpa/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/substrate/core/finality-grandpa/src/lib.rs b/substrate/core/finality-grandpa/src/lib.rs index d00c94cdbf..c14dc96dc2 100644 --- a/substrate/core/finality-grandpa/src/lib.rs +++ b/substrate/core/finality-grandpa/src/lib.rs @@ -415,6 +415,14 @@ impl, B, E, N, RA> grandpa::Chain Option<(Block::Hash, NumberFor)> { + // NOTE: when we finalize an authority set change through the sync protocol the voter is + // signalled asynchronously. therefore the voter could still vote in the next round + // before activating the new set. the `authority_set` is updated immediately thus we + // restrict the voter based on that. + if self.set_id != self.authority_set.inner().read().current().0 { + return None; + } + // we refuse to vote beyond the current limit number where transitions are scheduled to // occur. // once blocks are finalized that make that transition irrelevant or activate it,