Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit db7657a

Browse files
arkparandresilva
authored andcommitted
Don't search for authority set change block if delay is zero (#4076)
1 parent 6aa8551 commit db7657a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/finality-grandpa/src/import.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use fg_primitives::{GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog};
3434
use sr_primitives::Justification;
3535
use sr_primitives::generic::{BlockId, OpaqueDigestItemId};
3636
use sr_primitives::traits::{
37-
Block as BlockT, DigestFor, Header as HeaderT, NumberFor,
37+
Block as BlockT, DigestFor, Header as HeaderT, NumberFor, Zero,
3838
};
3939
use primitives::{H256, Blake2Hasher};
4040

@@ -97,10 +97,14 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, SC> JustificationImport<Block>
9797
pending_change.effective_number() > chain_info.finalized_number &&
9898
pending_change.effective_number() <= chain_info.best_number
9999
{
100-
let effective_block_hash = self.select_chain.finality_target(
101-
pending_change.canon_hash,
102-
Some(pending_change.effective_number()),
103-
);
100+
let effective_block_hash = if !pending_change.delay.is_zero() {
101+
self.select_chain.finality_target(
102+
pending_change.canon_hash,
103+
Some(pending_change.effective_number()),
104+
)
105+
} else {
106+
Ok(Some(pending_change.canon_hash))
107+
};
104108

105109
if let Ok(Some(hash)) = effective_block_hash {
106110
if let Ok(Some(header)) = self.inner.header(&BlockId::Hash(hash)) {

0 commit comments

Comments
 (0)