update ncli_db to use Opt (#6575)

This commit is contained in:
tersec 2024-09-23 08:02:09 +00:00 committed by GitHub
parent 85d7109065
commit 71d8fb546d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View File

@ -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)

View File

@ -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

View File

@ -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,