diff options
author | Determinant <[email protected]> | 2018-08-16 23:56:59 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2018-08-16 23:56:59 -0400 |
commit | 20500e74613f69f937e404cbabb3982da3b72881 (patch) | |
tree | 5e35b68649d39ccaf8690a9f4b82eeadfef66f8f /src/consensus.cpp | |
parent | 055dd5432a60954199ecc167831a4bf588e3ae84 (diff) |
fix vheight bug in self-voting
Diffstat (limited to 'src/consensus.cpp')
-rw-r--r-- | src/consensus.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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<command_t> &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 << "<hotstuff " << "bqc=" << get_hex10(bqc->get_hash()) << " " - << "bexec=" << get_hex10(bqc->get_hash()) << " " + << "bqc.rheight=" << std::to_string(bqc->qc_ref->height) << " " + << "bexec=" << get_hex10(bexec->get_hash()) << " " << "vheight=" << std::to_string(vheight) << " " << "tails=" << std::to_string(tails.size()) << ">"; return std::move(s); |