Skip to content

Commit 401948a

Browse files
etan-statussiddarthkay
authored andcommitted
Cleanup validator change fetching (#7506)
When building a block, allow BLS to Execution change to be included for a validator that exits in the same block. Credential changes can happen together with (or even after) an exit.
1 parent bd792f0 commit 401948a

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

beacon_chain/consensus_object_pools/validator_change_pool.nim

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ proc getValidatorChangeMessagesForBlock(
259259
if not validateValidatorChangeMessage(cfg, state, validator_change_message):
260260
continue
261261

262-
var skip = false
262+
# Filter messages that don't affect any new validators
263+
var skip = true
263264
for slashed_index in getValidatorIndices(validator_change_message):
264-
if seen.containsOrIncl(slashed_index):
265-
skip = true
266-
break
265+
if not seen.containsOrIncl(slashed_index):
266+
skip = false
267267
if skip:
268268
continue
269269

@@ -273,31 +273,34 @@ proc getValidatorChangeMessagesForBlock(
273273
proc getBeaconBlockValidatorChanges*(
274274
pool: var ValidatorChangePool, cfg: RuntimeConfig, state: ForkyBeaconState):
275275
BeaconBlockValidatorChanges =
276-
var
277-
indices: HashSet[uint64]
278-
res: BeaconBlockValidatorChanges
279-
280-
getValidatorChangeMessagesForBlock(
281-
pool.phase0_attester_slashings, cfg, state, indices,
282-
res.phase0_attester_slashings)
283-
getValidatorChangeMessagesForBlock(
284-
pool.proposer_slashings, cfg, state, indices, res.proposer_slashings)
285-
getValidatorChangeMessagesForBlock(
286-
pool.voluntary_exits, cfg, state, indices, res.voluntary_exits)
287-
288-
when typeof(state).kind >= ConsensusFork.Capella:
289-
# Prioritize these
276+
var res: BeaconBlockValidatorChanges
277+
278+
# Exits (with priority on slashings)
279+
block:
280+
var indices: HashSet[uint64]
281+
when typeof(state).kind >= ConsensusFork.Electra:
282+
getValidatorChangeMessagesForBlock(
283+
pool.electra_attester_slashings, cfg, state, indices,
284+
res.electra_attester_slashings)
285+
else:
286+
getValidatorChangeMessagesForBlock(
287+
pool.phase0_attester_slashings, cfg, state, indices,
288+
res.phase0_attester_slashings)
290289
getValidatorChangeMessagesForBlock(
291-
pool.bls_to_execution_changes_api, cfg, state, indices,
292-
res.bls_to_execution_changes)
293-
290+
pool.proposer_slashings, cfg, state, indices, res.proposer_slashings)
294291
getValidatorChangeMessagesForBlock(
295-
pool.bls_to_execution_changes_gossip, cfg, state, indices,
296-
res.bls_to_execution_changes)
292+
pool.voluntary_exits, cfg, state, indices, res.voluntary_exits)
297293

298-
when typeof(state).kind >= ConsensusFork.Electra:
299-
getValidatorChangeMessagesForBlock(
300-
pool.electra_attester_slashings, cfg, state, indices,
301-
res.electra_attester_slashings)
294+
# Credential changes (can be combined with exit)
295+
when typeof(state).kind >= ConsensusFork.Capella:
296+
block:
297+
var indices: HashSet[uint64]
298+
# Prioritize those from API
299+
getValidatorChangeMessagesForBlock(
300+
pool.bls_to_execution_changes_api, cfg, state, indices,
301+
res.bls_to_execution_changes)
302+
getValidatorChangeMessagesForBlock(
303+
pool.bls_to_execution_changes_gossip, cfg, state, indices,
304+
res.bls_to_execution_changes)
302305

303306
res

0 commit comments

Comments
 (0)