mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 17:26:04 +00:00
Reduce big-O complexity of address change pruning
I'm not sure this is *actually* useful, but it might come in handy if we see a ton of address changes at the fork boundary. I know the devops team have been testing with ~100k changes, so maybe this will help in that case.
This commit is contained in:
@@ -106,6 +106,16 @@ impl<T: EthSpec> BlsToExecutionChanges<T> {
|
|||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) {
|
) {
|
||||||
let mut validator_indices_pruned = vec![];
|
let mut validator_indices_pruned = vec![];
|
||||||
|
let recently_changed_indices: HashSet<u64> = head_block
|
||||||
|
.message()
|
||||||
|
.body()
|
||||||
|
.bls_to_execution_changes()
|
||||||
|
.map_or(HashSet::default(), |recent_changes| {
|
||||||
|
recent_changes
|
||||||
|
.iter()
|
||||||
|
.map(|c| c.message.validator_index)
|
||||||
|
.collect()
|
||||||
|
});
|
||||||
|
|
||||||
self.queue.retain(|address_change| {
|
self.queue.retain(|address_change| {
|
||||||
let validator_index = address_change.as_inner().message.validator_index;
|
let validator_index = address_change.as_inner().message.validator_index;
|
||||||
@@ -114,15 +124,7 @@ impl<T: EthSpec> BlsToExecutionChanges<T> {
|
|||||||
.get(validator_index as usize)
|
.get(validator_index as usize)
|
||||||
.map_or(true, |validator| {
|
.map_or(true, |validator| {
|
||||||
let prune = validator.has_eth1_withdrawal_credential(spec)
|
let prune = validator.has_eth1_withdrawal_credential(spec)
|
||||||
&& head_block
|
&& !recently_changed_indices.contains(&validator_index);
|
||||||
.message()
|
|
||||||
.body()
|
|
||||||
.bls_to_execution_changes()
|
|
||||||
.map_or(true, |recent_changes| {
|
|
||||||
!recent_changes
|
|
||||||
.iter()
|
|
||||||
.any(|c| c.message.validator_index == validator_index)
|
|
||||||
});
|
|
||||||
if prune {
|
if prune {
|
||||||
validator_indices_pruned.push(validator_index);
|
validator_indices_pruned.push(validator_index);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user