optimize phase 0 -> Altair transition state processing (#2679)
This commit is contained in:
parent
72544f06c0
commit
ec54173667
|
@ -824,6 +824,8 @@ proc get_next_sync_committee*(state: altair.BeaconState): SyncCommittee =
|
||||||
func translate_participation(
|
func translate_participation(
|
||||||
state: var altair.BeaconState,
|
state: var altair.BeaconState,
|
||||||
pending_attestations: openArray[phase0.PendingAttestation]) =
|
pending_attestations: openArray[phase0.PendingAttestation]) =
|
||||||
|
|
||||||
|
var cache = StateCache()
|
||||||
for attestation in pending_attestations:
|
for attestation in pending_attestations:
|
||||||
let
|
let
|
||||||
data = attestation.data
|
data = attestation.data
|
||||||
|
@ -834,8 +836,6 @@ func translate_participation(
|
||||||
get_attestation_participation_flag_indices(state, data, inclusion_delay)
|
get_attestation_participation_flag_indices(state, data, inclusion_delay)
|
||||||
|
|
||||||
# Apply flags to all attesting validators
|
# Apply flags to all attesting validators
|
||||||
var cache = StateCache() # TODO hoist/pass as param
|
|
||||||
|
|
||||||
for index in get_attesting_indices(
|
for index in get_attesting_indices(
|
||||||
state, data, attestation.aggregation_bits, cache):
|
state, data, attestation.aggregation_bits, cache):
|
||||||
for flag_index in participation_flag_indices:
|
for flag_index in participation_flag_indices:
|
||||||
|
@ -852,10 +852,12 @@ proc upgrade_to_altair*(pre: phase0.BeaconState): ref altair.BeaconState =
|
||||||
empty_participation =
|
empty_participation =
|
||||||
HashList[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]()
|
HashList[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]()
|
||||||
inactivity_scores = HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]()
|
inactivity_scores = HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]()
|
||||||
for _ in 0 ..< len(pre.validators):
|
|
||||||
doAssert empty_participation.add 0.ParticipationFlags
|
doAssert empty_participation.data.setLen(pre.validators.len)
|
||||||
for _ in 0 ..< len(pre.validators):
|
empty_participation.resetCache()
|
||||||
doAssert inactivity_scores.add 0'u64
|
|
||||||
|
doAssert inactivity_scores.data.setLen(pre.validators.len)
|
||||||
|
inactivity_scores.resetCache()
|
||||||
|
|
||||||
var post = (ref altair.BeaconState)(
|
var post = (ref altair.BeaconState)(
|
||||||
genesis_time: pre.genesis_time,
|
genesis_time: pre.genesis_time,
|
||||||
|
|
Loading…
Reference in New Issue