From 2669c7bf35a793bda5eddd8a6980cb91027f3e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Patron?= Date: Sat, 21 Dec 2024 10:33:39 +0100 Subject: [PATCH 1/5] fix path --- scripts/tig_pool_master.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tig_pool_master.sh b/scripts/tig_pool_master.sh index 78bcc73..d8ba3da 100755 --- a/scripts/tig_pool_master.sh +++ b/scripts/tig_pool_master.sh @@ -127,9 +127,9 @@ wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/requirements.txt -O requirements.txt mkdir -p common cd common -wget https://raw.githubusercontent.com/tig-pool-nk/tig-monorepo/refs/heads/$branch/tig-benchmarker/common/__init__.py -O __init__.py -wget https://raw.githubusercontent.com/tig-pool-nk/tig-monorepo/refs/heads/$branch/tig-benchmarker/common/merkle_tree.py -O merkle_tree.py -wget https://raw.githubusercontent.com/tig-pool-nk/tig-monorepo/refs/heads/$branch/tig-benchmarker/common/structs.py -O structs.py +wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/__init__.py -O __init__.py +wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/merkle_tree.py -O structs.py +wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/structs.py -O structs.py wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/utils.py -O utils.py From b07fa82bbf29f7f1541f6802c4d3a750bb7ef6c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Patron?= Date: Sat, 21 Dec 2024 10:41:38 +0100 Subject: [PATCH 2/5] add no chache to wget --- install.sh | 2 +- scripts/tig_pool_master.sh | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index c2ea42a..8d01b33 100755 --- a/install.sh +++ b/install.sh @@ -27,7 +27,7 @@ cd "tig_pool_$branch" || exit 1 screen -ls | grep pool_tig | awk '{print $1}' | xargs -I {} screen -S {} -X kill # Download and run the updated script -wget "https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/scripts/tig_pool_master.sh" +wget --no-cache "https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/scripts/tig_pool_master.sh" sudo chmod +x tig_pool_master.sh ./tig_pool_master.sh \ diff --git a/scripts/tig_pool_master.sh b/scripts/tig_pool_master.sh index d8ba3da..450a607 100755 --- a/scripts/tig_pool_master.sh +++ b/scripts/tig_pool_master.sh @@ -123,14 +123,14 @@ python3 -m venv venv mkdir -p tig-benchmarker cd tig-benchmarker -wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/slave.py -O slave.py -wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/requirements.txt -O requirements.txt +wget --no-cache https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/slave.py -O slave.py +wget --no-cache https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/requirements.txt -O requirements.txt mkdir -p common cd common -wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/__init__.py -O __init__.py -wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/merkle_tree.py -O structs.py -wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/structs.py -O structs.py -wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/utils.py -O utils.py +wget --no-cache https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/__init__.py -O __init__.py +wget --no-cache https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/merkle_tree.py -O merkle_tree.py +wget --no-cache https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/structs.py -O structs.py +wget --no-cache https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/tig-benchmarker/common/utils.py -O utils.py @@ -143,20 +143,20 @@ mkdir -p bin cd bin # Download the files and check if the download was successful -wget https://github.com/tig-pool-nk/client/raw/refs/heads/$branch/bin/client -O client_tig_pool +wget --no-cache https://github.com/tig-pool-nk/client/raw/refs/heads/$branch/bin/client -O client_tig_pool if [ $? -ne 0 ]; then echo "Error downloading client_tig_pool" exit 1 fi -wget https://github.com/tig-pool-nk/client/raw/refs/heads/$branch/bin/bench -O bench +wget --no-cache https://github.com/tig-pool-nk/client/raw/refs/heads/$branch/bin/bench -O bench if [ $? -ne 0 ]; then echo "Error downloading bench" exit 1 fi -wget https://github.com/tig-pool-nk/client/raw/refs/heads/$branch/bin/tig_idle -O tig_idle +wget --no-cache https://github.com/tig-pool-nk/client/raw/refs/heads/$branch/bin/tig_idle -O tig_idle if [ $? -ne 0 ]; then echo "Error downloading tig_idle" exit 1 @@ -170,7 +170,7 @@ chmod +x tig_idle cd $current_path # Download the launch file and rename it according to the provided parameters -wget -O pool_tig_launch_${id_slave}_${nom_slave}.sh https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/test/scripts/pool_tig_launch_master.sh +wget --no-cache -O pool_tig_launch_${id_slave}_${nom_slave}.sh https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/test/scripts/pool_tig_launch_master.sh # Replace placeholders with variable values sed -i "s|@id@|$id_slave|g" pool_tig_launch_${id_slave}_${nom_slave}.sh @@ -199,7 +199,7 @@ screen -dmL -Logfile "$current_path/logs/pool_tig.log" -S pool_tig bash -c "cd \ cd $current_path mkdir game cd game -wget https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/scripts/snake.sh -O snake.sh +wget --no-cache https://raw.githubusercontent.com/tig-pool-nk/client/refs/heads/$branch/scripts/snake.sh -O snake.sh cd $current_path set +H From f8a0c1ef6f00d85d5a578d4ddb6dd4d74208f799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Patron?= Date: Sat, 21 Dec 2024 11:10:06 +0100 Subject: [PATCH 3/5] review logs --- scripts/tig_pool_master.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tig_pool_master.sh b/scripts/tig_pool_master.sh index 450a607..45ca6d3 100755 --- a/scripts/tig_pool_master.sh +++ b/scripts/tig_pool_master.sh @@ -220,13 +220,13 @@ echo "" echo "To follow the benchmarker, use the commands below:" echo echo " 1. Follow pool:" -echo " tail -f logs/pool_tig" +echo " tail -f ~/tig_pool_main/logs/pool_tig.log" echo echo " 2. Follow slave:" -echo " tail -f logs/slave_tig" +echo " tail -f ~/tig_pool_main/logs/slave_tig.log" echo echo " 3. Have some time to lose :)" -echo " bash game/snake.sh" +echo " bash ~/tig_pool_main/game/snake.sh" echo echo -e "\e[33mGood mining and happy benchmarking!\e[0m" From 8862d951b3a66c8e8c9f644022fe36b792851f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Patron?= Date: Mon, 23 Dec 2024 14:32:17 +0100 Subject: [PATCH 4/5] Fix type for BlockData --- tig-benchmarker/common/structs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tig-benchmarker/common/structs.py b/tig-benchmarker/common/structs.py index c746f3d..c2d29f1 100644 --- a/tig-benchmarker/common/structs.py +++ b/tig-benchmarker/common/structs.py @@ -161,8 +161,8 @@ class BlockDetails(FromDict): @dataclass class BlockData(FromDict): - confirmed_ids: Dict[str, Set[int]] - active_ids: Dict[str, Set[int]] + confirmed_ids: Dict[str, Set[str]] + active_ids: Dict[str, Set[str]] @dataclass class Block(FromDict): From b801f9bf824f35f04faf62ff33186e4908cdbd31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Patron?= Date: Sat, 28 Dec 2024 17:38:21 +0100 Subject: [PATCH 5/5] Add last TIG changes --- tig-benchmarker/slave.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tig-benchmarker/slave.py b/tig-benchmarker/slave.py index 82c706e..d2387b6 100644 --- a/tig-benchmarker/slave.py +++ b/tig-benchmarker/slave.py @@ -10,7 +10,7 @@ import time import zlib from threading import Thread from common.structs import OutputData, MerkleProof -from common.merkle_tree import MerkleTree +from common.merkle_tree import MerkleTree, MerkleHash from datetime import datetime, timedelta logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0]) @@ -97,7 +97,11 @@ def send_results(session, master_ip, master_port, tig_worker_path, download_wasm try: batch_id = READY_BATCH_IDS.pop() except KeyError: - logger.debug("No pending batches") + logger.debug("No batches to send") + return + + if now() - FINISHED_BATCH_IDS.get(batch_id, 0) < 10000: + logger.debug(f"Batch {batch_id} submitted recently") return output_folder = f"{output_path}/{batch_id}" @@ -107,6 +111,7 @@ def send_results(session, master_ip, master_port, tig_worker_path, download_wasm if ( not os.path.exists(f"{output_folder}/result.json") or not os.path.exists(f"{output_folder}/data.zlib") + or not os.path.exists(f"{output_folder}/hashes.zlib") ): if os.path.exists(f"{output_folder}/result.json"): os.remove(f"{output_folder}/result.json") @@ -132,22 +137,21 @@ def send_results(session, master_ip, master_port, tig_worker_path, download_wasm READY_BATCH_IDS.add(batch_id) # requeue else: + with open(f"{output_folder}/hashes.zlib", "rb") as f: + hashes = json.loads(zlib.decompress(f.read()).decode()) with open(f"{output_folder}/data.zlib", "rb") as f: - leafs = [ - OutputData.from_dict(x) - for x in json.loads(zlib.decompress(f.read()).decode()) - ] - + leafs = json.loads(zlib.decompress(f.read()).decode()) + merkle_tree = MerkleTree( - [x.to_merkle_hash() for x in leafs], + [MerkleHash.from_str(x) for x in hashes], batch["batch_size"] ) proofs_to_submit = [ - MerkleProof( + dict( leaf=leafs[n - batch["start_nonce"]], - branch=merkle_tree.calc_merkle_branch(branch_idx=n - batch["start_nonce"]) - ).to_dict() + branch=merkle_tree.calc_merkle_branch(branch_idx=n - batch["start_nonce"]).to_str() + ) for n in batch["sampled_nonces"] ]