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 ++++++++-- src/hotstuff_app.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') 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); diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp index 622cd0b..ead4e0b 100644 --- a/src/hotstuff_app.cpp +++ b/src/hotstuff_app.cpp @@ -175,7 +175,7 @@ int main(int argc, char **argv) { auto parent_limit = opt_parent_limit->get(); hotstuff::pacemaker_bt pmaker; if (opt_pace_maker->get() == "sticky") - pmaker = new hotstuff::PaceMakerSticky(parent_limit, 5, ec); + pmaker = new hotstuff::PaceMakerSticky(parent_limit, 0.5, ec); else pmaker = new hotstuff::PaceMakerDummyFixed(1, parent_limit); -- cgit v1.2.3