aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gen_conf.py38
-rwxr-xr-xscripts/run_client.sh2
-rwxr-xr-xscripts/run_replicas.sh12
-rw-r--r--scripts/thr_hist.py50
4 files changed, 102 insertions, 0 deletions
diff --git a/scripts/gen_conf.py b/scripts/gen_conf.py
new file mode 100644
index 0000000..bc45540
--- /dev/null
+++ b/scripts/gen_conf.py
@@ -0,0 +1,38 @@
+import os, re
+import subprocess
+import itertools
+import argparse
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description='Generate configuration file for a batch of replicas')
+ parser.add_argument('--prefix', type=str, default='hotstuff.gen')
+ parser.add_argument('--iplist', type=str, default=None)
+ parser.add_argument('--iter', type=int, default=10)
+ parser.add_argument('--pport', type=int, default=10000)
+ parser.add_argument('--cport', type=int, default=20000)
+ parser.add_argument('--keygen', type=str, default='./hotstuff-keygen')
+ args = parser.parse_args()
+
+
+ if args.iplist is None:
+ ips = ['127.0.0.1']
+ else:
+ ips = [l.strip() for l in open(args.iplist, 'r').readlines()]
+ prefix = args.prefix
+ iter = args.iter
+ base_pport = args.pport
+ base_cport = args.cport
+ keygen_bin= args.keygen
+
+ main_conf = open("{}.conf".format(prefix), 'w')
+ replicas = ["{}:{};{}".format(ip, base_pport + i, base_cport + i)
+ for ip in ips
+ for i in range(iter)]
+ p = subprocess.Popen([keygen_bin, '--num', str(len(replicas))],
+ stdout=subprocess.PIPE, stderr=open(os.devnull, 'w'))
+ keys = [[t[4:] for t in l.decode('ascii').split()] for l in p.stdout]
+ for r in zip(replicas, keys, itertools.count(0)):
+ main_conf.write("replica = {}, {}\n".format(r[0], r[1][0]))
+ r_conf = open("{}-sec{}.conf".format(prefix, r[2]), 'w')
+ r_conf.write("privkey = {}\n".format(r[1][1]))
+ r_conf.write("idx = {}\n".format(r[2]))
diff --git a/scripts/run_client.sh b/scripts/run_client.sh
new file mode 100755
index 0000000..93a9148
--- /dev/null
+++ b/scripts/run_client.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+./hotstuff-client --idx 0 --iter -1 --max-async 3
diff --git a/scripts/run_replicas.sh b/scripts/run_replicas.sh
new file mode 100755
index 0000000..5f54787
--- /dev/null
+++ b/scripts/run_replicas.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+rep=({0..3})
+if [[ $# -gt 0 ]]; then
+ rep=($@)
+fi
+for i in "${rep[@]}"; do
+ echo "starting replica $i"
+ #valgrind --leak-check=full ./hotstuff-app --conf hotstuff-sec${i}.conf > log${i} 2>&1 &
+ #gdb -ex r -ex bt -ex q --args ./hotstuff-app --conf hotstuff-sec${i}.conf > log${i} 2>&1 &
+ ./hotstuff-app --conf hotstuff-sec${i}.conf > log${i} 2>&1 &
+done
+wait
diff --git a/scripts/thr_hist.py b/scripts/thr_hist.py
new file mode 100644
index 0000000..6f6a43f
--- /dev/null
+++ b/scripts/thr_hist.py
@@ -0,0 +1,50 @@
+import sys
+import re
+import argparse
+from datetime import datetime, timedelta
+
+def str2datetime(s):
+ parts = s.split('.')
+ dt = datetime.strptime(parts[0], "%Y-%m-%d %H:%M:%S")
+ return dt.replace(microsecond=int(parts[1]))
+
+
+def plot_thr(fname):
+ import matplotlib.pyplot as plt
+ x = range(len(values))
+ y = values
+ plt.xlabel(r"time")
+ plt.ylabel(r"tx/sec")
+ plt.plot(x, y)
+ plt.show()
+ plt.savefig(fname)
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--interval', type=float, default=1, required=False)
+ parser.add_argument('--output', type=str, default="hist.png", required=False)
+ args = parser.parse_args()
+ commit_pat = re.compile('([^[].*) \[hotstuff info\].*got <fin decision=1')
+ interval = args.interval
+ begin_time = None
+ next_begin_time = None
+ cnt = 0
+ timestamps = []
+ values = []
+ for line in sys.stdin:
+ m = commit_pat.match(line)
+ if m:
+ timestamps.append(str2datetime(m.group(1)))
+ timestamps.sort()
+ for timestamp in timestamps:
+ if begin_time and timestamp < next_begin_time:
+ cnt += 1
+ else:
+ if begin_time:
+ values.append(cnt)
+ begin_time = timestamp
+ next_begin_time = begin_time + timedelta(seconds=interval)
+ cnt = 1
+ values.append(cnt)
+ print(values)
+ plot_thr(args.output)