Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: rename protocol parameters for consistency in signer and aggregator #2058

Merged
merged 15 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod tests {
..AggregatorEpochSettings::dummy()
};
let epoch_service = FakeEpochServiceBuilder {
epoch_settings: epoch_settings.clone(),
current_epoch_settings: epoch_settings.clone(),
current_signers_with_stake: signers_with_stake.clone(),
next_signers_with_stake: signers_with_stake.clone(),
..FakeEpochServiceBuilder::dummy(Epoch(1))
Expand Down
35 changes: 25 additions & 10 deletions mithril-aggregator/src/http_server/routes/epoch_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ async fn get_epoch_settings_message(
let epoch_service = epoch_service.read().await;

let epoch = epoch_service.epoch_of_current_data()?;
let protocol_parameters = epoch_service.next_protocol_parameters()?.clone();
let next_protocol_parameters = epoch_service.upcoming_protocol_parameters()?.clone();
let protocol_parameters = Some(epoch_service.next_protocol_parameters()?.clone());
let signer_registration_protocol_parameters = epoch_service
.signer_registration_protocol_parameters()?
.clone();
let next_protocol_parameters = Some(signer_registration_protocol_parameters.clone());
let current_signers = epoch_service.current_signers()?;
let next_signers = epoch_service.next_signers()?;

Expand All @@ -55,10 +58,12 @@ async fn get_epoch_settings_message(
.transpose()?
.cloned();

#[allow(deprecated)]
let epoch_settings_message = EpochSettingsMessage {
epoch,
protocol_parameters,
next_protocol_parameters,
signer_registration_protocol_parameters,
current_signers: SignerMessagePart::from_signers(current_signers.to_vec()),
next_signers: SignerMessagePart::from_signers(next_signers.to_vec()),
cardano_transactions_signing_config,
Expand Down Expand Up @@ -178,15 +183,15 @@ mod tests {
protocol_parameters: ProtocolParameters::new(102, 20, 0.5),
..AggregatorEpochSettings::dummy()
};
let upcoming_epoch_settings = AggregatorEpochSettings {
let signer_registration_epoch_settings = AggregatorEpochSettings {
protocol_parameters: ProtocolParameters::new(103, 30, 0.5),
..AggregatorEpochSettings::dummy()
};

let epoch_service = FakeEpochServiceBuilder {
epoch_settings: current_epoch_settings,
current_epoch_settings,
next_epoch_settings: next_epoch_settings.clone(),
upcoming_epoch_settings: upcoming_epoch_settings.clone(),
signer_registration_epoch_settings: signer_registration_epoch_settings.clone(),
current_signers_with_stake: fake_data::signers_with_stakes(5),
next_signers_with_stake: fake_data::signers_with_stakes(3),
..FakeEpochServiceBuilder::dummy(Epoch(1))
Expand All @@ -200,13 +205,23 @@ mod tests {
.await
.unwrap();

#[allow(deprecated)]
let message_protocol_parameters = message.protocol_parameters.unwrap();
assert_eq!(
message.protocol_parameters,
message_protocol_parameters,
next_epoch_settings.protocol_parameters
);

#[allow(deprecated)]
let message_next_protocol_parameters = message.next_protocol_parameters.unwrap();
assert_eq!(
message_next_protocol_parameters,
signer_registration_epoch_settings.protocol_parameters
);

assert_eq!(
message.next_protocol_parameters,
upcoming_epoch_settings.protocol_parameters
message.signer_registration_protocol_parameters,
signer_registration_epoch_settings.protocol_parameters
);
}

Expand All @@ -228,9 +243,9 @@ mod tests {
};

let epoch_service = FakeEpochServiceBuilder {
epoch_settings: current_epoch_settings.clone(),
current_epoch_settings: current_epoch_settings.clone(),
next_epoch_settings: next_epoch_settings.clone(),
upcoming_epoch_settings: AggregatorEpochSettings::dummy(),
signer_registration_epoch_settings: AggregatorEpochSettings::dummy(),
current_signers_with_stake: fake_data::signers_with_stakes(5),
next_signers_with_stake: fake_data::signers_with_stakes(3),
..FakeEpochServiceBuilder::dummy(Epoch(1))
Expand Down
4 changes: 2 additions & 2 deletions mithril-aggregator/src/multi_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ mod tests {
let multi_signer = MultiSignerImpl::new(
Arc::new(RwLock::new(
FakeEpochServiceBuilder {
epoch_settings: AggregatorEpochSettings {
current_epoch_settings: AggregatorEpochSettings {
protocol_parameters: fixture.protocol_parameters(),
..AggregatorEpochSettings::dummy()
},
next_epoch_settings: AggregatorEpochSettings {
protocol_parameters: next_fixture.protocol_parameters(),
..AggregatorEpochSettings::dummy()
},
upcoming_epoch_settings: AggregatorEpochSettings {
signer_registration_epoch_settings: AggregatorEpochSettings {
protocol_parameters: next_fixture.protocol_parameters(),
..AggregatorEpochSettings::dummy()
},
Expand Down
13 changes: 6 additions & 7 deletions mithril-aggregator/src/runtime/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,17 @@ impl AggregatorRunnerTrait for AggregatorRunner {
let protocol_parameters = epoch_service.next_protocol_parameters().with_context(|| {
format!("no current protocol parameters found for time point {time_point:?}")
})?;
let next_protocol_parameters =
epoch_service
.upcoming_protocol_parameters()
.with_context(|| {
format!("no next protocol parameters found for time point {time_point:?}")
})?;
let signer_registration_protocol_parameters = epoch_service
.signer_registration_protocol_parameters()
.with_context(|| {
format!("no signer registration protocol parameters found for time point {time_point:?}")
})?;

let pending_certificate = CertificatePending::new(
time_point.epoch,
signed_entity_type.to_owned(),
protocol_parameters.clone(),
next_protocol_parameters.clone(),
signer_registration_protocol_parameters.clone(),
Signer::vec_from(signers.clone()),
Signer::vec_from(next_signers.clone()),
);
Expand Down
Loading