aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--TODO.rst1
-rw-r--r--include/hotstuff/consensus.h3
-rw-r--r--include/hotstuff/entity.h4
-rw-r--r--include/hotstuff/hotstuff.h2
-rw-r--r--include/hotstuff/util.h6
m---------salticidae0
-rw-r--r--src/config.h.in7
-rw-r--r--src/consensus.cpp10
-rw-r--r--src/hotstuff.cpp4
-rw-r--r--src/hotstuff_app.cpp31
11 files changed, 32 insertions, 43 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e65e00..63e92f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,8 +55,11 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release")
endif()
-option(HOTSTUFF_ENABLE_DEBUG_LOG "enable debug log" OFF)
-option(HOTSTUFF_ENABLE_NORMAL_LOG "enable normal log" ON)
+option(HOTSTUFF_DEBUG_LOG "enable debug log" OFF)
+option(HOTSTUFF_NORMAL_LOG "enable normal log" ON)
+option(HOTSTUFF_PROTO_LOG "enable protocol log" OFF)
+option(HOTSTUFF_MSG_STAT "eanble message statistics" ON)
+option(HOTSTUFF_BLK_PROFILE "enable block profiling" OFF)
configure_file(src/config.h.in include/hotstuff/config.h @ONLY)
diff --git a/TODO.rst b/TODO.rst
index e9e67ea..3455e2a 100644
--- a/TODO.rst
+++ b/TODO.rst
@@ -1 +1,2 @@
- Implement a basic long-standing leader PaceMaker
+- Persistent protocol state (for safety)
diff --git a/include/hotstuff/consensus.h b/include/hotstuff/consensus.h
index cb86bf6..1ff8f79 100644
--- a/include/hotstuff/consensus.h
+++ b/include/hotstuff/consensus.h
@@ -57,7 +57,8 @@ class HotStuffCore {
* functions. */
void on_init(uint32_t nfaulty) { config.nmajority = 2 * nfaulty + 1; }
- /** Call to deliver a block.
+ /* TODO: better name for "delivery" ? */
+ /** Call to inform the state machine that a block is ready to be handled.
* A block is only delivered if itself is fetched, the block for the
* contained qc is fetched and all parents are delivered. The user should
* always ensure this invariant. The invalid blocks will be dropped by this
diff --git a/include/hotstuff/entity.h b/include/hotstuff/entity.h
index ba3906b..333b66e 100644
--- a/include/hotstuff/entity.h
+++ b/include/hotstuff/entity.h
@@ -266,7 +266,7 @@ class EntityStorage {
if (blk.get_cnt() == 2) /* only referred by blk and the storage */
{
const auto &blk_hash = blk->get_hash();
-#ifdef HOTSTUFF_ENABLE_LOG_PROTO
+#ifdef HOTSTUFF_PROTO_LOG
HOTSTUFF_LOG_INFO("releasing blk %.10s", get_hex(blk_hash).c_str());
#endif
for (const auto &cmd: blk->get_cmds())
@@ -274,7 +274,7 @@ class EntityStorage {
blk_cache.erase(blk_hash);
return true;
}
-#ifdef HOTSTUFF_ENABLE_LOG_PROTO
+#ifdef HOTSTUFF_PROTO_LOG
else
HOTSTUFF_LOG_INFO("cannot release (%lu)", blk.get_cnt());
#endif
diff --git a/include/hotstuff/hotstuff.h b/include/hotstuff/hotstuff.h
index 4e7332f..287cbac 100644
--- a/include/hotstuff/hotstuff.h
+++ b/include/hotstuff/hotstuff.h
@@ -135,7 +135,7 @@ class HotStuffBase: public HotStuffCore {
bool eb_loop;
/** network stack */
PeerNetwork<opcode_t> pn;
-#ifdef HOTSTUFF_ENABLE_BLK_PROFILE
+#ifdef HOTSTUFF_BLK_PROFILE
BlockProfiler blk_profiler;
#endif
/* queues for async tasks */
diff --git a/include/hotstuff/util.h b/include/hotstuff/util.h
index 2b02cfd..99b5ea4 100644
--- a/include/hotstuff/util.h
+++ b/include/hotstuff/util.h
@@ -13,12 +13,12 @@ class Logger: public salticidae::Logger {
extern Logger logger;
-#ifdef HOTSTUFF_ENABLE_DEBUG_LOG
+#ifdef HOTSTUFF_DEBUG_LOG
#define HOTSTUFF_NORMAL_LOG
#define HOTSTUFF_ENABLE_LOG_DEBUG
#endif
-#ifdef HOTSTUFF_ENABLE_NORMAL_LOG
+#ifdef HOTSTUFF_NORMAL_LOG
#define HOTSTUFF_ENABLE_LOG_INFO
#define HOTSTUFF_ENABLE_LOG_WARN
#endif
@@ -43,7 +43,7 @@ extern Logger logger;
#define HOTSTUFF_LOG_ERROR(...) hotstuff::logger.error(__VA_ARGS__)
-#ifdef HOTSTUFF_ENABLE_BLK_PROFILE
+#ifdef HOTSTUFF_BLK_PROFILE
class BlockProfiler {
enum BlockState {
BLK_SEEN,
diff --git a/salticidae b/salticidae
-Subproject d2de1d9a704fc4b23e9a9fb8d610620d6d4752c
+Subproject c9faab354fb314bacd9849503d8b4566a8c9ea6
diff --git a/src/config.h.in b/src/config.h.in
index ce1e575..eb92a20 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -1,7 +1,10 @@
#ifndef _HOTSTUFF_CONFIG_H
#define _HOTSTUFF_CONFIG_H
-#cmakedefine HOTSTUFF_ENABLE_DEBUG_LOG
-#cmakedefine HOTSTUFF_ENABLE_NORMAL_LOG
+#cmakedefine HOTSTUFF_DEBUG_LOG
+#cmakedefine HOTSTUFF_NORMAL_LOG
+#cmakedefine HOTSTUFF_PROTO_LOG
+#cmakedefine HOTSTUFF_MSG_STAT
+#cmakedefine HOTSTUFF_BLK_PROFILE
#endif
diff --git a/src/consensus.cpp b/src/consensus.cpp
index ac7e56a..cc1d572 100644
--- a/src/consensus.cpp
+++ b/src/consensus.cpp
@@ -88,7 +88,7 @@ void HotStuffCore::check_commit(const block_t &_blk) {
{
const block_t &blk = *it;
blk->decision = 1;
-#ifdef HOTSTUFF_ENABLE_LOG_PROTO
+#ifdef HOTSTUFF_PROTO_LOG
LOG_INFO("commit %s", std::string(*blk).c_str());
#endif
size_t idx = 0;
@@ -137,7 +137,7 @@ void HotStuffCore::on_propose(const std::vector<command_t> &cmds,
on_deliver_blk(bnew);
update(bnew_hash);
Proposal prop(id, bqc->get_hash(), bnew, nullptr);
-#ifdef HOTSTUFF_ENABLE_LOG_PROTO
+#ifdef HOTSTUFF_PROTO_LOG
LOG_INFO("propose %s", std::string(*bnew).c_str());
#endif
/* self-vote */
@@ -151,7 +151,7 @@ void HotStuffCore::on_propose(const std::vector<command_t> &cmds,
void HotStuffCore::on_receive_proposal(const Proposal &prop) {
if (!update(prop.bqc_hash)) return;
-#ifdef HOTSTUFF_ENABLE_LOG_PROTO
+#ifdef HOTSTUFF_PROTO_LOG
LOG_INFO("got %s", std::string(prop).c_str());
#endif
block_t bnew = prop.blk;
@@ -170,7 +170,7 @@ void HotStuffCore::on_receive_proposal(const Proposal &prop) {
vheight = bnew->height;
}
}
-#ifdef HOTSTUFF_ENABLE_LOG_PROTO
+#ifdef HOTSTUFF_PROTO_LOG
LOG_INFO("now state: %s", std::string(*this).c_str());
#endif
do_vote(prop.proposer,
@@ -185,7 +185,7 @@ void HotStuffCore::on_receive_proposal(const Proposal &prop) {
void HotStuffCore::on_receive_vote(const Vote &vote) {
if (!update(vote.bqc_hash)) return;
-#ifdef HOTSTUFF_ENABLE_LOG_PROTO
+#ifdef HOTSTUFF_PROTO_LOG
LOG_INFO("got %s", std::string(vote).c_str());
LOG_INFO("now state: %s", std::string(*this).c_str());
#endif
diff --git a/src/hotstuff.cpp b/src/hotstuff.cpp
index c01f2f3..abd5116 100644
--- a/src/hotstuff.cpp
+++ b/src/hotstuff.cpp
@@ -96,7 +96,7 @@ void HotStuffBase::add_replica(ReplicaID idx, const NetAddr &addr,
}
void HotStuffBase::on_fetch_blk(const block_t &blk) {
-#ifdef HOTSTUFF_ENABLE_TX_PROFILE
+#ifdef HOTSTUFF_BLK_PROFILE
blk_profiler.get_tx(blk->get_hash());
#endif
LOG_DEBUG("fetched %.10s", get_hex(blk->get_hash()).c_str());
@@ -174,7 +174,7 @@ promise_t HotStuffBase::async_fetch_blk(const uint256_t &blk_hash,
auto it = blk_fetch_waiting.find(blk_hash);
if (it == blk_fetch_waiting.end())
{
-#ifdef HOTSTUFF_ENABLE_TX_PROFILE
+#ifdef HOTSTUFF_BLK_PROFILE
blk_profiler.rec_tx(blk_hash, false);
#endif
it = blk_fetch_waiting.insert(
diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp
index e91919e..8edec56 100644
--- a/src/hotstuff_app.cpp
+++ b/src/hotstuff_app.cpp
@@ -134,7 +134,7 @@ int main(int argc, char **argv) {
config.add_opt("help", opt_help, Config::SWITCH_ON, 'h', "show this help info");
EventContext eb;
-#ifndef HOTSTUFF_ENABLE_LOG_DEBUG
+#ifdef HOTSTUFF_NORMAL_LOG
try {
#endif
config.parse(argc, argv);
@@ -185,7 +185,7 @@ int main(int argc, char **argv) {
hotstuff::from_hex(replicas[i].second));
}
papp->start();
-#ifndef HOTSTUFF_ENABLE_LOG_DEBUG
+#ifdef HOTSTUFF_NORMAL_LOG
} catch (std::exception &e) {
HOTSTUFF_LOG_INFO("exception: %s", e.what());
elapsed.stop(true);
@@ -220,24 +220,10 @@ void HotStuffApp::client_request_cmd_handler(MsgReqCmd &&msg, conn_t conn) {
msg.postponed_parse(this);
auto cmd = msg.cmd;
std::vector<promise_t> pms;
- bool flag = true;
-#ifndef HOTSTUFF_DISABLE_TX_VERIFY
- flag &= cmd->verify();
-#endif
- const uint256_t cmd_hash = cmd->get_hash();
- if (!flag)
- {
- LOG_WARN("invalid client cmd");
- cn.send_msg(MsgRespCmd(
- Finality(get_id(), -1, 0, 0, cmd_hash, uint256_t())), addr);
- }
- else
- {
- LOG_DEBUG("processing %s", std::string(*cmd).c_str());
- exec_command(cmd).then([this, addr](Finality fin) {
- cn.send_msg(MsgRespCmd(fin), addr);
- });
- }
+ LOG_DEBUG("processing %s", std::string(*cmd).c_str());
+ exec_command(cmd).then([this, addr](Finality fin) {
+ cn.send_msg(MsgRespCmd(fin), addr);
+ });
}
void HotStuffApp::start() {
@@ -249,11 +235,6 @@ void HotStuffApp::start() {
LOG_INFO("parent_limit = %d", parent_limit);
LOG_INFO("conns = %lu", HotStuff::size());
LOG_INFO("** starting the event loop...");
-#ifdef HOTSTUFF_DISABLE_TX_VERIFY
- LOG_INFO("!! verification disabled !!");
-#else
- LOG_INFO("** verification enabled **");
-#endif
HotStuff::start();
/* enter the event main loop */
eb.dispatch();