Skip to content

Commit a39d9cc

Browse files
committed
Detect bootstrap header in tendermint worker
Tendermint worker skips some process for the genesis block since it doesn't have a parent, and this should be applied to the bootstrap header too.
1 parent 3273c43 commit a39d9cc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/src/consensus/tendermint/worker.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ use crate::encoded;
5252
use crate::error::{BlockError, Error};
5353
use crate::snapshot_notify::NotifySender as SnapshotNotifySender;
5454
use crate::transaction::{SignedTransaction, UnverifiedTransaction};
55+
use crate::types::BlockStatus;
5556
use crate::views::BlockView;
5657
use crate::BlockId;
5758
use std::cell::Cell;
@@ -958,7 +959,7 @@ impl Worker {
958959
}
959960

960961
pub fn on_imported_proposal(&mut self, proposal: &Header) {
961-
if proposal.number() < 1 {
962+
if self.client().block_status(&BlockId::Hash(*proposal.parent_hash())) == BlockStatus::Unknown {
962963
return
963964
}
964965

@@ -1660,11 +1661,10 @@ impl Worker {
16601661
let mut last_term_end = None;
16611662
for block_hash in &enacted {
16621663
let header = c.block_header(&BlockId::Hash(*block_hash)).expect("Block is enacted").decode();
1663-
if header.number() == 0 {
1664-
continue
1665-
}
1666-
let parent_header =
1667-
c.block_header(&BlockId::Hash(*header.parent_hash())).expect("Parent block should be enacted").decode();
1664+
let parent_header = match c.block_header(&BlockId::Hash(*header.parent_hash())) {
1665+
Some(h) => h.decode(),
1666+
None => continue,
1667+
};
16681668
let term_common_params = if let Some(p) = c.term_common_params(parent_header.hash().into()) {
16691669
p
16701670
} else {

0 commit comments

Comments
 (0)