Skip to content

Commit 6fafd47

Browse files
authored
Merge pull request #378 from yungwine/shard-complaints
fine non-master vals that created zero blocks
2 parents d8d165d + fdde23b commit 6fafd47

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mytoncore/mytoncore.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ def CreateWallet(self, name, workchain=0, version="v1", **kwargs):
16241624
if os.path.isfile(wallet_path + ".pk") and "v3" not in version:
16251625
self.local.add_log("CreateWallet error: Wallet already exists: " + name, "warning")
16261626
else:
1627-
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
1627+
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
16281628
wallet_path=wallet_path, subwallet=subwallet)
16291629
result = self.fift.Run(fift_args)
16301630
if "Creating new" not in result:
@@ -1681,7 +1681,7 @@ def import_wallet_with_version(self, key, version, **kwargs):
16811681
wallet_path = self.walletsDir + wallet_name
16821682
with open(wallet_path + ".pk", 'wb') as file:
16831683
file.write(pk_bytes)
1684-
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
1684+
fift_args = self.get_new_wallet_fift_args(version, workchain=workchain,
16851685
wallet_path=wallet_path, subwallet=subwallet)
16861686
result = self.fift.Run(fift_args)
16871687
if "Creating new" not in result:
@@ -2310,6 +2310,7 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
23102310
continue
23112311

23122312
exists = False
2313+
vload = None
23132314
for item in validators_load.values():
23142315
if 'fileName' not in item:
23152316
continue
@@ -2319,15 +2320,16 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
23192320
pseudohash = pubkey + str(election_id)
23202321
if pseudohash == complaint['pseudohash']:
23212322
exists = True
2322-
vid = item['id']
2323+
vload = item
23232324
break
23242325

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

2329-
if vid >= config32['mainValidators']:
2330-
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator", "info")
2330+
if (vload["id"] >= config32['mainValidators'] and
2331+
vload["masterBlocksCreated"] + vload["workBlocksCreated"] > 0):
2332+
self.local.add_log(f"complaint {complaint['hash_hex']} declined: complaint created for non masterchain validator that created more than zero blocks", "info")
23312333
continue
23322334

23332335
# check complaint fine value
@@ -2524,7 +2526,7 @@ def CheckValidators(self, start, end):
25242526
pseudohash = pubkey + str(electionId)
25252527
if pseudohash in valid_complaints or pseudohash in voted_complaints_pseudohashes: # do not create complaints that already created or voted by ourself
25262528
continue
2527-
if item['id'] >= config['mainValidators']: # do not create complaints for non-masterchain validators
2529+
if item['id'] >= config['mainValidators'] and item["masterBlocksCreated"] + item["workBlocksCreated"] > 0: # create complaints for non-masterchain validators only if they created 0 blocks
25282530
continue
25292531
# Create complaint
25302532
fileName = self.remove_proofs_from_complaint(fileName)

0 commit comments

Comments
 (0)