Skip to content

Commit 57d4bd0

Browse files
remagpieforiequal0
authored andcommitted
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 44bf2cf commit 57d4bd0

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;
@@ -961,7 +962,8 @@ impl Worker {
961962
}
962963

963964
fn on_imported_proposal(&mut self, proposal: &Header) {
964-
if proposal.number() < 1 {
965+
// NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
966+
if self.client().block_status(&BlockId::Hash(*proposal.parent_hash())) == BlockStatus::Unknown {
965967
return
966968
}
967969

@@ -1663,11 +1665,11 @@ impl Worker {
16631665
let mut last_term_end = None;
16641666
for block_hash in &enacted {
16651667
let header = c.block_header(&BlockId::Hash(*block_hash)).expect("Block is enacted").decode();
1666-
if header.number() == 0 {
1667-
continue
1668-
}
1669-
let parent_header =
1670-
c.block_header(&BlockId::Hash(*header.parent_hash())).expect("Parent block should be enacted").decode();
1668+
let parent_header = match c.block_header(&BlockId::Hash(*header.parent_hash())) {
1669+
Some(h) => h.decode(),
1670+
// NOTE: Only the genesis block and the snapshot target don't have the parent in the blockchain
1671+
None => continue,
1672+
};
16711673
let term_seconds = if let Some(p) = c.term_common_params(parent_header.hash().into()) {
16721674
p.term_seconds()
16731675
} else {

0 commit comments

Comments
 (0)