Skip to content

Commit

Permalink
feat: random interval while mining
Browse files Browse the repository at this point in the history
using a random interval we can simulate a cycling attack using mitigations currently implemented
  • Loading branch information
a-mpch committed Dec 10, 2024
1 parent d6e123d commit b56f961
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion resources/scenarios/miner_std.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

from random import randint
from time import sleep

from commander import Commander
Expand Down Expand Up @@ -35,6 +36,12 @@ def add_options(self, parser):
type=int,
help="Number of seconds between block generation (default 60 seconds)",
)
parser.add_argument(
"--random-interval",
dest="random_interval",
action="store_true",
help="Should the interval be randomized between 0 and the interval value",
)
parser.add_argument(
"--mature",
dest="mature",
Expand Down Expand Up @@ -71,7 +78,10 @@ def run_test(self):
)
except Exception as e:
self.log.error(f"node {miner.node.index} error: {e}")
sleep(self.options.interval)
if self.options.random_interval:
sleep(randint(0, self.options.interval))
else:
sleep(self.options.interval)


def main():
Expand Down

0 comments on commit b56f961

Please sign in to comment.