From 13fa82b522eb7c90469a767af8da8b71030386e9 Mon Sep 17 00:00:00 2001 From: mfrankovi Date: Thu, 31 Oct 2024 12:47:02 +0100 Subject: [PATCH] fix: pillar block save --- .../core_libs/consensus/src/pbft/pbft_manager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp b/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp index 13a2fca473..f2d4235e11 100644 --- a/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp +++ b/libraries/core_libs/consensus/src/pbft/pbft_manager.cpp @@ -41,6 +41,17 @@ PbftManager::PbftManager(const FullNodeConfig &conf, std::shared_ptr const auto &node_addr = node_addr_; LOG_OBJECTS_CREATE("PBFT_MGR"); + auto current_pbft_period = pbft_chain_->getPbftChainSize(); + if (kGenesisConfig.state.hardforks.ficus_hf.isPillarBlockPeriod(current_pbft_period)) { + const auto current_pillar_block = pillar_chain_mgr_->getCurrentPillarBlock(); + // There is a race condition where pbt block could have been saved and node stopped before saving pillar block + if (current_pbft_period == + current_pillar_block->getPeriod() + kGenesisConfig.state.hardforks.ficus_hf.pillar_blocks_interval) + LOG(log_er_) << "Pillar block was not processed before restart, current period: " << current_pbft_period + << ", current pillar block period: " << current_pillar_block->getPeriod(); + processPillarBlock(current_pbft_period); + } + for (auto period = final_chain_->lastBlockNumber() + 1, curr_period = pbft_chain_->getPbftChainSize(); period <= curr_period; ++period) { auto period_raw = db_->getPeriodDataRaw(period);