aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2018-09-10 16:23:35 -0400
committerDeterminant <ted.sybil@gmail.com>2018-09-10 16:23:35 -0400
commit95b193bb3b0bba62f168c7e2c3f45c54d4849e27 (patch)
treef5164f02d35b1b3a5723a52ff4f05a300d794119
parent073f33b2bdbef4fb711174033707d7b164036b6e (diff)
...
-rw-r--r--hotstuff.conf1
-rw-r--r--include/hotstuff/hotstuff.h8
-rwxr-xr-xscripts/run_client.sh6
-rw-r--r--src/hotstuff_app.cpp13
4 files changed, 20 insertions, 8 deletions
diff --git a/hotstuff.conf b/hotstuff.conf
index 4823340..6ad5b4e 100644
--- a/hotstuff.conf
+++ b/hotstuff.conf
@@ -1,3 +1,4 @@
+nworker = 8
replica = 127.0.0.1:2234;22234, 028a1caf2c503a1e9b0b3ddf1d1df30253facdd50b93add05ebc7f708db00c11e4
replica = 127.0.0.1:2235;22235, 034ca53338e69321c1bc83e2fa76b1b00d68f64911074221abda88aac8af9d2b53
replica = 127.0.0.1:2236;22236, 0340f9d12dd1532968f7d8a99f95c3cd03992346487e15bd43265a3f273558ff2e
diff --git a/include/hotstuff/hotstuff.h b/include/hotstuff/hotstuff.h
index 983a7b3..eeffaab 100644
--- a/include/hotstuff/hotstuff.h
+++ b/include/hotstuff/hotstuff.h
@@ -185,7 +185,7 @@ class HotStuffBase: public HotStuffCore {
NetAddr listen_addr,
pacemaker_bt pmaker,
EventContext eb,
- size_t nworker = 4);
+ size_t nworker);
~HotStuffBase();
@@ -248,13 +248,15 @@ class HotStuff: public HotStuffBase {
const bytearray_t &raw_privkey,
NetAddr listen_addr,
pacemaker_bt pmaker,
- EventContext eb = EventContext()):
+ EventContext eb = EventContext(),
+ size_t nworker = 4):
HotStuffBase(blk_size,
rid,
new PrivKeyType(raw_privkey),
listen_addr,
std::move(pmaker),
- eb) {}
+ eb,
+ nworker) {}
void add_replica(ReplicaID idx, const NetAddr &addr, const bytearray_t &pubkey_raw) {
DataStream s(pubkey_raw);
diff --git a/scripts/run_client.sh b/scripts/run_client.sh
index 9e7d1db..7825c02 100755
--- a/scripts/run_client.sh
+++ b/scripts/run_client.sh
@@ -17,6 +17,7 @@ copy_from_remote_pat="rsync -avz <remote_user>@<remote_ip>:<remote_path> <local_
exe_remote_pat="ssh <remote_user>@<remote_ip> bash"
run_remote_pat="cd \"<rworkdir>\"; '$proj_client_path' --idx \"<node_id>\" --iter -1 --max-async 3"
reset_remote_pat="pgrep -f '$proj_client_bin' | xargs kill -9"
+node_id_step=1
function join { local IFS="$1"; shift; echo "$*"; }
function split {
@@ -143,7 +144,8 @@ function _remote_start {
local client_port="$5"
local client_ip="$6"
local cmd="${run_remote_pat//<rworkdir>/$rworkdir}"
- cmd="${cmd//<node_id>/$node_id}"
+ cmd="${cmd//<node_id_step>/$node_id_step}"
+ cmd="${cmd//<node_id>/$((node_id * node_id_step))}"
cmd="${cmd//<server>/$node_ip:$client_port}"
execute_remote_cmd_pid "$client_ip" "$cmd" \
"\"$rworkdir/$remote_log\"" > "$workdir/${node_id}.pid"
@@ -313,6 +315,7 @@ exe-remote-pat:,\
run-remote-pat:,\
reset-remote-pat:,\
force-peer-list,\
+node-id-step:,\
help'
PARSED=$(getopt --options "$SHORT" --longoptions "$LONG" --name "$0" -- "$@")
@@ -334,6 +337,7 @@ while true; do
--exe-remote-pat) exe_remote_pat="$2"; shift 2;;
--run-remote-pat) run_remote_pat="$2"; shift 2;;
--reset-remote-pat) reset_remote_pat="$2"; shift 2;;
+ --node-id-step) node_id_step="$2"; shift 2;;
--help) print_help; shift 1;;
--) shift; break;;
*) die "internal error";;
diff --git a/src/hotstuff_app.cpp b/src/hotstuff_app.cpp
index 768e81e..87c80e3 100644
--- a/src/hotstuff_app.cpp
+++ b/src/hotstuff_app.cpp
@@ -92,7 +92,8 @@ class HotStuffApp: public HotStuff {
NetAddr plisten_addr,
NetAddr clisten_addr,
hotstuff::pacemaker_bt pmaker,
- const EventContext &ec);
+ const EventContext &ec,
+ size_t nworker);
void start();
};
@@ -131,6 +132,7 @@ int main(int argc, char **argv) {
auto opt_fixed_proposer = Config::OptValInt::create(1);
auto opt_qc_timeout = Config::OptValDouble::create(0.5);
auto opt_imp_timeout = Config::OptValDouble::create(11);
+ auto opt_nworker = Config::OptValInt::create(4);
config.add_opt("block-size", opt_blk_size, Config::SET_VAL);
config.add_opt("parent-limit", opt_parent_limit, Config::SET_VAL);
@@ -143,6 +145,7 @@ int main(int argc, char **argv) {
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)");
+ config.add_opt("nworker", opt_nworker, Config::SET_VAL, 'n', "the number of threads for verification");
config.add_opt("help", opt_help, Config::SWITCH_ON, 'h', "show this help info");
EventContext ec;
@@ -199,7 +202,8 @@ int main(int argc, char **argv) {
plisten_addr,
NetAddr("0.0.0.0", client_port),
std::move(pmaker),
- ec);
+ ec,
+ opt_nworker->get());
for (size_t i = 0; i < replicas.size(); i++)
{
auto p = split_ip_port_cport(replicas[i].first);
@@ -224,9 +228,10 @@ HotStuffApp::HotStuffApp(uint32_t blk_size,
NetAddr plisten_addr,
NetAddr clisten_addr,
hotstuff::pacemaker_bt pmaker,
- const EventContext &ec):
+ const EventContext &ec,
+ size_t nworker):
HotStuff(blk_size, idx, raw_privkey,
- plisten_addr, std::move(pmaker), ec),
+ plisten_addr, std::move(pmaker), ec, nworker),
stat_period(stat_period),
impeach_timeout(impeach_timeout),
ec(ec),