Skip to content

Commit b56f961

Browse files
committed
feat: random interval while mining
using a random interval we can simulate a cycling attack using mitigations currently implemented
1 parent d6e123d commit b56f961

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

resources/scenarios/miner_std.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
from random import randint
34
from time import sleep
45

56
from commander import Commander
@@ -35,6 +36,12 @@ def add_options(self, parser):
3536
type=int,
3637
help="Number of seconds between block generation (default 60 seconds)",
3738
)
39+
parser.add_argument(
40+
"--random-interval",
41+
dest="random_interval",
42+
action="store_true",
43+
help="Should the interval be randomized between 0 and the interval value",
44+
)
3845
parser.add_argument(
3946
"--mature",
4047
dest="mature",
@@ -71,7 +78,10 @@ def run_test(self):
7178
)
7279
except Exception as e:
7380
self.log.error(f"node {miner.node.index} error: {e}")
74-
sleep(self.options.interval)
81+
if self.options.random_interval:
82+
sleep(randint(0, self.options.interval))
83+
else:
84+
sleep(self.options.interval)
7585

7686

7787
def main():

0 commit comments

Comments
 (0)