From 71d8fb546da34dc9b71c39c8654d9e23b10accbc Mon Sep 17 00:00:00 2001 From: tersec Date: Mon, 23 Sep 2024 08:02:09 +0000 Subject: [PATCH] update ncli_db to use Opt (#6575) --- ncli/ncli_common.nim | 10 +++++----- ncli/ncli_db.nim | 4 ++-- ncli/validator_db_aggregator.nim | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ncli/ncli_common.nim b/ncli/ncli_common.nim index 66cf07888..0180ad0eb 100644 --- a/ncli/ncli_common.nim +++ b/ncli/ncli_common.nim @@ -39,7 +39,7 @@ type inactivity_penalty*: Gwei slashing_outcome*: int64 deposits*: Gwei - inclusion_delay*: Option[uint64] + inclusion_delay*: Opt[uint64] ParticipationFlags* = object currentEpochParticipation: EpochParticipationFlags @@ -399,13 +399,13 @@ func collectFromAttestations( forkyState.data, attestation.data, attestation.aggregation_bits, attestation.committee_bits, cache): rewardsAndPenalties[index].inclusion_delay = - some(inclusionDelay.uint64) + Opt.some(inclusionDelay.uint64) else: for index in get_attesting_indices( forkyState.data, attestation.data, attestation.aggregation_bits, cache): rewardsAndPenalties[index].inclusion_delay = - some(inclusionDelay.uint64) + Opt.some(inclusionDelay.uint64) from ".."/beacon_chain/validator_bucket_sort import findValidatorIndex, sortValidatorBuckets @@ -433,7 +433,7 @@ proc collectFromDeposits( if index.isSome: try: rewardsAndPenalties[index.get()].deposits += amount - except KeyError as e: + except KeyError: raiseAssert "rewardsAndPenalties lacks expected index " & $index.get() elif verify_deposit_signature(cfg, deposit.data): pubkeyToIndex[pubkey] = ValidatorIndex(rewardsAndPenalties.len) @@ -494,7 +494,7 @@ proc collectBlockRewardsAndPenalties*( func serializeToCsv*(rp: RewardsAndPenalties, avgInclusionDelay = none(float)): string = for name, value in fieldPairs(rp): - if value isnot Option: + if value isnot Opt: result &= $value & "," if avgInclusionDelay.isSome: result.addFloat(avgInclusionDelay.get) diff --git a/ncli/ncli_db.nim b/ncli/ncli_db.nim index 3129e31e1..e29acd345 100644 --- a/ncli/ncli_db.nim +++ b/ncli/ncli_db.nim @@ -1097,9 +1097,9 @@ proc cmdValidatorDb(conf: DbConf, cfg: RuntimeConfig) = rp.inclusion_delay = block: let notSlashed = (RewardFlags.isSlashed notin validator.flags) if notSlashed and validator.is_previous_epoch_attester.isSome(): - some(validator.is_previous_epoch_attester.get().delay.uint64) + Opt.some(validator.is_previous_epoch_attester.get().delay.uint64) else: - none(uint64) + Opt.none(uint64) if conf.writeUnaggregatedFiles: csvLines.add rp.serializeToCsv diff --git a/ncli/validator_db_aggregator.nim b/ncli/validator_db_aggregator.nim index ff67d3660..ec3348670 100644 --- a/ncli/validator_db_aggregator.nim +++ b/ncli/validator_db_aggregator.nim @@ -82,7 +82,7 @@ func `+=`(lhs: var RewardsAndPenalties, rhs: RewardsAndPenalties) = lhs.inclusion_delay.get += rhs.inclusion_delay.get else: if rhs.inclusion_delay.isSome: - lhs.inclusion_delay = some(rhs.inclusion_delay.get) + lhs.inclusion_delay = Opt.some(rhs.inclusion_delay.get) func average(rp: var RewardsAndPenalties, averageInclusionDelay: var Option[float], @@ -206,7 +206,7 @@ when isMainModule: slashing_outcome: parseBiggestInt(csvRow[12]), deposits: parseBiggestUInt(csvRow[13]).Gwei) if csvRow[14].len > 0: - result.inclusion_delay = some(parseBiggestUInt(csvRow[14])) + result.inclusion_delay = Opt.some(parseBiggestUInt(csvRow[14])) proc aggregateEpochs( startEpoch, endEpoch: Epoch, resolution: uint,