Cache validator registration only after successful publish (#7034)

This commit is contained in:
realbigsean
2025-02-24 21:00:51 -08:00
committed by GitHub
parent cf4104abe5
commit 8a772520a5

View File

@@ -428,7 +428,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
pubkey, pubkey,
} = key.clone(); } = key.clone();
let signed_data = match self match self
.validator_store .validator_store
.sign_validator_registration_data(ValidatorRegistrationData { .sign_validator_registration_data(ValidatorRegistrationData {
fee_recipient, fee_recipient,
@@ -458,13 +458,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
); );
continue; continue;
} }
}; }
self.validator_registration_cache
.write()
.insert(key, signed_data.clone());
signed_data
}; };
signed.push(signed_data); signed.push(signed_data);
} }
@@ -478,11 +472,20 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
}) })
.await .await
{ {
Ok(()) => info!( Ok(()) => {
log, info!(
"Published validator registrations to the builder network"; log,
"count" => batch.len(), "Published validator registrations to the builder network";
), "count" => batch.len(),
);
let mut guard = self.validator_registration_cache.write();
for signed_data in batch {
guard.insert(
ValidatorRegistrationKey::from(signed_data.message.clone()),
signed_data.clone(),
);
}
}
Err(e) => warn!( Err(e) => warn!(
log, log,
"Unable to publish validator registrations to the builder network"; "Unable to publish validator registrations to the builder network";