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
15 changes: 4 additions & 11 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,6 @@ 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 @@ -2320,14 +2319,14 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
pseudohash = pubkey + str(election_id)
if pseudohash == complaint['pseudohash']:
exists = True
vload = item
vid = item['id']
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 vload["id"] >= config32['mainValidators']:
if vid >= config32['mainValidators']:
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator", "info")
continue

Expand All @@ -2336,13 +2335,8 @@ 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
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
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 @@ -2492,7 +2486,6 @@ 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: 2 additions & 13 deletions mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,22 +483,11 @@ 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"] == 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)
if c["adnl"] == ton.GetAdnlAddr() and c["isPassed"]:
print_warning(local, "slashed_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 {0} for low efficiency in the previous round.{endc}",
"ru": "{red}Вы были оштрафованы на {0} за низкую эффективность в предыдущем раунде.{endc}",
"zh_TW": "{red}您因上一輪效率低而被罰款 {0}。{endc}"
"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}"
},
"add_custom_overlay_cmd": {
"en": "Add custom overlay",
Expand Down