only invalidate {current,previous}_epoch_participation flag cache once (#3063)
This commit is contained in:
parent
a0f6a19267
commit
95b0ecc5a2
|
@ -621,22 +621,27 @@ proc process_attestation*(
|
||||||
pa[].inclusion_delay = state.slot - attestation.data.slot
|
pa[].inclusion_delay = state.slot - attestation.data.slot
|
||||||
pa[].proposer_index = proposer_index.get().uint64
|
pa[].proposer_index = proposer_index.get().uint64
|
||||||
|
|
||||||
# For Altair
|
# Altair and Merge
|
||||||
template updateParticipationFlags(epoch_participation: untyped) =
|
template updateParticipationFlags(epoch_participation: untyped) =
|
||||||
var proposer_reward_numerator = 0'u64
|
var proposer_reward_numerator = 0'u64
|
||||||
|
|
||||||
# Participation flag indices
|
# Participation flag indices
|
||||||
let
|
let participation_flag_indices =
|
||||||
participation_flag_indices =
|
|
||||||
get_attestation_participation_flag_indices(
|
get_attestation_participation_flag_indices(
|
||||||
state, attestation.data, state.slot - attestation.data.slot)
|
state, attestation.data, state.slot - attestation.data.slot)
|
||||||
|
|
||||||
for index in get_attesting_indices(state, attestation.data, attestation.aggregation_bits, cache):
|
for index in get_attesting_indices(
|
||||||
|
state, attestation.data, attestation.aggregation_bits, cache):
|
||||||
for flag_index, weight in PARTICIPATION_FLAG_WEIGHTS:
|
for flag_index, weight in PARTICIPATION_FLAG_WEIGHTS:
|
||||||
if flag_index in participation_flag_indices and not has_flag(epoch_participation[index], flag_index):
|
if flag_index in participation_flag_indices and
|
||||||
epoch_participation[index] = add_flag(epoch_participation[index], flag_index)
|
not has_flag(epoch_participation.asSeq[index], flag_index):
|
||||||
|
epoch_participation.asSeq[index] =
|
||||||
|
add_flag(epoch_participation.asSeq[index], flag_index)
|
||||||
|
|
||||||
|
# these are all valid; TODO statically verify or do it type-safely
|
||||||
proposer_reward_numerator += get_base_reward(
|
proposer_reward_numerator += get_base_reward(
|
||||||
state, index, base_reward_per_increment) * weight.uint64 # these are all valid, #TODO statically verify or do it type-safely
|
state, index, base_reward_per_increment) * weight.uint64
|
||||||
|
epoch_participation.clearCache()
|
||||||
|
|
||||||
# Reward proposer
|
# Reward proposer
|
||||||
let
|
let
|
||||||
|
|
|
@ -72,8 +72,8 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
|
||||||
validatorKeyToIndex = initTable[ValidatorPubKey, int]()
|
validatorKeyToIndex = initTable[ValidatorPubKey, int]()
|
||||||
cfg = defaultRuntimeConfig
|
cfg = defaultRuntimeConfig
|
||||||
|
|
||||||
cfg.ALTAIR_FORK_EPOCH = 96.Slot.epoch
|
cfg.ALTAIR_FORK_EPOCH = 64.Slot.epoch
|
||||||
cfg.MERGE_FORK_EPOCH = 160.Slot.epoch
|
cfg.MERGE_FORK_EPOCH = 128.Slot.epoch
|
||||||
|
|
||||||
echo "Starting simulation..."
|
echo "Starting simulation..."
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue