Skip to content

Commit 8a77252

Browse files
authored
Cache validator registration only after successful publish (#7034)
1 parent cf4104a commit 8a77252

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

validator_client/validator_services/src/preparation_service.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
428428
pubkey,
429429
} = key.clone();
430430

431-
let signed_data = match self
431+
match self
432432
.validator_store
433433
.sign_validator_registration_data(ValidatorRegistrationData {
434434
fee_recipient,
@@ -458,13 +458,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
458458
);
459459
continue;
460460
}
461-
};
462-
463-
self.validator_registration_cache
464-
.write()
465-
.insert(key, signed_data.clone());
466-
467-
signed_data
461+
}
468462
};
469463
signed.push(signed_data);
470464
}
@@ -478,11 +472,20 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
478472
})
479473
.await
480474
{
481-
Ok(()) => info!(
482-
log,
483-
"Published validator registrations to the builder network";
484-
"count" => batch.len(),
485-
),
475+
Ok(()) => {
476+
info!(
477+
log,
478+
"Published validator registrations to the builder network";
479+
"count" => batch.len(),
480+
);
481+
let mut guard = self.validator_registration_cache.write();
482+
for signed_data in batch {
483+
guard.insert(
484+
ValidatorRegistrationKey::from(signed_data.message.clone()),
485+
signed_data.clone(),
486+
);
487+
}
488+
}
486489
Err(e) => warn!(
487490
log,
488491
"Unable to publish validator registrations to the builder network";

0 commit comments

Comments
 (0)