mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-19 02:52:58 +00:00
Do not cache resolved hostnames in REST client. (#6570)
This commit is contained in:
parent
77e835153c
commit
841904bd53
@ -151,8 +151,11 @@ proc getPayloadBuilderClient*(
|
||||
|
||||
if payloadBuilderAddress.isNone:
|
||||
return err "Payload builder disabled"
|
||||
let res = RestClientRef.new(payloadBuilderAddress.get)
|
||||
if res.isOk and res.get.isNil:
|
||||
err "Got nil payload builder REST client reference"
|
||||
else:
|
||||
res
|
||||
|
||||
let
|
||||
flags = {RestClientFlag.CommaSeparatedArray,
|
||||
RestClientFlag.ResolveAlways}
|
||||
socketFlags = {SocketFlags.TcpNoDelay}
|
||||
|
||||
RestClientRef.new(payloadBuilderAddress.get, flags = flags,
|
||||
socketFlags = socketFlags)
|
||||
|
@ -149,7 +149,15 @@ func getIdent*(storage: ValidatorStorage): ValidatorIdent =
|
||||
|
||||
proc restValidatorExit(config: BeaconNodeConf) {.async.} =
|
||||
let
|
||||
client = RestClientRef.new(config.restUrlForExit).valueOr:
|
||||
client =
|
||||
block:
|
||||
let
|
||||
flags = {RestClientFlag.CommaSeparatedArray,
|
||||
RestClientFlag.ResolveAlways}
|
||||
socketFlags = {SocketFlags.TcpNoDelay}
|
||||
|
||||
RestClientRef.new(config.restUrlForExit, flags = flags,
|
||||
socketFlags = socketFlags).valueOr:
|
||||
raise (ref RestError)(msg: $error)
|
||||
|
||||
stateIdHead = StateIdent(kind: StateQueryKind.Named,
|
||||
|
@ -61,6 +61,13 @@ func shortLog*(v: TrustedNodeSyncTarget): auto =
|
||||
|
||||
chronicles.formatIt(TrustedNodeSyncTarget): shortLog(it)
|
||||
|
||||
proc createNewRestClient(url: string): Result[RestClientRef, cstring] =
|
||||
let
|
||||
flags = {RestClientFlag.CommaSeparatedArray,
|
||||
RestClientFlag.ResolveAlways}
|
||||
socketFlags = {SocketFlags.TcpNoDelay}
|
||||
RestClientRef.new(url, flags = flags, socketFlags = socketFlags)
|
||||
|
||||
proc doTrustedNodeSync*(
|
||||
db: BeaconChainDB,
|
||||
cfg: RuntimeConfig,
|
||||
@ -80,8 +87,8 @@ proc doTrustedNodeSync*(
|
||||
databaseDir, backfill, reindex
|
||||
|
||||
var
|
||||
client = RestClientRef.new(restUrl).valueOr:
|
||||
error "Cannot connect to server", error = error
|
||||
client = createNewRestClient(restUrl).valueOr:
|
||||
error "Cannot connect to server", reason = error
|
||||
quit 1
|
||||
|
||||
# If possible, we'll store the genesis state in the database - this is not
|
||||
@ -440,8 +447,8 @@ proc doTrustedNodeSync*(
|
||||
lastError = exc
|
||||
|
||||
warn "Retrying download of block", slot, err = exc.msg
|
||||
client = RestClientRef.new(restUrl).valueOr:
|
||||
error "Cannot connect to server", url = restUrl, error = error
|
||||
client = createNewRestClient(restUrl).valueOr:
|
||||
error "Cannot connect to server", url = restUrl, reason = error
|
||||
quit 1
|
||||
|
||||
raise lastError
|
||||
|
@ -1718,10 +1718,15 @@ proc registerValidatorsPerBuilder(
|
||||
BUILDER_VALIDATOR_REGISTRATION_DELAY_TOLERANCE = 6.seconds
|
||||
|
||||
let payloadBuilderClient =
|
||||
RestClientRef.new(payloadBuilderAddress).valueOr:
|
||||
block:
|
||||
let
|
||||
flags = {RestClientFlag.CommaSeparatedArray,
|
||||
RestClientFlag.ResolveAlways}
|
||||
socketFlags = {SocketFlags.TcpNoDelay}
|
||||
RestClientRef.new(payloadBuilderAddress, flags = flags,
|
||||
socketFlags = socketFlags).valueOr:
|
||||
debug "Unable to initialize payload builder client while registering validators",
|
||||
payloadBuilderAddress, epoch,
|
||||
err = error
|
||||
payloadBuilderAddress, epoch, reason = error
|
||||
return
|
||||
|
||||
if payloadBuilderClient.isNil:
|
||||
|
@ -183,7 +183,8 @@ proc addRemoteValidator(pool: var ValidatorPool,
|
||||
{HttpClientFlag.NoVerifyHost, HttpClientFlag.NoVerifyServerName}
|
||||
else:
|
||||
{}
|
||||
prestoFlags = {RestClientFlag.CommaSeparatedArray}
|
||||
prestoFlags = {RestClientFlag.CommaSeparatedArray,
|
||||
RestClientFlag.ResolveAlways}
|
||||
socketFlags = {SocketFlags.TcpNoDelay}
|
||||
clients =
|
||||
block:
|
||||
|
Loading…
x
Reference in New Issue
Block a user