diff --git a/.gitignore b/.gitignore index 9af2b39..94acc89 100644 --- a/.gitignore +++ b/.gitignore @@ -137,10 +137,12 @@ dmypy.json # Cython debug symbols cython_debug/ -mytestnet/ +node +client +mytestnet/ persistent_peer.txt -node -client -frontend/node_modules \ No newline at end of file +frontend/node_modules + +.*.json \ No newline at end of file diff --git a/benchmark/commands.py b/benchmark/commands.py index 5d5ad8b..7255c9d 100644 --- a/benchmark/commands.py +++ b/benchmark/commands.py @@ -12,7 +12,7 @@ def clean_node_config(i): @staticmethod def cleanup(): return ( - f'rm -r .db-* ; rm .*.json ; mkdir -p {PathMaker.results_path()}' + f'rm -r .db-* ; rm .*.json ; rm -r mytestnet; mkdir -p {PathMaker.results_path()}' ) @staticmethod diff --git a/benchmark/remote.py b/benchmark/remote.py index b7db467..47bca74 100644 --- a/benchmark/remote.py +++ b/benchmark/remote.py @@ -12,7 +12,7 @@ # import pandas as pd from benchmark.config import Committee, Key, NodeParameters, BenchParameters, ConfigError -from benchmark.utils import BenchError, Print, PathMaker, progress_bar +from benchmark.utils import BenchError, Print, PathMaker, progress_bar, set_weight_cometbft from benchmark.commands import CommandMaker from benchmark.instance import InstanceManager from benchmark.geodec import GeoDec @@ -140,7 +140,11 @@ def _update(self, hosts): def _config(self, hosts, node_parameters, bench_parameters=None): Print.info('Generating configuration files...') - + + # Cleanup all local configuration files. + cmd = CommandMaker.cleanup() + subprocess.run([cmd], shell=True, stderr=subprocess.DEVNULL) + if self.mechanism.name == 'cometbft': # Cleanup node configuration files on hosts for i, host in enumerate(hosts): @@ -158,10 +162,13 @@ def _config(self, hosts, node_parameters, bench_parameters=None): f.close() # Create testnet config files - # cmd = [f'~/cometbft testnet --v {len(hosts)} --config ~/geodec/testdata/cometbft-config.toml'] cmd = [f'~/cometbft testnet --v {len(hosts)}'] + # cmd = [f'~/cometbft testnet --v {len(hosts)} --config ~/geodec/testdata/cometbft-config.toml'] # NOTE custom configuration subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL) + # Update the stake weights in the configuration file + set_weight_cometbft(self.settings.geo_input) + # Run the bash file and store the ouput in this file cmd = [ # 'chmod u+x ./persistent.sh', @@ -169,27 +176,19 @@ def _config(self, hosts, node_parameters, bench_parameters=None): ] subprocess.run(cmd, shell=True) - # NOTE Upload configuration files. + # Upload configuration files. progress = progress_bar(hosts, prefix='Uploading config files:') for i, host in enumerate(hosts): - # Print.info("Sent node config file to " + host) - # NOTE: Path of the node config files - cmd = [f'scp -i {self.settings.key_path} -r ~/geodec/mytestnet/node{i} ubuntu@{host}:~/'] + cmd = [f'scp -i {self.settings.key_path} -r ~/geodec/mytestnet/node{i} ubuntu@{host}:~/'] # NOTE Path of the node config files subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL) else: - # Cleanup all local configuration files. - cmd = CommandMaker.cleanup() - subprocess.run([cmd], shell=True, stderr=subprocess.DEVNULL) - # Recompile the latest code. cmd = CommandMaker.compile().split() subprocess.run(cmd, check=True, cwd=PathMaker.node_crate_path(self.settings.repo_name)) - # subprocess.run(cmd, check=True, cwd=PathMaker.node_crate_path('hotstuff')) # Create alias for the client and nodes binary. cmd = CommandMaker.alias_binaries(PathMaker.binary_path(self.settings.repo_name), self.mechanism.name) - # cmd = CommandMaker.alias_binaries(PathMaker.binary_path('hotstuff'), self.settings.repo_name) subprocess.run([cmd], shell=True) # Generate configuration files. @@ -287,9 +286,9 @@ def _run_single(self, hosts, rate, bench_parameters, node_parameters, debug=Fals # Print.info("Persistent Peers: " + persistent_peers) # Run the clients - # committee = Committee.load(PathMaker.committee_file()) # TODO for cometbft + # committee = Committee.load(PathMaker.committee_file()) # TODO for cometbft addresses = [f'{x}:{self.settings.ports["front"]}' for x in hosts] - # rate_share = ceil(rate / committee.size()) # TODO Take faults into account. + # rate_share = ceil(rate / committee.size()) # TODO Take faults into account. rate_share = ceil(rate / len(hosts)) duration = bench_parameters.duration # Duration for which the client should run client_logs = [PathMaker.client_log_file(i) for i in range(len(hosts))] diff --git a/benchmark/utils.py b/benchmark/utils.py index f635742..e344f9a 100644 --- a/benchmark/utils.py +++ b/benchmark/utils.py @@ -1,3 +1,5 @@ +import csv +import json from os.path import join @@ -165,3 +167,26 @@ def printProgressBar(iteration): yield item printProgressBar(i + 1) print() + +def set_weight_cometbft(geo_input_file): + # Get the stake values + stakes = [] + with open(geo_input_file, mode='r') as file: + csv_reader = csv.DictReader(file) + for row in csv_reader: + if row['stake'] and row['id']: + stakes.append(row['stake']) + + def get_path(i): + return './mytestnet/node{i}/config/genesis.json'.format(i=i) + + # Set the weights + for i in range(len(stakes)): + path = get_path(i) + with open(path, 'r') as file: + data = json.load(file) + for j, validator in enumerate(data['validators']): + validator['power'] = stakes[j] # New value for the "power" field + + with open(path, 'w') as file: + json.dump(data, file, indent=4) \ No newline at end of file diff --git a/fab-params.json b/fab-params.json index 2c84ecf..c717ba8 100644 --- a/fab-params.json +++ b/fab-params.json @@ -27,9 +27,9 @@ "bench_params": { "faults": 0, "nodes": [4], - "rate": [10000], + "rate": [1000], "tx_size": 256, - "duration": 100, + "duration": 60, "runs": 1 }, "node_params": { diff --git a/frontend/public/index.html b/frontend/public/index.html index c10e4d2..291a301 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -42,32 +42,45 @@ cursor: pointer; font-size: 16px; } - #selected-locations { - padding: 10px; - background-color: #282828; - color: #ffffff; - overflow-y: auto; - max-height: 50vh; + #selected-locations-table { + width: 100%; + border-collapse: collapse; } - .location-entry { - margin-bottom: 10px; + #selected-locations-table th, + #selected-locations-table td { + border: 1px solid #0ff; + padding: 8px; + text-align: center; } - .location-entry label { - margin-right: 10px; + #selected-locations-table th { + background-color: #282828; + color: #0ff; } - .location-entry input { - width: 50px; + #selected-locations-table td { + background-color: #1b1b1b; + color: #ffffff; }
- - Download Geo Input +
-
+
+ + + + + + + + + +
NameCountStake
+
diff --git a/frontend/public/script.js b/frontend/public/script.js index 35f7f11..6c28099 100644 --- a/frontend/public/script.js +++ b/frontend/public/script.js @@ -33,6 +33,7 @@ document.addEventListener("DOMContentLoaded", function () { ) if (index === -1) { place.count = 1 // Initialize count + place.stake = 1 // Initialize stake to 1 selectedCoordinates.push(place) addLocationEntry(place) @@ -58,46 +59,44 @@ document.addEventListener("DOMContentLoaded", function () { }) function addLocationEntry(place) { - const entryDiv = document.createElement("div") - entryDiv.className = "location-entry" - entryDiv.dataset.latitude = place.latitude - entryDiv.dataset.longitude = place.longitude + const row = document.createElement("tr") + row.className = "location-entry" + row.dataset.latitude = place.latitude + row.dataset.longitude = place.longitude - const label = document.createElement("label") - label.textContent = place.name + const nameCell = document.createElement("td") + nameCell.textContent = place.name - const input = document.createElement("input") - input.type = "number" - input.value = place.count ? place.count : 1 - input.addEventListener("input", function () { - place.count = parseInt(input.value, 10) - const marker = markers.find( - (m) => - m.getLatLng().lat === place.latitude && - m.getLatLng().lng === place.longitude - ) - if (marker) { - marker - .bindTooltip(`${place.name} (Count: ${place.count})`, { - permanent: true, - direction: "right", - className: "neon-text", - }) - .openTooltip() - } + const countCell = document.createElement("td") + const countInput = document.createElement("input") + countInput.type = "number" + countInput.value = place.count + countInput.addEventListener("input", function () { + place.count = parseInt(countInput.value, 10) + }) + countCell.appendChild(countInput) + + const stakeCell = document.createElement("td") + const stakeInput = document.createElement("input") + stakeInput.type = "number" + stakeInput.value = place.stake + stakeInput.addEventListener("input", function () { + place.stake = parseInt(stakeInput.value, 10) }) + stakeCell.appendChild(stakeInput) - entryDiv.appendChild(label) - entryDiv.appendChild(input) - selectedLocationsContainer.appendChild(entryDiv) + row.appendChild(nameCell) + row.appendChild(countCell) + row.appendChild(stakeCell) + selectedLocationsContainer.appendChild(row) } function removeLocationEntry(place) { - const entryDiv = selectedLocationsContainer.querySelector( - `.location-entry[data-latitude='${place.latitude}'][data-longitude='${place.longitude}']` + const row = selectedLocationsContainer.querySelector( + `tr.location-entry[data-latitude='${place.latitude}'][data-longitude='${place.longitude}']` ) - if (entryDiv) { - selectedLocationsContainer.removeChild(entryDiv) + if (row) { + selectedLocationsContainer.removeChild(row) } } @@ -116,6 +115,7 @@ document.addEventListener("DOMContentLoaded", function () { document.body.removeChild(link) } } + window.saveSelected = function () { fetch("/save-coordinates", { method: "POST", diff --git a/results/bench-cometbft-4-1000-256-0.txt b/results/bench-cometbft-4-1000-256-0.txt new file mode 100644 index 0000000..5d922c8 --- /dev/null +++ b/results/bench-cometbft-4-1000-256-0.txt @@ -0,0 +1,138 @@ +GeoRemote: False +----------------------------------------- + COMETBFT SUMMARY: +----------------------------------------- + Date and Time: 2024-06-23 13:51:10 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 1,000 tx/s + Transaction size: 256 B + Execution time: 44 s + GeoRemote: + + + RESULTS: + Consensus TPS: 857 tx/s + Consensus BPS: 219,483 B/s + Consensus latency: 355 ms + + End-to-end TPS: 903 tx/s + End-to-end BPS: 231,110 B/s + End-to-end latency: 1,141 ms +----------------------------------------- +GeoRemote: False +----------------------------------------- + COMETBFT SUMMARY: +----------------------------------------- + Date and Time: 2024-06-23 13:53:43 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 1,000 tx/s + Transaction size: 256 B + Execution time: 96 s + GeoRemote: + + + RESULTS: + Consensus TPS: 849 tx/s + Consensus BPS: 217,390 B/s + Consensus latency: 373 ms + + End-to-end TPS: 876 tx/s + End-to-end BPS: 224,175 B/s + End-to-end latency: 1,379 ms +----------------------------------------- +GeoRemote: False +----------------------------------------- + COMETBFT SUMMARY: +----------------------------------------- + Date and Time: 2024-06-23 13:57:43 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 1,000 tx/s + Transaction size: 256 B + Execution time: 95 s + GeoRemote: + + + RESULTS: + Consensus TPS: 1,253 tx/s + Consensus BPS: 320,780 B/s + Consensus latency: 419 ms + + End-to-end TPS: 1,295 tx/s + End-to-end BPS: 331,599 B/s + End-to-end latency: 4,784 ms +----------------------------------------- +GeoRemote: False +----------------------------------------- + COMETBFT SUMMARY: +----------------------------------------- + Date and Time: 2024-06-23 14:05:32 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 1,000 tx/s + Transaction size: 256 B + Execution time: 26 s + GeoRemote: + + + RESULTS: + Consensus TPS: 726 tx/s + Consensus BPS: 185,758 B/s + Consensus latency: 353 ms + + End-to-end TPS: 818 tx/s + End-to-end BPS: 209,341 B/s + End-to-end latency: 240,000 ms +----------------------------------------- +GeoRemote: False +----------------------------------------- + COMETBFT SUMMARY: +----------------------------------------- + Date and Time: 2024-06-23 21:42:26 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 1,000 tx/s + Transaction size: 256 B + Execution time: 55 s + GeoRemote: + + + RESULTS: + Consensus TPS: 908 tx/s + Consensus BPS: 232,519 B/s + Consensus latency: 341 ms + + End-to-end TPS: 957 tx/s + End-to-end BPS: 245,099 B/s + End-to-end latency: 1,097 ms +----------------------------------------- +GeoRemote: False +----------------------------------------- + COMETBFT SUMMARY: +----------------------------------------- + Date and Time: 2024-06-23 21:46:57 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 1,000 tx/s + Transaction size: 256 B + Execution time: 55 s + GeoRemote: + + + RESULTS: + Consensus TPS: 885 tx/s + Consensus BPS: 226,530 B/s + Consensus latency: 361 ms + + End-to-end TPS: 930 tx/s + End-to-end BPS: 238,197 B/s + End-to-end latency: 1,786 ms +----------------------------------------- diff --git a/results/bench-hotstuff-4-10000-256-0.txt b/results/bench-hotstuff-4-10000-256-0.txt index 46af8a7..7ddc91d 100644 --- a/results/bench-hotstuff-4-10000-256-0.txt +++ b/results/bench-hotstuff-4-10000-256-0.txt @@ -31,3 +31,65 @@ GeoRemote: True End-to-end BPS: 2,544,894 B/s End-to-end latency: 642 ms ----------------------------------------- +GeoRemote: False +----------------------------------------- + HOTSTUFF SUMMARY: +----------------------------------------- + Date and Time: 2024-06-22 11:37:07 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 10,000 tx/s + Transaction size: 256 B + Execution time: 93 s + GeoRemote: + + Consensus timeout delay: 5,000 ms + Consensus sync retry delay: 5,000 ms + Mempool GC depth: 50 rounds + Mempool sync retry delay: 5,000 ms + Mempool sync retry nodes: 3 nodes + Mempool batch size: 204,800 B + Mempool max batch delay: 100 ms + + + RESULTS: + Consensus TPS: 9,944 tx/s + Consensus BPS: 2,545,658 B/s + Consensus latency: 1,980 ms + + End-to-end TPS: 9,942 tx/s + End-to-end BPS: 2,545,162 B/s + End-to-end latency: 6,793 ms +----------------------------------------- +GeoRemote: False +----------------------------------------- + HOTSTUFF SUMMARY: +----------------------------------------- + Date and Time: 2024-06-22 11:44:16 +----------------------------------------- + + CONFIG: + Faults: 0 nodes + Committee size: 4 nodes + Input rate: 10,000 tx/s + Transaction size: 256 B + Execution time: 93 s + GeoRemote: + + Consensus timeout delay: 5,000 ms + Consensus sync retry delay: 5,000 ms + Mempool GC depth: 50 rounds + Mempool sync retry delay: 5,000 ms + Mempool sync retry nodes: 3 nodes + Mempool batch size: 204,800 B + Mempool max batch delay: 100 ms + + + RESULTS: + Consensus TPS: 3,345 tx/s + Consensus BPS: 856,210 B/s + Consensus latency: 179 ms + + End-to-end TPS: 3,197 tx/s + End-to-end BPS: 818,315 B/s + End-to-end latency: 3,027 ms +----------------------------------------- diff --git a/rundata/geo_input.csv b/rundata/geo_input.csv index 739d487..7574161 100644 --- a/rundata/geo_input.csv +++ b/rundata/geo_input.csv @@ -1,5 +1,5 @@ -id,count -1,1 -2,1 -3,1 -4,1 \ No newline at end of file +id,count,stake +1,1,1 +2,1,1 +3,1,1 +4,1,3 \ No newline at end of file