Skip to content

Commit 2897f5b

Browse files
authored
Merge pull request #171 from ton-blockchain/mytonctrl2_dev
merge mytonctrl2_dev to mytonctrl2
2 parents 42ad887 + 94569e7 commit 2897f5b

File tree

6 files changed

+237
-60
lines changed

6 files changed

+237
-60
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/fift -s
2+
"TonUtil.fif" include
3+
4+
{ ."usage: " @' $0 type ." <complaint-boc> <savefile>" cr
5+
."Removes proof cells from complaint." cr cr
6+
7+
."<complaint-boc> is a filename of the serialized TL-B ValidatorComplaint boc." cr
8+
."Saves the result boc into `<savefile>`." cr 1 halt
9+
} : usage
10+
$# 2 = { cr } { usage } cond
11+
12+
$1 =: filename
13+
$2 =: savefile
14+
15+
filename file>B dup
16+
8 B| drop B>$ "b5ee9c72" $= { B>$ x>B? drop } if
17+
B>boc =: complaint
18+
19+
."got: " cr
20+
complaint <s csr. cr
21+
22+
23+
// replaces 2 refs with empty cells
24+
// c - c
25+
{
26+
<b // s, c, b
27+
swap // s, b, c
28+
<s // s, b, s
29+
ref@+ drop
30+
ref@+ drop
31+
s, // s, b
32+
<b b> ref,
33+
<b b> ref,
34+
b> // s, c
35+
} : clear_producer_info
36+
37+
{ // c
38+
<s // s
39+
ref@+ // s, c
40+
41+
clear_producer_info // s, c
42+
43+
<b // s, c, b
44+
swap ref, // s, b
45+
swap s, // b
46+
b> // c
47+
} : clean_descr
48+
49+
{ // c
50+
<s // s
51+
52+
ref@+ clear_producer_info // s, c1
53+
swap // c1, s
54+
ref@+ clear_producer_info // c1, s, c2
55+
56+
<b // c1, s, c2, b
57+
3 roll ref, // s, c2, b
58+
swap ref, // s, b
59+
swap s, // b
60+
b> // c
61+
} : clean_descr_with_diff
62+
63+
64+
// prod_info#34 utime:uint32 mc_blk_ref:ExtBlkRef state_proof:^(MERKLE_PROOF Block)
65+
// prod_proof:^(MERKLE_PROOF ShardState) = ProducerInfo;
66+
//
67+
// no_blk_gen#450e8bd9 from_utime:uint32 prod_info:^ProducerInfo = ComplaintDescr;
68+
// no_blk_gen_diff#c737b0ca prod_info_old:^ProducerInfo prod_info_new:^ProducerInfo = ComplaintDescr;
69+
//
70+
// validator_complaint#bc validator_pubkey:bits256 description:^ComplaintDescr created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams suggested_fine_part:uint32 = ValidatorComplaint;
71+
72+
complaint <s
73+
ref@+ =: descr
74+
=: comlaint_no_ref
75+
76+
<b comlaint_no_ref s,
77+
descr dup <s
78+
32 u@ 0x450e8bd9 =
79+
{ clean_descr }
80+
{ clean_descr_with_diff }
81+
cond
82+
ref,
83+
b> =: result_cell
84+
85+
"result: " type cr
86+
result_cell <s csr.
87+
88+
result_cell 2 boc+>B
89+
savefile tuck B>file
90+
."(Saved to file " type .")" cr

mytoncore/functions.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,11 @@ def Complaints(local, ton):
504504
# Voting for complaints
505505
config32 = ton.GetConfig32()
506506
electionId = config32.get("startWorkTime")
507-
complaintsHashes = ton.SaveComplaints(electionId)
508-
complaints = ton.GetComplaints(electionId)
509-
for key, item in complaints.items():
510-
complaintHash = item.get("hash")
511-
complaintHash_hex = Dec2HexAddr(complaintHash)
512-
if complaintHash_hex in complaintsHashes:
513-
ton.VoteComplaint(electionId, complaintHash)
507+
complaints = ton.GetComplaints(electionId) # get complaints from Elector
508+
for c in complaints.values():
509+
complaint_hash = c.get("hash")
510+
if ton.complaint_is_valid(c):
511+
ton.VoteComplaint(electionId, complaint_hash)
514512
# end define
515513

516514

@@ -525,6 +523,10 @@ def Slashing(local, ton):
525523
config32 = ton.GetConfig32()
526524
start = config32.get("startWorkTime")
527525
end = config32.get("endWorkTime")
526+
config15 = ton.GetConfig15()
527+
ts = get_timestamp()
528+
if not(end < ts < end + config15['stakeHeldFor']): # check that currently is freeze time
529+
return
528530
local.add_log("slash_time {}, start {}, end {}".format(slash_time, start, end), "debug")
529531
if slash_time != start:
530532
end -= 60
@@ -560,15 +562,20 @@ def ScanLiteServers(local, ton):
560562
def General(local):
561563
local.add_log("start General function", "debug")
562564
ton = MyTonCore(local)
563-
scanner = Dict()
565+
# scanner = Dict()
564566
# scanner.Run()
565567

566-
# Запустить потоки
568+
# Start threads
567569
local.start_cycle(Elections, sec=600, args=(local, ton, ))
568570
local.start_cycle(Statistics, sec=10, args=(local, ))
569571
local.start_cycle(Offers, sec=600, args=(local, ton, ))
570-
local.start_cycle(Complaints, sec=600, args=(local, ton, ))
571-
local.start_cycle(Slashing, sec=600, args=(local, ton, ))
572+
573+
t = 600
574+
if ton.GetNetworkName() != 'mainnet':
575+
t = 60
576+
local.start_cycle(Complaints, sec=t, args=(local, ton, ))
577+
local.start_cycle(Slashing, sec=t, args=(local, ton, ))
578+
572579
local.start_cycle(Domains, sec=600, args=(local, ton, ))
573580
local.start_cycle(Telemetry, sec=60, args=(local, ton, ))
574581
local.start_cycle(OverlayTelemetry, sec=7200, args=(local, ton, ))

0 commit comments

Comments
 (0)