From 20500e74613f69f937e404cbabb3982da3b72881 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 16 Aug 2018 23:56:59 -0400 Subject: fix vheight bug in self-voting --- src/consensus.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/consensus.cpp') diff --git a/src/consensus.cpp b/src/consensus.cpp index c9ceb9b..1c02585 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -75,6 +75,7 @@ void HotStuffCore::check_commit(const block_t &_blk) { /* decided blk could possible be incomplete due to pruning */ if (blk->decision) return; block_t p = blk->parents[0]; + if (p->decision) return; /* commit requires direct parent */ if (p != blk->qc_ref) return; /* otherwise commit */ @@ -85,7 +86,9 @@ void HotStuffCore::check_commit(const block_t &_blk) { commit_queue.push_back(b); } if (b != bexec) - throw std::runtime_error("safety breached :("); + throw std::runtime_error("safety breached :( " + + std::string(*p) + " " + + std::string(*bexec)); for (auto it = commit_queue.rbegin(); it != commit_queue.rend(); it++) { const block_t &blk = *it; @@ -142,6 +145,8 @@ void HotStuffCore::on_propose(const std::vector &cmds, Proposal prop(id, bqc->get_hash(), bnew, nullptr); LOG_PROTO("propose %s", std::string(*bnew).c_str()); /* self-vote */ + assert(bnew->height > vheight); + vheight = bnew->height; on_receive_vote( Vote(id, bqc->get_hash(), bnew_hash, create_part_cert(*priv_key, bnew_hash), this)); @@ -306,7 +311,8 @@ HotStuffCore::operator std::string () const { DataStream s; s << ""; return std::move(s); -- cgit v1.2.3-70-g09d2