Skip to content

Commit 39f3ae0

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 39f3ae0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

core/src/consensus/tendermint/worker.rs

Lines changed: 8 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,8 @@ impl Worker {
958959
}
959960

960961
pub fn on_imported_proposal(&mut self, proposal: &Header) {
961-
if proposal.number() < 1 {
962+
// NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
963+
if self.client().block_status(&BlockId::Hash(*proposal.parent_hash())) == BlockStatus::Unknown {
962964
return
963965
}
964966

@@ -1660,11 +1662,11 @@ impl Worker {
16601662
let mut last_term_end = None;
16611663
for block_hash in &enacted {
16621664
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();
1665+
let parent_header = match c.block_header(&BlockId::Hash(*header.parent_hash())) {
1666+
Some(h) => h.decode(),
1667+
// NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
1668+
None => continue,
1669+
};
16681670
let term_common_params = if let Some(p) = c.term_common_params(parent_header.hash().into()) {
16691671
p
16701672
} else {

0 commit comments

Comments
 (0)