fix some `Name` and `XDeclaredButNotUsed` hints (#5670)
This commit is contained in:
parent
13c9f3b1e1
commit
0b9c632b69
|
@ -153,8 +153,6 @@ proc restValidatorExit(config: BeaconNodeConf) {.async.} =
|
|||
|
||||
stateIdHead = StateIdent(kind: StateQueryKind.Named,
|
||||
value: StateIdentType.Head)
|
||||
blockIdentHead = BlockIdent(kind: BlockQueryKind.Named,
|
||||
value: BlockIdentType.Head)
|
||||
|
||||
# Before making any REST requests, we'll make sure that the supplied
|
||||
# inputs are correct:
|
||||
|
|
|
@ -1387,7 +1387,7 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} =
|
|||
GC_fullCollect()
|
||||
except Defect as exc:
|
||||
raise exc # Reraise to maintain call stack
|
||||
except Exception as exc:
|
||||
except Exception:
|
||||
# TODO upstream
|
||||
raiseAssert "Unexpected exception during GC collection"
|
||||
|
||||
|
|
|
@ -247,7 +247,6 @@ proc doTrustedNodeSync*(
|
|||
else:
|
||||
break
|
||||
startPeriod = periods.a
|
||||
lastPeriod = periods.b
|
||||
count = min(periods.len, MAX_REQUEST_LIGHT_CLIENT_UPDATES).uint64
|
||||
|
||||
var updates =
|
||||
|
|
|
@ -322,9 +322,9 @@ proc pollForAttesterDuties*(service: DutiesServiceRef) {.async.} =
|
|||
debug "Attestation selection proofs have been received",
|
||||
signatures_requested = sigres.signaturesRequested,
|
||||
signatures_received = sigres.signaturesReceived,
|
||||
selections_requested = sigres.selections_requested,
|
||||
selections_received = sigres.selections_received,
|
||||
selections_processed = sigres.selections_processed,
|
||||
selections_requested = sigres.selectionsRequested,
|
||||
selections_received = sigres.selectionsReceived,
|
||||
selections_processed = sigres.selectionsProcessed,
|
||||
total_elapsed_time = (Moment.now() - moment)
|
||||
else:
|
||||
debug "Attestation selection proofs have been received",
|
||||
|
@ -412,9 +412,9 @@ proc pollForSyncCommitteeDuties*(service: DutiesServiceRef) {.async.} =
|
|||
debug "Sync committee selection proofs have been received",
|
||||
signatures_requested = sigres.signaturesRequested,
|
||||
signatures_received = sigres.signaturesReceived,
|
||||
selections_requested = sigres.selections_requested,
|
||||
selections_received = sigres.selections_received,
|
||||
selections_processed = sigres.selections_processed,
|
||||
selections_requested = sigres.selectionsRequested,
|
||||
selections_received = sigres.selectionsReceived,
|
||||
selections_processed = sigres.selectionsProcessed,
|
||||
total_elapsed_time = (Moment.now() - moment)
|
||||
else:
|
||||
debug "Sync committee selection proofs have been received",
|
||||
|
|
|
@ -466,12 +466,6 @@ proc fillSyncCommitteeSelectionProofs*(
|
|||
validator_index = uint64(selection.validator_index),
|
||||
reason = $error
|
||||
continue
|
||||
selectionProof = selection.selection_proof.load().valueOr:
|
||||
warn "Invalid signature encountered while processing " &
|
||||
"sync committee selections",
|
||||
validator_index = vindex, slot = slot,
|
||||
selection_proof = shortLog(selection.selection_proof)
|
||||
continue
|
||||
validator =
|
||||
block:
|
||||
# Selections operating using validator indices, so we should check
|
||||
|
@ -509,6 +503,6 @@ proc fillSyncCommitteeSelectionProofs*(
|
|||
epochProofs[].proofs.withValue(validator.pubkey, signatures):
|
||||
signatures[].setSignature(request.sync_committee_index,
|
||||
selection.slot,
|
||||
Opt.some(selection.selectionProof))
|
||||
Opt.some(selection.selection_proof))
|
||||
inc(sigres.selectionsProcessed)
|
||||
sigres
|
||||
|
|
|
@ -203,10 +203,7 @@ proc produceAndPublishContributions(service: SyncCommitteeServiceRef,
|
|||
slot: Slot,
|
||||
beaconBlockRoot: Eth2Digest,
|
||||
duties: seq[SyncCommitteeDuty]) {.async.} =
|
||||
let
|
||||
vc = service.client
|
||||
epoch = slot.epoch
|
||||
fork = vc.forkAtEpoch(epoch)
|
||||
let vc = service.client
|
||||
|
||||
var (contributions, pendingFutures, contributionsMap) =
|
||||
block:
|
||||
|
|
|
@ -581,139 +581,140 @@ proc sendDeposits(deposits: seq[LaunchPadDeposit],
|
|||
web3 = await initWeb3(web3Url, privateKey)
|
||||
|
||||
{.pop.} # TODO confutils.nim(775, 17) Error: can raise an unlisted exception: ref IOError
|
||||
proc main() {.async.} =
|
||||
var conf = try: CliConfig.load()
|
||||
except CatchableError as exc:
|
||||
raise exc
|
||||
except Exception as exc: # TODO fix confutils
|
||||
raiseAssert exc.msg
|
||||
|
||||
let rng = HmacDrbgContext.new()
|
||||
|
||||
if conf.cmd == StartUpCommand.generateDeposits:
|
||||
let
|
||||
mnemonic = generateMnemonic(rng[])
|
||||
seed = getSeed(mnemonic, KeystorePass.init "")
|
||||
cfg = getRuntimeConfig(conf.eth2Network)
|
||||
|
||||
if (let res = secureCreatePath(string conf.outValidatorsDir); res.isErr):
|
||||
warn "Could not create validators folder",
|
||||
path = string conf.outValidatorsDir, err = ioErrorMsg(res.error)
|
||||
|
||||
if (let res = secureCreatePath(string conf.outSecretsDir); res.isErr):
|
||||
warn "Could not create secrets folder",
|
||||
path = string conf.outSecretsDir, err = ioErrorMsg(res.error)
|
||||
|
||||
let deposits = generateDeposits(
|
||||
cfg,
|
||||
rng[],
|
||||
seed,
|
||||
0, conf.simulationDepositsCount,
|
||||
string conf.outValidatorsDir,
|
||||
string conf.outSecretsDir,
|
||||
conf.remoteSignersUrls,
|
||||
conf.threshold,
|
||||
conf.remoteValidatorsCount,
|
||||
KeystoreMode.Fast)
|
||||
|
||||
if deposits.isErr:
|
||||
fatal "Failed to generate deposits", err = deposits.error
|
||||
quit 1
|
||||
|
||||
let launchPadDeposits =
|
||||
mapIt(deposits.value, LaunchPadDeposit.init(cfg, it))
|
||||
|
||||
Json.saveFile(string conf.outDepositsFile, launchPadDeposits)
|
||||
notice "Deposit data written", filename = conf.outDepositsFile
|
||||
quit 0
|
||||
|
||||
var deposits: seq[LaunchPadDeposit]
|
||||
if conf.cmd == StartUpCommand.sendDeposits:
|
||||
deposits = Json.loadFile(string conf.depositsFile, seq[LaunchPadDeposit])
|
||||
|
||||
if conf.askForKey:
|
||||
var
|
||||
privateKey: string # TODO consider using a SecretString type
|
||||
reasonForKey = ""
|
||||
|
||||
if conf.cmd == StartUpCommand.sendDeposits:
|
||||
let
|
||||
depositsWord = if deposits.len > 1: "deposits" else: "deposit"
|
||||
totalEthNeeded = 32 * deposits.len
|
||||
reasonForKey = " in order to make your $1 (you'll need access to $2 ETH)" %
|
||||
[depositsWord, $totalEthNeeded]
|
||||
|
||||
echo "Please enter your Goerli Eth1 private key in hex form (e.g. 0x1a2...f3c)" &
|
||||
reasonForKey
|
||||
|
||||
if not readPasswordFromStdin("> ", privateKey):
|
||||
error "Failed to read an Eth1 private key from standard input"
|
||||
|
||||
if privateKey.len > 0:
|
||||
conf.privateKey = privateKey.string
|
||||
|
||||
case conf.cmd
|
||||
of StartUpCommand.createTestnet:
|
||||
let rng = HmacDrbgContext.new()
|
||||
doCreateTestnet(conf, rng[])
|
||||
|
||||
of StartUpCommand.createTestnetEnr:
|
||||
let rng = HmacDrbgContext.new()
|
||||
doCreateTestnetEnr(conf, rng[])
|
||||
|
||||
of StartUpCommand.deployDepositContract:
|
||||
let web3 = await initWeb3(conf.web3Url, conf.privateKey)
|
||||
let receipt = await web3.deployContract(depositContractCode)
|
||||
echo receipt.contractAddress.get, ";", receipt.blockHash
|
||||
|
||||
of StartUpCommand.sendEth:
|
||||
let web3 = await initWeb3(conf.web3Url, conf.privateKey)
|
||||
echo await sendEth(web3, conf.toAddress, conf.valueEth.parseInt)
|
||||
|
||||
of StartUpCommand.sendDeposits:
|
||||
var delayGenerator: DelayGenerator
|
||||
if not (conf.maxDelay > 0.0):
|
||||
conf.maxDelay = conf.minDelay
|
||||
elif conf.minDelay > conf.maxDelay:
|
||||
echo "The minimum delay should not be larger than the maximum delay"
|
||||
quit 1
|
||||
|
||||
if conf.maxDelay > 0.0:
|
||||
delayGenerator = proc (): chronos.Duration =
|
||||
let
|
||||
minDelay = (conf.minDelay*1000).int64
|
||||
maxDelay = (conf.maxDelay*1000).int64
|
||||
chronos.milliseconds (rng[].rand(maxDelay - minDelay) + minDelay)
|
||||
|
||||
await sendDeposits(deposits, conf.web3Url, conf.privateKey,
|
||||
conf.depositContractAddress, delayGenerator)
|
||||
|
||||
of StartUpCommand.run:
|
||||
discard
|
||||
|
||||
of StartUpCommand.analyzeLogs:
|
||||
try:
|
||||
logtrace.run(LogTraceConf(
|
||||
cmd: logtrace.StartUpCommand.localSimChecks,
|
||||
logFiles: conf.logFiles,
|
||||
simDir: conf.simDir,
|
||||
netDir: conf.netDir,
|
||||
logDir: conf.logDir,
|
||||
ignoreSerializationErrors: conf.ignoreSerializationErrors,
|
||||
dumpSerializationErrors: conf.dumpSerializationErrors,
|
||||
nodes: conf.nodes,
|
||||
allowedLag: conf.allowedLag,
|
||||
constPreset: conf.constPreset
|
||||
))
|
||||
except CatchableError as err:
|
||||
fatal "Unexpected error in logtrace", err = err.msg
|
||||
except Exception as exc:
|
||||
# TODO: Investigate where is this coming from?
|
||||
fatal "Unexpected exception in logtrace", err = exc.msg
|
||||
|
||||
of StartUpCommand.generateDeposits:
|
||||
# This is handled above before the case statement
|
||||
discard
|
||||
|
||||
when isMainModule:
|
||||
proc main() {.async.} =
|
||||
var conf = try: CliConfig.load()
|
||||
except CatchableError as exc:
|
||||
raise exc
|
||||
except Exception as exc: # TODO fix confutils
|
||||
raiseAssert exc.msg
|
||||
|
||||
let rng = HmacDrbgContext.new()
|
||||
|
||||
if conf.cmd == StartUpCommand.generateDeposits:
|
||||
let
|
||||
mnemonic = generateMnemonic(rng[])
|
||||
seed = getSeed(mnemonic, KeystorePass.init "")
|
||||
cfg = getRuntimeConfig(conf.eth2Network)
|
||||
|
||||
if (let res = secureCreatePath(string conf.outValidatorsDir); res.isErr):
|
||||
warn "Could not create validators folder",
|
||||
path = string conf.outValidatorsDir, err = ioErrorMsg(res.error)
|
||||
|
||||
if (let res = secureCreatePath(string conf.outSecretsDir); res.isErr):
|
||||
warn "Could not create secrets folder",
|
||||
path = string conf.outSecretsDir, err = ioErrorMsg(res.error)
|
||||
|
||||
let deposits = generateDeposits(
|
||||
cfg,
|
||||
rng[],
|
||||
seed,
|
||||
0, conf.simulationDepositsCount,
|
||||
string conf.outValidatorsDir,
|
||||
string conf.outSecretsDir,
|
||||
conf.remoteSignersUrls,
|
||||
conf.threshold,
|
||||
conf.remoteValidatorsCount,
|
||||
KeystoreMode.Fast)
|
||||
|
||||
if deposits.isErr:
|
||||
fatal "Failed to generate deposits", err = deposits.error
|
||||
quit 1
|
||||
|
||||
let launchPadDeposits =
|
||||
mapIt(deposits.value, LaunchPadDeposit.init(cfg, it))
|
||||
|
||||
Json.saveFile(string conf.outDepositsFile, launchPadDeposits)
|
||||
notice "Deposit data written", filename = conf.outDepositsFile
|
||||
quit 0
|
||||
|
||||
var deposits: seq[LaunchPadDeposit]
|
||||
if conf.cmd == StartUpCommand.sendDeposits:
|
||||
deposits = Json.loadFile(string conf.depositsFile, seq[LaunchPadDeposit])
|
||||
|
||||
if conf.askForKey:
|
||||
var
|
||||
privateKey: string # TODO consider using a SecretString type
|
||||
reasonForKey = ""
|
||||
|
||||
if conf.cmd == StartUpCommand.sendDeposits:
|
||||
let
|
||||
depositsWord = if deposits.len > 1: "deposits" else: "deposit"
|
||||
totalEthNeeded = 32 * deposits.len
|
||||
reasonForKey = " in order to make your $1 (you'll need access to $2 ETH)" %
|
||||
[depositsWord, $totalEthNeeded]
|
||||
|
||||
echo "Please enter your Goerli Eth1 private key in hex form (e.g. 0x1a2...f3c)" &
|
||||
reasonForKey
|
||||
|
||||
if not readPasswordFromStdin("> ", privateKey):
|
||||
error "Failed to read an Eth1 private key from standard input"
|
||||
|
||||
if privateKey.len > 0:
|
||||
conf.privateKey = privateKey.string
|
||||
|
||||
case conf.cmd
|
||||
of StartUpCommand.createTestnet:
|
||||
let rng = HmacDrbgContext.new()
|
||||
doCreateTestnet(conf, rng[])
|
||||
|
||||
of StartUpCommand.createTestnetEnr:
|
||||
let rng = HmacDrbgContext.new()
|
||||
doCreateTestnetEnr(conf, rng[])
|
||||
|
||||
of StartUpCommand.deployDepositContract:
|
||||
let web3 = await initWeb3(conf.web3Url, conf.privateKey)
|
||||
let receipt = await web3.deployContract(depositContractCode)
|
||||
echo receipt.contractAddress.get, ";", receipt.blockHash
|
||||
|
||||
of StartUpCommand.sendEth:
|
||||
let web3 = await initWeb3(conf.web3Url, conf.privateKey)
|
||||
echo await sendEth(web3, conf.toAddress, conf.valueEth.parseInt)
|
||||
|
||||
of StartUpCommand.sendDeposits:
|
||||
var delayGenerator: DelayGenerator
|
||||
if not (conf.maxDelay > 0.0):
|
||||
conf.maxDelay = conf.minDelay
|
||||
elif conf.minDelay > conf.maxDelay:
|
||||
echo "The minimum delay should not be larger than the maximum delay"
|
||||
quit 1
|
||||
|
||||
if conf.maxDelay > 0.0:
|
||||
delayGenerator = proc (): chronos.Duration =
|
||||
let
|
||||
minDelay = (conf.minDelay*1000).int64
|
||||
maxDelay = (conf.maxDelay*1000).int64
|
||||
chronos.milliseconds (rng[].rand(maxDelay - minDelay) + minDelay)
|
||||
|
||||
await sendDeposits(deposits, conf.web3Url, conf.privateKey,
|
||||
conf.depositContractAddress, delayGenerator)
|
||||
|
||||
of StartUpCommand.run:
|
||||
discard
|
||||
|
||||
of StartUpCommand.analyzeLogs:
|
||||
try:
|
||||
logtrace.run(LogTraceConf(
|
||||
cmd: logtrace.StartUpCommand.localSimChecks,
|
||||
logFiles: conf.logFiles,
|
||||
simDir: conf.simDir,
|
||||
netDir: conf.netDir,
|
||||
logDir: conf.logDir,
|
||||
ignoreSerializationErrors: conf.ignoreSerializationErrors,
|
||||
dumpSerializationErrors: conf.dumpSerializationErrors,
|
||||
nodes: conf.nodes,
|
||||
allowedLag: conf.allowedLag,
|
||||
constPreset: conf.constPreset
|
||||
))
|
||||
except CatchableError as err:
|
||||
fatal "Unexpected error in logtrace", err = err.msg
|
||||
except Exception as exc:
|
||||
# TODO: Investigate where is this coming from?
|
||||
fatal "Unexpected exception in logtrace", err = exc.msg
|
||||
|
||||
of StartUpCommand.generateDeposits:
|
||||
# This is handled above before the case statement
|
||||
discard
|
||||
|
||||
waitFor main()
|
||||
|
|
Loading…
Reference in New Issue