--stop-at-synced-epoch (#3464)

* --stop-at-synced-epoch

This allows benchmarking the initial sync (only forward sync, 1s error
margin). Might be useful in CI, with a timeout, as a sanity check.
This commit is contained in:
Ștefan Talpalaru 2022-03-04 18:38:01 +01:00 committed by GitHub
parent a84ab5d47f
commit e4b7dbf330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -261,10 +261,17 @@ type
name: "verify-finalization" }: bool
stopAtEpoch* {.
desc: "A positive epoch selects the epoch at which to stop"
hidden
desc: "The wall-time epoch at which to exit the program. (for testing purposes)"
defaultValue: 0
name: "stop-at-epoch" }: uint64
stopAtSyncedEpoch* {.
hidden
desc: "The synced epoch at which to exit the program. (for testing purposes)"
defaultValue: 0
name: "stop-at-synced-epoch" }: uint64
metricsEnabled* {.
desc: "Enable the metrics server"
defaultValue: false

View File

@ -1118,6 +1118,10 @@ proc onSecond(node: BeaconNode) =
# Nim GC metrics (for the main thread)
updateThreadMetrics()
if node.config.stopAtSyncedEpoch != 0 and node.dag.head.slot.epoch >= node.config.stopAtSyncedEpoch:
notice "Shutting down after having reached the target synced epoch"
bnStatus = BeaconNodeStatus.Stopping
proc runOnSecondLoop(node: BeaconNode) {.async.} =
let sleepTime = chronos.seconds(1)
const nanosecondsIn1s = float(chronos.seconds(1).nanoseconds)