aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-07-06 18:37:11 -0400
committerDeterminant <[email protected]>2019-07-06 18:37:11 -0400
commit24b6cea7be8b78eaa3681d6274d671057ed112b5 (patch)
treef3e8ae2a279344340085b96aa5622452dd5af624 /src
parent346f688916d87ff856a81e9cf3f3e69245101475 (diff)
finish the simple Round-Robin Pacemakerpacemaker-clean-up
Diffstat (limited to 'src')
-rw-r--r--src/hotstuff.cpp25
-rw-r--r--src/hotstuff_app.cpp20
-rw-r--r--src/hotstuff_client.cpp1
3 files changed, 28 insertions, 18 deletions
diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp
index 22f0d82..69501c0 100644
--- a/src/hotstuff.cpp
+++ b/src/hotstuff.cpp
@@ -17,6 +17,7 @@
#include "hotstuff/hotstuff.h"
#include "hotstuff/client.h"
+#include "hotstuff/liveness.h"
using salticidae::static_pointer_cast;
@@ -79,6 +80,17 @@ void HotStuffBase::exec_command(uint256_t cmd_hash, commit_cb_t callback) {
cmd_pending.enqueue(std::make_pair(cmd_hash, callback));
}
+void HotStuffBase::do_elected() {
+ // TODO: improve this
+ tcall.async_call([this](salticidae::ThreadCall::Handle &) {
+ HOTSTUFF_LOG_PROTO("reproposing waiting commands");
+ std::vector<uint256_t> cmds;
+ for (auto &p: decision_waiting)
+ cmds.push_back(p.first);
+ on_propose(cmds, pmaker->get_parents());
+ });
+}
+
void HotStuffBase::on_fetch_blk(const block_t &blk) {
#ifdef HOTSTUFF_BLK_PROFILE
blk_profiler.get_tx(blk->get_hash());
@@ -329,6 +341,7 @@ HotStuffBase::HotStuffBase(uint32_t blk_size,
listen_addr(listen_addr),
blk_size(blk_size),
ec(ec),
+ tcall(ec),
vpool(ec, nworker),
pn(ec, netconfig),
pmaker(std::move(pmaker)),
@@ -420,21 +433,15 @@ void HotStuffBase::start(
while (q.try_dequeue(e))
{
ReplicaID proposer = pmaker->get_proposer();
- if (proposer != get_id()) continue;
const auto &cmd_hash = e.first;
- cmd_pending_buffer.push(cmd_hash);
-
auto it = decision_waiting.find(cmd_hash);
if (it == decision_waiting.end())
- {
it = decision_waiting.insert(std::make_pair(cmd_hash, e.second)).first;
- }
else
- {
- // TODO: duplicate commands
- }
-
+ e.second(Finality(id, 0, 0, 0, cmd_hash, uint256_t()));
+ if (proposer != get_id()) continue;
+ cmd_pending_buffer.push(cmd_hash);
if (cmd_pending_buffer.size() >= blk_size)
{
std::vector<uint256_t> cmds;
diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp
index 778c195..871bafb 100644
--- a/src/hotstuff_app.cpp
+++ b/src/hotstuff_app.cpp
@@ -35,6 +35,7 @@
#include "hotstuff/util.h"
#include "hotstuff/client.h"
#include "hotstuff/hotstuff.h"
+#include "hotstuff/liveness.h"
using salticidae::MsgNetwork;
using salticidae::ClientNetwork;
@@ -113,6 +114,10 @@ class HotStuffApp: public HotStuff {
resp_queue.enqueue(fin);
}
+ void do_elected() override {
+ HotStuff::do_elected();
+ }
+
//#ifdef HOTSTUFF_AUTOCLI
// void do_demand_commands(size_t blk_size) override {
// size_t ncli = client_conns.size();
@@ -191,7 +196,7 @@ int main(int argc, char **argv) {
config.add_opt("privkey", opt_privkey, Config::SET_VAL);
config.add_opt("tls-privkey", opt_tls_privkey, Config::SET_VAL);
config.add_opt("tls-cert", opt_tls_cert, Config::SET_VAL);
- config.add_opt("pace-maker", opt_pace_maker, Config::SET_VAL, 'p', "specify pace maker (sticky, dummy)");
+ config.add_opt("pace-maker", opt_pace_maker, Config::SET_VAL, 'p', "specify pace maker (dummy, rr)");
config.add_opt("proposer", opt_fixed_proposer, Config::SET_VAL, 'l', "set the fixed proposer (for dummy)");
config.add_opt("qc-timeout", opt_qc_timeout, Config::SET_VAL, 't', "set QC timeout (for sticky)");
config.add_opt("imp-timeout", opt_imp_timeout, Config::SET_VAL, 'u', "set impeachment timeout (for sticky)");
@@ -239,12 +244,10 @@ 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, opt_qc_timeout->get(), ec);
- else if (opt_pace_maker->get() == "rr")
- pmaker = new hotstuff::PaceMakerRR(parent_limit, opt_qc_timeout->get(), ec);
- else
+ if (opt_pace_maker->get() == "dummy")
pmaker = new hotstuff::PaceMakerDummyFixed(opt_fixed_proposer->get(), parent_limit);
+ else
+ pmaker = new hotstuff::PaceMakerRR(parent_limit, opt_qc_timeout->get(), ec);
HotStuffApp::Net::Config repnet_config;
ClientNetwork<opcode_t>::Config clinet_config;
@@ -374,10 +377,11 @@ void HotStuffApp::start(const std::vector<std::tuple<NetAddr, bytearray_t, bytea
});
ev_stat_timer.add(stat_period);
impeach_timer = TimerEvent(ec, [this](TimerEvent &) {
- get_pace_maker().impeach();
+ if (get_decision_waiting().size())
+ get_pace_maker()->impeach();
reset_imp_timer();
});
- //impeach_timer.add(impeach_timeout);
+ impeach_timer.add(impeach_timeout);
HOTSTUFF_LOG_INFO("** starting the system with parameters **");
HOTSTUFF_LOG_INFO("blk_size = %lu", blk_size);
HOTSTUFF_LOG_INFO("conns = %lu", HotStuff::size());
diff --git a/src/hotstuff_client.cpp b/src/hotstuff_client.cpp
index 9f7423d..7914125 100644
--- a/src/hotstuff_client.cpp
+++ b/src/hotstuff_client.cpp
@@ -37,7 +37,6 @@ using hotstuff::EventContext;
using hotstuff::MsgReqCmd;
using hotstuff::MsgRespCmd;
using hotstuff::CommandDummy;
-using hotstuff::Finality;
using hotstuff::HotStuffError;
using hotstuff::uint256_t;
using hotstuff::opcode_t;