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 1 commit
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
6 changes: 4 additions & 2 deletions mithril-aggregator/src/http_server/routes/epoch_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ async fn get_epoch_settings_message(

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 signer_registration_protocol_parameters = epoch_service
.signer_registration_protocol_parameters()?
.clone();
let current_signers = epoch_service.current_signers()?;
let next_signers = epoch_service.next_signers()?;

Expand All @@ -58,7 +60,7 @@ async fn get_epoch_settings_message(
let epoch_settings_message = EpochSettingsMessage {
epoch,
protocol_parameters,
next_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
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
30 changes: 16 additions & 14 deletions mithril-aggregator/src/services/epoch_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ pub trait EpochService: Sync + Send {
/// Get the current epoch for which the data stored in this service are computed.
fn epoch_of_current_data(&self) -> StdResult<Epoch>;

/// Get protocol parameters used in current epoch (associated with the previous epoch)
/// Get protocol parameters used for signing the protocol message in the current epoch.
dlachaume marked this conversation as resolved.
Show resolved Hide resolved
fn current_protocol_parameters(&self) -> StdResult<&ProtocolParameters>;

/// Get next protocol parameters used in next epoch (associated with the actual epoch)
/// Get protocol parameters used for signing the protocol message in the next epoch.
dlachaume marked this conversation as resolved.
Show resolved Hide resolved
fn next_protocol_parameters(&self) -> StdResult<&ProtocolParameters>;

/// Get upcoming protocol parameters used in next epoch (associated with the next epoch)
fn upcoming_protocol_parameters(&self) -> StdResult<&ProtocolParameters>;
/// Get protocol parameters for signer registration.
fn signer_registration_protocol_parameters(&self) -> StdResult<&ProtocolParameters>;

/// Get cardano transactions signing configuration used in current epoch
fn current_cardano_transactions_signing_config(
Expand Down Expand Up @@ -330,7 +330,7 @@ impl EpochService for MithrilEpochService {
Ok(&self.unwrap_data()?.next_epoch_settings.protocol_parameters)
}

fn upcoming_protocol_parameters(&self) -> StdResult<&ProtocolParameters> {
fn signer_registration_protocol_parameters(&self) -> StdResult<&ProtocolParameters> {
Ok(&self
.unwrap_data()?
.upcoming_epoch_settings
Expand Down Expand Up @@ -581,7 +581,7 @@ impl EpochService for FakeEpochService {
Ok(&self.unwrap_data()?.next_epoch_settings.protocol_parameters)
}

fn upcoming_protocol_parameters(&self) -> StdResult<&ProtocolParameters> {
fn signer_registration_protocol_parameters(&self) -> StdResult<&ProtocolParameters> {
Ok(&self
.unwrap_data()?
.upcoming_epoch_settings
Expand Down Expand Up @@ -663,7 +663,7 @@ mod tests {
next_protocol_parameters: ProtocolParameters,
cardano_signing_config: CardanoTransactionsSigningConfig,
next_cardano_signing_config: CardanoTransactionsSigningConfig,
upcoming_protocol_parameters: ProtocolParameters,
signer_registration_protocol_parameters: ProtocolParameters,
current_signers_with_stake: BTreeSet<SignerWithStake>,
next_signers_with_stake: BTreeSet<SignerWithStake>,
current_signers: BTreeSet<Signer>,
Expand All @@ -683,7 +683,9 @@ mod tests {
epoch: service.epoch_of_current_data()?,
protocol_parameters: service.current_protocol_parameters()?.clone(),
next_protocol_parameters: service.next_protocol_parameters()?.clone(),
upcoming_protocol_parameters: service.upcoming_protocol_parameters()?.clone(),
signer_registration_protocol_parameters: service
.signer_registration_protocol_parameters()?
.clone(),
cardano_signing_config: service
.current_cardano_transactions_signing_config()?
.clone(),
Expand Down Expand Up @@ -817,7 +819,7 @@ mod tests {
.with_protocol_parameters(ProtocolParameters::new(8, 80, 0.80))
.with_signers(5)
.build();
let upcoming_protocol_parameters = fake_data::protocol_parameters();
let signer_registration_protocol_parameters = fake_data::protocol_parameters();

let epoch = Epoch(5);
let builder = EpochServiceBuilder {
Expand All @@ -827,7 +829,7 @@ mod tests {
..AggregatorEpochSettings::dummy()
},
stored_upcoming_epoch_settings: AggregatorEpochSettings {
protocol_parameters: upcoming_protocol_parameters.clone(),
protocol_parameters: signer_registration_protocol_parameters.clone(),
..AggregatorEpochSettings::dummy()
},
network: SignedEntityConfig::dummy().network,
Expand All @@ -852,7 +854,7 @@ mod tests {
epoch,
protocol_parameters: current_epoch_fixture.protocol_parameters(),
next_protocol_parameters: next_epoch_fixture.protocol_parameters(),
upcoming_protocol_parameters,
signer_registration_protocol_parameters,
cardano_signing_config: CardanoTransactionsSigningConfig::dummy(),
next_cardano_signing_config: CardanoTransactionsSigningConfig::dummy(),
current_signers_with_stake: current_epoch_fixture
Expand Down Expand Up @@ -1035,8 +1037,8 @@ mod tests {
service.next_protocol_parameters().err(),
),
(
"upcoming_protocol_parameters",
service.upcoming_protocol_parameters().err(),
"signer_registration_protocol_parameters",
service.signer_registration_protocol_parameters().err(),
),
(
"current_cardano_transactions_signing_config",
Expand Down Expand Up @@ -1094,7 +1096,7 @@ mod tests {
assert!(service.epoch_of_current_data().is_ok());
assert!(service.current_protocol_parameters().is_ok());
assert!(service.next_protocol_parameters().is_ok());
assert!(service.upcoming_protocol_parameters().is_ok());
assert!(service.signer_registration_protocol_parameters().is_ok());
assert!(service
.current_cardano_transactions_signing_config()
.is_ok());
Expand Down