From 67d962083e8993d6ec097a0677fa010cee220e9b Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:12:24 +0400 Subject: [PATCH 1/3] Revert "update complaints validation and warnings" --- modules/validator.py | 4 ++-- mytoncore/mytoncore.py | 15 ++++----------- mytonctrl/mytonctrl.py | 15 ++------------- mytonctrl/resources/translate.json | 6 +++--- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/modules/validator.py b/modules/validator.py index 3ce5cd6f..8efbc904 100644 --- a/modules/validator.py +++ b/modules/validator.py @@ -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(f"Validator index is greater than {config32['mainValidators']} in the previous round - no efficiency data.") + print("Validator index is greater than 100 in the previous round - no efficiency data.") elif validator.get('efficiency') is None: print('Failed to get efficiency for the previous round') else: @@ -75,7 +75,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(f"Validator index is greater than {config34['mainValidators']} in the current round - no efficiency data.") + print("Validator index is greater than 100 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.") diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index 87ab360f..3f3db256 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 1bc78e4d..1020c5c9 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -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): diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index 19dfbeec..632158b4 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -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", From 306f7b3ddb9bfa998d0abbf4fb3260eea2e7ec8f Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:13:39 +0400 Subject: [PATCH 2/3] fix fine warning for testnet --- modules/validator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/validator.py b/modules/validator.py index 8efbc904..3f4e56d5 100644 --- a/modules/validator.py +++ b/modules/validator.py @@ -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: @@ -75,7 +75,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 previous 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.") From 4a45167d35bae7f98ffae823e7a22ce727779091 Mon Sep 17 00:00:00 2001 From: Maksim Kurbatov <94808996+yungwine@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:14:39 +0400 Subject: [PATCH 3/3] fix typo --- modules/validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/validator.py b/modules/validator.py index 3f4e56d5..3ce5cd6f 100644 --- a/modules/validator.py +++ b/modules/validator.py @@ -75,7 +75,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(f"Validator index is greater than {config34['mainValidators']} in the previous 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.")