Skip to content

Commit bc2e5d5

Browse files
committed
WIP: using mithril network configuration provider in EPoch Service
1 parent 3f97072 commit bc2e5d5

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

mithril-aggregator/src/dependency_injection/builder/enablers/epoch.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ impl DependenciesBuilder {
1111
let chain_observer = self.get_chain_observer().await?;
1212
let era_checker = self.get_era_checker().await?;
1313
let stake_store = self.get_stake_store().await?;
14+
//remove conf usage for epoch_settings and allowed_discriminants and send mithril_network_configuration instread
1415
let epoch_settings = self.configuration.get_epoch_settings_configuration();
1516
let allowed_discriminants = self
1617
.configuration
1718
.compute_allowed_signed_entity_types_discriminants()?;
1819

20+
let network_configuration_provider = self.get_mithril_network_configuration_provider();
1921
let epoch_service = Arc::new(RwLock::new(MithrilEpochService::new(
20-
epoch_settings,
22+
network_configuration_provider,
2123
EpochServiceDependencies::new(
2224
epoch_settings_storer,
2325
verification_key_store,

mithril-aggregator/src/services/epoch_service.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use anyhow::{Context, anyhow};
22
use async_trait::async_trait;
3+
use mithril_protocol_config::interface::MithrilNetworkConfigurationProvider;
34
use slog::{Logger, debug};
45
use std::collections::BTreeSet;
56
use std::sync::Arc;
@@ -180,7 +181,8 @@ impl EpochServiceDependencies {
180181
/// Implementation of the [epoch service][EpochService].
181182
pub struct MithrilEpochService {
182183
/// Epoch settings that will be inserted when inform_epoch is called
183-
future_epoch_settings: AggregatorEpochSettings,
184+
//future_epoch_settings: AggregatorEpochSettings,
185+
mithril_network_configuration_provider: Arc<dyn MithrilNetworkConfigurationProvider>,
184186
epoch_data: Option<EpochData>,
185187
computed_epoch_data: Option<ComputedEpochData>,
186188
epoch_settings_storer: Arc<dyn EpochSettingsStorer>,
@@ -195,13 +197,15 @@ pub struct MithrilEpochService {
195197
impl MithrilEpochService {
196198
/// Create a new service instance
197199
pub fn new(
198-
future_epoch_settings: AggregatorEpochSettings,
200+
//future_epoch_settings: AggregatorEpochSettings,
201+
mithril_network_configuration_provider: Arc<dyn MithrilNetworkConfigurationProvider>,
199202
dependencies: EpochServiceDependencies,
200203
allowed_discriminants: BTreeSet<SignedEntityTypeDiscriminants>,
201204
logger: Logger,
202205
) -> Self {
203206
Self {
204-
future_epoch_settings,
207+
//future_epoch_settings,
208+
mithril_network_configuration_provider,
205209
epoch_data: None,
206210
computed_epoch_data: None,
207211
epoch_settings_storer: dependencies.epoch_settings_storer,
@@ -266,15 +270,31 @@ impl MithrilEpochService {
266270
async fn insert_future_epoch_settings(&self, actual_epoch: Epoch) -> StdResult<()> {
267271
let recording_epoch = actual_epoch.offset_to_epoch_settings_recording_epoch();
268272

269-
debug!(
273+
/* debug!(
270274
self.logger, "Inserting epoch settings in epoch {recording_epoch}";
271275
"epoch_settings" => ?self.future_epoch_settings
272-
);
276+
); */
277+
278+
let network_configuration = self
279+
.mithril_network_configuration_provider
280+
.get_network_configuration()
281+
.await?;
273282

283+
let aggregator_epoch_settings = AggregatorEpochSettings {
284+
protocol_parameters: network_configuration
285+
.signer_registration_protocol_parameters
286+
.clone(),
287+
cardano_transactions_signing_config: network_configuration
288+
.signed_entity_types_config
289+
.cardano_transactions
290+
.clone()
291+
.unwrap(),
292+
};
274293
self.epoch_settings_storer
275294
.save_epoch_settings(
276295
recording_epoch,
277-
self.future_epoch_settings.clone(),
296+
/* self.future_epoch_settings.clone(), */
297+
aggregator_epoch_settings
278298
)
279299
.await
280300
.with_context(|| format!("Epoch service failed to insert future_epoch_settings to epoch {recording_epoch}"))

0 commit comments

Comments
 (0)