From 960666d1ed936aadb3982eb06fb58be8389e8d23 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 21 Jan 2021 19:39:04 +0200 Subject: [PATCH] Remove std/random again --- beacon_chain/nimbus_beacon_node.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 5490f28592..f0c693bed4 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -8,7 +8,6 @@ import # Standard library std/[math, os, strformat, strutils, tables, times, - random, # TODO: review usage of Nim RNG terminal, osproc], system/ansi_c, @@ -656,12 +655,11 @@ proc setupSelfSlashingProtection(node: BeaconNode, slot: Slot) = # 2 epochs is dangerous because it'll guarantee colliding probes in the # overlapping case. - # TODO: is a pseudo-random RNG enough here? - # If so, should we store the state explicitly? + let rng = node.network.rng # So dPE == 2 -> epoch + 1, always; dPE == 3 -> epoch + (1 or 2), etc. node.processor.gossipSlashingProtection.probeEpoch = - slot.epoch + 1 + rand(duplicateValidatorEpochs.int - 2).uint64 + slot.epoch + 1 + rng[].rand(duplicateValidatorEpochs.int - 2).uint64 doAssert node.processor.gossipSlashingProtection.probeEpoch < node.processor.gossipSlashingProtection.broadcastStartEpoch