Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
244cad8
Merge pull request #210 from ton-blockchain/mytonctrl1_dev
igroman787 Mar 11, 2024
877f66e
Merge pull request #220 from yungwine/mytonctrl1_dev
igroman787 Mar 26, 2024
5f4db2e
Merge pull request #224 from yungwine/mytonctrl1_dev
igroman787 Mar 29, 2024
aaa758d
add custom overlays
yungwine Apr 2, 2024
fab1484
fix config parsing
yungwine Apr 2, 2024
e935a4d
fix circular import
yungwine Apr 2, 2024
d0b2f59
bugfix
yungwine Apr 2, 2024
3863ef0
rm mytoncore_local from custom_overlays
yungwine Apr 2, 2024
8d584bc
improves
yungwine Apr 2, 2024
1b9ff1c
rm global variables from custom_overlays
yungwine Apr 2, 2024
b0c15b3
bugfix
yungwine Apr 2, 2024
cb8ab7d
logging improve
yungwine Apr 2, 2024
acef9c5
Merge pull request #229 from yungwine/mytonctrl1_dev
igroman787 Apr 2, 2024
af8bc48
delete old code
igroman787 Apr 2, 2024
4f70dfa
add default custom overlays
yungwine Apr 3, 2024
39f2717
bugfix
yungwine Apr 3, 2024
6250661
add set_archive_ttl
yungwine Apr 4, 2024
c649737
update error message on set_archive_ttl
yungwine Apr 4, 2024
65112ea
Merge pull request #230 from yungwine/mytonctrl1_dev
igroman787 Apr 4, 2024
96a5db2
Merge pull request #231 from yungwine/archive-ttl
igroman787 Apr 4, 2024
8683e66
add disk usage warning
yungwine Apr 5, 2024
4bc7ceb
customize message warning
yungwine Apr 5, 2024
c401a2f
Merge pull request #233 from yungwine/mytonctrl1_dev
igroman787 Apr 5, 2024
536f0d5
improve custom overlays
yungwine Apr 8, 2024
3e7d491
Merge pull request #235 from yungwine/mytonctrl1_dev
igroman787 Apr 8, 2024
a0d75b2
dont check verbosity in set_archive_ttl
yungwine Apr 8, 2024
0604637
Merge pull request #236 from yungwine/mytonctrl1_dev
igroman787 Apr 8, 2024
80c1c37
download default custom overlays from github
yungwine Apr 9, 2024
53feb3f
Merge pull request #237 from yungwine/mytonctrl1_dev
igroman787 Apr 9, 2024
4a258de
Update default_custom_overlays_url
igroman787 Apr 10, 2024
9182448
Merge pull request #238 from ton-blockchain/mytonctrl1_dev
igroman787 Apr 10, 2024
1a04eea
fix vo
yungwine Apr 19, 2024
b97d502
Merge pull request #245 from yungwine/vo-fix
igroman787 Apr 19, 2024
138da0a
use jemalloc
May 11, 2024
9310e68
use jemalloc on upgrade
neodix42 May 12, 2024
76be48d
Merge pull request #252 from neodix42/use-jemalloc
igroman787 May 13, 2024
0b8bd01
Revert "use jemalloc"
igroman787 May 13, 2024
703e2cf
Merge pull request #253 from ton-blockchain/revert-252-use-jemalloc
igroman787 May 13, 2024
3257127
use jemmaloc
igroman787 May 25, 2024
93b5580
add set_state_ttl script
yungwine Jun 7, 2024
f48f8bc
Merge pull request #285 from yungwine/mytonctrl1_dev
igroman787 Jun 7, 2024
40daf3c
Merge pull request #287 from ton-blockchain/mytonctrl1_dev
igroman787 Jun 10, 2024
c92c6d6
Exclude deletion of `local.config.json`
awesome-doge Jun 18, 2024
d7e879b
add warning to update to mtc2.0 for non-validators
yungwine Jun 19, 2024
f628636
add find_myself_in_vl
yungwine Jun 19, 2024
c563ed5
make mtc2 warning red
yungwine Jun 19, 2024
4629d3f
fix color
yungwine Jun 19, 2024
86dcdbb
add try
yungwine Jun 19, 2024
41e03cc
handle list saved offers
yungwine Jul 11, 2024
f293da1
Merge pull request #300 from yungwine/mytonctrl1_dev
igroman787 Jul 14, 2024
41dfd36
Merge pull request #290 from awesome-doge/patch-2
igroman787 Jul 14, 2024
394f781
Merge pull request #291 from yungwine/master
igroman787 Jul 14, 2024
e9ea856
replace `find_myself_in_vl` with `find_myself_in_el`
igroman787 Jul 14, 2024
47275a9
Merge pull request #301 from ton-blockchain/add_warning
igroman787 Jul 14, 2024
622c3f6
add collator config
yungwine Jul 18, 2024
ca211e9
bugfix
yungwine Jul 18, 2024
09d330b
Merge pull request #305 from yungwine/mytonctrl2_dev
igroman787 Jul 22, 2024
7c8a5c9
fix incorrect warning for --state-ttl changing
yungwine Aug 5, 2024
cf3f94c
Merge pull request #313 from yungwine/mytonctrl2_dev
igroman787 Aug 5, 2024
c34a459
check validator wallet status before activating pool
yungwine Aug 6, 2024
968437a
fixes
yungwine Aug 6, 2024
f50f6af
Merge branch 'ton-blockchain:mytonctrl2_dev' into mytonctrl2_dev
yungwine Aug 6, 2024
a464438
Merge branch 'mytoncrl1_merge' into mytonctrl2_merge
yungwine Aug 6, 2024
ed83c22
delete unused files form mtc1
yungwine Aug 6, 2024
e3d152e
Merge pull request #314 from yungwine/mytonctrl2_dev
igroman787 Aug 6, 2024
b40c9c7
Merge pull request #315 from yungwine/mytonctrl2_merge
igroman787 Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Setting:
'stake': Setting('validator', None, 'Stake amount'),
'stakePercent': Setting('validator', 99, 'Stake percent if `stake` is null'),
'isSlashing': Setting('validator', None, 'Create complaints to validators'),
'validatorWalletName': Setting('validator', 'wallet_001', 'Validator\'s wallet name'),
'maxFactor': Setting('validator', None, 'Param send to Elector. if null will be taken from 17 config param'),
'participateBeforeEnd': Setting('validator', None, 'Amount of seconds before start of round to participate'),
'liquid_pool_addr': Setting('liquid-staking', None, 'Liquid staking pool address'),
Expand Down
91 changes: 91 additions & 0 deletions modules/collator_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import json
import requests

from mypylib.mypylib import color_print
from modules.module import MtcModule


class CollatorConfigModule(MtcModule):

@staticmethod
def check_config_url(url):
try:
r = requests.get(url, timeout=3)
if r.status_code != 200:
print(f'Failed to get config from {url}: {r.status_code} code; {r.text}')
return
return r.json()
except Exception as e:
print(f'Failed to get config from {url}: {e}')
return

@staticmethod
def check_config_file(path):
try:
with open(path, 'r') as f:
return json.load(f)
except Exception as e:
print(f'Failed to read config from {path}: {e}')
return

@staticmethod
def get_config(path):
if 'http' in path:
config = CollatorConfigModule.check_config_url(path)
else:
config = CollatorConfigModule.check_config_file(path)
if config is None:
raise Exception(f'Failed to get config')
return config

def add_collator_config_to_vc(self, config: dict):
self.local.add_log(f"Adding collator options config to validator console", "debug")
path = self.ton.tempDir + f'/collator_config.json'
with open(path, 'w') as f:
json.dump(config, f)
result = self.ton.validatorConsole.Run(f"setcollatoroptionsjson {path}")
return 'success' in result, result

def set_collator_config(self, args):
if len(args) != 1:
color_print("{red}Bad args. Usage:{endc} set_collator_config <path/url>")
return
location = args[0]
config = self.get_config(location)
self.ton.set_collator_config(location)
added, msg = self.add_collator_config_to_vc(config)
if not added:
print(f'Failed to add collator config to validator console: {msg}')
color_print("set_collator_config - {red}ERROR{endc}")
return
color_print("set_collator_config - {green}OK{endc}")

def get_collator_config(self, args):
location = self.ton.get_collator_config_location()
print(f'Collator config location: {location}')
path = self.ton.tempDir + f'/current_collator_config.json'
output = self.ton.validatorConsole.Run(f'getcollatoroptionsjson {path}')
if 'saved config to' not in output:
print(f'Failed to get collator config: {output}')
color_print("get_collator_config - {red}ERROR{endc}")
return
with open(path, 'r') as f:
config = json.load(f)
print(f'Collator config:')
print(json.dumps(config, indent=4))
color_print("get_collator_config - {green}OK{endc}")

def update_collator_config(self, args):
location = self.ton.get_collator_config_location()
config = self.get_config(location)
added, msg = self.add_collator_config_to_vc(config)
if not added:
print(f'Failed to add collator config to validator console: {msg}')
color_print("update_collator_config - {red}ERROR{endc}")
return
color_print("update_collator_config - {green}OK{endc}")

def add_console_commands(self, console):
console.AddItem("set_collator_config", self.set_collator_config, self.local.translate("set_collator_config_cmd"))
console.AddItem("update_collator_config", self.update_collator_config, self.local.translate("update_collator_config_cmd"))
console.AddItem("get_collator_config", self.get_collator_config, self.local.translate("get_collator_config_cmd"))
2 changes: 2 additions & 0 deletions modules/nominator_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def do_activate_pool(self, pool, ex=True):
elif account.status == "active":
self.local.add_log("do_activate_pool warning: account status is active", "warning")
else:
validator_wallet = self.ton.GetValidatorWallet()
self.ton.check_account_active(validator_wallet.addrB64)
self.ton.SendFile(pool.bocFilePath, pool, timeout=False, remove=False)
#end define

Expand Down
1 change: 1 addition & 0 deletions modules/single_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def do_activate_single_pool(self, pool):
self.local.add_log("start activate_single_pool function", "debug")
boc_mode = "--with-init"
validator_wallet = self.ton.GetValidatorWallet()
self.ton.check_account_active(validator_wallet.addrB64)
result_file_path = self.ton.SignBocWithWallet(validator_wallet, pool.bocFilePath, pool.addrB64_init, 1, boc_mode=boc_mode)
self.ton.SendFile(result_file_path, validator_wallet)

Expand Down
40 changes: 32 additions & 8 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,9 +1180,7 @@ def SignBocWithWallet(self, wallet, boc_path, dest, coins, **kwargs):

# Balance checking
account = self.GetAccount(wallet.addrB64)
if account.balance < coins + 0.1:
raise Exception("Wallet balance is less than requested coins")
#end if
self.check_account_balance(account, coins + 0.1)

# Bounceable checking
destAccount = self.GetAccount(dest)
Expand Down Expand Up @@ -1864,6 +1862,25 @@ def GetWalletId(self, wallet):
return subwallet
#end define

def check_account_balance(self, account, coins):
if not isinstance(account, Account):
account = self.GetAccount(account)
if account.balance < coins:
raise Exception(f"Account {account.addrB64} balance is less than requested coins. Balance: {account.balance}, requested amount: {coins} (need {coins - account.balance} more)")
# end if
# end define

def check_account_active(self, account):
if not isinstance(account, Account):
address = account
account = self.GetAccount(account)
else:
address = account.addrB64
if account.status != "active":
raise Exception(f"Account {address} account is uninitialized")
# end if
# end define

def MoveCoins(self, wallet, dest, coins, **kwargs):
self.local.add_log("start MoveCoins function", "debug")
flags = kwargs.get("flags", list())
Expand All @@ -1884,11 +1901,8 @@ def MoveCoins(self, wallet, dest, coins, **kwargs):

# Balance checking
account = self.GetAccount(wallet.addrB64)
if account.balance < coins + 0.1:
raise Exception("Wallet balance is less than requested coins")
if account.status != "active":
raise Exception("Wallet account is uninitialized")
#end if
self.check_account_balance(account, coins + 0.1)
self.check_account_active(account)

# Bounceable checking
destAccount = self.GetAccount(dest)
Expand Down Expand Up @@ -3986,6 +4000,16 @@ def delete_custom_overlay(self, name: str):
del self.local.db['custom_overlays'][name]
self.local.save()

def set_collator_config(self, location: str):
self.local.db['collator_config'] = location
self.local.save()

def get_collator_config_location(self):
default = 'https://raw.githubusercontent.com/ton-blockchain/ton-blockchain.github.io/main/default_collator_options.json'
location = self.local.db.get('collator_config', default)
if location is None:
location = default
return location

def GetNetworkName(self):
data = self.local.read_db(self.liteClient.configPath)
Expand Down
6 changes: 5 additions & 1 deletion mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def inject_globals(func):
module = CustomOverlayModule(ton, local)
module.add_console_commands(console)

from modules.collator_config import CollatorConfigModule
module = CollatorConfigModule(ton, local)
module.add_console_commands(console)

if ton.using_validator():
from modules.validator import ValidatorModule
module = ValidatorModule(ton, local)
Expand Down Expand Up @@ -384,7 +388,7 @@ def Upgrade(ton, args):
try:
from mytoninstaller.mytoninstaller import set_node_argument, get_node_args
node_args = get_node_args()
if node_args['--state-ttl'] == '604800':
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}}")
Expand Down
10 changes: 10 additions & 0 deletions mytonctrl/resources/translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,16 @@
"ru": "{green}Доступно обновление MyTonCtrl. {red}Пожалуйста, обновите его с помощью команды `update`.{endc}",
"zh_TW": "{green}MyTonCtrl 有可用更新. {red}請使用 `update` 命令進行更新.{endc}"
},
"update_mtc2_warning": {
"en": "{red}This version is outdated. Please update to the second version: `update mytonctrl2`{endc}",
"ru": "{red}Данная версия устарела. Пожалуйста обновитесь на вторую версию: `update mytonctrl2`{endc}",
"zh_TW": "{red}這個版本已經過時了。請更新至第二版本: `update mytonctrl2`{endc}"
},
"disk_usage_warning": {
"en": "{red} Disk is almost full, clean the TON database immediately: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}",
"ru": "{red} Диск почти заполнен, немедленно очистите базу данных TON: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}",
"zh_TW": "{red} 磁盤幾乎滿了,立即清理 TON 數據庫: https://docs.ton.org/participate/nodes/node-maintenance-and-security#database-grooming {endc}"
},
"ton_update_available": {
"en": "{green}TON update available. {red}Please update it with `upgrade` command.{endc}",
"ru": "{green}Доступно обновление TON. {red}Пожалуйста, обновите его с помощью команды `upgrade`.{endc}",
Expand Down