Skip to content

Commit e3841bd

Browse files
committed
use checkloadall-v2 for complaints generation and validation
1 parent fea34bc commit e3841bd

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

mytoncore/functions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ def Complaints(local, ton):
496496
config32 = ton.GetConfig32()
497497
election_id = config32.get("startWorkTime")
498498
complaints = ton.GetComplaints(election_id) # get complaints from Elector
499+
if not complaints:
500+
return
499501
valid_complaints = ton.get_valid_complaints(complaints, election_id)
500502
for c in valid_complaints.values():
501503
complaint_hash = c.get("hash")
@@ -653,9 +655,9 @@ def General(local):
653655
local.start_cycle(Offers, sec=600, args=(local, ton, ))
654656
local.start_cycle(save_past_events, sec=300, args=(local, ton, ))
655657

656-
t = 600
658+
t = 1800
657659
if ton.GetNetworkName() != 'mainnet':
658-
t = 60
660+
t = 300
659661
local.start_cycle(Complaints, sec=t, args=(local, ton, ))
660662
local.start_cycle(Slashing, sec=t, args=(local, ton, ))
661663

mytoncore/mytoncore.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,7 @@ def get_valid_complaints(self, complaints: dict, election_id: int):
22782278
start = config32.get("startWorkTime")
22792279
assert start == election_id, 'provided election_id != election_id from config32'
22802280
end = config32.get("endWorkTime")
2281-
validators_load = self.GetValidatorsLoad(start, end - 60, saveCompFiles=True)
2281+
validators_load = self.GetValidatorsLoad(start, end - 60, save_comp_files=True, v2=True)
22822282
voted_complaints = self.GetVotedComplaints(complaints)
22832283
voted_complaints_pseudohashes = [complaint['pseudohash'] for complaint in voted_complaints.values()]
22842284
result = {}
@@ -2341,21 +2341,24 @@ def GetOnlineValidators(self):
23412341
return onlineValidators
23422342
#end define
23432343

2344-
def GetValidatorsLoad(self, start, end, saveCompFiles=False) -> dict:
2345-
# Get buffer
2346-
bname = f"validatorsLoad{start}{end}{saveCompFiles}"
2347-
buff = self.GetFunctionBuffer(bname, timeout=60)
2344+
def GetValidatorsLoad(self, start: int, end: int, save_comp_files: bool = False, v2: bool = False) -> dict:
2345+
bname = f"validatorsLoad{start}{end}{save_comp_files}{v2}"
2346+
timeout = 60
2347+
cmd_suf = ""
2348+
if v2:
2349+
cmd_suf = "-v2"
2350+
timeout = 3600
2351+
buff = self.GetFunctionBuffer(bname, timeout=timeout)
23482352
if buff:
23492353
return buff
2350-
#end if
23512354
text = "start GetValidatorsLoad function ({}, {})".format(start, end)
23522355
self.local.add_log(text, "debug")
2353-
if saveCompFiles is True:
2356+
if save_comp_files:
23542357
filePrefix = self.tempDir + f"checkload_{start}_{end}"
23552358
else:
23562359
filePrefix = ""
2357-
cmd = f"checkloadall {start} {end} {filePrefix}"
2358-
result = self.liteClient.Run(cmd, timeout=30)
2360+
cmd = f"checkloadall{cmd_suf} {start} {end} {filePrefix}"
2361+
result = self.liteClient.Run(cmd, timeout=180 if v2 else 30)
23592362
lines = result.split('\n')
23602363
data = dict()
23612364
for line in lines:
@@ -2488,14 +2491,14 @@ def GetValidatorsList(self, past=False, fast=False, start=None, end=None):
24882491
return validators
24892492
#end define
24902493

2491-
def CheckValidators(self, start, end):
2494+
def CheckValidators(self, start: int, end: int):
24922495
self.local.add_log("start CheckValidators function", "debug")
24932496
electionId = start
24942497
complaints = self.GetComplaints(electionId)
24952498
valid_complaints = self.get_valid_complaints(complaints, electionId)
24962499
voted_complaints = self.GetVotedComplaints(complaints)
24972500
voted_complaints_pseudohashes = [complaint['pseudohash'] for complaint in voted_complaints.values()]
2498-
data = self.GetValidatorsLoad(start, end, saveCompFiles=True)
2501+
data = self.GetValidatorsLoad(start, end, save_comp_files=True, v2=True)
24992502
fullElectorAddr = self.GetFullElectorAddr()
25002503
wallet = self.GetValidatorWallet(mode="vote")
25012504
config = self.GetConfig32()
@@ -3826,7 +3829,7 @@ def get_node_ip(self):
38263829
def get_validator_engine_ip(self):
38273830
return self.validatorConsole.addr.split(':')[0]
38283831

3829-
def GetFunctionBuffer(self, name, timeout=10):
3832+
def GetFunctionBuffer(self, name: str, timeout: int | float = 10):
38303833
timestamp = get_timestamp()
38313834
buff = self.local.buffer.get(name)
38323835
if buff is None:

0 commit comments

Comments
 (0)