drop get_attesting_indices()/get_unslashed_attesting_indices() from 15% to 1% of workload at block_sim at 100k validators (#1351)

This commit is contained in:
tersec 2020-07-21 16:35:43 +00:00 committed by GitHub
parent 8c5aa7cbe7
commit 83abbcb917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -875,7 +875,7 @@ proc isInitialized*(T: type CandidateChains, db: BeaconChainDB): bool =
if not db.containsState(tailBlock.get().message.state_root): if not db.containsState(tailBlock.get().message.state_root):
return false return false
return true true
proc preInit*( proc preInit*(
T: type CandidateChains, db: BeaconChainDB, state: BeaconState, T: type CandidateChains, db: BeaconChainDB, state: BeaconState,

View File

@ -290,7 +290,7 @@ func is_valid_genesis_state*(preset: RuntimePreset,
# This is an okay get_active_validator_indices(...) for the time being. # This is an okay get_active_validator_indices(...) for the time being.
if active_validator_indices.len.uint64 < preset.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: if active_validator_indices.len.uint64 < preset.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT:
return false return false
return true true
# TODO this is now a non-spec helper function, and it's not really accurate # TODO this is now a non-spec helper function, and it's not really accurate
# so only usable/used in research/ and tests/ # so only usable/used in research/ and tests/
@ -527,7 +527,7 @@ proc isValidAttestationSlot*(attestationSlot, stateSlot: Slot): bool =
state_slot = shortLog(stateSlot)) state_slot = shortLog(stateSlot))
return false return false
return true true
# TODO remove/merge with p2p-interface validation # TODO remove/merge with p2p-interface validation
proc isValidAttestationTargetEpoch*( proc isValidAttestationTargetEpoch*(

View File

@ -326,7 +326,7 @@ func init*(T: typedesc[ValidatorPrivKey], hex: string): T {.noInit, raises: [Val
let v = T.fromHex(hex) let v = T.fromHex(hex)
if v.isErr: if v.isErr:
raise (ref ValueError)(msg: $v.error) raise (ref ValueError)(msg: $v.error)
return v[] v[]
# For mainchain monitor # For mainchain monitor
@ -334,11 +334,11 @@ func init*(T: typedesc[ValidatorPubKey], data: array[RawPubKeySize, byte]): T {.
let v = T.fromRaw(data) let v = T.fromRaw(data)
if v.isErr: if v.isErr:
raise (ref ValueError)(msg: $v.error) raise (ref ValueError)(msg: $v.error)
return v[] v[]
# For mainchain monitor # For mainchain monitor
func init*(T: typedesc[ValidatorSig], data: array[RawSigSize, byte]): T {.noInit, raises: [ValueError, Defect].} = func init*(T: typedesc[ValidatorSig], data: array[RawSigSize, byte]): T {.noInit, raises: [ValueError, Defect].} =
let v = T.fromRaw(data) let v = T.fromRaw(data)
if v.isErr: if v.isErr:
raise (ref ValueError)(msg: $v.error) raise (ref ValueError)(msg: $v.error)
return v[] v[]

View File

@ -32,8 +32,8 @@ func get_attesting_indices*(
# Exported bceause of external trace-level chronicles logging. # Exported bceause of external trace-level chronicles logging.
result = initHashSet[ValidatorIndex]() result = initHashSet[ValidatorIndex]()
for a in attestations: for a in attestations:
result = result.union(get_attesting_indices( result.incl get_attesting_indices(
state, a.data, a.aggregation_bits, stateCache)) state, a.data, a.aggregation_bits, stateCache)
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#helper-functions-1 # https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#helper-functions-1
func get_unslashed_attesting_indices*( func get_unslashed_attesting_indices*(