Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions modules/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def check_efficiency(self, args):
color_print(f"Previous round time: {{yellow}}from {start_time} to {end_time}{{endc}}")
if validator:
if validator.is_masterchain == False:
print("Validator index is greater than 100 in the previous round - no efficiency data.")
print(f"Validator index is greater than {config32['mainValidators']} in the previous round - no efficiency data.")
elif validator.get('efficiency') is None:
print('Failed to get efficiency for the previous round')
else:
Expand All @@ -72,7 +72,7 @@ def check_efficiency(self, args):
color_print(f"Current round time: {{green}}from {start_time} to {end_time}{{endc}}")
if validator:
if validator.is_masterchain == False:
print("Validator index is greater than 100 in the current round - no efficiency data.")
print(f"Validator index is greater than {config34['mainValidators']} in the current round - no efficiency data.")
elif (time.time() - config34.startWorkTime) / (config34.endWorkTime - config34.startWorkTime) < 0.8:
print("The validation round has started recently, there is not enough data yet. "
"The efficiency evaluation will become more accurate towards the end of the round.")
Expand Down
15 changes: 11 additions & 4 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2305,6 +2305,7 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
continue

exists = False
vload = None
for item in validators_load.values():
if 'fileName' not in item:
continue
Expand All @@ -2314,14 +2315,14 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
pseudohash = pubkey + str(election_id)
if pseudohash == complaint['pseudohash']:
exists = True
vid = item['id']
vload = item
break

if not exists:
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint info was not found, probably it's wrong", "info")
continue

if vid >= config32['mainValidators']:
if vload["id"] >= config32['mainValidators']:
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator", "info")
continue

Expand All @@ -2330,8 +2331,13 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint fine value is {complaint['suggestedFine']} ton", "info")
continue
if complaint['suggestedFinePart'] != 0: # https://github.com/ton-blockchain/ton/blob/5847897b3758bc9ea85af38e7be8fc867e4c133a/lite-client/lite-client.cpp#L3709
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint fine part value is {complaint['suggestedFinePart']} ton", "info")
continue
if vload["id"] < config32['mainValidators'] and vload["masterBlocksCreated"] + vload["workBlocksCreated"] == 0: # masterchain validator that created 0 blocks
if complaint['suggestedFinePart'] != 42949672: # (1LL << 32) / 100
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint fine part value is {complaint['suggestedFinePart']} ton", "info")
continue
else:
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint fine part value is {complaint['suggestedFinePart']} ton", "info")
continue

result[complaint['pseudohash']] = complaint
return result
Expand Down Expand Up @@ -2476,6 +2482,7 @@ def GetValidatorsList(self, past=False, fast=False):
validator["efficiency"] = round(validator["wr"] * 100, 2)
if saveElectionEntries and adnlAddr in saveElectionEntries:
validator["walletAddr"] = saveElectionEntries[adnlAddr]["walletAddr"]
validator["stake"] = saveElectionEntries[adnlAddr].get("stake")
#end for

# Set buffer
Expand Down
15 changes: 13 additions & 2 deletions mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,22 @@ def check_slashed(local, ton):
config32 = ton.GetConfig32()
save_complaints = ton.GetSaveComplaints()
complaints = save_complaints.get(str(config32['startWorkTime']))
from modules.validator import ValidatorModule
module = ValidatorModule(ton, local)
vl = ton.GetValidatorsList(past=True)
me = module.find_myself(vl)
if not me: # we were not a validator in the previous round
return
if not complaints:
return
for c in complaints.values():
if c["adnl"] == ton.GetAdnlAddr() and c["isPassed"]:
print_warning(local, "slashed_warning")
if c["adnl"] == me["adnlAddr"] and c["isPassed"]:
if me.get("stake"):
fine = f"""{round(c['suggestedFine'] + me["stake"] * (c['suggestedFinePart'] / (1<<32)))} TON"""
else: # unknown stake amount so just print percents
fine = f"""{round(c['suggestedFine'])} TON + {(c['suggestedFinePart'] / (1<<32)) * 100} % of stake"""
warning = local.translate("slashed_warning").format(fine)
print_warning(local, warning)
#end define

def check_adnl(local, ton):
Expand Down
6 changes: 3 additions & 3 deletions mytonctrl/resources/translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@
"zh_TW": "{red}錯誤 - 驗證器的 UDP 端口無法從外部訪問.{endc}"
},
"slashed_warning": {
"en": "{red}You were fined by 101 TON for low efficiency in the previous round.{endc}",
"ru": "{red}Вы были оштрафованы на 101 TON за низкую эффективность в предыдущем раунде.{endc}",
"zh_TW": "{red}您因上一輪效率低而被罰款 101 TON。{endc}"
"en": "{red}You were fined by {0} for low efficiency in the previous round.{endc}",
"ru": "{red}Вы были оштрафованы на {0} за низкую эффективность в предыдущем раунде.{endc}",
"zh_TW": "{red}您因上一輪效率低而被罰款 {0}。{endc}"
},
"add_custom_overlay_cmd": {
"en": "Add custom overlay",
Expand Down