Skip to content

Commit

Permalink
Cache validator registration only after successful publish (#7034)
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean authored Feb 25, 2025
1 parent cf4104a commit 8a77252
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions validator_client/validator_services/src/preparation_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
pubkey,
} = key.clone();

let signed_data = match self
match self
.validator_store
.sign_validator_registration_data(ValidatorRegistrationData {
fee_recipient,
Expand Down Expand Up @@ -458,13 +458,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
);
continue;
}
};

self.validator_registration_cache
.write()
.insert(key, signed_data.clone());

signed_data
}
};
signed.push(signed_data);
}
Expand All @@ -478,11 +472,20 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
})
.await
{
Ok(()) => info!(
log,
"Published validator registrations to the builder network";
"count" => batch.len(),
),
Ok(()) => {
info!(
log,
"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!(
log,
"Unable to publish validator registrations to the builder network";
Expand Down

0 comments on commit 8a77252

Please sign in to comment.