mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 06:46:10 +00:00
fix XDeclaredButNotUsed warnings (#5648)
This commit is contained in:
parent
4a56faa579
commit
c36d2aa103
@ -214,7 +214,6 @@ proc processObject(
|
||||
obj: SomeForkedLightClientObject,
|
||||
wallTime: BeaconTime): Result[void, VerifierError] =
|
||||
let
|
||||
wallSlot = wallTime.slotOrZero()
|
||||
res = withForkyObject(obj):
|
||||
when lcDataFork > LightClientDataFork.None:
|
||||
when forkyObject is ForkyLightClientBootstrap:
|
||||
@ -242,7 +241,9 @@ proc processObject(
|
||||
self.store[].migrateToDataFork(lcDataFork)
|
||||
withForkyStore(self.store[]):
|
||||
when lcDataFork > LightClientDataFork.None:
|
||||
let upgradedObject = obj.migratingToDataFork(lcDataFork)
|
||||
let
|
||||
wallSlot = wallTime.slotOrZero()
|
||||
upgradedObject = obj.migratingToDataFork(lcDataFork)
|
||||
process_light_client_update(
|
||||
forkyStore, upgradedObject.forky(lcDataFork), wallSlot,
|
||||
self.cfg, self.genesis_validators_root)
|
||||
|
@ -427,7 +427,7 @@ template runWithSignals(sn: SigningNodeRef, body: untyped): bool =
|
||||
discard await race(future, sn.sigintHandleFut, sn.sigtermHandleFut)
|
||||
if future.finished():
|
||||
if future.failed() or future.cancelled():
|
||||
let exc = future.readError()
|
||||
discard future.readError()
|
||||
debug "Signing node initialization failed"
|
||||
var pending: seq[Future[void]]
|
||||
if not(sn.sigintHandleFut.finished()):
|
||||
|
@ -289,7 +289,6 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
node.withStateForBlockSlotId(bslot):
|
||||
let
|
||||
stateEpoch = getStateField(state, slot).epoch()
|
||||
validatorsCount = lenu64(getStateField(state, validators))
|
||||
indices = node.getIndices(validatorIds, state).valueOr:
|
||||
return RestApiResponse.jsonError(error)
|
||||
response =
|
||||
|
@ -14,7 +14,6 @@ import "."/[common, fallback_service, scoring]
|
||||
export eth2_rest_serialization, common
|
||||
|
||||
const
|
||||
ResponseSuccess = "Received successful response"
|
||||
ResponseInvalidError = "Received invalid request response"
|
||||
ResponseInternalError = "Received internal error response"
|
||||
ResponseUnexpectedError = "Received unexpected error response"
|
||||
|
@ -243,8 +243,8 @@ proc publishBlock(vc: ValidatorClientRef, currentSlot, slot: Slot,
|
||||
if not(normalBlockFut.finished()):
|
||||
await normalBlockFut.cancelAndWait()
|
||||
raise exc
|
||||
except CatchableError as exc:
|
||||
# This should not be happened, because all the exceptions handled.
|
||||
except CatchableError:
|
||||
# This should not happen, because all the exceptions are handled.
|
||||
Opt.none(PreparedBlindedBeaconBlock)
|
||||
|
||||
let normalBlock =
|
||||
@ -253,8 +253,8 @@ proc publishBlock(vc: ValidatorClientRef, currentSlot, slot: Slot,
|
||||
await normalBlockFut
|
||||
except CancelledError as exc:
|
||||
raise exc
|
||||
except CatchableError as exc:
|
||||
# This should not be happened, because all the exceptions handled.
|
||||
except CatchableError:
|
||||
# This should not happen, because all the exceptions are handled.
|
||||
Opt.none(PreparedBeaconBlock)
|
||||
else:
|
||||
if not(normalBlockFut.finished()):
|
||||
@ -449,7 +449,7 @@ proc proposeBlock(vc: ValidatorClientRef, slot: Slot,
|
||||
debug "Block proposing process was interrupted",
|
||||
slot = slot, validator = shortLog(proposerKey)
|
||||
raise exc
|
||||
except CatchableError as exc:
|
||||
except CatchableError:
|
||||
error "Unexpected error encountered while proposing block",
|
||||
slot = slot, validator = shortLog(validator)
|
||||
|
||||
@ -814,7 +814,7 @@ proc mainLoop(service: BlockServiceRef) {.async.} =
|
||||
# Future is not going to be completed, so the only way to exit, is to
|
||||
# cancel it.
|
||||
await future
|
||||
except CancelledError as exc:
|
||||
except CancelledError:
|
||||
debug "Service interrupted"
|
||||
except CatchableError as exc:
|
||||
error "Service crashed with unexpected error", err_name = exc.name,
|
||||
|
@ -406,7 +406,6 @@ func getFailureReason*(failure: ApiNodeFailure): string =
|
||||
[failure.reason, status, request, $failure.failure].join(";")
|
||||
|
||||
proc getFailureReason*(exc: ref ValidatorApiError): string =
|
||||
var counts: array[int(high(ApiFailure)) + 1, int]
|
||||
let
|
||||
errors = exc[].data
|
||||
errorsCount = len(errors)
|
||||
@ -825,7 +824,6 @@ proc getDurationToNextAttestation*(vc: ValidatorClientRef,
|
||||
for key, item in vc.attesters:
|
||||
let duty = item.duties.getOrDefault(epoch, DefaultDutyAndProof)
|
||||
if not(duty.isDefault()):
|
||||
let dutySlotTime = duty.data.slot
|
||||
if (duty.data.slot < minSlot) and (duty.data.slot >= slot):
|
||||
minSlot = duty.data.slot
|
||||
if minSlot != FAR_FUTURE_SLOT:
|
||||
|
@ -484,7 +484,7 @@ proc mainLoop(service: FallbackServiceRef) {.async.} =
|
||||
if await service.checkNodes(): service.changesEvent.fire()
|
||||
await sleepAsync(2.seconds)
|
||||
false
|
||||
except CancelledError as exc:
|
||||
except CancelledError:
|
||||
debug "Service interrupted"
|
||||
if not(timeMonitorFut.finished()): await timeMonitorFut.cancelAndWait()
|
||||
true
|
||||
|
@ -1815,9 +1815,7 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
|
||||
|
||||
curSlot += 1
|
||||
|
||||
let
|
||||
newHead = await handleProposal(node, head, slot)
|
||||
didSubmitBlock = (newHead != head)
|
||||
let newHead = await handleProposal(node, head, slot)
|
||||
head = newHead
|
||||
|
||||
let
|
||||
|
@ -44,13 +44,6 @@ type
|
||||
desc: "A directory to store the generated validator keystores"
|
||||
name: "out-dir" }: OutDir
|
||||
|
||||
template valueOr(x: Option, elseBlock: untyped): untyped =
|
||||
let val = x
|
||||
if val.isSome:
|
||||
val.get
|
||||
else:
|
||||
elseBlock
|
||||
|
||||
proc main =
|
||||
let conf = load Config
|
||||
if conf.threshold == 0:
|
||||
|
@ -6,13 +6,13 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
std/[os, strutils, streams, parsecsv],
|
||||
std/[parsecsv, streams],
|
||||
stew/[io2, byteutils], chronicles, confutils, snappy,
|
||||
../beacon_chain/spec/datatypes/base,
|
||||
./ncli_common
|
||||
|
||||
when defined(posix):
|
||||
import system/ansi_c
|
||||
from std/os import fileExists
|
||||
from std/strutils import parseBiggestInt, parseBiggestUInt
|
||||
|
||||
type
|
||||
AggregatorConf = object
|
||||
@ -199,51 +199,54 @@ proc advanceEpochs*(aggregator: var ValidatorDbAggregator, epoch: Epoch,
|
||||
aggregator.inclusionDelaysCount.setLen(0)
|
||||
aggregator.epochsAggregated = 0
|
||||
|
||||
proc aggregateEpochs(startEpoch, endEpoch: Epoch, resolution: uint,
|
||||
inputDir, outputDir: string) =
|
||||
if startEpoch > endEpoch:
|
||||
fatal "Start epoch cannot be larger than the end one.",
|
||||
startEpoch = startEpoch, endEpoch = endEpoch
|
||||
quit QuitFailure
|
||||
|
||||
info "Aggregating epochs ...", startEpoch = startEpoch, endEpoch = endEpoch,
|
||||
inputDir = inputDir, outputDir = outputDir
|
||||
|
||||
var aggregator = ValidatorDbAggregator.init(outputDir, resolution, endEpoch)
|
||||
|
||||
for epoch in startEpoch .. endEpoch:
|
||||
let filePath = getFilePathForEpoch(epoch, inputDir)
|
||||
info "Processing file ...", file = filePath
|
||||
|
||||
let data = io2.readAllBytes(filePath)
|
||||
doAssert data.isOk
|
||||
let dataStream = newStringStream(
|
||||
string.fromBytes(snappy.decode(
|
||||
data.get.toOpenArray(0, data.get.len - 1))))
|
||||
|
||||
var csvParser: CsvParser
|
||||
csvParser.open(dataStream, filePath)
|
||||
|
||||
var validatorsCount = 0
|
||||
while csvParser.readRow:
|
||||
inc validatorsCount
|
||||
let rp = parseRow(csvParser.row)
|
||||
aggregator.addValidatorData(validatorsCount - 1, rp)
|
||||
|
||||
aggregator.advanceEpochs(epoch, shouldShutDown)
|
||||
|
||||
if shouldShutDown:
|
||||
quit QuitSuccess
|
||||
|
||||
proc controlCHook {.noconv.} =
|
||||
notice "Shutting down after having received SIGINT."
|
||||
shouldShutDown = true
|
||||
|
||||
proc exitOnSigterm(signal: cint) {.noconv.} =
|
||||
notice "Shutting down after having received SIGTERM."
|
||||
shouldShutDown = true
|
||||
|
||||
when isMainModule:
|
||||
when defined(posix):
|
||||
import system/ansi_c
|
||||
|
||||
proc aggregateEpochs(startEpoch, endEpoch: Epoch, resolution: uint,
|
||||
inputDir, outputDir: string) =
|
||||
if startEpoch > endEpoch:
|
||||
fatal "Start epoch cannot be larger than the end one.",
|
||||
startEpoch = startEpoch, endEpoch = endEpoch
|
||||
quit QuitFailure
|
||||
|
||||
info "Aggregating epochs ...", startEpoch = startEpoch, endEpoch = endEpoch,
|
||||
inputDir = inputDir, outputDir = outputDir
|
||||
|
||||
var aggregator = ValidatorDbAggregator.init(outputDir, resolution, endEpoch)
|
||||
|
||||
for epoch in startEpoch .. endEpoch:
|
||||
let filePath = getFilePathForEpoch(epoch, inputDir)
|
||||
info "Processing file ...", file = filePath
|
||||
|
||||
let data = io2.readAllBytes(filePath)
|
||||
doAssert data.isOk
|
||||
let dataStream = newStringStream(
|
||||
string.fromBytes(snappy.decode(
|
||||
data.get.toOpenArray(0, data.get.len - 1))))
|
||||
|
||||
var csvParser: CsvParser
|
||||
csvParser.open(dataStream, filePath)
|
||||
|
||||
var validatorsCount = 0
|
||||
while csvParser.readRow:
|
||||
inc validatorsCount
|
||||
let rp = parseRow(csvParser.row)
|
||||
aggregator.addValidatorData(validatorsCount - 1, rp)
|
||||
|
||||
aggregator.advanceEpochs(epoch, shouldShutDown)
|
||||
|
||||
if shouldShutDown:
|
||||
quit QuitSuccess
|
||||
|
||||
proc controlCHook {.noconv.} =
|
||||
notice "Shutting down after having received SIGINT."
|
||||
shouldShutDown = true
|
||||
|
||||
proc exitOnSigterm(signal: cint) {.noconv.} =
|
||||
notice "Shutting down after having received SIGTERM."
|
||||
shouldShutDown = true
|
||||
|
||||
proc main =
|
||||
setControlCHook(controlCHook)
|
||||
when defined(posix):
|
||||
|
Loading…
x
Reference in New Issue
Block a user