update ncli_db to use Opt (#6575)
This commit is contained in:
parent
85d7109065
commit
71d8fb546d
|
@ -39,7 +39,7 @@ type
|
||||||
inactivity_penalty*: Gwei
|
inactivity_penalty*: Gwei
|
||||||
slashing_outcome*: int64
|
slashing_outcome*: int64
|
||||||
deposits*: Gwei
|
deposits*: Gwei
|
||||||
inclusion_delay*: Option[uint64]
|
inclusion_delay*: Opt[uint64]
|
||||||
|
|
||||||
ParticipationFlags* = object
|
ParticipationFlags* = object
|
||||||
currentEpochParticipation: EpochParticipationFlags
|
currentEpochParticipation: EpochParticipationFlags
|
||||||
|
@ -399,13 +399,13 @@ func collectFromAttestations(
|
||||||
forkyState.data, attestation.data, attestation.aggregation_bits,
|
forkyState.data, attestation.data, attestation.aggregation_bits,
|
||||||
attestation.committee_bits, cache):
|
attestation.committee_bits, cache):
|
||||||
rewardsAndPenalties[index].inclusion_delay =
|
rewardsAndPenalties[index].inclusion_delay =
|
||||||
some(inclusionDelay.uint64)
|
Opt.some(inclusionDelay.uint64)
|
||||||
else:
|
else:
|
||||||
for index in get_attesting_indices(
|
for index in get_attesting_indices(
|
||||||
forkyState.data, attestation.data, attestation.aggregation_bits,
|
forkyState.data, attestation.data, attestation.aggregation_bits,
|
||||||
cache):
|
cache):
|
||||||
rewardsAndPenalties[index].inclusion_delay =
|
rewardsAndPenalties[index].inclusion_delay =
|
||||||
some(inclusionDelay.uint64)
|
Opt.some(inclusionDelay.uint64)
|
||||||
|
|
||||||
from ".."/beacon_chain/validator_bucket_sort import
|
from ".."/beacon_chain/validator_bucket_sort import
|
||||||
findValidatorIndex, sortValidatorBuckets
|
findValidatorIndex, sortValidatorBuckets
|
||||||
|
@ -433,7 +433,7 @@ proc collectFromDeposits(
|
||||||
if index.isSome:
|
if index.isSome:
|
||||||
try:
|
try:
|
||||||
rewardsAndPenalties[index.get()].deposits += amount
|
rewardsAndPenalties[index.get()].deposits += amount
|
||||||
except KeyError as e:
|
except KeyError:
|
||||||
raiseAssert "rewardsAndPenalties lacks expected index " & $index.get()
|
raiseAssert "rewardsAndPenalties lacks expected index " & $index.get()
|
||||||
elif verify_deposit_signature(cfg, deposit.data):
|
elif verify_deposit_signature(cfg, deposit.data):
|
||||||
pubkeyToIndex[pubkey] = ValidatorIndex(rewardsAndPenalties.len)
|
pubkeyToIndex[pubkey] = ValidatorIndex(rewardsAndPenalties.len)
|
||||||
|
@ -494,7 +494,7 @@ proc collectBlockRewardsAndPenalties*(
|
||||||
func serializeToCsv*(rp: RewardsAndPenalties,
|
func serializeToCsv*(rp: RewardsAndPenalties,
|
||||||
avgInclusionDelay = none(float)): string =
|
avgInclusionDelay = none(float)): string =
|
||||||
for name, value in fieldPairs(rp):
|
for name, value in fieldPairs(rp):
|
||||||
if value isnot Option:
|
if value isnot Opt:
|
||||||
result &= $value & ","
|
result &= $value & ","
|
||||||
if avgInclusionDelay.isSome:
|
if avgInclusionDelay.isSome:
|
||||||
result.addFloat(avgInclusionDelay.get)
|
result.addFloat(avgInclusionDelay.get)
|
||||||
|
|
|
@ -1097,9 +1097,9 @@ proc cmdValidatorDb(conf: DbConf, cfg: RuntimeConfig) =
|
||||||
rp.inclusion_delay = block:
|
rp.inclusion_delay = block:
|
||||||
let notSlashed = (RewardFlags.isSlashed notin validator.flags)
|
let notSlashed = (RewardFlags.isSlashed notin validator.flags)
|
||||||
if notSlashed and validator.is_previous_epoch_attester.isSome():
|
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:
|
else:
|
||||||
none(uint64)
|
Opt.none(uint64)
|
||||||
|
|
||||||
if conf.writeUnaggregatedFiles:
|
if conf.writeUnaggregatedFiles:
|
||||||
csvLines.add rp.serializeToCsv
|
csvLines.add rp.serializeToCsv
|
||||||
|
|
|
@ -82,7 +82,7 @@ func `+=`(lhs: var RewardsAndPenalties, rhs: RewardsAndPenalties) =
|
||||||
lhs.inclusion_delay.get += rhs.inclusion_delay.get
|
lhs.inclusion_delay.get += rhs.inclusion_delay.get
|
||||||
else:
|
else:
|
||||||
if rhs.inclusion_delay.isSome:
|
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,
|
func average(rp: var RewardsAndPenalties,
|
||||||
averageInclusionDelay: var Option[float],
|
averageInclusionDelay: var Option[float],
|
||||||
|
@ -206,7 +206,7 @@ when isMainModule:
|
||||||
slashing_outcome: parseBiggestInt(csvRow[12]),
|
slashing_outcome: parseBiggestInt(csvRow[12]),
|
||||||
deposits: parseBiggestUInt(csvRow[13]).Gwei)
|
deposits: parseBiggestUInt(csvRow[13]).Gwei)
|
||||||
if csvRow[14].len > 0:
|
if csvRow[14].len > 0:
|
||||||
result.inclusion_delay = some(parseBiggestUInt(csvRow[14]))
|
result.inclusion_delay = Opt.some(parseBiggestUInt(csvRow[14]))
|
||||||
|
|
||||||
proc aggregateEpochs(
|
proc aggregateEpochs(
|
||||||
startEpoch, endEpoch: Epoch, resolution: uint,
|
startEpoch, endEpoch: Epoch, resolution: uint,
|
||||||
|
|
Loading…
Reference in New Issue