Skip to content

Commit 86ac0fc

Browse files
committed
refactor(signer): use new shared aggregator client
instead of an internal implementation
1 parent c2c51b1 commit 86ac0fc

File tree

6 files changed

+61
-1330
lines changed

6 files changed

+61
-1330
lines changed

mithril-signer/src/dependency_injection/builder.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ use crate::dependency_injection::SignerDependencyContainer;
5151
#[cfg(feature = "future_dmq")]
5252
use crate::services::SignaturePublisherDmq;
5353
use crate::services::{
54-
AggregatorHTTPClient, CardanoTransactionsImporter,
55-
CardanoTransactionsPreloaderActivationSigner, MithrilEpochService, MithrilSingleSigner,
56-
SignaturePublishRetryPolicy, SignaturePublisherDelayer, SignaturePublisherNoop,
57-
SignaturePublisherRetrier, SignerCertifierService, SignerSignableSeedBuilder,
58-
SignerSignedEntityConfigProvider, SignerUpkeepService, TransactionsImporterByChunk,
59-
TransactionsImporterWithPruner, TransactionsImporterWithVacuum,
54+
CardanoTransactionsImporter, CardanoTransactionsPreloaderActivationSigner, MithrilEpochService,
55+
MithrilSingleSigner, SignaturePublishRetryPolicy, SignaturePublisherDelayer,
56+
SignaturePublisherNoop, SignaturePublisherRetrier, SignerCertifierService,
57+
SignerSignableSeedBuilder, SignerSignedEntityConfigProvider, SignerUpkeepService,
58+
TransactionsImporterByChunk, TransactionsImporterWithPruner, TransactionsImporterWithVacuum,
6059
};
6160
use crate::store::MKTreeStoreSqlite;
6261
use crate::{
@@ -270,21 +269,14 @@ impl<'a> DependenciesBuilder<'a> {
270269
));
271270

272271
let api_version_provider = Arc::new(APIVersionProvider::new(era_checker.clone()));
273-
let aggregator_client_for_network_config = Arc::new(
272+
let aggregator_client = Arc::new(
274273
AggregatorHttpClient::builder(self.config.aggregator_endpoint.clone())
275274
.with_relay_endpoint(self.config.relay_endpoint.clone())
276275
.with_api_version_provider(api_version_provider.clone())
277276
.with_timeout(Duration::from_millis(HTTP_REQUEST_TIMEOUT_DURATION))
278277
.with_logger(self.root_logger())
279278
.build()?,
280279
);
281-
let aggregator_client = Arc::new(AggregatorHTTPClient::new(
282-
self.config.aggregator_endpoint.clone(),
283-
self.config.relay_endpoint.clone(),
284-
api_version_provider.clone(),
285-
Some(Duration::from_millis(HTTP_REQUEST_TIMEOUT_DURATION)),
286-
self.root_logger(),
287-
));
288280

289281
let cardano_immutable_snapshot_builder =
290282
Arc::new(CardanoImmutableFilesFullSignableBuilder::new(
@@ -385,7 +377,7 @@ impl<'a> DependenciesBuilder<'a> {
385377
));
386378
let metrics_service = Arc::new(MetricsService::new(self.root_logger())?);
387379
let network_configuration_service = Arc::new(HttpMithrilNetworkConfigurationProvider::new(
388-
aggregator_client_for_network_config,
380+
aggregator_client.clone(),
389381
));
390382
let preloader_activation = CardanoTransactionsPreloaderActivationSigner::new(
391383
network_configuration_service.clone(),

mithril-signer/src/runtime/runner.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ impl Runner for SignerRunner {
134134
) -> StdResult<Option<SignerEpochSettings>> {
135135
debug!(self.logger, ">> get_epoch_settings");
136136

137-
self.services
138-
.certificate_handler
139-
.retrieve_epoch_settings()
140-
.await
141-
.map_err(|e| e.into())
137+
self.services.certificate_handler.retrieve_epoch_settings().await
142138
}
143139

144140
async fn get_beacon_to_sign(&self, time_point: TimePoint) -> StdResult<Option<BeaconToSign>> {

mithril-signer/src/runtime/state_machine.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ use mithril_common::{
1010
logging::LoggerExtensions,
1111
};
1212

13+
use mithril_aggregator_client::AggregatorHttpClientError;
1314
use mithril_protocol_config::model::MithrilNetworkConfiguration;
1415

15-
use crate::{MetricsService, entities::BeaconToSign, services::AggregatorClientError};
16+
use crate::{MetricsService, entities::BeaconToSign};
1617

1718
use super::{Runner, RuntimeError};
1819

@@ -333,8 +334,8 @@ impl StateMachine {
333334
epoch: Epoch,
334335
) -> Result<Option<SignerState>, RuntimeError> {
335336
if let Err(e) = register_result {
336-
if let Some(AggregatorClientError::RegistrationRoundNotYetOpened(_)) =
337-
e.downcast_ref::<AggregatorClientError>()
337+
if let Some(AggregatorHttpClientError::RegistrationRoundNotYetOpened(_)) =
338+
e.downcast_ref::<AggregatorHttpClientError>()
338339
{
339340
Ok(Some(SignerState::Unregistered { epoch }))
340341
} else if e.downcast_ref::<ProtocolInitializerError>().is_some() {
@@ -497,7 +498,6 @@ mod tests {
497498

498499
use crate::SignerEpochSettings;
499500
use crate::runtime::runner::MockSignerRunner;
500-
use crate::services::AggregatorClientError;
501501
use crate::test_tools::TestLogger;
502502

503503
use super::*;
@@ -720,7 +720,7 @@ mod tests {
720720
.returning(|| Ok(TimePoint::dummy()));
721721
runner.expect_update_stake_distribution().once().returning(|_| Ok(()));
722722
runner.expect_register_signer_to_aggregator().once().returning(|| {
723-
Err(AggregatorClientError::RegistrationRoundNotYetOpened(
723+
Err(AggregatorHttpClientError::RegistrationRoundNotYetOpened(
724724
anyhow!("Not yet opened"),
725725
))?
726726
});

0 commit comments

Comments
 (0)