diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 8b3dce353c..32ac96087c 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -874,6 +874,11 @@ type defaultValue: false name: "with-deposit-snapshot" .}: bool + largeRequestsTimeout* {. + desc: "Timeout for large requests (in seconds)" + defaultValue: 120 + name: "large-requests-timeout" .}: int + ValidatorClientConf* = object configFile* {. desc: "Loads the configuration from a TOML file" diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index e99b93358f..d7031839b7 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -112,6 +112,7 @@ proc doRunTrustedNodeSync( backfill: bool, reindex: bool, downloadDepositSnapshot: bool, + largeRequestsTimeout: int, genesisState: ref ForkedHashedBeaconState) {.async.} = let syncTarget = if stateId.isSome: @@ -139,6 +140,7 @@ proc doRunTrustedNodeSync( backfill, reindex, downloadDepositSnapshot, + largeRequestsTimeout, genesisState) func getVanityLogs(stdoutKind: StdoutLogKind): VanityLogs = @@ -791,6 +793,7 @@ proc init*(T: type BeaconNode, backfill = false, reindex = false, downloadDepositSnapshot = false, + config.largeRequestsTimeout, genesisState) if config.finalizedCheckpointBlock.isSome: @@ -2560,6 +2563,7 @@ proc handleStartUpCmd(config: var BeaconNodeConf) {.raises: [CatchableError].} = config.backfillBlocks, config.reindex, config.downloadDepositSnapshot, + config.largeRequestsTimeout, genesisState) db.close() diff --git a/beacon_chain/trusted_node_sync.nim b/beacon_chain/trusted_node_sync.nim index d6c03da9ef..d4c64e94e7 100644 --- a/beacon_chain/trusted_node_sync.nim +++ b/beacon_chain/trusted_node_sync.nim @@ -21,8 +21,8 @@ import from presto import RestDecodingError const - largeRequestsTimeout = 120.seconds # Downloading large items such as states. smallRequestsTimeout = 30.seconds # Downloading smaller items such as blocks and deposit snapshots. +# largeRequestsTimeout # Downloading large items such as states. The value is set via the --large-requests-timeout parameter. proc fetchDepositSnapshot( client: RestClientRef @@ -78,13 +78,14 @@ proc doTrustedNodeSync*( backfill: bool, reindex: bool, downloadDepositSnapshot: bool, + largeRequestsTimeout: int, genesisState: ref ForkedHashedBeaconState = nil) {.async.} = logScope: restUrl syncTarget notice "Starting trusted node sync", - databaseDir, backfill, reindex + databaseDir, backfill, reindex, largeRequestsTimeout var client = createNewRestClient(restUrl).valueOr: @@ -145,7 +146,7 @@ proc doTrustedNodeSync*( try: awaitWithTimeout( client.getStateV2(StateIdent.init(StateIdentType.Genesis), cfg), - largeRequestsTimeout): + largeRequestsTimeout.seconds): info "Attempt to download genesis state timed out" # https://github.com/nim-lang/Nim/issues/22180 (ref ForkedHashedBeaconState)(nil) @@ -336,7 +337,7 @@ proc doTrustedNodeSync*( StateIdent.init(tmp.slot.epoch().start_slot) else: tmp - awaitWithTimeout(client.getStateV2(id, cfg), largeRequestsTimeout): + awaitWithTimeout(client.getStateV2(id, cfg), largeRequestsTimeout.seconds): error "Attempt to download checkpoint state timed out" quit 1 except CatchableError as exc: