aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2018-08-16 23:56:59 -0400
committerDeterminant <ted.sybil@gmail.com>2018-08-16 23:56:59 -0400
commit20500e74613f69f937e404cbabb3982da3b72881 (patch)
tree5e35b68649d39ccaf8690a9f4b82eeadfef66f8f
parent055dd5432a60954199ecc167831a4bf588e3ae84 (diff)
fix vheight bug in self-voting
-rw-r--r--include/hotstuff/entity.h3
-rw-r--r--include/hotstuff/liveness.h4
-rw-r--r--src/consensus.cpp10
-rw-r--r--src/hotstuff_app.cpp2
4 files changed, 13 insertions, 6 deletions
diff --git a/include/hotstuff/entity.h b/include/hotstuff/entity.h
index 29300a9..6f73db8 100644
--- a/include/hotstuff/entity.h
+++ b/include/hotstuff/entity.h
@@ -196,7 +196,8 @@ class Block {
s << "<block "
<< "id=" << get_hex10(hash) << " "
<< "height=" << std::to_string(height) << " "
- << "parent=" << get_hex10(parent_hashes[0]) << ">";
+ << "parent=" << get_hex10(parent_hashes[0]) << " "
+ << "qc_ref=" << (qc_ref ? get_hex10(qc_ref->get_hash()) : "null") << ">";
return std::move(s);
}
};
diff --git a/include/hotstuff/liveness.h b/include/hotstuff/liveness.h
index 5dfb2e0..6396fe3 100644
--- a/include/hotstuff/liveness.h
+++ b/include/hotstuff/liveness.h
@@ -52,8 +52,8 @@ class PMAllParents: public virtual PaceMaker {
for (b = blk;
b->get_height() > bqc->get_height();
b = b->get_parents()[0]);
- if (b == bqc && b->get_height() > bqc_tail->get_height())
- bqc_tail = b;
+ if (b == bqc && blk->get_height() > bqc_tail->get_height())
+ bqc_tail = blk;
}
reg_bqc_update();
});
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);
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);