-
Notifications
You must be signed in to change notification settings - Fork 2
/
sktest_snapshot.py
70 lines (54 loc) · 1.56 KB
/
sktest_snapshot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
import sys
import time
from sktest import LocalStarter, Node, SChain
if os.geteuid() != 0:
print("Please run with sudo")
exit(1)
global sktest_exe
sktest_exe = os.getenv("SKTEST_EXE",
"/home/dimalit/skaled/build-no-mp/skaled/skaled")
emptyBlockIntervalMs = 1
snapshotIntervalSec = 10
n1 = Node(emptyBlockIntervalMs=emptyBlockIntervalMs,
snapshotInterval=snapshotIntervalSec)
n2 = Node(emptyBlockIntervalMs=emptyBlockIntervalMs,
snapshotInterval=snapshotIntervalSec)
n3 = Node(emptyBlockIntervalMs=emptyBlockIntervalMs,
snapshotInterval=snapshotIntervalSec)
n4 = Node(emptyBlockIntervalMs=emptyBlockIntervalMs,
snapshotInterval=snapshotIntervalSec,
snapshottedStartSeconds=60) # 90 # 18
starter = LocalStarter(sktest_exe)
ch = SChain(
[n1, n2, n3, n4],
starter,
prefill=[1000000000000000000, 2000000000000000000],
emptyBlockIntervalMs=emptyBlockIntervalMs,
snapshotIntervalSec=snapshotIntervalSec,
bls=True
)
ch.start(start_timeout=0) # 300
print("Waiting for full catch-up")
res = 1
# while True:
for _ in range(50):
bn1 = n1.eth.blockNumber
bn2 = n2.eth.blockNumber
bn3 = n3.eth.blockNumber
try:
bn4 = n4.eth.blockNumber
except Exception:
bn4 = None
print(f"blockNumber's: {bn1} {bn2} {bn3} {bn4}")
if bn1 == bn2 and bn2 == bn3 and bn3 == bn4:
res = 0
break
try:
ch.transaction_async()
except:
pass # already exists
time.sleep(0.6)
print("Exiting")
ch.stop()
sys.exit(res)