Skip to content

Commit 39aa220

Browse files
committed
refactor(signer): Remove AggregatorClient::retrieve_aggregator_features
As it was supersed by the mithril network configuration and have now no usage even in tests.
1 parent 7584085 commit 39aa220

File tree

3 files changed

+8
-95
lines changed

3 files changed

+8
-95
lines changed
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use async_trait::async_trait;
22

33
use mithril_aggregator_client::AggregatorHttpClient;
4-
use mithril_aggregator_client::query::{GetAggregatorFeaturesQuery, GetEpochSettingsQuery};
5-
use mithril_common::{
6-
StdResult,
7-
messages::{AggregatorFeaturesMessage, TryFromMessageAdapter},
8-
};
4+
use mithril_aggregator_client::query::GetEpochSettingsQuery;
5+
use mithril_common::{StdResult, messages::TryFromMessageAdapter};
96

107
use crate::entities::SignerEpochSettings;
118
use crate::message_adapters::FromEpochSettingsAdapter;
@@ -16,9 +13,6 @@ use crate::message_adapters::FromEpochSettingsAdapter;
1613
pub trait AggregatorClient: Sync + Send {
1714
/// Retrieves epoch settings from the aggregator
1815
async fn retrieve_epoch_settings(&self) -> StdResult<Option<SignerEpochSettings>>;
19-
20-
/// Retrieves aggregator features message from the aggregator
21-
async fn retrieve_aggregator_features(&self) -> StdResult<AggregatorFeaturesMessage>;
2216
}
2317

2418
#[async_trait]
@@ -29,11 +23,6 @@ impl AggregatorClient for AggregatorHttpClient {
2923

3024
Ok(Some(epoch_settings))
3125
}
32-
33-
async fn retrieve_aggregator_features(&self) -> StdResult<AggregatorFeaturesMessage> {
34-
let aggregator_features = self.send(GetAggregatorFeaturesQuery::current()).await?;
35-
Ok(aggregator_features)
36-
}
3726
}
3827

3928
#[cfg(test)]
@@ -48,14 +37,12 @@ pub(crate) mod dumb {
4837
/// It is driven by a Tester that controls the data it can return, and it can return its internal state for testing.
4938
pub struct DumbAggregatorClient {
5039
epoch_settings: RwLock<Option<SignerEpochSettings>>,
51-
aggregator_features: RwLock<AggregatorFeaturesMessage>,
5240
}
5341

5442
impl Default for DumbAggregatorClient {
5543
fn default() -> Self {
5644
Self {
5745
epoch_settings: RwLock::new(Some(SignerEpochSettings::dummy())),
58-
aggregator_features: RwLock::new(AggregatorFeaturesMessage::dummy()),
5946
}
6047
}
6148
}
@@ -67,10 +54,5 @@ pub(crate) mod dumb {
6754

6855
Ok(epoch_settings)
6956
}
70-
71-
async fn retrieve_aggregator_features(&self) -> StdResult<AggregatorFeaturesMessage> {
72-
let aggregator_features = self.aggregator_features.read().await;
73-
Ok(aggregator_features.clone())
74-
}
7557
}
7658
}

mithril-signer/tests/test_extensions/certificate_handler.rs

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
use async_trait::async_trait;
2-
use std::collections::BTreeSet;
32
use std::{collections::HashMap, sync::Arc};
43
use tokio::sync::RwLock;
54

65
use mithril_common::{
76
StdResult,
8-
entities::{
9-
CardanoTransactionsSigningConfig, Epoch, ProtocolMessage, SignedEntityConfig,
10-
SignedEntityType, SignedEntityTypeDiscriminants, Signer, SingleSignature, TimePoint,
11-
},
12-
messages::AggregatorFeaturesMessage,
7+
entities::{Epoch, ProtocolMessage, SignedEntityType, Signer, SingleSignature, TimePoint},
138
test::double::Dummy,
149
};
1510
use mithril_ticker::{MithrilTickerService, TickerService};
@@ -18,19 +13,14 @@ use mithril_signer::services::{SignaturePublisher, SignerRegistrationPublisher};
1813
use mithril_signer::{entities::SignerEpochSettings, services::AggregatorClient};
1914

2015
pub struct FakeAggregator {
21-
signed_entity_config: RwLock<SignedEntityConfig>,
2216
registered_signers: RwLock<HashMap<Epoch, Vec<Signer>>>,
2317
ticker_service: Arc<MithrilTickerService>,
2418
withhold_epoch_settings: RwLock<bool>,
2519
}
2620

2721
impl FakeAggregator {
28-
pub fn new(
29-
signed_entity_config: SignedEntityConfig,
30-
ticker_service: Arc<MithrilTickerService>,
31-
) -> Self {
22+
pub fn new(ticker_service: Arc<MithrilTickerService>) -> Self {
3223
Self {
33-
signed_entity_config: RwLock::new(signed_entity_config),
3424
registered_signers: RwLock::new(HashMap::new()),
3525
ticker_service,
3626
withhold_epoch_settings: RwLock::new(true),
@@ -47,14 +37,6 @@ impl FakeAggregator {
4737
*settings = false;
4838
}
4939

50-
pub async fn change_allowed_discriminants(
51-
&self,
52-
discriminants: &BTreeSet<SignedEntityTypeDiscriminants>,
53-
) {
54-
let mut signed_entity_config = self.signed_entity_config.write().await;
55-
signed_entity_config.allowed_discriminants = discriminants.clone();
56-
}
57-
5840
async fn get_time_point(&self) -> StdResult<TimePoint> {
5941
let time_point = self.ticker_service.get_current_time_point().await?;
6042
Ok(time_point)
@@ -123,16 +105,6 @@ impl AggregatorClient for FakeAggregator {
123105
}))
124106
}
125107
}
126-
127-
async fn retrieve_aggregator_features(&self) -> StdResult<AggregatorFeaturesMessage> {
128-
let signed_entity_config = self.signed_entity_config.read().await;
129-
130-
let mut message = AggregatorFeaturesMessage::dummy();
131-
message.capabilities.signed_entity_types =
132-
signed_entity_config.allowed_discriminants.clone();
133-
134-
Ok(message)
135-
}
136108
}
137109

138110
#[cfg(test)]
@@ -158,10 +130,7 @@ mod tests {
158130
immutable_observer.clone(),
159131
));
160132

161-
(
162-
chain_observer,
163-
FakeAggregator::new(SignedEntityConfig::dummy(), ticker_service),
164-
)
133+
(chain_observer, FakeAggregator::new(ticker_service))
165134
}
166135

167136
#[tokio::test]
@@ -249,35 +218,4 @@ mod tests {
249218
assert_eq!(2, epoch_settings.current_signers.len());
250219
assert_eq!(1, epoch_settings.next_signers.len());
251220
}
252-
253-
#[tokio::test]
254-
async fn retrieve_aggregator_features() {
255-
let (_chain_observer, fake_aggregator) = init().await;
256-
257-
{
258-
let mut signing_config = fake_aggregator.signed_entity_config.write().await;
259-
signing_config.allowed_discriminants = SignedEntityTypeDiscriminants::all();
260-
signing_config.cardano_transactions_signing_config =
261-
CardanoTransactionsSigningConfig::dummy();
262-
}
263-
264-
let features = fake_aggregator.retrieve_aggregator_features().await.unwrap();
265-
assert_eq!(
266-
&SignedEntityTypeDiscriminants::all(),
267-
&features.capabilities.signed_entity_types,
268-
);
269-
270-
let new_discriminants = BTreeSet::from([
271-
SignedEntityTypeDiscriminants::CardanoTransactions,
272-
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
273-
]);
274-
275-
fake_aggregator.change_allowed_discriminants(&new_discriminants).await;
276-
277-
let updated_features = fake_aggregator.retrieve_aggregator_features().await.unwrap();
278-
assert_eq!(
279-
&new_discriminants,
280-
&updated_features.capabilities.signed_entity_types,
281-
);
282-
}
283221
}

mithril-signer/tests/test_extensions/state_machine_tester.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ use mithril_common::{
3434
api_version::APIVersionProvider,
3535
crypto_helper::{KesSigner, KesSignerStandard},
3636
entities::{
37-
BlockNumber, CardanoTransactionsSigningConfig, ChainPoint, Epoch, SignedEntityConfig,
38-
SignedEntityType, SignedEntityTypeDiscriminants, SignerWithStake, SlotNumber, SupportedEra,
39-
TimePoint,
37+
BlockNumber, CardanoTransactionsSigningConfig, ChainPoint, Epoch, SignedEntityType,
38+
SignedEntityTypeDiscriminants, SignerWithStake, SlotNumber, SupportedEra, TimePoint,
4039
},
4140
signable_builder::{
4241
CardanoStakeDistributionSignableBuilder, CardanoTransactionsSignableBuilder,
@@ -167,13 +166,7 @@ impl StateMachineTester {
167166
security_parameter: BlockNumber(0),
168167
step: BlockNumber(30),
169168
};
170-
let certificate_handler = Arc::new(FakeAggregator::new(
171-
SignedEntityConfig {
172-
allowed_discriminants: SignedEntityTypeDiscriminants::all(),
173-
cardano_transactions_signing_config: cardano_transactions_signing_config.clone(),
174-
},
175-
ticker_service.clone(),
176-
));
169+
let certificate_handler = Arc::new(FakeAggregator::new(ticker_service.clone()));
177170

178171
let configuration_for_aggregation = MithrilNetworkConfigurationForEpoch {
179172
signed_entity_types_config: SignedEntityTypeConfiguration {

0 commit comments

Comments
 (0)