Skip to content

Commit

Permalink
Merge pull request FISCO-BCOS#708 from cyjseagull/release-2.0.0-rc2-b…
Browse files Browse the repository at this point in the history
…ugfix

fix the problem of can't reach to consensus when the leader is down in the case of node_num is 2*f+1
  • Loading branch information
bxq2011hust authored Apr 28, 2019
2 parents b30783c + 0e469a3 commit f78403a
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 77 deletions.
1 change: 0 additions & 1 deletion libblockchain/BlockChainImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,6 @@ CommitResult BlockChainImp::commitBlock(Block& block, std::shared_ptr<ExecutiveC
{
return CommitResult::ERROR_PARENT_HASH;
}

auto write_record_time = utcTime();
// writeBlockInfo(block, context);
writeHash2Block(block, context);
Expand Down
2 changes: 2 additions & 0 deletions libblockverifier/BlockVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ ExecutiveContext::Ptr BlockVerifier::serialExecuteBlock(
{
BLOCKVERIFIER_LOG(ERROR)
<< "Invalid Block with bad stateRoot or receiptRoot or dbHash"
<< LOG_KV("blkNum", block.blockHeader().number())
<< LOG_KV("originHash", tmpHeader.hash().abridged())
<< LOG_KV("curHash", block.header().hash().abridged())
<< LOG_KV("orgReceipt", tmpHeader.receiptsRoot().abridged())
Expand Down Expand Up @@ -279,6 +280,7 @@ ExecutiveContext::Ptr BlockVerifier::parallelExecuteBlock(
{
BLOCKVERIFIER_LOG(ERROR)
<< "Invalid Block with bad stateRoot or receiptRoot or dbHash"
<< LOG_KV("blkNum", block.blockHeader().number())
<< LOG_KV("originHash", tmpHeader.hash().abridged())
<< LOG_KV("curHash", block.header().hash().abridged())
<< LOG_KV("orgReceipt", tmpHeader.receiptsRoot().abridged())
Expand Down
173 changes: 110 additions & 63 deletions libconsensus/pbft/PBFTEngine.cpp

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion libconsensus/pbft/PBFTEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ class PBFTEngine : public ConsensusEngineBase
template <typename T>
inline bool isFutureBlock(T const& req) const
{
/// to ensure that the signReq can reach to consensus even if the view has been changed
if (req.height >= m_consensusBlockNumber || req.view > m_view)
{
return true;
Expand Down Expand Up @@ -542,9 +543,10 @@ class PBFTEngine : public ConsensusEngineBase
m_signalled.notify_all();
}
void notifySealing(dev::eth::Block const& block);
/// to ensure at least 100MB available disk space
virtual bool isDiskSpaceEnough(std::string const& path)
{
return boost::filesystem::space(path).available > 1024;
return boost::filesystem::space(path).available > 1024 * 1024 * 100;
}

void updateViewMap(IDXTYPE const& idx, VIEWTYPE const& view)
Expand Down
1 change: 0 additions & 1 deletion libconsensus/pbft/TimeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ struct TimeManager
{
m_lastConsensusTime = 0;
m_lastSignTime = 0;
m_changeCycle = 0;
}

inline void updateChangeCycle()
Expand Down
3 changes: 2 additions & 1 deletion libinitializer/Initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ void Initializer::init(std::string const& _path)
m_rpcInitializer->setSSLContext(
m_secureInitializer->SSLContext(SecureInitializer::Usage::ForRPC));
m_rpcInitializer->initChannelRPCServer(pt);
m_rpcInitializer->channelRPCServer()->StartListening();

m_ledgerInitializer = std::make_shared<LedgerInitializer>();
m_ledgerInitializer->setP2PService(m_p2pInitializer->p2pService());
Expand All @@ -69,6 +68,8 @@ void Initializer::init(std::string const& _path)
m_rpcInitializer->setLedgerManager(m_ledgerInitializer->ledgerManager());
m_rpcInitializer->initConfig(pt);
m_ledgerInitializer->startAll();
/// start RPC at last when everything is ready
m_rpcInitializer->channelRPCServer()->StartListening();
}
catch (std::exception& e)
{
Expand Down
7 changes: 5 additions & 2 deletions libledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ void Ledger::initIniConfig(std::string const& iniConfigFileName)
<< LOG_DESC("initTxPoolConfig/initSyncConfig/initTxExecuteConfig")
<< LOG_KV("configFile", iniConfigFileName);
ptree pt;
/// read the configuration file for a specified group
read_ini(iniConfigFileName, pt);
if (boost::filesystem::exists(iniConfigFileName))
{
/// read the configuration file for a specified group
read_ini(iniConfigFileName, pt);
}
/// init params related to txpool
initTxPoolConfig(pt);
/// init params related to sync
Expand Down
5 changes: 3 additions & 2 deletions libstorage/LevelDBStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,13 @@ size_t LevelDBStorage::commit(h256 hash, int64_t num, const std::vector<TableDat

return total.load();
}
catch (std::exception& e)
catch (std::exception const& e)
{
// This should never happen, if happened exit.
STORAGE_LEVELDB_LOG(ERROR) << LOG_DESC("Commit leveldb exception")
<< LOG_KV("msg", boost::diagnostic_information(e));
BOOST_THROW_EXCEPTION(e);
BOOST_THROW_EXCEPTION(
StorageException(-1, "Commit leveldb exception:" + boost::diagnostic_information(e)));
}

return 0;
Expand Down
3 changes: 2 additions & 1 deletion libstorage/LevelDBStorage2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ size_t LevelDBStorage2::commit(h256 hash, int64_t num, const std::vector<TableDa
{
STORAGE_LEVELDB_LOG(ERROR) << LOG_DESC("Commit leveldb exception")
<< LOG_KV("msg", boost::diagnostic_information(e));
BOOST_THROW_EXCEPTION(e);
BOOST_THROW_EXCEPTION(
StorageException(-1, "Commit leveldb exception:" + boost::diagnostic_information(e)));
}

return 0;
Expand Down
8 changes: 3 additions & 5 deletions libstorage/TableFactoryPrecompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ bytes TableFactoryPrecompiled::call(
{ // openTable(string)
string tableName;
abi.abiOut(data, tableName);
STORAGE_LOG(DEBUG) << LOG_BADGE("TableFactoryPrecompiled") << LOG_DESC("open table")
<< LOG_KV("table name", tableName);
tableName = storage::USER_TABLE_PREFIX + tableName;
Address address;
auto table = m_memoryTableFactory->openTable(tableName);
Expand All @@ -80,9 +78,9 @@ bytes TableFactoryPrecompiled::call(
}
else
{
STORAGE_LOG(DEBUG) << LOG_BADGE("TableFactoryPrecompiled")
<< LOG_DESC("Open new table failed")
<< LOG_KV("table name", tableName);
STORAGE_LOG(WARNING) << LOG_BADGE("TableFactoryPrecompiled")
<< LOG_DESC("Open new table failed")
<< LOG_KV("table name", tableName);
}

out = abi.abiIn("", address);
Expand Down
1 change: 1 addition & 0 deletions tools/build_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ if [ ! -z \${node_pid} ];then
exit 0
else
${start_cmd} &
echo "start time: "\$(date '+%Y-%m-%d %H:%M:%S') >> nohup.out
sleep 1
fi
try_times=5
Expand Down

0 comments on commit f78403a

Please sign in to comment.