Skip to content

Commit 2e76bb7

Browse files
committed
Defer snapshot timing by one block in Tendermint
1 parent f6550fe commit 2e76bb7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/consensus/tendermint/worker.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,12 +1708,17 @@ impl Worker {
17081708
// NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
17091709
None => continue,
17101710
};
1711-
let term_seconds = if let Some(p) = c.term_common_params(parent_header.hash().into()) {
1711+
let grandparent_header = match c.block_header(&BlockId::Hash(*header.parent_hash())) {
1712+
Some(h) => h.decode(),
1713+
// Grandparent can be missing if the block number < 2 or there is a missing
1714+
None => continue,
1715+
};
1716+
let term_seconds = if let Some(p) = c.term_common_params(grandparent_header.hash().into()) {
17121717
p.term_seconds()
17131718
} else {
17141719
continue
17151720
};
1716-
if super::engine::is_term_changed(&header, &parent_header, term_seconds) {
1721+
if super::engine::is_term_changed(&parent_header, &grandparent_header, term_seconds) {
17171722
last_term_end = Some(*block_hash);
17181723
}
17191724
}

0 commit comments

Comments
 (0)