From 97346db4c537c5f3080031a424493a3e58612ff4 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 16 Oct 2024 15:04:09 +0400 Subject: [PATCH 01/67] enable THA for validators --- mytoncore/mytoncore.py | 5 ++--- mytonctrl/mytonctrl.py | 15 ++++++--------- mytoninstaller/utils.py | 22 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 76cf58cd..e607f9b6 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -32,6 +32,7 @@ dec2hex, Dict ) +from mytoninstaller.utils import enable_tha class MyTonCore(): @@ -3048,9 +3049,7 @@ def check_enable_mode(self, name): if self.using_liteserver(): raise Exception(f'Cannot enable validator mode while liteserver mode is enabled. ' f'Use `disable_mode liteserver` first.') - if name == 'liquid-staking': - from mytoninstaller.settings import enable_ton_http_api - enable_ton_http_api(self.local) + enable_tha(self.local) def enable_mode(self, name): if name not in MODES: diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 44a868e5..0635b8cc 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -50,6 +50,7 @@ import sys, getopt, os from mytoninstaller.config import get_own_ip +from mytoninstaller.utils import enable_tha def Init(local, ton, console, argv): @@ -327,7 +328,7 @@ def check_branch_exists(author, repo, branch): raise Exception(f"Branch {branch} not found in {url}") #end define -def Update(local, args): +def Update(local, ton, args): repo = "mytonctrl" author, repo, branch = check_git(args, repo, "update") @@ -335,6 +336,8 @@ def Update(local, args): update_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/update.sh') runArgs = ["bash", update_script_path, "-a", author, "-r", repo, "-b", branch] exitCode = run_as_root(runArgs) + if ton.using_validator(): + enable_tha(local) if exitCode == 0: text = "Update - {green}OK{endc}" else: @@ -343,7 +346,7 @@ def Update(local, args): local.exit() #end define -def Upgrade(ton, args): +def Upgrade(local, ton, args): repo = "ton" author, repo, branch = check_git(args, repo, "upgrade") @@ -370,13 +373,7 @@ def Upgrade(ton, args): runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch] exitCode = run_as_root(runArgs) if ton.using_validator(): - try: - from mytoninstaller.mytoninstaller import set_node_argument, get_node_args - node_args = get_node_args() - if node_args.get('--state-ttl') == '604800': - set_node_argument(ton.local, ["--state-ttl", "-d"]) - except Exception as e: - color_print(f"{{red}}Failed to set node argument: {e} {{endc}}") + enable_tha(local) if exitCode == 0: text = "Upgrade - {green}OK{endc}" else: diff --git a/mytoninstaller/utils.py b/mytoninstaller/utils.py index a2cd817f..dc914e30 100644 --- a/mytoninstaller/utils.py +++ b/mytoninstaller/utils.py @@ -2,6 +2,8 @@ import json import time import subprocess + +import requests from nacl.signing import SigningKey @@ -50,3 +52,23 @@ def get_ed25519_pubkey(privkey): pubkey = privkey_obj.verify_key.encode() return pubkey #end define + + +def tha_exists(): + try: + resp = requests.get('http://127.0.0.1:8801/getMasterchainInfo', timeout=3) + except: + return False + if resp.status_code == 200: + return True + return False + + +def enable_tha(local): + try: + if not tha_exists(): + from mytoninstaller.settings import enable_ton_http_api + enable_ton_http_api(local) + except Exception as e: + local.add_log(f"Error in enable_tha: {e}", "warning") + pass From 358dce71ed89e670bca09041277f355e0f4b18c9 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 17 Oct 2024 21:55:14 +0400 Subject: [PATCH 02/67] change tha_exists request --- mytoninstaller/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mytoninstaller/utils.py b/mytoninstaller/utils.py index dc914e30..69c2e022 100644 --- a/mytoninstaller/utils.py +++ b/mytoninstaller/utils.py @@ -56,10 +56,10 @@ def get_ed25519_pubkey(privkey): def tha_exists(): try: - resp = requests.get('http://127.0.0.1:8801/getMasterchainInfo', timeout=3) + resp = requests.get('http://127.0.0.1:8801/healthcheck', timeout=3) except: return False - if resp.status_code == 200: + if resp.status_code == 200 and resp.text == '"OK"': return True return False From 7da7caa1bb28dfaa030f4078bb92b7d31658b566 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 22 Oct 2024 17:20:10 +0400 Subject: [PATCH 03/67] add btc teleport installation --- modules/btc_teleport.py | 52 +++++++++++++++++++++++++++++++ mytonctrl/mytonctrl.py | 8 +++++ mytonctrl/scripts/btc_teleport.sh | 26 ++++++++++++++++ mytonctrl/scripts/update.sh | 2 ++ mytonctrl/scripts/upgrade.sh | 2 +- 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 modules/btc_teleport.py create mode 100644 mytonctrl/scripts/btc_teleport.sh diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py new file mode 100644 index 00000000..78c03465 --- /dev/null +++ b/modules/btc_teleport.py @@ -0,0 +1,52 @@ +import os +import subprocess + +import pkg_resources + +from modules.module import MtcModule +from mypylib.mypylib import add2systemd +from mytoninstaller.utils import start_service + + +class BtcTeleportModule(MtcModule): + + def __init__(self, ton, local, *args, **kwargs): + super().__init__(ton, local, *args, **kwargs) + self.keystore_path = os.path.abspath(self.ton.local.buffer.my_work_dir + '../btc_teleport/keystore/') + os.makedirs(self.keystore_path, exist_ok=True) + self.src_dir = '/usr/src/ton-teleport-btc-oracle/' + + def create_env_file(self): + env_path = self.src_dir + '.env' + if os.path.exists(env_path): + return + + text = f""" +STANDALONE=0 +TON_CENTER_V2_ENDPOINT=http://127.0.0.1:8801 +COORDINATOR=EQDIEVARwkn6_4qNWeDlHwT40kzJBGIzKo4vcqRSvDUUS6bT +VALIDATOR_SERVER_ADDRESS={self.ton.validatorConsole.addr} +KEYSTORE_DIR={self.keystore_path} +SERVER_PUBLIC_KEY_PATH={self.ton.validatorConsole.pubKeyPath} +CLIENT_PRIVATE_KEY_PATH={self.ton.validatorConsole.privKeyPath} +VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath} +""" + with open(env_path, 'w') as f: + f.write(text) + + @staticmethod + def install_sources(): + script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') + subprocess.run("bash", script_path) + + def add_daemon(self): + add2systemd(name="btc_teleport", user=os.getlogin(), start="bun start", workdir=self.src_dir) + start_service(self.local, "btc_teleport") + + def init(self): + self.install_sources() + self.create_env_file() + self.add_daemon() + + def add_console_commands(self, console): + pass diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 0635b8cc..644e847d 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -232,6 +232,7 @@ def PreUp(local: MyPyClass, ton: MyTonCore): check_installer_user(local) check_vport(local, ton) warnings(local, ton) + check_btc_teleport(local, ton) # CheckTonUpdate() #end define @@ -511,6 +512,13 @@ def warnings(local, ton): local.try_function(check_slashed, args=[local, ton]) #end define +def check_btc_teleport(local, ton): + if not ton.using_validator(): + return + from modules.btc_teleport import BtcTeleportModule + module = BtcTeleportModule(ton, local) + local.try_function(module.init) + def CheckTonUpdate(local): git_path = "/usr/src/ton" result = check_git_update(git_path) diff --git a/mytonctrl/scripts/btc_teleport.sh b/mytonctrl/scripts/btc_teleport.sh new file mode 100644 index 00000000..327ed93b --- /dev/null +++ b/mytonctrl/scripts/btc_teleport.sh @@ -0,0 +1,26 @@ +SOURCES_DIR=/usr/src +REPO=ton-teleport-btc-oracle +REPO_URL=https://github.com/RSquad/${REPO}.git + + +if ! command -v rustc >/dev/null 2>&1 +then + echo "installing rust" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rust.sh && bash /tmp/rust.sh -y + rm /tmp/rust.sh +fi + +if ! command -v bun >/dev/null 2>&1 +then + echo "installing bun" + curl -fsSL https://bun.sh/install -o /tmp/bun.sh && bash /tmp/bun.sh + rm /tmp/bun.sh +fi + +cd $SOURCES_DIR +rm -rf $REPO +git clone $REPO_URL + +cd $REPO +bun install +bun run build:frost \ No newline at end of file diff --git a/mytonctrl/scripts/update.sh b/mytonctrl/scripts/update.sh index 8bd4ecd9..02f424ff 100644 --- a/mytonctrl/scripts/update.sh +++ b/mytonctrl/scripts/update.sh @@ -44,6 +44,8 @@ pip3 install -U . systemctl daemon-reload systemctl restart mytoncore +apt-get install -y unzip + # Конец echo -e "${COLOR}[1/1]${ENDC} MyTonCtrl components update completed" exit 0 diff --git a/mytonctrl/scripts/upgrade.sh b/mytonctrl/scripts/upgrade.sh index 81a9fd0b..afb552b1 100644 --- a/mytonctrl/scripts/upgrade.sh +++ b/mytonctrl/scripts/upgrade.sh @@ -29,7 +29,7 @@ COLOR='\033[92m' ENDC='\033[0m' # Установить дополнительные зависимости -apt-get install -y libsecp256k1-dev libsodium-dev ninja-build fio rocksdb-tools liblz4-dev libjemalloc-dev +apt-get install -y libsecp256k1-dev libsodium-dev ninja-build fio rocksdb-tools liblz4-dev libjemalloc-dev unzip # bugfix if the files are in the wrong place wget "https://ton-blockchain.github.io/global.config.json" -O global.config.json From 61031a5ea8a3cbed1fbda1260e8a0a23746b9b39 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 22 Oct 2024 17:44:01 +0400 Subject: [PATCH 04/67] fix enabling tha --- mytonctrl/mytonctrl.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 644e847d..5725b197 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -233,6 +233,7 @@ def PreUp(local: MyPyClass, ton: MyTonCore): check_vport(local, ton) warnings(local, ton) check_btc_teleport(local, ton) + check_tha(local, ton) # CheckTonUpdate() #end define @@ -329,7 +330,7 @@ def check_branch_exists(author, repo, branch): raise Exception(f"Branch {branch} not found in {url}") #end define -def Update(local, ton, args): +def Update(local, args): repo = "mytonctrl" author, repo, branch = check_git(args, repo, "update") @@ -337,8 +338,6 @@ def Update(local, ton, args): update_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/update.sh') runArgs = ["bash", update_script_path, "-a", author, "-r", repo, "-b", branch] exitCode = run_as_root(runArgs) - if ton.using_validator(): - enable_tha(local) if exitCode == 0: text = "Update - {green}OK{endc}" else: @@ -347,7 +346,7 @@ def Update(local, ton, args): local.exit() #end define -def Upgrade(local, ton, args): +def Upgrade(ton, args): repo = "ton" author, repo, branch = check_git(args, repo, "upgrade") @@ -373,8 +372,6 @@ def Upgrade(local, ton, args): upgrade_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/upgrade.sh') runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch] exitCode = run_as_root(runArgs) - if ton.using_validator(): - enable_tha(local) if exitCode == 0: text = "Upgrade - {green}OK{endc}" else: @@ -519,6 +516,12 @@ def check_btc_teleport(local, ton): module = BtcTeleportModule(ton, local) local.try_function(module.init) + +def check_tha(local, ton): + if ton.using_validator(): + enable_tha(local) + + def CheckTonUpdate(local): git_path = "/usr/src/ton" result = check_git_update(git_path) From 131c31886c4473783b851c8f0edadbafe8f624b2 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 23 Oct 2024 14:27:28 +0400 Subject: [PATCH 05/67] fix btct init --- modules/btc_teleport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 78c03465..2d4f90b2 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -37,7 +37,7 @@ def create_env_file(self): @staticmethod def install_sources(): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') - subprocess.run("bash", script_path) + subprocess.run(["bash", script_path]) def add_daemon(self): add2systemd(name="btc_teleport", user=os.getlogin(), start="bun start", workdir=self.src_dir) From f5bbc0f5b37a8ae87ef1329975f2db6f9b622dab Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 23 Oct 2024 15:35:34 +0400 Subject: [PATCH 06/67] update src dir for btct --- modules/btc_teleport.py | 28 ++++++++++++---------------- mytonctrl/scripts/btc_teleport.sh | 25 +++++++++++++++++++++---- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 2d4f90b2..4260c973 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -1,20 +1,18 @@ import os -import subprocess import pkg_resources from modules.module import MtcModule -from mypylib.mypylib import add2systemd -from mytoninstaller.utils import start_service +from mypylib.mypylib import run_as_root class BtcTeleportModule(MtcModule): def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) - self.keystore_path = os.path.abspath(self.ton.local.buffer.my_work_dir + '../btc_teleport/keystore/') - os.makedirs(self.keystore_path, exist_ok=True) - self.src_dir = '/usr/src/ton-teleport-btc-oracle/' + self.workdir = os.path.abspath(self.ton.local.buffer.my_work_dir + '../btc_teleport/') + self.keystore_path = self.workdir + '/keystore/' + self.src_dir = self.workdir + '/src/' def create_env_file(self): env_path = self.src_dir + '.env' @@ -34,19 +32,17 @@ def create_env_file(self): with open(env_path, 'w') as f: f.write(text) - @staticmethod - def install_sources(): + def install(self): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') - subprocess.run(["bash", script_path]) - - def add_daemon(self): - add2systemd(name="btc_teleport", user=os.getlogin(), start="bun start", workdir=self.src_dir) - start_service(self.local, "btc_teleport") + run_as_root(["bash", script_path, "-s", self.src_dir]) - def init(self): - self.install_sources() + def init(self, reinstall=False): + if os.path.exists(self.src_dir) and not reinstall: + return + os.makedirs(self.keystore_path, exist_ok=True) + os.makedirs(self.src_dir, exist_ok=True) + self.install() self.create_env_file() - self.add_daemon() def add_console_commands(self, console): pass diff --git a/mytonctrl/scripts/btc_teleport.sh b/mytonctrl/scripts/btc_teleport.sh index 327ed93b..be4692f1 100644 --- a/mytonctrl/scripts/btc_teleport.sh +++ b/mytonctrl/scripts/btc_teleport.sh @@ -1,7 +1,22 @@ -SOURCES_DIR=/usr/src REPO=ton-teleport-btc-oracle +SRC_DIR="" + +while getopts s:r: flag +do + case "${flag}" in + s) SRC_DIR=${OPTARG};; + r) REPO=${OPTARG};; + *) echo "Flag -${flag} is not recognized. Aborting"; exit 1 ;; + esac +done + REPO_URL=https://github.com/RSquad/${REPO}.git +if ! command -v unzip >/dev/null 2>&1 +then + echo "installing unzip" + apt-get install -y unzip +fi if ! command -v rustc >/dev/null 2>&1 then @@ -17,10 +32,12 @@ then rm /tmp/bun.sh fi -cd $SOURCES_DIR +cd $SRC_DIR || exit 1 rm -rf $REPO git clone $REPO_URL -cd $REPO +cd $REPO || exit 1 bun install -bun run build:frost \ No newline at end of file +bun run build:frost + +python3 -c "import mypylib; mypylib.add2systemd(name='btc_teleport', user=os.getlogin(), start='bun start', workdir=${SRC_DIR})" From 460284e2486f66d761391b7c98383f553a133663 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 24 Oct 2024 11:47:20 +0400 Subject: [PATCH 07/67] update btct installation --- modules/btc_teleport.py | 14 ++++++++------ mytonctrl/scripts/btc_teleport.sh | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 4260c973..86538877 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -1,4 +1,5 @@ import os +import subprocess import pkg_resources @@ -10,12 +11,13 @@ class BtcTeleportModule(MtcModule): def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) - self.workdir = os.path.abspath(self.ton.local.buffer.my_work_dir + '../btc_teleport/') - self.keystore_path = self.workdir + '/keystore/' - self.src_dir = self.workdir + '/src/' + self.workdir = os.path.abspath(self.ton.local.buffer.my_work_dir + '../btc_teleport') + self.keystore_path = self.workdir + '/keystore' + self.repo_name = 'ton-teleport-btc-oracle' + self.src_dir = self.workdir + f'/{self.repo_name}' def create_env_file(self): - env_path = self.src_dir + '.env' + env_path = self.src_dir + '/.env' if os.path.exists(env_path): return @@ -34,13 +36,13 @@ def create_env_file(self): def install(self): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') - run_as_root(["bash", script_path, "-s", self.src_dir]) + subprocess.run(["bash", script_path, "-s", self.workdir, "-r", self.repo_name]) def init(self, reinstall=False): if os.path.exists(self.src_dir) and not reinstall: return os.makedirs(self.keystore_path, exist_ok=True) - os.makedirs(self.src_dir, exist_ok=True) + os.makedirs(self.workdir, exist_ok=True) self.install() self.create_env_file() diff --git a/mytonctrl/scripts/btc_teleport.sh b/mytonctrl/scripts/btc_teleport.sh index be4692f1..79e986b1 100644 --- a/mytonctrl/scripts/btc_teleport.sh +++ b/mytonctrl/scripts/btc_teleport.sh @@ -15,7 +15,7 @@ REPO_URL=https://github.com/RSquad/${REPO}.git if ! command -v unzip >/dev/null 2>&1 then echo "installing unzip" - apt-get install -y unzip + sudo apt-get install -y unzip fi if ! command -v rustc >/dev/null 2>&1 @@ -40,4 +40,6 @@ cd $REPO || exit 1 bun install bun run build:frost -python3 -c "import mypylib; mypylib.add2systemd(name='btc_teleport', user=os.getlogin(), start='bun start', workdir=${SRC_DIR})" +bun_executable=$(which bun) + +sudo python3 -c "import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='${bun_executable} start', workdir='${SRC_DIR}/${REPO}'); subprocess.run(['systemctl', 'daemon-reload']); subprocess.run(['systemctl', 'restart', 'btc_teleport'])" \ No newline at end of file From 962c246125e92842e83662e64dbadcf1f45e8156 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 25 Oct 2024 16:49:23 +0400 Subject: [PATCH 08/67] move btct installing to Upgrade --- mytonctrl/mytonctrl.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 5725b197..8d5c7782 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -232,8 +232,6 @@ def PreUp(local: MyPyClass, ton: MyTonCore): check_installer_user(local) check_vport(local, ton) warnings(local, ton) - check_btc_teleport(local, ton) - check_tha(local, ton) # CheckTonUpdate() #end define @@ -346,7 +344,11 @@ def Update(local, args): local.exit() #end define -def Upgrade(ton, args): +def Upgrade(local, ton, args): + if '--btc-teleport' in args: # upgrade --btc-teleport + enable_tha(local) + upgrade_btc_teleport(local, ton) + return repo = "ton" author, repo, branch = check_git(args, repo, "upgrade") @@ -372,6 +374,9 @@ def Upgrade(ton, args): upgrade_script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/upgrade.sh') runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch] exitCode = run_as_root(runArgs) + if ton.using_validator(): + enable_tha(local) + upgrade_btc_teleport(local, ton) if exitCode == 0: text = "Upgrade - {green}OK{endc}" else: @@ -379,6 +384,11 @@ def Upgrade(ton, args): color_print(text) #end define +def upgrade_btc_teleport(local, ton): + from modules.btc_teleport import BtcTeleportModule + module = BtcTeleportModule(ton, local) + local.try_function(module.init) + def rollback_to_mtc1(local, ton, args): color_print("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}") a = input("Do you want to continue? [Y/n]\n") @@ -509,18 +519,6 @@ def warnings(local, ton): local.try_function(check_slashed, args=[local, ton]) #end define -def check_btc_teleport(local, ton): - if not ton.using_validator(): - return - from modules.btc_teleport import BtcTeleportModule - module = BtcTeleportModule(ton, local) - local.try_function(module.init) - - -def check_tha(local, ton): - if ton.using_validator(): - enable_tha(local) - def CheckTonUpdate(local): git_path = "/usr/src/ton" From 8a4b9ca720a4dcff0b19dac4f5111a8111084513 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 25 Oct 2024 19:19:25 +0400 Subject: [PATCH 09/67] fix rights in btct installer --- modules/btc_teleport.py | 11 +++++++++++ mytonctrl/scripts/btc_teleport.sh | 11 +---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 86538877..b1814e18 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -34,9 +34,20 @@ def create_env_file(self): with open(env_path, 'w') as f: f.write(text) + @staticmethod + def install_unzip(): + if subprocess.run(['command', '-v', 'unzip']).returncode != 0: + run_as_root(['apt-get', 'install', 'unzip']) + + def add_daemon(self): + bun_executable = subprocess.run(['command', '-v', 'bun'], stdout=subprocess.PIPE).stdout.decode().strip() + cmd = f"import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='{bun_executable} start', workdir='{self.src_dir}'); subprocess.run(['systemctl', 'daemon-reload']); subprocess.run(['systemctl', 'restart', 'btc_teleport'])" + run_as_root(['python3', '-c', cmd]) + def install(self): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') subprocess.run(["bash", script_path, "-s", self.workdir, "-r", self.repo_name]) + self.add_daemon() def init(self, reinstall=False): if os.path.exists(self.src_dir) and not reinstall: diff --git a/mytonctrl/scripts/btc_teleport.sh b/mytonctrl/scripts/btc_teleport.sh index 79e986b1..038537fe 100644 --- a/mytonctrl/scripts/btc_teleport.sh +++ b/mytonctrl/scripts/btc_teleport.sh @@ -12,12 +12,6 @@ done REPO_URL=https://github.com/RSquad/${REPO}.git -if ! command -v unzip >/dev/null 2>&1 -then - echo "installing unzip" - sudo apt-get install -y unzip -fi - if ! command -v rustc >/dev/null 2>&1 then echo "installing rust" @@ -30,6 +24,7 @@ then echo "installing bun" curl -fsSL https://bun.sh/install -o /tmp/bun.sh && bash /tmp/bun.sh rm /tmp/bun.sh + source /${HOME}/.bashrc fi cd $SRC_DIR || exit 1 @@ -39,7 +34,3 @@ git clone $REPO_URL cd $REPO || exit 1 bun install bun run build:frost - -bun_executable=$(which bun) - -sudo python3 -c "import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='${bun_executable} start', workdir='${SRC_DIR}/${REPO}'); subprocess.run(['systemctl', 'daemon-reload']); subprocess.run(['systemctl', 'restart', 'btc_teleport'])" \ No newline at end of file From 976acfec8031d9e9c2228b94bf1a42b19680d479 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 28 Oct 2024 15:02:35 +0400 Subject: [PATCH 10/67] fix CreateLocalConfigFile --- mytoninstaller/mytoninstaller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mytoninstaller/mytoninstaller.py b/mytoninstaller/mytoninstaller.py index 270afe97..2445eb1d 100644 --- a/mytoninstaller/mytoninstaller.py +++ b/mytoninstaller/mytoninstaller.py @@ -194,6 +194,8 @@ def PrintLiteServerConfig(local, args): def CreateLocalConfigFile(local, args): initBlock = GetInitBlock() initBlock_b64 = dict2b64(initBlock) + if local.buffer.user is None: + local.buffer.user = os.environ.get("USER", "root") args = ["python3", "-m", "mytoninstaller", "-u", local.buffer.user, "-e", "clc", "-i", initBlock_b64] run_as_root(args) #end define From 9cefe55fbae5f46c2e4639dc309d50baefc03d2a Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 28 Oct 2024 15:13:09 +0400 Subject: [PATCH 11/67] fix btct installation --- modules/btc_teleport.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index b1814e18..83da78f1 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -36,15 +36,16 @@ def create_env_file(self): @staticmethod def install_unzip(): - if subprocess.run(['command', '-v', 'unzip']).returncode != 0: + if subprocess.run('command -v unzip', shell=True).returncode != 0: run_as_root(['apt-get', 'install', 'unzip']) def add_daemon(self): - bun_executable = subprocess.run(['command', '-v', 'bun'], stdout=subprocess.PIPE).stdout.decode().strip() - cmd = f"import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='{bun_executable} start', workdir='{self.src_dir}'); subprocess.run(['systemctl', 'daemon-reload']); subprocess.run(['systemctl', 'restart', 'btc_teleport'])" + bun_executable = subprocess.run('command -v bun', stdout=subprocess.PIPE, shell=True).stdout.decode().strip() + cmd = f'''"import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='{bun_executable} start', workdir='{self.src_dir}'); subprocess.run(['systemctl', 'daemon-reload']); subprocess.run(['systemctl', 'restart', 'btc_teleport'])"''' run_as_root(['python3', '-c', cmd]) def install(self): + self.install_unzip() script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') subprocess.run(["bash", script_path, "-s", self.workdir, "-r", self.repo_name]) self.add_daemon() From 1a47cdecb9b302ff9440eb5aa30f2797e7ef9a83 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 31 Jan 2025 10:25:49 +0400 Subject: [PATCH 12/67] fix list_alerts --- modules/alert_bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/alert_bot.py b/modules/alert_bot.py index 58316e73..d03e6a39 100644 --- a/modules/alert_bot.py +++ b/modules/alert_bot.py @@ -218,6 +218,7 @@ def disable_alert(self, args): color_print("disable_alert - {green}OK{endc}") def print_alerts(self, args): + init_alerts() table = [['Name', 'Enabled', 'Last sent']] for alert_name in ALERTS: alert = self.get_alert_from_db(alert_name) From 9caa06cccd7d0616d09b8614d25293c3d013a0fa Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 25 Mar 2025 12:21:09 +0000 Subject: [PATCH 13/67] rm unzip dependency --- modules/btc_teleport.py | 6 ------ mytonctrl/scripts/update.sh | 2 -- mytonctrl/scripts/upgrade.sh | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 83da78f1..f6629290 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -34,18 +34,12 @@ def create_env_file(self): with open(env_path, 'w') as f: f.write(text) - @staticmethod - def install_unzip(): - if subprocess.run('command -v unzip', shell=True).returncode != 0: - run_as_root(['apt-get', 'install', 'unzip']) - def add_daemon(self): bun_executable = subprocess.run('command -v bun', stdout=subprocess.PIPE, shell=True).stdout.decode().strip() cmd = f'''"import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='{bun_executable} start', workdir='{self.src_dir}'); subprocess.run(['systemctl', 'daemon-reload']); subprocess.run(['systemctl', 'restart', 'btc_teleport'])"''' run_as_root(['python3', '-c', cmd]) def install(self): - self.install_unzip() script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') subprocess.run(["bash", script_path, "-s", self.workdir, "-r", self.repo_name]) self.add_daemon() diff --git a/mytonctrl/scripts/update.sh b/mytonctrl/scripts/update.sh index da5037ef..c9de406b 100644 --- a/mytonctrl/scripts/update.sh +++ b/mytonctrl/scripts/update.sh @@ -46,8 +46,6 @@ pip3 install -U . systemctl daemon-reload systemctl restart mytoncore -apt-get install -y unzip - # Конец echo -e "${COLOR}[1/1]${ENDC} MyTonCtrl components update completed" exit 0 diff --git a/mytonctrl/scripts/upgrade.sh b/mytonctrl/scripts/upgrade.sh index 95daccdb..fe952562 100644 --- a/mytonctrl/scripts/upgrade.sh +++ b/mytonctrl/scripts/upgrade.sh @@ -30,7 +30,7 @@ COLOR='\033[92m' ENDC='\033[0m' # Установить дополнительные зависимости -apt-get install -y libsecp256k1-dev libsodium-dev ninja-build fio rocksdb-tools liblz4-dev libjemalloc-dev automake libtool unzip +apt-get install -y libsecp256k1-dev libsodium-dev ninja-build fio rocksdb-tools liblz4-dev libjemalloc-dev automake libtool # bugfix if the files are in the wrong place wget "https://ton-blockchain.github.io/global.config.json" -O global.config.json From 473d502a4b30e3f6f76f13143d613f7e3069638e Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 25 Mar 2025 13:50:39 +0000 Subject: [PATCH 14/67] rm bun, enabling tha --- mytoncore/mytoncore.py | 5 +++-- mytonctrl/mytonctrl.py | 3 --- mytonctrl/scripts/btc_teleport.sh | 10 ---------- mytoninstaller/utils.py | 22 ---------------------- 4 files changed, 3 insertions(+), 37 deletions(-) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 313a5ebe..63c571ed 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -32,7 +32,6 @@ dec2hex, Dict, int2ip ) -from mytoninstaller.utils import enable_tha class MyTonCore(): @@ -3092,7 +3091,9 @@ def check_enable_mode(self, name): if self.using_liteserver(): raise Exception(f'Cannot enable validator mode while liteserver mode is enabled. ' f'Use `disable_mode liteserver` first.') - enable_tha(self.local) + if name == 'liquid-staking': + from mytoninstaller.settings import enable_ton_http_api + enable_ton_http_api(self.local) def enable_mode(self, name): if name not in MODES: diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index d3d2e847..3f590ab5 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -50,7 +50,6 @@ import sys, getopt, os from mytoninstaller.config import get_own_ip -from mytoninstaller.utils import enable_tha def Init(local, ton, console, argv): @@ -347,7 +346,6 @@ def Update(local, args): def Upgrade(local, ton, args): if '--btc-teleport' in args: # upgrade --btc-teleport - enable_tha(local) upgrade_btc_teleport(local, ton) return repo = "ton" @@ -376,7 +374,6 @@ def Upgrade(local, ton, args): runArgs = ["bash", upgrade_script_path, "-a", author, "-r", repo, "-b", branch] exitCode = run_as_root(runArgs) if ton.using_validator(): - enable_tha(local) upgrade_btc_teleport(local, ton) if exitCode == 0: text = "Upgrade - {green}OK{endc}" diff --git a/mytonctrl/scripts/btc_teleport.sh b/mytonctrl/scripts/btc_teleport.sh index 038537fe..3e61a98d 100644 --- a/mytonctrl/scripts/btc_teleport.sh +++ b/mytonctrl/scripts/btc_teleport.sh @@ -19,18 +19,8 @@ then rm /tmp/rust.sh fi -if ! command -v bun >/dev/null 2>&1 -then - echo "installing bun" - curl -fsSL https://bun.sh/install -o /tmp/bun.sh && bash /tmp/bun.sh - rm /tmp/bun.sh - source /${HOME}/.bashrc -fi - cd $SRC_DIR || exit 1 rm -rf $REPO git clone $REPO_URL cd $REPO || exit 1 -bun install -bun run build:frost diff --git a/mytoninstaller/utils.py b/mytoninstaller/utils.py index 69c2e022..a2cd817f 100644 --- a/mytoninstaller/utils.py +++ b/mytoninstaller/utils.py @@ -2,8 +2,6 @@ import json import time import subprocess - -import requests from nacl.signing import SigningKey @@ -52,23 +50,3 @@ def get_ed25519_pubkey(privkey): pubkey = privkey_obj.verify_key.encode() return pubkey #end define - - -def tha_exists(): - try: - resp = requests.get('http://127.0.0.1:8801/healthcheck', timeout=3) - except: - return False - if resp.status_code == 200 and resp.text == '"OK"': - return True - return False - - -def enable_tha(local): - try: - if not tha_exists(): - from mytoninstaller.settings import enable_ton_http_api - enable_ton_http_api(local) - except Exception as e: - local.add_log(f"Error in enable_tha: {e}", "warning") - pass From a28110cb0c0853cb48f33aaccbfcde0b76a3c7d4 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 27 Mar 2025 13:28:00 +0000 Subject: [PATCH 15/67] update btc teleport installation --- modules/btc_teleport.py | 41 ++++++++++++++++-------------- mytonctrl/mytonctrl.py | 6 ++--- mytonctrl/scripts/btc_teleport.sh | 26 ------------------- mytonctrl/scripts/btc_teleport1.sh | 35 +++++++++++++++++++++++++ mytonctrl/scripts/btc_teleport2.sh | 38 +++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 48 deletions(-) delete mode 100644 mytonctrl/scripts/btc_teleport.sh create mode 100644 mytonctrl/scripts/btc_teleport1.sh create mode 100644 mytonctrl/scripts/btc_teleport2.sh diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index f6629290..9678b9b5 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -11,46 +11,49 @@ class BtcTeleportModule(MtcModule): def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) - self.workdir = os.path.abspath(self.ton.local.buffer.my_work_dir + '../btc_teleport') - self.keystore_path = self.workdir + '/keystore' - self.repo_name = 'ton-teleport-btc-oracle' - self.src_dir = self.workdir + f'/{self.repo_name}' + self.keystore_path = self.ton.local.buffer.my_work_dir + '/btc_oracle_keystore' + self.repo_name = 'ton-teleport-btc-periphery' + self.src_dir = '/usr/src/' + f'/{self.repo_name}' + self.bin_dir = self.src_dir + '/out' def create_env_file(self): - env_path = self.src_dir + '/.env' + env_path = self.bin_dir + '/.env' if os.path.exists(env_path): return text = f""" -STANDALONE=0 -TON_CENTER_V2_ENDPOINT=http://127.0.0.1:8801 -COORDINATOR=EQDIEVARwkn6_4qNWeDlHwT40kzJBGIzKo4vcqRSvDUUS6bT -VALIDATOR_SERVER_ADDRESS={self.ton.validatorConsole.addr} -KEYSTORE_DIR={self.keystore_path} -SERVER_PUBLIC_KEY_PATH={self.ton.validatorConsole.pubKeyPath} -CLIENT_PRIVATE_KEY_PATH={self.ton.validatorConsole.privKeyPath} -VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath} +COMMON_TON_CONFIG_URL=https://ton-blockchain.github.io/testnet-global.config.json +COMMON_TON_CONTRACT_COORDINATOR=EQD5URgpjt00h5x4i9MFHWX1UjmuniYPMWnYVGwmZguJ0tMh +ORACLE_STANDALONE_MODE=false +ORACLE_KEYSTORE_PATH={self.keystore_path} +ORACLE_VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath} +ORACLE_SERVER_PUBLIC_KEY_PATH={self.ton.validatorConsole.pubKeyPath} +ORACLE_CLIENT_PRIVATE_KEY_PATH={self.ton.validatorConsole.privKeyPath} +ORACLE_VALIDATOR_SERVER_ADDR={self.ton.validatorConsole.addr} """ with open(env_path, 'w') as f: f.write(text) def add_daemon(self): - bun_executable = subprocess.run('command -v bun', stdout=subprocess.PIPE, shell=True).stdout.decode().strip() - cmd = f'''"import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='{bun_executable} start', workdir='{self.src_dir}'); subprocess.run(['systemctl', 'daemon-reload']); subprocess.run(['systemctl', 'restart', 'btc_teleport'])"''' + start = f'{self.bin_dir}/oracle' + cmd = f'''import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='{start}', workdir='{self.bin_dir}'); subprocess.run(['systemctl', 'restart', 'btc_teleport'])''' run_as_root(['python3', '-c', cmd]) def install(self): - script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport.sh') - subprocess.run(["bash", script_path, "-s", self.workdir, "-r", self.repo_name]) - self.add_daemon() + script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport1.sh') + exit_code = run_as_root(["bash", script_path, "-s", '/usr/src', "-r", self.repo_name]) + if exit_code != 0: + raise Exception('Failed to install btc_teleport') + script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport2.sh') + subprocess.run(["bash", script_path, "-s", self.src_dir]) def init(self, reinstall=False): if os.path.exists(self.src_dir) and not reinstall: return os.makedirs(self.keystore_path, exist_ok=True) - os.makedirs(self.workdir, exist_ok=True) self.install() self.create_env_file() + self.add_daemon() def add_console_commands(self, console): pass diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 3f590ab5..dedde08d 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -346,7 +346,7 @@ def Update(local, args): def Upgrade(local, ton, args): if '--btc-teleport' in args: # upgrade --btc-teleport - upgrade_btc_teleport(local, ton) + upgrade_btc_teleport(local, ton, reinstall=True) return repo = "ton" author, repo, branch = check_git(args, repo, "upgrade") @@ -382,10 +382,10 @@ def Upgrade(local, ton, args): color_print(text) #end define -def upgrade_btc_teleport(local, ton): +def upgrade_btc_teleport(local, ton, reinstall=False): from modules.btc_teleport import BtcTeleportModule module = BtcTeleportModule(ton, local) - local.try_function(module.init) + local.try_function(module.init, args=[reinstall]) def rollback_to_mtc1(local, ton, args): color_print("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}") diff --git a/mytonctrl/scripts/btc_teleport.sh b/mytonctrl/scripts/btc_teleport.sh deleted file mode 100644 index 3e61a98d..00000000 --- a/mytonctrl/scripts/btc_teleport.sh +++ /dev/null @@ -1,26 +0,0 @@ -REPO=ton-teleport-btc-oracle -SRC_DIR="" - -while getopts s:r: flag -do - case "${flag}" in - s) SRC_DIR=${OPTARG};; - r) REPO=${OPTARG};; - *) echo "Flag -${flag} is not recognized. Aborting"; exit 1 ;; - esac -done - -REPO_URL=https://github.com/RSquad/${REPO}.git - -if ! command -v rustc >/dev/null 2>&1 -then - echo "installing rust" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rust.sh && bash /tmp/rust.sh -y - rm /tmp/rust.sh -fi - -cd $SRC_DIR || exit 1 -rm -rf $REPO -git clone $REPO_URL - -cd $REPO || exit 1 diff --git a/mytonctrl/scripts/btc_teleport1.sh b/mytonctrl/scripts/btc_teleport1.sh new file mode 100644 index 00000000..4c4dd340 --- /dev/null +++ b/mytonctrl/scripts/btc_teleport1.sh @@ -0,0 +1,35 @@ +REPO="" +SRC_DIR="" +USER=$(logname) + +while getopts s:r: flag +do + case "${flag}" in + s) SRC_DIR=${OPTARG};; + r) REPO=${OPTARG};; + *) echo "Flag -${flag} is not recognized. Aborting"; exit 1 ;; + esac +done + +# install go +GO_BIN_PATH=/usr/local/go/bin/go +if [ ! -f $GO_BIN_PATH ] || { [ -f $GO_BIN_PATH ] && [[ "$($GO_BIN_PATH version)" != *"1.23.1"* ]]; }; then + wget https://go.dev/dl/go1.23.1.linux-amd64.tar.gz + rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz && rm go1.23.1.linux-amd64.tar.gz + echo installed go 1.23.1 +fi + + +# clone repo + +REPO_URL=https://github.com/RSquad/${REPO}.git + +cd $SRC_DIR || exit 1 +rm -rf $REPO +git clone $REPO_URL + +chown -R $USER:$USER $REPO + +git config --global --add safe.directory $SRC_DIR/$REPO + +echo "oracle sources cloned successfully" diff --git a/mytonctrl/scripts/btc_teleport2.sh b/mytonctrl/scripts/btc_teleport2.sh new file mode 100644 index 00000000..180bee51 --- /dev/null +++ b/mytonctrl/scripts/btc_teleport2.sh @@ -0,0 +1,38 @@ +SRC_DIR="" + +while getopts s: flag +do + case "${flag}" in + s) SRC_DIR=${OPTARG};; + *) echo "Flag -${flag} is not recognized. Aborting"; exit 1 ;; + esac +done + +# install rust +if ! command -v rustc >/dev/null 2>&1 +then + echo "installing rust" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rust.sh && bash /tmp/rust.sh -y + rm /tmp/rust.sh + echo "installed rust" +fi + +cargo install cbindgen + +# build frost + +cd $SRC_DIR/frost || exit 1 + +cd rust +./build.sh +cd .. + +/usr/local/go/bin/go build . +/usr/local/go/bin/go test -v || exit 1 + +echo "frost built successfully" + +cd $SRC_DIR +/usr/local/go/bin/go build -o out/oracle ./oracle/cmd/main.go + +echo "oracle built successfully" From ef7766a3c0d24a6ebee90a82a5ee6180bc15d1b6 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 27 Mar 2025 23:35:45 +0000 Subject: [PATCH 16/67] fix install rust --- mytonctrl/scripts/btc_teleport2.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/mytonctrl/scripts/btc_teleport2.sh b/mytonctrl/scripts/btc_teleport2.sh index 180bee51..6f314d13 100644 --- a/mytonctrl/scripts/btc_teleport2.sh +++ b/mytonctrl/scripts/btc_teleport2.sh @@ -14,6 +14,7 @@ then echo "installing rust" curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rust.sh && bash /tmp/rust.sh -y rm /tmp/rust.sh + . "$HOME/.cargo/env" echo "installed rust" fi From f8237164f36eeb832e01eb3f370e034de03895f8 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 27 Mar 2025 23:49:54 +0000 Subject: [PATCH 17/67] add chmod --- modules/btc_teleport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 9678b9b5..64fd3c1f 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -50,7 +50,7 @@ def install(self): def init(self, reinstall=False): if os.path.exists(self.src_dir) and not reinstall: return - os.makedirs(self.keystore_path, exist_ok=True) + os.makedirs(self.keystore_path, mode=0o700, exist_ok=True) self.install() self.create_env_file() self.add_daemon() From f8e9f610a7c0de2a7f2798e6e5ce1d76a543b8b2 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 1 Apr 2025 11:36:33 +0100 Subject: [PATCH 18/67] add btc teleport version to status --- modules/btc_teleport.py | 2 +- mytonctrl/mytonctrl.py | 17 +++++++++++++++++ mytonctrl/resources/translate.json | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 64fd3c1f..9fc4f0ac 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -23,7 +23,7 @@ def create_env_file(self): text = f""" COMMON_TON_CONFIG_URL=https://ton-blockchain.github.io/testnet-global.config.json -COMMON_TON_CONTRACT_COORDINATOR=EQD5URgpjt00h5x4i9MFHWX1UjmuniYPMWnYVGwmZguJ0tMh +COMMON_TON_CONTRACT_COORDINATOR=EQAmHFjKpq3ecr3WqSY4w-qy6VHVVdjYH8kIRWq5xdwudIPC ORACLE_STANDALONE_MODE=false ORACLE_KEYSTORE_PATH={self.keystore_path} ORACLE_VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath} diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index dedde08d..cb5a3619 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -754,8 +754,18 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, mtcGitPath = "/usr/src/mytonctrl" validatorGitPath = "/usr/src/ton" validatorBinGitPath = "/usr/bin/ton/validator-engine/validator-engine" + btc_teleport_path = "/usr/src/ton-teleport-btc-periphery/" mtcGitHash = get_git_hash(mtcGitPath, short=True) validatorGitHash = GetBinGitHash(validatorBinGitPath, short=True) + btc_teleport_git_hash = None + btc_teleport_git_branch = None + if ton.using_validator(): + if os.path.exists(btc_teleport_path): + btc_teleport_git_hash = get_git_hash(btc_teleport_path, short=True) + btc_teleport_git_branch = get_git_branch(btc_teleport_path) + else: + btc_teleport_git_hash = "n/a" + btc_teleport_git_branch = "n/a" fix_git_config(mtcGitPath) fix_git_config(validatorGitPath) mtcGitBranch = get_git_branch(mtcGitPath) @@ -766,6 +776,11 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, validatorGitBranch_text = bcolors.yellow_text(validatorGitBranch) mtcVersion_text = local.translate("local_status_version_mtc").format(mtcGitHash_text, mtcGitBranch_text) validatorVersion_text = local.translate("local_status_version_validator").format(validatorGitHash_text, validatorGitBranch_text) + btc_teleport_version_text = None + if btc_teleport_git_hash: + btc_teleport_git_hash_text = bcolors.yellow_text(btc_teleport_git_hash) + btc_teleport_git_branch_text = bcolors.yellow_text(btc_teleport_git_branch) + btc_teleport_version_text = local.translate("local_status_version_teleport").format(btc_teleport_git_hash_text, btc_teleport_git_branch_text) color_print(local.translate("local_status_head")) node_ip = ton.get_validator_engine_ip() @@ -796,6 +811,8 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, print(dbStatus_text) print(mtcVersion_text) print(validatorVersion_text) + if btc_teleport_version_text: + print(btc_teleport_version_text) print() #end define diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index 0bdef05b..b935e5aa 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -354,6 +354,11 @@ "ru": "Версия валидатора: {0} ({1})", "zh_TW": "驗證者版本: {0} ({1})" }, + "local_status_version_teleport": { + "en": "Version BTC Teleport: {0} ({1})", + "ru": "Версия BTC Teleport: {0} ({1})", + "zh_TW": "BTC Teleport 版本: {0} ({1})" + }, "ton_config_head": { "en": "{cyan}===[ TON network configuration ]==={endc}", "ru": "{cyan}===[ Конфигурация сети TON ]==={endc}", From 4f8c1399b50da333f4a8a6d126189accf3b91330 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 1 Apr 2025 12:50:02 +0100 Subject: [PATCH 19/67] add installing teleport on enabling validator mode --- modules/btc_teleport.py | 5 +++++ mytoncore/mytoncore.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 9fc4f0ac..5bf38074 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -50,10 +50,15 @@ def install(self): def init(self, reinstall=False): if os.path.exists(self.src_dir) and not reinstall: return + self.local.add_log('Installing btc_teleport', 'info') os.makedirs(self.keystore_path, mode=0o700, exist_ok=True) self.install() self.create_env_file() self.add_daemon() + self.local.add_log('Installed btc_teleport', 'info') + + def remove_btc_teleport(self, args: list): + pass def add_console_commands(self, console): pass diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 63c571ed..7b389848 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -12,6 +12,7 @@ from fastcrc import crc16 from modules import MODES +from modules.btc_teleport import BtcTeleportModule from mytoncore.utils import xhex2hex, ng2g from mytoncore.liteclient import LiteClient from mytoncore.validator_console import ValidatorConsole @@ -3091,6 +3092,7 @@ def check_enable_mode(self, name): if self.using_liteserver(): raise Exception(f'Cannot enable validator mode while liteserver mode is enabled. ' f'Use `disable_mode liteserver` first.') + BtcTeleportModule(self, self.local).init() if name == 'liquid-staking': from mytoninstaller.settings import enable_ton_http_api enable_ton_http_api(self.local) From 063b3fadbad1a0a976375b629275bd79b479f0cf Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 1 Apr 2025 13:14:05 +0100 Subject: [PATCH 20/67] add remove_btc_teleport cmd --- modules/btc_teleport.py | 16 +++++++++++++--- mytonctrl/mytonctrl.py | 4 ++++ mytonctrl/resources/translate.json | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 5bf38074..4f44b182 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -4,7 +4,7 @@ import pkg_resources from modules.module import MtcModule -from mypylib.mypylib import run_as_root +from mypylib.mypylib import run_as_root, color_print class BtcTeleportModule(MtcModule): @@ -58,7 +58,17 @@ def init(self, reinstall=False): self.local.add_log('Installed btc_teleport', 'info') def remove_btc_teleport(self, args: list): - pass + if len(args) > 1: + color_print("{red}Bad args. Usage:{endc} remove_btc_teleport [--force]") + return + if '--force' not in args: + if -1 < self.ton.GetValidatorIndex() < self.ton.GetConfig34()['mainValidators']: + self.local.add_log('You can not remove btc_teleport on working masterchain validator', 'error') + return + import shutil + shutil.rmtree(self.keystore_path) + run_as_root(['rm', '-rf', self.src_dir]) + self.local.add_log('Removed btc_teleport', 'info') def add_console_commands(self, console): - pass + console.AddItem("remove_btc_teleport", self.remove_btc_teleport, self.local.translate("remove_btc_teleport_cmd")) diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index cb5a3619..ba58e6ea 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -100,6 +100,10 @@ def inject_globals(func): module = CustomOverlayModule(ton, local) module.add_console_commands(console) + from modules.btc_teleport import BtcTeleportModule + module = BtcTeleportModule(ton, local) + module.add_console_commands(console) + if ton.using_validator(): from modules.validator import ValidatorModule module = ValidatorModule(ton, local) diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index b935e5aa..39a4bff6 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -509,6 +509,11 @@ "ru": "Настроить Telegram Bot для оповещений", "zh_TW": "設置 Telegram Bot 以接收警報" }, + "remove_btc_teleport_cmd": { + "en": "Remove BTC Teleport Oracle", + "ru": "Удалить BTC Teleport Oracle", + "zh_TW": "刪除 BTC Teleport Oracle" + }, "benchmark_cmd": { "en": "Run benchmark", "ru": "Запустить бенчмарк", From 2b8083b01ad18ddea12cd36798203825da42280d Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 3 Apr 2025 12:37:29 +0100 Subject: [PATCH 21/67] upd teleport repo url --- mytonctrl/scripts/btc_teleport1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/scripts/btc_teleport1.sh b/mytonctrl/scripts/btc_teleport1.sh index 4c4dd340..b78f6d1d 100644 --- a/mytonctrl/scripts/btc_teleport1.sh +++ b/mytonctrl/scripts/btc_teleport1.sh @@ -22,7 +22,7 @@ fi # clone repo -REPO_URL=https://github.com/RSquad/${REPO}.git +REPO_URL=git@github.com:RSquad/${REPO}.git cd $SRC_DIR || exit 1 rm -rf $REPO From d84185fd9825ddaae2dd35912f0761a108bbfcb8 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 3 Apr 2025 12:43:57 +0100 Subject: [PATCH 22/67] upd btc teleport removing --- modules/btc_teleport.py | 7 ++++--- mytonctrl/scripts/remove_btc_teleport.sh | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 mytonctrl/scripts/remove_btc_teleport.sh diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 4f44b182..edab9e71 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -65,9 +65,10 @@ def remove_btc_teleport(self, args: list): if -1 < self.ton.GetValidatorIndex() < self.ton.GetConfig34()['mainValidators']: self.local.add_log('You can not remove btc_teleport on working masterchain validator', 'error') return - import shutil - shutil.rmtree(self.keystore_path) - run_as_root(['rm', '-rf', self.src_dir]) + script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/remove_btc_teleport.sh') + exit_code = run_as_root(["bash", script_path, "-s", self.src_dir, "-k", self.keystore_path]) + if exit_code != 0: + raise Exception('Failed to remove btc_teleport') self.local.add_log('Removed btc_teleport', 'info') def add_console_commands(self, console): diff --git a/mytonctrl/scripts/remove_btc_teleport.sh b/mytonctrl/scripts/remove_btc_teleport.sh new file mode 100644 index 00000000..e143b243 --- /dev/null +++ b/mytonctrl/scripts/remove_btc_teleport.sh @@ -0,0 +1,17 @@ +SRC_DIR="" +KEYSTORE_PATH="" + +while getopts s:k: flag +do + case "${flag}" in + s) SRC_DIR=${OPTARG};; + k) KEYSTORE_PATH=${OPTARG};; + *) echo "Flag -${flag} is not recognized. Aborting"; exit 1 ;; + esac +done + + +rm -rf $KEYSTORE_PATH +rm -rf $SRC_DIR +systemctl stop btc_teleport +rm -rf /etc/systemd/system/btc_teleport.service From 0c6697d65ce0283a5758521c6cc9e57f274e9e59 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 7 Apr 2025 11:51:35 +0100 Subject: [PATCH 23/67] rename env var in teleport --- modules/btc_teleport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index edab9e71..2921e4b5 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -22,7 +22,7 @@ def create_env_file(self): return text = f""" -COMMON_TON_CONFIG_URL=https://ton-blockchain.github.io/testnet-global.config.json +COMMON_TON_CONFIG=https://ton-blockchain.github.io/testnet-global.config.json COMMON_TON_CONTRACT_COORDINATOR=EQAmHFjKpq3ecr3WqSY4w-qy6VHVVdjYH8kIRWq5xdwudIPC ORACLE_STANDALONE_MODE=false ORACLE_KEYSTORE_PATH={self.keystore_path} From 1e6de87b107d31294c54c0562b38b87e69f03dd6 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 7 Apr 2025 12:01:57 +0100 Subject: [PATCH 24/67] add removing btc teleport on uninstall --- scripts/uninstall.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 9e1f275c..6da3f8c8 100644 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -20,6 +20,7 @@ ENDC='\033[0m' systemctl stop validator systemctl stop mytoncore systemctl stop dht-server +systemctl stop btc_teleport # Переменные str=$(systemctl cat mytoncore | grep User | cut -d '=' -f2) @@ -29,6 +30,7 @@ user=$(echo ${str}) rm -rf /etc/systemd/system/validator.service rm -rf /etc/systemd/system/mytoncore.service rm -rf /etc/systemd/system/dht-server.service +rm -rf /etc/systemd/system/btc_teleport.service systemctl daemon-reload # Удаление файлов @@ -41,6 +43,7 @@ if $full; then fi rm -rf /usr/src/mytonctrl +rm -rf /usr/src/ton-teleport-btc-periphery rm -rf /usr/src/mtc-jsonrpc rm -rf /usr/src/pytonv3 rm -rf /tmp/myton* From ee50e93aaa0a54564b8cb36f2a75c8013605723a Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 7 Apr 2025 13:42:14 +0100 Subject: [PATCH 25/67] create local config for btc teleport --- modules/btc_teleport.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 2921e4b5..84394221 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -16,13 +16,17 @@ def __init__(self, ton, local, *args, **kwargs): self.src_dir = '/usr/src/' + f'/{self.repo_name}' self.bin_dir = self.src_dir + '/out' + def create_local_file(self): + from mytoninstaller.mytoninstaller import CreateLocalConfigFile + CreateLocalConfigFile(self.local, []) + def create_env_file(self): env_path = self.bin_dir + '/.env' if os.path.exists(env_path): return - + self.create_local_file() text = f""" -COMMON_TON_CONFIG=https://ton-blockchain.github.io/testnet-global.config.json +COMMON_TON_CONFIG=/usr/bin/ton/local.config.json COMMON_TON_CONTRACT_COORDINATOR=EQAmHFjKpq3ecr3WqSY4w-qy6VHVVdjYH8kIRWq5xdwudIPC ORACLE_STANDALONE_MODE=false ORACLE_KEYSTORE_PATH={self.keystore_path} From 0abafc9115c0ddcc293edb35229f508395a87932 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 7 Apr 2025 21:47:39 +0100 Subject: [PATCH 26/67] update env --- modules/btc_teleport.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 84394221..60aa2e56 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -27,13 +27,14 @@ def create_env_file(self): self.create_local_file() text = f""" COMMON_TON_CONFIG=/usr/bin/ton/local.config.json -COMMON_TON_CONTRACT_COORDINATOR=EQAmHFjKpq3ecr3WqSY4w-qy6VHVVdjYH8kIRWq5xdwudIPC +COMMON_TON_CONTRACT_COORDINATOR=EQDnwZfGuNxUyIt78PuG6INOl-50DOtHJU5KFU5-4COEj_1x ORACLE_STANDALONE_MODE=false ORACLE_KEYSTORE_PATH={self.keystore_path} ORACLE_VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath} ORACLE_SERVER_PUBLIC_KEY_PATH={self.ton.validatorConsole.pubKeyPath} ORACLE_CLIENT_PRIVATE_KEY_PATH={self.ton.validatorConsole.privKeyPath} ORACLE_VALIDATOR_SERVER_ADDR={self.ton.validatorConsole.addr} +API_CALL_TIMEOUT=30 """ with open(env_path, 'w') as f: f.write(text) From b45210c1353e78c3d883d766bd5cd024abeb97eb Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 8 Apr 2025 12:09:51 +0100 Subject: [PATCH 27/67] add warning in case local config file was not created --- modules/btc_teleport.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 60aa2e56..f5f36353 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -25,8 +25,17 @@ def create_env_file(self): if os.path.exists(env_path): return self.create_local_file() + config_path = "/usr/bin/ton/local.config.json" + if not os.path.exists(config_path): + config_path = 'https://ton.org/global-config.json' + warning_text = f""" +WARNING: Could not create local config file. Using global config file ({config_path}). +Please try to create local config file (`mytonctrl <<< "installer clcf"`) and update its path in {env_path} and restart +btc teleport service (`systemctl restart btc_teleport`) or contact validators support. +""" + self.local.add_log(warning_text, 'warning') text = f""" -COMMON_TON_CONFIG=/usr/bin/ton/local.config.json +COMMON_TON_CONFIG={config_path} COMMON_TON_CONTRACT_COORDINATOR=EQDnwZfGuNxUyIt78PuG6INOl-50DOtHJU5KFU5-4COEj_1x ORACLE_STANDALONE_MODE=false ORACLE_KEYSTORE_PATH={self.keystore_path} From 197c4eb91455f738bd48b00b3559793c78a154df Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 8 Apr 2025 12:40:36 +0100 Subject: [PATCH 28/67] add log file --- modules/btc_teleport.py | 1 + mytonctrl/scripts/btc_teleport1.sh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index f5f36353..bcda7528 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -44,6 +44,7 @@ def create_env_file(self): ORACLE_CLIENT_PRIVATE_KEY_PATH={self.ton.validatorConsole.privKeyPath} ORACLE_VALIDATOR_SERVER_ADDR={self.ton.validatorConsole.addr} API_CALL_TIMEOUT=30 +LOG_FILE=/var/log/btc_teleport/btc_teleport.log """ with open(env_path, 'w') as f: f.write(text) diff --git a/mytonctrl/scripts/btc_teleport1.sh b/mytonctrl/scripts/btc_teleport1.sh index b78f6d1d..2cb34701 100644 --- a/mytonctrl/scripts/btc_teleport1.sh +++ b/mytonctrl/scripts/btc_teleport1.sh @@ -33,3 +33,6 @@ chown -R $USER:$USER $REPO git config --global --add safe.directory $SRC_DIR/$REPO echo "oracle sources cloned successfully" + +mkdir -p /var/log/btc_teleport +chown -R $USER:$USER /var/log/btc_teleport From f49ddd2a63b1b9543f92d3ee6cc25c4684542739 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 8 Apr 2025 13:10:44 +0100 Subject: [PATCH 29/67] update adding to systemd --- modules/btc_teleport.py | 5 +++-- mytoninstaller/scripts/add2systemd.sh | 7 +++++-- mytoninstaller/scripts/jsonrpcinstaller.sh | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index bcda7528..b215168c 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -51,8 +51,9 @@ def create_env_file(self): def add_daemon(self): start = f'{self.bin_dir}/oracle' - cmd = f'''import subprocess; import os; from mypylib.mypylib import add2systemd; add2systemd(name='btc_teleport', user=os.getlogin(), start='{start}', workdir='{self.bin_dir}'); subprocess.run(['systemctl', 'restart', 'btc_teleport'])''' - run_as_root(['python3', '-c', cmd]) + script_path = pkg_resources.resource_filename('mytoninstaller', 'scripts/add2systemd.sh') + user = os.environ.get("USER", "root") + run_as_root(['bash', script_path, '-n', 'btc_teleport', '-u', user, '-g', user, '-s', start, '-w', self.bin_dir]) def install(self): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport1.sh') diff --git a/mytoninstaller/scripts/add2systemd.sh b/mytoninstaller/scripts/add2systemd.sh index 13626522..e8c8b5f8 100755 --- a/mytoninstaller/scripts/add2systemd.sh +++ b/mytoninstaller/scripts/add2systemd.sh @@ -11,7 +11,7 @@ post="/bin/echo service down" user=root group=root -while getopts n:s:p:u:g: flag +while getopts n:s:p:u:g:w: flag do case "${flag}" in n) name=${OPTARG};; @@ -19,6 +19,7 @@ do p) post=${OPTARG};; u) user=${OPTARG};; g) group=${OPTARG};; + w) workdir=${OPTARG};; esac done @@ -37,7 +38,7 @@ DAEMON_PATH="/etc/systemd/system/${name}.service" cat < $DAEMON_PATH [Unit] -Description = $name service. Created by https://github.com/igroman787/mypylib. +Description = $name service. After = network.target [Service] @@ -48,6 +49,7 @@ ExecStart = $start ExecStopPost = $post User = $user Group = $group +WorkingDirectory = $workdir LimitNOFILE = infinity LimitNPROC = infinity LimitMEMLOCK = infinity @@ -60,3 +62,4 @@ chmod 664 $DAEMON_PATH chmod +x $DAEMON_PATH systemctl daemon-reload systemctl enable ${name} +systemctl restart ${name} diff --git a/mytoninstaller/scripts/jsonrpcinstaller.sh b/mytoninstaller/scripts/jsonrpcinstaller.sh index 926d61e1..32476729 100755 --- a/mytoninstaller/scripts/jsonrpcinstaller.sh +++ b/mytoninstaller/scripts/jsonrpcinstaller.sh @@ -43,7 +43,6 @@ echo -e "${COLOR}[3/4]${ENDC} Add to startup" SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) echo "Script dir: ${SCRIPT_DIR}" ${SCRIPT_DIR}/add2systemd.sh -n mtc-jsonrpc -s "/usr/bin/python3 /usr/src/mtc-jsonrpc/mtc-jsonrpc.py" -u ${user} -g ${user} -systemctl restart mtc-jsonrpc # Выход из программы echo -e "${COLOR}[4/4]${ENDC} JsonRPC installation complete" From 2d1974df40a324f14d4b9b356708cf0d7c4b16de Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Thu, 10 Apr 2025 12:43:22 +0100 Subject: [PATCH 30/67] Update repo url --- mytonctrl/scripts/btc_teleport1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/scripts/btc_teleport1.sh b/mytonctrl/scripts/btc_teleport1.sh index 2cb34701..38142365 100644 --- a/mytonctrl/scripts/btc_teleport1.sh +++ b/mytonctrl/scripts/btc_teleport1.sh @@ -22,7 +22,7 @@ fi # clone repo -REPO_URL=git@github.com:RSquad/${REPO}.git +REPO_URL=https://github.com/RSquad/${REPO}.git cd $SRC_DIR || exit 1 rm -rf $REPO From a16eb7106cc0072fbdbc80540c251c886ee08982 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 11 Apr 2025 12:31:28 +0100 Subject: [PATCH 31/67] install btc teleport on restoring from backup --- modules/backups.py | 6 +++++- modules/btc_teleport.py | 12 ++++++++---- modules/module.py | 4 +++- mytoncore/functions.py | 6 ++++++ mytonctrl/scripts/remove_btc_teleport.sh | 1 + mytoninstaller/settings.py | 6 +++++- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/modules/backups.py b/modules/backups.py index 8ea0b2fa..079486ba 100644 --- a/modules/backups.py +++ b/modules/backups.py @@ -6,7 +6,7 @@ import pkg_resources from modules.module import MtcModule -from mypylib.mypylib import color_print, ip2int, run_as_root, parse +from mypylib.mypylib import color_print, ip2int, run_as_root, parse, MyPyClass from mytoninstaller.config import get_own_ip @@ -80,6 +80,10 @@ def restore_backup(self, args): command_args = ["-m", self.ton.local.buffer.my_work_dir, "-n", args[0], "-i", ip] if self.run_restore_backup(command_args) == 0: + self.local.load_db() + if self.ton.using_validator(): + from modules.btc_teleport import BtcTeleportModule + BtcTeleportModule(self.ton, self.local).init(reinstall=True) color_print("restore_backup - {green}OK{endc}") self.local.exit() else: diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index b215168c..84a19f02 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -20,9 +20,9 @@ def create_local_file(self): from mytoninstaller.mytoninstaller import CreateLocalConfigFile CreateLocalConfigFile(self.local, []) - def create_env_file(self): + def create_env_file(self, reinit=False): env_path = self.bin_dir + '/.env' - if os.path.exists(env_path): + if os.path.exists(env_path) and not reinit: return self.create_local_file() config_path = "/usr/bin/ton/local.config.json" @@ -73,6 +73,11 @@ def init(self, reinstall=False): self.add_daemon() self.local.add_log('Installed btc_teleport', 'info') + @staticmethod + def run_remove_btc_teleport(args): + script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/remove_btc_teleport.sh') + return run_as_root(["bash", script_path] + args) + def remove_btc_teleport(self, args: list): if len(args) > 1: color_print("{red}Bad args. Usage:{endc} remove_btc_teleport [--force]") @@ -81,8 +86,7 @@ def remove_btc_teleport(self, args: list): if -1 < self.ton.GetValidatorIndex() < self.ton.GetConfig34()['mainValidators']: self.local.add_log('You can not remove btc_teleport on working masterchain validator', 'error') return - script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/remove_btc_teleport.sh') - exit_code = run_as_root(["bash", script_path, "-s", self.src_dir, "-k", self.keystore_path]) + exit_code = self.run_remove_btc_teleport(["-s", self.src_dir, "-k", self.keystore_path]) if exit_code != 0: raise Exception('Failed to remove btc_teleport') self.local.add_log('Removed btc_teleport', 'info') diff --git a/modules/module.py b/modules/module.py index b1ce709a..7d9a185a 100644 --- a/modules/module.py +++ b/modules/module.py @@ -1,5 +1,7 @@ from abc import ABC, abstractmethod +from mypylib.mypylib import MyPyClass + class MtcModule(ABC): @@ -9,7 +11,7 @@ class MtcModule(ABC): def __init__(self, ton, local, *args, **kwargs): from mytoncore.mytoncore import MyTonCore self.ton: MyTonCore = ton - self.local = local + self.local: MyPyClass = local @abstractmethod def add_console_commands(self, console): ... diff --git a/mytoncore/functions.py b/mytoncore/functions.py index a8c08d76..8d995507 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -57,6 +57,8 @@ def Event(local, event_name): enable_ton_storage_provider_event(local) elif event_name.startswith("enable_mode"): enable_mode(local, event_name) + elif event_name == "enable_btc_teleport": + enable_btc_teleport(local) local.exit() # end define @@ -101,6 +103,10 @@ def enable_mode(local, event_name): ton.enable_mode(mode) #end define +def enable_btc_teleport(local): + ton = MyTonCore(local) + from modules.btc_teleport import BtcTeleportModule + BtcTeleportModule(ton, local).init(reinstall=True) def Elections(local, ton): use_pool = ton.using_pool() diff --git a/mytonctrl/scripts/remove_btc_teleport.sh b/mytonctrl/scripts/remove_btc_teleport.sh index e143b243..b9f7fbe7 100644 --- a/mytonctrl/scripts/remove_btc_teleport.sh +++ b/mytonctrl/scripts/remove_btc_teleport.sh @@ -15,3 +15,4 @@ rm -rf $KEYSTORE_PATH rm -rf $SRC_DIR systemctl stop btc_teleport rm -rf /etc/systemd/system/btc_teleport.service +systemctl daemon-reload \ No newline at end of file diff --git a/mytoninstaller/settings.py b/mytoninstaller/settings.py index f8452dba..d1a67aa4 100644 --- a/mytoninstaller/settings.py +++ b/mytoninstaller/settings.py @@ -950,7 +950,7 @@ def CreateSymlinks(local): def EnableMode(local): args = ["python3", "-m", "mytoncore", "-e"] - if local.buffer.mode and local.buffer.mode != "none": + if local.buffer.mode and local.buffer.mode != "none" and not local.buffer.backup: args.append("enable_mode_" + local.buffer.mode) else: return @@ -997,6 +997,10 @@ def ConfigureFromBackup(local): return set_external_ip(local, node_ip) + args = ["python3", "-m", "mytoncore", "-e", "enable_btc_teleport"] + args = ["su", "-l", local.buffer.user, "-c", ' '.join(args)] + subprocess.run(args) + def ConfigureOnlyNode(local): if not local.buffer.only_node: From 748eb99b4a20e2c77cb05e4c43762d6871f4e533 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 11 Apr 2025 12:46:36 +0100 Subject: [PATCH 32/67] Revert "Update repo url" This reverts commit 2d1974df40a324f14d4b9b356708cf0d7c4b16de. --- mytonctrl/scripts/btc_teleport1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/scripts/btc_teleport1.sh b/mytonctrl/scripts/btc_teleport1.sh index 38142365..2cb34701 100644 --- a/mytonctrl/scripts/btc_teleport1.sh +++ b/mytonctrl/scripts/btc_teleport1.sh @@ -22,7 +22,7 @@ fi # clone repo -REPO_URL=https://github.com/RSquad/${REPO}.git +REPO_URL=git@github.com:RSquad/${REPO}.git cd $SRC_DIR || exit 1 rm -rf $REPO From 01705c4625a323e9ee1dcb3d0d0a4b94604ca8a8 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 14 Apr 2025 12:11:20 +0100 Subject: [PATCH 33/67] fix restore_backup --- modules/backups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backups.py b/modules/backups.py index 079486ba..36fb8bd7 100644 --- a/modules/backups.py +++ b/modules/backups.py @@ -80,7 +80,7 @@ def restore_backup(self, args): command_args = ["-m", self.ton.local.buffer.my_work_dir, "-n", args[0], "-i", ip] if self.run_restore_backup(command_args) == 0: - self.local.load_db() + self.ton.local.load_db() if self.ton.using_validator(): from modules.btc_teleport import BtcTeleportModule BtcTeleportModule(self.ton, self.local).init(reinstall=True) From 06e3720943908ec9ab72803b6d572db966e83205 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 17 Apr 2025 12:09:44 +0100 Subject: [PATCH 34/67] Revert "Revert "Update repo url"" This reverts commit 748eb99b4a20e2c77cb05e4c43762d6871f4e533. --- mytonctrl/scripts/btc_teleport1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/scripts/btc_teleport1.sh b/mytonctrl/scripts/btc_teleport1.sh index 2cb34701..38142365 100644 --- a/mytonctrl/scripts/btc_teleport1.sh +++ b/mytonctrl/scripts/btc_teleport1.sh @@ -22,7 +22,7 @@ fi # clone repo -REPO_URL=git@github.com:RSquad/${REPO}.git +REPO_URL=https://github.com/RSquad/${REPO}.git cd $SRC_DIR || exit 1 rm -rf $REPO From 6088012adeaac4861d89fcb2ab1e1cae3b0ae0f1 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 9 May 2025 12:48:22 +0400 Subject: [PATCH 35/67] add branch option to btc teleport upgrading --- modules/btc_teleport.py | 8 ++++---- mytonctrl/mytonctrl.py | 11 ++++++----- mytonctrl/scripts/btc_teleport1.sh | 6 +++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 84a19f02..76f4ab60 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -55,20 +55,20 @@ def add_daemon(self): user = os.environ.get("USER", "root") run_as_root(['bash', script_path, '-n', 'btc_teleport', '-u', user, '-g', user, '-s', start, '-w', self.bin_dir]) - def install(self): + def install(self, branch): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport1.sh') - exit_code = run_as_root(["bash", script_path, "-s", '/usr/src', "-r", self.repo_name]) + exit_code = run_as_root(["bash", script_path, "-s", '/usr/src', "-r", self.repo_name, "-b", branch]) if exit_code != 0: raise Exception('Failed to install btc_teleport') script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/btc_teleport2.sh') subprocess.run(["bash", script_path, "-s", self.src_dir]) - def init(self, reinstall=False): + def init(self, reinstall=False, branch: str = 'master'): if os.path.exists(self.src_dir) and not reinstall: return self.local.add_log('Installing btc_teleport', 'info') os.makedirs(self.keystore_path, mode=0o700, exist_ok=True) - self.install() + self.install(branch) self.create_env_file() self.add_daemon() self.local.add_log('Installed btc_teleport', 'info') diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index ba58e6ea..3d9aaa29 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -348,9 +348,10 @@ def Update(local, args): local.exit() #end define -def Upgrade(local, ton, args): - if '--btc-teleport' in args: # upgrade --btc-teleport - upgrade_btc_teleport(local, ton, reinstall=True) +def Upgrade(local, ton, args: list): + if '--btc-teleport' in args: # upgrade --btc-teleport [branch] + branch = args[args.index('--btc-teleport') + 1] if len(args) > args.index('--btc-teleport') + 1 else 'master' + upgrade_btc_teleport(local, ton, reinstall=True, branch=branch) return repo = "ton" author, repo, branch = check_git(args, repo, "upgrade") @@ -386,10 +387,10 @@ def Upgrade(local, ton, args): color_print(text) #end define -def upgrade_btc_teleport(local, ton, reinstall=False): +def upgrade_btc_teleport(local, ton, reinstall=False, branch: str = 'master'): from modules.btc_teleport import BtcTeleportModule module = BtcTeleportModule(ton, local) - local.try_function(module.init, args=[reinstall]) + local.try_function(module.init, args=[reinstall, branch]) def rollback_to_mtc1(local, ton, args): color_print("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}") diff --git a/mytonctrl/scripts/btc_teleport1.sh b/mytonctrl/scripts/btc_teleport1.sh index 38142365..94c88db7 100644 --- a/mytonctrl/scripts/btc_teleport1.sh +++ b/mytonctrl/scripts/btc_teleport1.sh @@ -1,12 +1,14 @@ REPO="" SRC_DIR="" USER=$(logname) +BRANCH=master -while getopts s:r: flag +while getopts s:r:b: flag do case "${flag}" in s) SRC_DIR=${OPTARG};; r) REPO=${OPTARG};; + b) BRANCH=${OPTARG};; *) echo "Flag -${flag} is not recognized. Aborting"; exit 1 ;; esac done @@ -27,6 +29,8 @@ REPO_URL=https://github.com/RSquad/${REPO}.git cd $SRC_DIR || exit 1 rm -rf $REPO git clone $REPO_URL +cd $REPO && git checkout $BRANCH +cd .. chown -R $USER:$USER $REPO From 939e182796d10e7e188ec5aedadad259fe01775e Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Thu, 15 May 2025 17:56:40 +0400 Subject: [PATCH 36/67] update coordinator address --- modules/btc_teleport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 76f4ab60..e99e6876 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -36,7 +36,7 @@ def create_env_file(self, reinit=False): self.local.add_log(warning_text, 'warning') text = f""" COMMON_TON_CONFIG={config_path} -COMMON_TON_CONTRACT_COORDINATOR=EQDnwZfGuNxUyIt78PuG6INOl-50DOtHJU5KFU5-4COEj_1x +COMMON_TON_CONTRACT_COORDINATOR=EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo ORACLE_STANDALONE_MODE=false ORACLE_KEYSTORE_PATH={self.keystore_path} ORACLE_VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath} From 806c7e6f0a049a8ed68fba002ef57b6f803be7af Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Tue, 27 May 2025 16:53:15 +0900 Subject: [PATCH 37/67] rm pow-miner target on upgrade --- mytonctrl/scripts/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/scripts/upgrade.sh b/mytonctrl/scripts/upgrade.sh index fe952562..a18b585b 100644 --- a/mytonctrl/scripts/upgrade.sh +++ b/mytonctrl/scripts/upgrade.sh @@ -89,7 +89,7 @@ memory=$(cat /proc/meminfo | grep MemAvailable | awk '{print $2}') cpuNumber=$(cat /proc/cpuinfo | grep "processor" | wc -l) cmake -DCMAKE_BUILD_TYPE=Release ${srcdir}/${repo} -GNinja -DTON_USE_JEMALLOC=ON -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$opensslPath/include -DOPENSSL_CRYPTO_LIBRARY=$opensslPath/libcrypto.a -ninja -j ${cpuNumber} fift validator-engine lite-client pow-miner validator-engine-console generate-random-id dht-server func tonlibjson rldp-http-proxy +ninja -j ${cpuNumber} fift validator-engine lite-client validator-engine-console generate-random-id dht-server func tonlibjson rldp-http-proxy systemctl restart validator # Конец From 140b3a6541fc36a3942da2bbb8d6efeda03579a4 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 4 Jun 2025 12:56:33 +0900 Subject: [PATCH 38/67] add vote_offer_btc_teleport --- modules/btc_teleport.py | 5 ++++- modules/validator.py | 23 +++++++++++++++++++++++ mytonctrl/resources/translate.json | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index e99e6876..c8510d49 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -9,6 +9,9 @@ class BtcTeleportModule(MtcModule): + COORDINATOR_ADDRESS = 'EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo' + CONFIGURATOR_ADDRESS = 'kQBV_cc8tD2lr2oogPOp1VCyP5m1xzdAZ77H3oM_Tix60dPP' + def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) self.keystore_path = self.ton.local.buffer.my_work_dir + '/btc_oracle_keystore' @@ -36,7 +39,7 @@ def create_env_file(self, reinit=False): self.local.add_log(warning_text, 'warning') text = f""" COMMON_TON_CONFIG={config_path} -COMMON_TON_CONTRACT_COORDINATOR=EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo +COMMON_TON_CONTRACT_COORDINATOR={self.COORDINATOR_ADDRESS} ORACLE_STANDALONE_MODE=false ORACLE_KEYSTORE_PATH={self.keystore_path} ORACLE_VALIDATOR_ENGINE_CONSOLE_PATH={self.ton.validatorConsole.appPath} diff --git a/modules/validator.py b/modules/validator.py index a0fdfa9c..dbb3bf7b 100644 --- a/modules/validator.py +++ b/modules/validator.py @@ -20,6 +20,28 @@ def vote_offer(self, args): self.ton.VoteOffer(offerHash) color_print("VoteOffer - {green}OK{endc}") + def vote_offer_btc_teleport(self, args): + if len(args) == 0: + color_print("{red}Bad args. Usage:{endc} vote_offer_btc_teleport [offer-hash-2 offer-hash-3 ...]") + return + from modules.btc_teleport import BtcTeleportModule + coordinator_addr = BtcTeleportModule.CONFIGURATOR_ADDRESS + wallet = self.ton.GetValidatorWallet(mode="vote") + validator_key = self.ton.GetValidatorKey() + validator_pubkey_b64 = self.ton.GetPubKeyBase64(validator_key) + validator_index = self.ton.GetValidatorIndex() + for offer_hash in args: + # offer = self.GetOffer(offerHash) + # if validatorIndex in offer.get("votedValidators"): + # self.local.add_log("Proposal already has been voted", "debug") + # return + request_hash = self.ton.CreateConfigProposalRequest(offer_hash, validator_index) + validator_signature = self.ton.GetValidatorSignature(validator_key, request_hash) + path = self.ton.SignProposalVoteRequestWithValidator(offer_hash, validator_index, validator_pubkey_b64, + validator_signature) + path = self.ton.SignBocWithWallet(wallet, path, coordinator_addr, 1.5) + self.ton.SendFile(path, wallet) + def vote_election_entry(self, args): from mytoncore.functions import Elections Elections(self.ton.local, self.ton) @@ -104,6 +126,7 @@ def get_my_complaint(self): def add_console_commands(self, console): console.AddItem("vo", self.vote_offer, self.local.translate("vo_cmd")) + console.AddItem("vote_offer_btc_teleport", self.vote_offer_btc_teleport, self.local.translate("vote_offer_btc_teleport_cmd")) console.AddItem("ve", self.vote_election_entry, self.local.translate("ve_cmd")) console.AddItem("vc", self.vote_complaint, self.local.translate("vc_cmd")) console.AddItem("check_ef", self.check_efficiency, self.local.translate("check_ef_cmd")) diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index 39a4bff6..39447365 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -139,6 +139,11 @@ "ru": "Голосовать за предложение", "zh_TW": "投票支持優惠" }, + "vote_offer_btc_teleport_cmd": { + "en": "Vote for BTC teleport offer", + "ru": "Голосовать за предложение BTC Teleport", + "zh_TW": "投票支持 BTC Teleport 優惠" + }, "od_cmd": { "en": "Show offer diff", "ru": "Показать разницу предложений", From ea3fae078907acbfc7d5faf7909a516a0556bd8e Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 9 Jun 2025 14:01:34 +0900 Subject: [PATCH 39/67] add print_offers_btc_teleport_list --- modules/btc_teleport.py | 82 +++++++++++++++++++++++++++++- modules/validator.py | 23 --------- mytonctrl/resources/translate.json | 7 ++- 3 files changed, 87 insertions(+), 25 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index c8510d49..805f3ca4 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -1,10 +1,11 @@ +import json import os import subprocess import pkg_resources from modules.module import MtcModule -from mypylib.mypylib import run_as_root, color_print +from mypylib.mypylib import run_as_root, color_print, bcolors, print_table class BtcTeleportModule(MtcModule): @@ -81,6 +82,83 @@ def run_remove_btc_teleport(args): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/remove_btc_teleport.sh') return run_as_root(["bash", script_path] + args) + def get_offers_btc_teleport(self): + self.local.add_log("start get_offers_btc_teleport function", "debug") + cmd = f"runmethodfull {self.CONFIGURATOR_ADDRESS} list_proposals" + result = self.ton.liteClient.Run(cmd) + raw_offers = self.ton.Result2List(result) + raw_offers = raw_offers[0] + config34 = self.ton.GetConfig34() + total_weight = config34.get("totalWeight") + offers = [] + for offer in raw_offers: + if len(offer) == 0: + continue + item = {} + hash = str(offer[0]) + item["hash"] = hash + item["price"] = offer[1] + item["proposal"] = offer[2] + item["votedValidators"] = offer[3] + weight_remaining = offer[4] + item["weightRemaining"] = weight_remaining + item["vset_id"] = offer[5] + item["creator"] = offer[6] + required_weight = total_weight * 3 / 4 + if len(item["votedValidators"]) == 0: + weight_remaining = required_weight + available_weight = required_weight - weight_remaining + item["weightRemaining"] = weight_remaining + item["approvedPercent"] = round(available_weight / total_weight * 100, 3) + item["isPassed"] = (weight_remaining < 0) + offers.append(item) + return offers + + def vote_offer_btc_teleport(self, args): + if len(args) == 0: + color_print("{red}Bad args. Usage:{endc} vote_offer_btc_teleport [offer-hash-2 offer-hash-3 ...]") + return + wallet = self.ton.GetValidatorWallet(mode="vote") + validator_key = self.ton.GetValidatorKey() + validator_pubkey_b64 = self.ton.GetPubKeyBase64(validator_key) + validator_index = self.ton.GetValidatorIndex() + for offer_hash in args: + # offer = self.GetOffer(offerHash) + # if validatorIndex in offer.get("votedValidators"): + # self.local.add_log("Proposal already has been voted", "debug") + # return + request_hash = self.ton.CreateConfigProposalRequest(offer_hash, validator_index) + validator_signature = self.ton.GetValidatorSignature(validator_key, request_hash) + path = self.ton.SignProposalVoteRequestWithValidator(offer_hash, validator_index, validator_pubkey_b64, + validator_signature) + path = self.ton.SignBocWithWallet(wallet, path, self.CONFIGURATOR_ADDRESS, 1.5) + self.ton.SendFile(path, wallet) + + def print_offers_btc_teleport_list(self, args): + data = self.get_offers_btc_teleport() + if not data: + print("No data") + return + if "--json" in args: + text = json.dumps(data, indent=2) + print(text) + return + table = [["Hash", "Votes", "Approved", "Is passed"]] + for item in data: + hash = item.get("hash") + voted_validators = len(item.get("votedValidators")) + approved_percent_text = f"{item.get('approvedPercent')}%" + is_passed = item.get("isPassed") + if "hash" not in args: + from modules.utilities import UtilitiesModule + hash = UtilitiesModule.reduct(hash) + if is_passed is True: + is_passed = bcolors.green_text("true") + if is_passed is False: + is_passed = bcolors.red_text("false") + table += [[hash, voted_validators, approved_percent_text, is_passed]] + print_table(table) + def remove_btc_teleport(self, args: list): if len(args) > 1: color_print("{red}Bad args. Usage:{endc} remove_btc_teleport [--force]") @@ -96,3 +174,5 @@ def remove_btc_teleport(self, args: list): def add_console_commands(self, console): console.AddItem("remove_btc_teleport", self.remove_btc_teleport, self.local.translate("remove_btc_teleport_cmd")) + console.AddItem("vote_offer_btc_teleport", self.vote_offer_btc_teleport, self.local.translate("vote_offer_btc_teleport_cmd")) + console.AddItem("print_offers_btc_teleport_list", self.print_offers_btc_teleport_list, self.local.translate("print_offers_btc_teleport_list_cmd")) \ No newline at end of file diff --git a/modules/validator.py b/modules/validator.py index dbb3bf7b..a0fdfa9c 100644 --- a/modules/validator.py +++ b/modules/validator.py @@ -20,28 +20,6 @@ def vote_offer(self, args): self.ton.VoteOffer(offerHash) color_print("VoteOffer - {green}OK{endc}") - def vote_offer_btc_teleport(self, args): - if len(args) == 0: - color_print("{red}Bad args. Usage:{endc} vote_offer_btc_teleport [offer-hash-2 offer-hash-3 ...]") - return - from modules.btc_teleport import BtcTeleportModule - coordinator_addr = BtcTeleportModule.CONFIGURATOR_ADDRESS - wallet = self.ton.GetValidatorWallet(mode="vote") - validator_key = self.ton.GetValidatorKey() - validator_pubkey_b64 = self.ton.GetPubKeyBase64(validator_key) - validator_index = self.ton.GetValidatorIndex() - for offer_hash in args: - # offer = self.GetOffer(offerHash) - # if validatorIndex in offer.get("votedValidators"): - # self.local.add_log("Proposal already has been voted", "debug") - # return - request_hash = self.ton.CreateConfigProposalRequest(offer_hash, validator_index) - validator_signature = self.ton.GetValidatorSignature(validator_key, request_hash) - path = self.ton.SignProposalVoteRequestWithValidator(offer_hash, validator_index, validator_pubkey_b64, - validator_signature) - path = self.ton.SignBocWithWallet(wallet, path, coordinator_addr, 1.5) - self.ton.SendFile(path, wallet) - def vote_election_entry(self, args): from mytoncore.functions import Elections Elections(self.ton.local, self.ton) @@ -126,7 +104,6 @@ def get_my_complaint(self): def add_console_commands(self, console): console.AddItem("vo", self.vote_offer, self.local.translate("vo_cmd")) - console.AddItem("vote_offer_btc_teleport", self.vote_offer_btc_teleport, self.local.translate("vote_offer_btc_teleport_cmd")) console.AddItem("ve", self.vote_election_entry, self.local.translate("ve_cmd")) console.AddItem("vc", self.vote_complaint, self.local.translate("vc_cmd")) console.AddItem("check_ef", self.check_efficiency, self.local.translate("check_ef_cmd")) diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index 39447365..c28c1038 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -140,10 +140,15 @@ "zh_TW": "投票支持優惠" }, "vote_offer_btc_teleport_cmd": { - "en": "Vote for BTC teleport offer", + "en": "Vote for BTC teleport proposal", "ru": "Голосовать за предложение BTC Teleport", "zh_TW": "投票支持 BTC Teleport 優惠" }, + "print_offers_btc_teleport_list_cmd": { + "en": "Show BTC teleport proposals list", + "ru": "Показать список предложений BTC Teleport", + "zh_TW": "顯示 BTC Teleport 優惠列表" + }, "od_cmd": { "en": "Show offer diff", "ru": "Показать разницу предложений", From b64077bdf6a371f051a3275b90497c64efa8cd26 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 11 Jun 2025 18:06:58 +0900 Subject: [PATCH 40/67] add auto vote for offers --- modules/btc_teleport.py | 62 ++++++++++++++++++++++++++++++----------- mytoncore/functions.py | 4 +++ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 805f3ca4..6485d008 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -11,7 +11,7 @@ class BtcTeleportModule(MtcModule): COORDINATOR_ADDRESS = 'EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo' - CONFIGURATOR_ADDRESS = 'kQBV_cc8tD2lr2oogPOp1VCyP5m1xzdAZ77H3oM_Tix60dPP' + CONFIGURATOR_ADDRESS = 'EQCPL1AFRXtvqIxaYK05EzSCnz5QQRb6UGXp6PAJurFeVQYC' def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) @@ -82,7 +82,30 @@ def run_remove_btc_teleport(args): script_path = pkg_resources.resource_filename('mytonctrl', 'scripts/remove_btc_teleport.sh') return run_as_root(["bash", script_path] + args) - def get_offers_btc_teleport(self): + def get_save_offers(self): + bname = "saveOffersBtcTeleport" + save_offers = self.ton.local.db.get(bname) + if save_offers is None: + save_offers = dict() + self.ton.local.db[bname] = save_offers + return save_offers + + def auto_vote_offers(self): + save_offers = self.get_save_offers() + if not save_offers: + return + current_offers = self.get_offers() + for save_offer in list(save_offers.values()): + offer_hash = save_offer['hash'] + if offer_hash not in current_offers: + continue + offer = current_offers[save_offer['hash']] + if offer['isPassed']: + save_offers.pop(offer_hash) + continue + self.vote_offer_btc_teleport([offer['hash']]) + + def get_offers(self): self.local.add_log("start get_offers_btc_teleport function", "debug") cmd = f"runmethodfull {self.CONFIGURATOR_ADDRESS} list_proposals" result = self.ton.liteClient.Run(cmd) @@ -90,13 +113,13 @@ def get_offers_btc_teleport(self): raw_offers = raw_offers[0] config34 = self.ton.GetConfig34() total_weight = config34.get("totalWeight") - offers = [] + offers = {} for offer in raw_offers: if len(offer) == 0: continue item = {} - hash = str(offer[0]) - item["hash"] = hash + o_hash = str(offer[0]) + item["hash"] = o_hash item["price"] = offer[1] item["proposal"] = offer[2] item["votedValidators"] = offer[3] @@ -108,10 +131,9 @@ def get_offers_btc_teleport(self): if len(item["votedValidators"]) == 0: weight_remaining = required_weight available_weight = required_weight - weight_remaining - item["weightRemaining"] = weight_remaining item["approvedPercent"] = round(available_weight / total_weight * 100, 3) item["isPassed"] = (weight_remaining < 0) - offers.append(item) + offers[o_hash] = item return offers def vote_offer_btc_teleport(self, args): @@ -123,10 +145,16 @@ def vote_offer_btc_teleport(self, args): validator_pubkey_b64 = self.ton.GetPubKeyBase64(validator_key) validator_index = self.ton.GetValidatorIndex() for offer_hash in args: - # offer = self.GetOffer(offerHash) - # if validatorIndex in offer.get("votedValidators"): - # self.local.add_log("Proposal already has been voted", "debug") - # return + current_offers = self.get_offers() + if offer_hash not in current_offers: + self.local.add_log("Offer not found, skip", "warning") + return + offer = current_offers[offer_hash] + if validator_index in offer.get("votedValidators"): + self.local.add_log("Proposal already has been voted", "debug") + return + self.get_save_offers()[offer_hash] = offer + self.ton.local.save() request_hash = self.ton.CreateConfigProposalRequest(offer_hash, validator_index) validator_signature = self.ton.GetValidatorSignature(validator_key, request_hash) path = self.ton.SignProposalVoteRequestWithValidator(offer_hash, validator_index, validator_pubkey_b64, @@ -135,7 +163,7 @@ def vote_offer_btc_teleport(self, args): self.ton.SendFile(path, wallet) def print_offers_btc_teleport_list(self, args): - data = self.get_offers_btc_teleport() + data = self.get_offers() if not data: print("No data") return @@ -144,19 +172,19 @@ def print_offers_btc_teleport_list(self, args): print(text) return table = [["Hash", "Votes", "Approved", "Is passed"]] - for item in data: - hash = item.get("hash") + for item in data.values(): + o_hash = item.get("hash") voted_validators = len(item.get("votedValidators")) approved_percent_text = f"{item.get('approvedPercent')}%" is_passed = item.get("isPassed") if "hash" not in args: from modules.utilities import UtilitiesModule - hash = UtilitiesModule.reduct(hash) + o_hash = UtilitiesModule.reduct(o_hash) if is_passed is True: is_passed = bcolors.green_text("true") if is_passed is False: is_passed = bcolors.red_text("false") - table += [[hash, voted_validators, approved_percent_text, is_passed]] + table += [[o_hash, voted_validators, approved_percent_text, is_passed]] print_table(table) def remove_btc_teleport(self, args: list): @@ -175,4 +203,4 @@ def remove_btc_teleport(self, args: list): def add_console_commands(self, console): console.AddItem("remove_btc_teleport", self.remove_btc_teleport, self.local.translate("remove_btc_teleport_cmd")) console.AddItem("vote_offer_btc_teleport", self.vote_offer_btc_teleport, self.local.translate("vote_offer_btc_teleport_cmd")) - console.AddItem("print_offers_btc_teleport_list", self.print_offers_btc_teleport_list, self.local.translate("print_offers_btc_teleport_list_cmd")) \ No newline at end of file + console.AddItem("print_offers_btc_teleport_list", self.print_offers_btc_teleport_list, self.local.translate("print_offers_btc_teleport_list_cmd")) diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 8d995507..38c361fc 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -585,6 +585,10 @@ def General(local): from modules.prometheus import PrometheusModule local.start_cycle(PrometheusModule(ton, local).push_metrics, sec=30, args=()) + from modules.btc_teleport import BtcTeleportModule + local.start_cycle(BtcTeleportModule(ton, local).auto_vote_offers, sec=600, args=()) + + thr_sleep() # end define From 835f5bbff049c8d7f71982489fc0680b85c18711 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 19 Jun 2025 15:54:08 +0900 Subject: [PATCH 41/67] proper calculate total weight for btc teleport offers --- modules/btc_teleport.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 6485d008..9c9f6741 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -111,8 +111,13 @@ def get_offers(self): result = self.ton.liteClient.Run(cmd) raw_offers = self.ton.Result2List(result) raw_offers = raw_offers[0] - config34 = self.ton.GetConfig34() - total_weight = config34.get("totalWeight") + validators = self.ton.GetValidatorsList(fast=True) + total_weight = 0 + for v in validators: + if v['is_masterchain'] is False: + continue + total_weight += v['weight'] + offers = {} for offer in raw_offers: if len(offer) == 0: From 12a2d55f2b4f181a58ea280ef28612a4eb4a5022 Mon Sep 17 00:00:00 2001 From: yungwine Date: Sat, 21 Jun 2025 08:57:56 +0900 Subject: [PATCH 42/67] upd configurator --- modules/btc_teleport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 9c9f6741..450ec459 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -11,7 +11,7 @@ class BtcTeleportModule(MtcModule): COORDINATOR_ADDRESS = 'EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo' - CONFIGURATOR_ADDRESS = 'EQCPL1AFRXtvqIxaYK05EzSCnz5QQRb6UGXp6PAJurFeVQYC' + CONFIGURATOR_ADDRESS = 'EQAFmcPeyXxpBsX7Y-fuGyDz3tvIMeMr5EXi9WuvFzgGPZSz' def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) From 44d515e929554233279cfbbce4fc2b490abfec61 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 26 Jun 2025 10:17:26 +0900 Subject: [PATCH 43/67] update teleport list_proposals parsing --- modules/btc_teleport.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 450ec459..6e3f8cae 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -125,13 +125,15 @@ def get_offers(self): item = {} o_hash = str(offer[0]) item["hash"] = o_hash - item["price"] = offer[1] - item["proposal"] = offer[2] - item["votedValidators"] = offer[3] - weight_remaining = offer[4] + item["remaining_losses"] = offer[1] + item["price"] = offer[2] + item["proposal"] = offer[3] + item["votedValidators"] = offer[4] + weight_remaining = offer[5] item["weightRemaining"] = weight_remaining - item["vset_id"] = offer[5] - item["creator"] = offer[6] + item["vset_id"] = offer[6] + item["creator"] = offer[7] + item["created_at"] = offer[-1] # todo: bug in parsing slice in get method output required_weight = total_weight * 3 / 4 if len(item["votedValidators"]) == 0: weight_remaining = required_weight From dcf9298f06d043e6635566cc4dd7df8f42042742 Mon Sep 17 00:00:00 2001 From: yungwine Date: Thu, 26 Jun 2025 10:44:20 +0900 Subject: [PATCH 44/67] allow vote for teleport offers only to master vals --- modules/btc_teleport.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 6e3f8cae..e04b8b8f 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -151,6 +151,10 @@ def vote_offer_btc_teleport(self, args): validator_key = self.ton.GetValidatorKey() validator_pubkey_b64 = self.ton.GetPubKeyBase64(validator_key) validator_index = self.ton.GetValidatorIndex() + config34 = self.ton.GetConfig34() + if validator_index == -1 or validator_index >= config34['mainValidators']: + self.local.add_log("Can not vote for BTC Teleport proposal from non-masterchain validator", "error") + return for offer_hash in args: current_offers = self.get_offers() if offer_hash not in current_offers: From 72e66cb44d6e8d91e466831e6b5d382a5a598e29 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 27 Jun 2025 19:13:10 +0900 Subject: [PATCH 45/67] update auto voting --- modules/btc_teleport.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index e04b8b8f..bbb1ce5e 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -95,14 +95,15 @@ def auto_vote_offers(self): if not save_offers: return current_offers = self.get_offers() + config34 = self.ton.GetConfig34() for save_offer in list(save_offers.values()): offer_hash = save_offer['hash'] if offer_hash not in current_offers: + if save_offer['ttl'] > config34['endWorkTime']: # offer is not expired but not found in current offers, so we assume it has been accepted + save_offers.pop(offer_hash) + self.local.add_log(f'Removing offer {offer_hash} from saved offers', 'debug') continue offer = current_offers[save_offer['hash']] - if offer['isPassed']: - save_offers.pop(offer_hash) - continue self.vote_offer_btc_teleport([offer['hash']]) def get_offers(self): @@ -143,6 +144,12 @@ def get_offers(self): offers[o_hash] = item return offers + def add_save_offer(self, offer: dict): + config15 = self.ton.GetConfig15() + offer['ttl'] = offer['created_at'] + config15['validatorsElectedFor'] * 3 # proposal lives 3 rounds + self.get_save_offers()[offer['hash']] = offer + self.ton.local.save() + def vote_offer_btc_teleport(self, args): if len(args) == 0: color_print("{red}Bad args. Usage:{endc} vote_offer_btc_teleport [offer-hash-2 offer-hash-3 ...]") @@ -164,8 +171,7 @@ def vote_offer_btc_teleport(self, args): if validator_index in offer.get("votedValidators"): self.local.add_log("Proposal already has been voted", "debug") return - self.get_save_offers()[offer_hash] = offer - self.ton.local.save() + self.add_save_offer(offer) request_hash = self.ton.CreateConfigProposalRequest(offer_hash, validator_index) validator_signature = self.ton.GetValidatorSignature(validator_key, request_hash) path = self.ton.SignProposalVoteRequestWithValidator(offer_hash, validator_index, validator_pubkey_b64, From d1dcbb95c2c2f779cc7339e4a66c18c83775d39e Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 30 Jun 2025 08:59:43 +0900 Subject: [PATCH 46/67] fix fast GetValidatorsList --- mytoncore/mytoncore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 7b389848..e4468d94 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -2495,7 +2495,7 @@ def GetValidatorsList(self, past=False, fast=False, start=None, end=None): end = timestamp - 60 if start is None: if fast: - start = end - 1000 + start = max(end - 1000, config.get("startWorkTime")) else: start = config.get("startWorkTime") if past: From 5bf19e453cd2ff5fbfea07e6e82b4fa2d5b94b2c Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 1 Jul 2025 10:11:26 +0900 Subject: [PATCH 47/67] fix displaying active_validator_groups when they are 0 --- mytonctrl/mytonctrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index b9fc178a..be3d5e0d 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -774,7 +774,7 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, active_validator_groups = None - if ton.using_validator() and validator_status.validator_groups_master and validator_status.validator_groups_shard: + if ton.using_validator() and validator_status.validator_groups_master is not None and validator_status.validator_groups_shard is not None: active_validator_groups = local.translate("active_validator_groups").format(validator_status.validator_groups_master, validator_status.validator_groups_shard) collated, validated = None, None From 588bda3e63efe7e2f527c5f77ff4ca1f29b03fec Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 4 Jul 2025 10:17:07 +0900 Subject: [PATCH 48/67] do not delete local ls config on upgrade --- mytonctrl/scripts/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytonctrl/scripts/upgrade.sh b/mytonctrl/scripts/upgrade.sh index a18b585b..fb22dad2 100644 --- a/mytonctrl/scripts/upgrade.sh +++ b/mytonctrl/scripts/upgrade.sh @@ -83,7 +83,7 @@ export CCACHE_DISABLE=1 # Update binary cd ${bindir}/${repo} -ls --hide=global.config.json | xargs -d '\n' rm -rf +ls --hide="*.config.json" | xargs -d '\n' rm -rf rm -rf .ninja_* memory=$(cat /proc/meminfo | grep MemAvailable | awk '{print $2}') cpuNumber=$(cat /proc/cpuinfo | grep "processor" | wc -l) From a44ba67cf99d9d4da910ffe228b07fcc204324fa Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 4 Jul 2025 11:05:23 +0900 Subject: [PATCH 49/67] add btc teleport status to status --- mytonctrl/mytonctrl.py | 10 ++++++++++ mytonctrl/resources/translate.json | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index bcd69656..a2616d06 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -771,6 +771,14 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, validatorStatus_color = GetColorStatus(validatorStatus_bool) mytoncoreStatus_text = local.translate("local_status_mytoncore_status").format(mytoncoreStatus_color, mytoncoreUptime_text) validatorStatus_text = local.translate("local_status_validator_status").format(validatorStatus_color, validatorUptime_text) + btc_teleport_status_text = None + if ton.using_validator(): + btc_teleport_status_bool = get_service_status("btc_teleport") + btc_teleport_status_uptime = get_service_uptime("btc_teleport") + btc_teleport_status_text = local.translate("local_status_btc_teleport_status").format( + GetColorStatus(btc_teleport_status_bool), + bcolors.green_text(time2human(btc_teleport_status_uptime)) if btc_teleport_status_bool else 'n/a' + ) validator_initial_sync_text = '' validator_out_of_sync_text = '' @@ -869,6 +877,8 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, print(mytoncoreStatus_text) if not is_node_remote: print(validatorStatus_text) + if btc_teleport_status_text: + print(btc_teleport_status_text) if validator_initial_sync_text: print(validator_initial_sync_text) if validator_out_of_sync_text: diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index 8ecd2ac5..e9823839 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -329,6 +329,11 @@ "ru": "Статус локального валидатора: {0}, {1}", "zh_TW": "本地驗證者狀態: {0}, {1}" }, + "local_status_btc_teleport_status": { + "en": "BTC Teleport status: {0}, {1}", + "ru": "Статус BTC Teleport: {0}, {1}", + "zh_TW": "BTC Teleport 狀態: {0}, {1}" + }, "local_status_validator_initial_sync": { "en": "Local validator initial sync status: {0}", "ru": "Статус начальной синхронизации локального валидатора: {0}", From 399c570b8a7f9a85cd74a55e4cee56160db68c96 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 7 Jul 2025 19:17:38 +0900 Subject: [PATCH 50/67] fix archive-ttl==0 --- mytoninstaller/settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mytoninstaller/settings.py b/mytoninstaller/settings.py index b403ec37..a9256eee 100644 --- a/mytoninstaller/settings.py +++ b/mytoninstaller/settings.py @@ -53,6 +53,8 @@ def FirstNodeSettings(local): if os.getenv('STATE_TTL'): state_ttl = int(os.getenv('STATE_TTL')) archive_ttl -= state_ttl + if archive_ttl == 0: + archive_ttl = 1 # todo: remove this when archive_ttl==0 will be allowed in node # Проверить конфигурацию if os.path.isfile(vconfig_path): From 871c095a765ee2041fe137cc0445098fbdb5c5bb Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 1 Jul 2025 12:27:52 +0900 Subject: [PATCH 51/67] fix getting node stats --- mytoncore/mytoncore.py | 22 +++++++++++----------- mytonctrl/mytonctrl.py | 26 ++++++++++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 514e17bb..8bcd30f9 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -3061,17 +3061,17 @@ def get_node_statistics(self): stats = self.local.db.get('statistics', {}).get('node') result = {} if stats is not None and len(stats) == 3 and stats[0] is not None: - for k in ['master', 'shard']: - result = { - 'collated': { - 'ok': 0, - 'error': 0, - }, - 'validated': { - 'ok': 0, - 'error': 0, - } + result = { + 'collated': { + 'ok': 0, + 'error': 0, + }, + 'validated': { + 'ok': 0, + 'error': 0, } + } + for k in ['master', 'shard']: collated_ok = stats[2]['collated_blocks'][k]['ok'] - stats[0]['collated_blocks'][k]['ok'] collated_error = stats[2]['collated_blocks'][k]['error'] - stats[0]['collated_blocks'][k]['error'] validated_ok = stats[2]['validated_blocks'][k]['ok'] - stats[0]['validated_blocks'][k]['ok'] @@ -3088,7 +3088,7 @@ def get_node_statistics(self): result['collated']['error'] += collated_error result['validated']['ok'] += validated_ok result['validated']['error'] += validated_error - if stats is not None and len(stats) >= 2 and stats[0] is not None: + if stats is not None and len(stats) >= 2 and stats[-2] is not None and stats[-1] is not None: result['ls_queries'] = { 'ok': stats[-1]['ls_queries']['ok'] - stats[-2]['ls_queries']['ok'], 'error': stats[-1]['ls_queries']['error'] - stats[-2]['ls_queries']['error'], diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index be3d5e0d..7165ebe5 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -779,18 +779,20 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency, collated, validated = None, None ls_queries = None - if ton.using_validator(): - node_stats = ton.get_node_statistics() - if node_stats and 'collated' in node_stats and 'validated' in node_stats: - collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error']) - validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error']) - else: - collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round') - validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round') - if ton.using_liteserver(): - node_stats = ton.get_node_statistics() - if node_stats and 'ls_queries' in node_stats: - ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error']) + node_stats = local.try_function(ton.get_node_statistics) + if node_stats is not None: + if ton.using_validator(): + if 'collated' in node_stats and 'validated' in node_stats: + collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error']) + validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error']) + else: + collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round') + validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round') + if ton.using_liteserver(): + if 'ls_queries' in node_stats: + ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error']) + else: + local.add_log("Failed to get node statistics", "warning") dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb") dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%") From 9550d3bdcfa178306fbf41d9a4a7f477e147fc79 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 2 Jul 2025 11:35:32 +0900 Subject: [PATCH 52/67] reduce config34 cache, add no_cache config34 in node stats --- mytoncore/functions.py | 2 +- mytoncore/mytoncore.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 8899e4d3..947e3287 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -317,7 +317,7 @@ def get_ok_error(value: str): # statistics['node'] = [stats_from_election_id, stats_from_prev_min, stats_now] - election_id = ton.GetConfig34()['startWorkTime'] + election_id = ton.GetConfig34(no_cache=True)['startWorkTime'] if 'node' not in statistics or len(statistics['node']) == 0: statistics['node'] = [None, data] elif len(statistics['node']) < 3: diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 8bcd30f9..1240b311 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -930,11 +930,11 @@ def GetConfig32(self): return config32 #end define - def GetConfig34(self): + def GetConfig34(self, no_cache: bool = False): # Get buffer bname = "config34" - buff = self.GetFunctionBuffer(bname, timeout=60) - if buff: + buff = self.GetFunctionBuffer(bname, timeout=10) + if buff and not no_cache: return buff #end if From 0cafaf874745d8549b1cc0a233997055d4654383 Mon Sep 17 00:00:00 2001 From: yungwine Date: Wed, 2 Jul 2025 21:17:03 +0900 Subject: [PATCH 53/67] improve saving node stats --- mytoncore/functions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 947e3287..72dc273e 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -328,9 +328,11 @@ def get_ok_error(value: str): statistics['node'][0] = data elif statistics['node'][0]['timestamp'] < election_id: statistics['node'][0] = data - statistics['node'] = statistics.get('node', []) + [data] - statistics['node'].pop(1) + temp = statistics.get('node', []) + [data] + temp.pop(1) + statistics['node'] = temp local.db["statistics"] = statistics + local.save() def ReadTransData(local, scanner): From 3e8fc7b4ca401b5481b30715c428237b8ba99166 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 11 Jul 2025 10:33:06 +0800 Subject: [PATCH 54/67] update configurator --- modules/btc_teleport.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index bbb1ce5e..57d2aa39 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -11,7 +11,7 @@ class BtcTeleportModule(MtcModule): COORDINATOR_ADDRESS = 'EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo' - CONFIGURATOR_ADDRESS = 'EQAFmcPeyXxpBsX7Y-fuGyDz3tvIMeMr5EXi9WuvFzgGPZSz' + CONFIGURATOR_ADDRESS = 'EQCY-A1I-jvZF7JnXp9nTKfAnOwVSbFeCpZQ1TfB-BNXXgYp' def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) @@ -135,7 +135,7 @@ def get_offers(self): item["vset_id"] = offer[6] item["creator"] = offer[7] item["created_at"] = offer[-1] # todo: bug in parsing slice in get method output - required_weight = total_weight * 3 / 4 + required_weight = total_weight * 2 / 3 if len(item["votedValidators"]) == 0: weight_remaining = required_weight available_weight = required_weight - weight_remaining From 8e590231d8d1ccc66adb2a4129c8bd63e6cacea1 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 11 Jul 2025 11:40:27 +0800 Subject: [PATCH 55/67] fix autovoting for teleport offer --- modules/btc_teleport.py | 6 +++++- mytoncore/functions.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 57d2aa39..c632fa90 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -104,7 +104,11 @@ def auto_vote_offers(self): self.local.add_log(f'Removing offer {offer_hash} from saved offers', 'debug') continue offer = current_offers[save_offer['hash']] - self.vote_offer_btc_teleport([offer['hash']]) + if offer['created_at'] != save_offer['created_at'] and save_offer['ttl'] > config34['endWorkTime']: # offer is not expired but has been changed, so it has been accepted and launched again + save_offers.pop(offer_hash) + self.local.add_log(f'Removing offer {offer_hash} from saved offers', 'debug') + continue + self.vote_offer_btc_teleport([offer_hash]) def get_offers(self): self.local.add_log("start get_offers_btc_teleport function", "debug") diff --git a/mytoncore/functions.py b/mytoncore/functions.py index d7ae76da..1c00b9aa 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -676,7 +676,7 @@ def General(local): local.start_cycle(PrometheusModule(ton, local).push_metrics, sec=30, args=()) from modules.btc_teleport import BtcTeleportModule - local.start_cycle(BtcTeleportModule(ton, local).auto_vote_offers, sec=600, args=()) + local.start_cycle(BtcTeleportModule(ton, local).auto_vote_offers, sec=180, args=()) if ton.in_initial_sync(): local.start_cycle(check_initial_sync, sec=120, args=(local, ton)) From 673866d6127503676f48728cefd475c15bfb95d8 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 11 Jul 2025 09:33:54 +0800 Subject: [PATCH 56/67] fix node stats resetting --- mytoncore/functions.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 72dc273e..7e909c61 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -312,17 +312,25 @@ def get_ok_error(value: str): data['ls_queries']['error'] = int(k.split(':')[1]) statistics = local.db.get("statistics", dict()) - if time.time() - int(status.start_time) <= 60: # was node restart <60 sec ago, resetting node statistics + # if time.time() - int(status.start_time) <= 60: # was node restart <60 sec ago, resetting node statistics + # statistics['node'] = [] + + if 'node' not in statistics: statistics['node'] = [] - # statistics['node'] = [stats_from_election_id, stats_from_prev_min, stats_now] + if statistics['node']: + if int(status.start_time) > statistics['node'][-1]['timestamp']: + # node was restarted, reset node statistics + statistics['node'] = [] + + # statistics['node']: [stats_from_election_id, stats_from_prev_min, stats_now] election_id = ton.GetConfig34(no_cache=True)['startWorkTime'] - if 'node' not in statistics or len(statistics['node']) == 0: + if len(statistics['node']) == 0: statistics['node'] = [None, data] elif len(statistics['node']) < 3: statistics['node'].append(data) - if len(statistics['node']) == 3: + elif len(statistics['node']) == 3: if statistics['node'][0] is None: if 0 < data['timestamp'] - election_id < 90: statistics['node'][0] = data From 7739d537843415c0902d35b5a716369f17836a29 Mon Sep 17 00:00:00 2001 From: yungwine Date: Fri, 11 Jul 2025 20:38:01 +0800 Subject: [PATCH 57/67] update mypylib --- mypylib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypylib b/mypylib index 3508d3aa..d7ecb725 160000 --- a/mypylib +++ b/mypylib @@ -1 +1 @@ -Subproject commit 3508d3aa07ec3ea1a47690a3e7477b2b8e677c4a +Subproject commit d7ecb7257dcef084bd4294b1bee3eba19de668f9 From 02d31b06b8ae8f3745b575fbacff06944e408655 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 14 Jul 2025 10:48:05 +0800 Subject: [PATCH 58/67] add submodules update on update --- mytonctrl/scripts/update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/mytonctrl/scripts/update.sh b/mytonctrl/scripts/update.sh index c9de406b..985b4542 100644 --- a/mytonctrl/scripts/update.sh +++ b/mytonctrl/scripts/update.sh @@ -41,6 +41,7 @@ pip3 uninstall -y mytonctrl cd ${srcdir} cp -rf ${tmpdir}/${repo} ${srcdir} cd ${repo} && git checkout ${branch} +git submodule update pip3 install -U . systemctl daemon-reload From 9dd2f75f329590cecf5e5c21e877ea7797e0cd8f Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 14 Jul 2025 11:14:04 +0800 Subject: [PATCH 59/67] fix stateserializerenabled parsing --- mytoncore/mytoncore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 1240b311..518df8af 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -818,7 +818,7 @@ def GetValidatorStatus(self, no_cache=False): status.out_of_sync = status.masterchain_out_of_sync if status.masterchain_out_of_sync > status.shardchain_out_of_sync else status.shardchain_out_of_sync status.out_of_ser = status.masterchain_out_of_ser status.last_deleted_mc_state = int(parse(result, "last_deleted_mc_state", '\n')) - status.stateserializerenabled = parse(result, "stateserializerenabled", '\n') == "true" + status.stateserializerenabled = parse(result, "stateserializerenabled", '\n').strip() == "true" self.local.try_function(self.parse_stats_from_vc, args=[result, status]) if 'active_validator_groups' in status: groups = status.active_validator_groups.split() # master:1 shard:2 From d5c85960b3f73beff9f55553fc11df2300e0f78d Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 14 Jul 2025 11:14:04 +0800 Subject: [PATCH 60/67] fix stateserializerenabled parsing --- mytoncore/mytoncore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index fccc1134..30757ee5 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -819,7 +819,7 @@ def GetValidatorStatus(self, no_cache=False): status.out_of_sync = status.masterchain_out_of_sync if status.masterchain_out_of_sync > status.shardchain_out_of_sync else status.shardchain_out_of_sync status.out_of_ser = status.masterchain_out_of_ser status.last_deleted_mc_state = int(parse(result, "last_deleted_mc_state", '\n')) - status.stateserializerenabled = parse(result, "stateserializerenabled", '\n') == "true" + status.stateserializerenabled = parse(result, "stateserializerenabled", '\n').strip() == "true" self.local.try_function(self.parse_stats_from_vc, args=[result, status]) if 'active_validator_groups' in status: groups = status.active_validator_groups.split() # master:1 shard:2 From 4b4384f23e21d689fc744235974fa55ab474a359 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 15 Jul 2025 10:30:47 +0800 Subject: [PATCH 61/67] increase check_zero_blocks_created period --- modules/alert_bot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/alert_bot.py b/modules/alert_bot.py index 78a8c4a0..e012e77d 100644 --- a/modules/alert_bot.py +++ b/modules/alert_bot.py @@ -76,9 +76,9 @@ def init_alerts(): ), "zero_block_created": Alert( "critical", - f"Validator has not created any blocks in the {int(VALIDATION_PERIOD // 6 // 3600)} hours", + "Validator has not created any blocks in the last few hours", "Validator has not created any blocks in the last {hours} hours.", - VALIDATION_PERIOD // 6 + int(VALIDATION_PERIOD / 2.3) ), "validator_slashed": Alert( "high", @@ -355,7 +355,7 @@ def check_zero_blocks_created(self): if not self.ton.using_validator(): return ts = get_timestamp() - period = VALIDATION_PERIOD // 6 # 3h for mainnet, 40m for testnet + period = int(VALIDATION_PERIOD / 2.3) # ~ 8h for mainnet, 100m for testnet start, end = ts - period, ts - 60 config34 = self.ton.GetConfig34() if start < config34.startWorkTime: # round started recently @@ -364,7 +364,7 @@ def check_zero_blocks_created(self): validator = self.validator_module.find_myself(validators) if validator is None or validator.blocks_created > 0: return - self.send_alert("zero_block_created", hours=round(period // 3600, 1)) + self.send_alert("zero_block_created", hours=round(period / 3600)) def check_slashed(self): if not self.ton.using_validator(): From 3879b49c000ff9a348268935e32ed4bffeaee090 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 14 Jul 2025 12:00:58 +0800 Subject: [PATCH 62/67] update configurator --- modules/btc_teleport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index c632fa90..6e131ca9 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -11,7 +11,7 @@ class BtcTeleportModule(MtcModule): COORDINATOR_ADDRESS = 'EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo' - CONFIGURATOR_ADDRESS = 'EQCY-A1I-jvZF7JnXp9nTKfAnOwVSbFeCpZQ1TfB-BNXXgYp' + CONFIGURATOR_ADDRESS = 'EQAeQjuHAnTEgrGZZPx9M9YXXEZejOD3yOMzF79uiFktorml' def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) From d91cad754b74239349f3b868c27e98606d1738e4 Mon Sep 17 00:00:00 2001 From: yungwine Date: Mon, 14 Jul 2025 12:49:05 +0800 Subject: [PATCH 63/67] update CreateLocalConfigFile --- mytoninstaller/mytoninstaller.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mytoninstaller/mytoninstaller.py b/mytoninstaller/mytoninstaller.py index 6bfcb5fb..285efd3d 100644 --- a/mytoninstaller/mytoninstaller.py +++ b/mytoninstaller/mytoninstaller.py @@ -15,7 +15,7 @@ from mytoninstaller.config import GetLiteServerConfig, get_ls_proxy_config from mytoninstaller.node_args import get_node_args from mytoninstaller.utils import GetInitBlock -from mytoncore.utils import dict2b64, str2bool, b642dict +from mytoncore.utils import dict2b64, str2bool, b642dict, b642hex from mytoninstaller.settings import ( FirstNodeSettings, @@ -196,10 +196,19 @@ def PrintLiteServerConfig(local, args): def CreateLocalConfigFile(local, args): - initBlock = GetInitBlock() - initBlock_b64 = dict2b64(initBlock) + init_block = GetInitBlock() + if init_block['rootHash'] is None: + local.add_log("Failed to get recent init block. Using init block from global config.", "warning") + with open('/usr/bin/ton/global.config.json', 'r') as f: + config = json.load(f) + config_init_block = config['validator']['init_block'] + init_block = dict() + init_block["seqno"] = config_init_block['seqno'] + init_block["rootHash"] = b642hex(config_init_block['root_hash']) + init_block["fileHash"] = b642hex(config_init_block['file_hash']) + init_block_b64 = dict2b64(init_block) user = local.buffer.user or os.environ.get("USER", "root") - args = ["python3", "-m", "mytoninstaller", "-u", user, "-e", "clc", "-i", initBlock_b64] + args = ["python3", "-m", "mytoninstaller", "-u", user, "-e", "clc", "-i", init_block_b64] run_as_root(args) #end define From f449d5006c3d5d82b41fc2634d50eeb00c5e9a39 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 15 Jul 2025 10:30:47 +0800 Subject: [PATCH 64/67] increase check_zero_blocks_created period --- modules/alert_bot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/alert_bot.py b/modules/alert_bot.py index 78a8c4a0..e012e77d 100644 --- a/modules/alert_bot.py +++ b/modules/alert_bot.py @@ -76,9 +76,9 @@ def init_alerts(): ), "zero_block_created": Alert( "critical", - f"Validator has not created any blocks in the {int(VALIDATION_PERIOD // 6 // 3600)} hours", + "Validator has not created any blocks in the last few hours", "Validator has not created any blocks in the last {hours} hours.", - VALIDATION_PERIOD // 6 + int(VALIDATION_PERIOD / 2.3) ), "validator_slashed": Alert( "high", @@ -355,7 +355,7 @@ def check_zero_blocks_created(self): if not self.ton.using_validator(): return ts = get_timestamp() - period = VALIDATION_PERIOD // 6 # 3h for mainnet, 40m for testnet + period = int(VALIDATION_PERIOD / 2.3) # ~ 8h for mainnet, 100m for testnet start, end = ts - period, ts - 60 config34 = self.ton.GetConfig34() if start < config34.startWorkTime: # round started recently @@ -364,7 +364,7 @@ def check_zero_blocks_created(self): validator = self.validator_module.find_myself(validators) if validator is None or validator.blocks_created > 0: return - self.send_alert("zero_block_created", hours=round(period // 3600, 1)) + self.send_alert("zero_block_created", hours=round(period / 3600)) def check_slashed(self): if not self.ton.using_validator(): From 949941c6dd8445c7bdf168de205e90bd2800b171 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 15 Jul 2025 17:06:38 +0800 Subject: [PATCH 65/67] update envs --- modules/btc_teleport.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index 6e131ca9..ef4da3cf 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -10,8 +10,8 @@ class BtcTeleportModule(MtcModule): - COORDINATOR_ADDRESS = 'EQD43RtdAQ_Y8nl86SqzxjlL_-rAvdZiBDk_s7OTF-oRxmwo' - CONFIGURATOR_ADDRESS = 'EQAeQjuHAnTEgrGZZPx9M9YXXEZejOD3yOMzF79uiFktorml' + COORDINATOR_ADDRESS = 'Ef_q19o4m94xfF-yhYB85Qe6rTHDX-VTSzxBh4XpAfZMaOvk' + CONFIGURATOR_ADDRESS = 'EQAR_I_lQm5wnEePggUKfioQUFs1vN1YYkK1Kl3WVAPiCzDZ' def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) @@ -47,7 +47,10 @@ def create_env_file(self, reinit=False): ORACLE_SERVER_PUBLIC_KEY_PATH={self.ton.validatorConsole.pubKeyPath} ORACLE_CLIENT_PRIVATE_KEY_PATH={self.ton.validatorConsole.privKeyPath} ORACLE_VALIDATOR_SERVER_ADDR={self.ton.validatorConsole.addr} -API_CALL_TIMEOUT=30 +ORACLE_DKG_FETCH_PERIOD=15 +ORACLE_EXECUTE_SIGN_PERIOD=15 +ORACLE_SEND_START_DKG_PERIOD=30 +API_CALL_TIMEOUT=15 LOG_FILE=/var/log/btc_teleport/btc_teleport.log """ with open(env_path, 'w') as f: From 59fb9aacf60ca26581532d3d0e6f45b1cc28aaea Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Tue, 15 Jul 2025 17:16:47 +0800 Subject: [PATCH 66/67] fix double slash in src_dir Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- modules/btc_teleport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index ef4da3cf..bcd0ca25 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -17,7 +17,7 @@ def __init__(self, ton, local, *args, **kwargs): super().__init__(ton, local, *args, **kwargs) self.keystore_path = self.ton.local.buffer.my_work_dir + '/btc_oracle_keystore' self.repo_name = 'ton-teleport-btc-periphery' - self.src_dir = '/usr/src/' + f'/{self.repo_name}' + self.src_dir = f"/usr/src/{self.repo_name}" self.bin_dir = self.src_dir + '/out' def create_local_file(self): From 6e2dab7223e11cc2efc77c511b5ad260b3553757 Mon Sep 17 00:00:00 2001 From: yungwine Date: Tue, 15 Jul 2025 21:33:12 +0800 Subject: [PATCH 67/67] fix vote_offer_btc_teleport --- modules/btc_teleport.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/btc_teleport.py b/modules/btc_teleport.py index bcd0ca25..4299c685 100644 --- a/modules/btc_teleport.py +++ b/modules/btc_teleport.py @@ -173,11 +173,11 @@ def vote_offer_btc_teleport(self, args): current_offers = self.get_offers() if offer_hash not in current_offers: self.local.add_log("Offer not found, skip", "warning") - return + continue offer = current_offers[offer_hash] if validator_index in offer.get("votedValidators"): self.local.add_log("Proposal already has been voted", "debug") - return + continue self.add_save_offer(offer) request_hash = self.ton.CreateConfigProposalRequest(offer_hash, validator_index) validator_signature = self.ton.GetValidatorSignature(validator_key, request_hash)