Skip to content

Commit 904b2fd

Browse files
committed
chore: prepare removal of protocol params & ctx config from EpochSettingsMessage
This ensures that nodes built with this patch won't fails when thoses fields will be removed.
1 parent f57be30 commit 904b2fd

File tree

6 files changed

+63
-43
lines changed

6 files changed

+63
-43
lines changed
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1-
use mithril_common::entities::{
2-
CardanoTransactionsSigningConfig, Epoch, ProtocolParameters, Signer,
3-
};
1+
use mithril_common::entities::{Epoch, Signer};
42

53
/// LeaderAggregatorEpochSettings represents the settings of an epoch
64
#[derive(Clone, Debug, PartialEq)]
75
pub struct LeaderAggregatorEpochSettings {
86
/// Current Epoch
97
pub epoch: Epoch,
108

11-
/// Registration protocol parameters
12-
pub registration_protocol_parameters: ProtocolParameters,
13-
149
/// Current Signers
1510
pub current_signers: Vec<Signer>,
1611

1712
/// Signers that will be able to sign on the next epoch
1813
pub next_signers: Vec<Signer>,
19-
20-
/// Cardano transactions signing configuration for the current epoch
21-
pub cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,
2214
}

mithril-aggregator/src/message_adapters/from_epoch_settings.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ impl TryFromMessageAdapter<EpochSettingsMessage, LeaderAggregatorEpochSettings>
1616
fn try_adapt(message: EpochSettingsMessage) -> StdResult<LeaderAggregatorEpochSettings> {
1717
let epoch_settings = LeaderAggregatorEpochSettings {
1818
epoch: message.epoch,
19-
registration_protocol_parameters: message.signer_registration_protocol_parameters,
2019
current_signers: SignerMessagePart::try_into_signers(message.current_signers)
2120
.with_context(|| "'FromMessageAdapter' can not convert the current signers")?,
2221
next_signers: SignerMessagePart::try_into_signers(message.next_signers)
2322
.with_context(|| "'FromMessageAdapter' can not convert the next signers")?,
24-
cardano_transactions_signing_config: message.cardano_transactions_signing_config,
2523
};
2624

2725
Ok(epoch_settings)

mithril-aggregator/src/services/message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl MessageService for MithrilMessageService {
185185

186186
let epoch_settings_message = EpochSettingsMessage {
187187
epoch,
188-
signer_registration_protocol_parameters,
188+
signer_registration_protocol_parameters: Some(signer_registration_protocol_parameters),
189189
current_signers: SignerMessagePart::from_signers(current_signers.to_vec()),
190190
next_signers: SignerMessagePart::from_signers(next_signers.to_vec()),
191191
cardano_transactions_signing_config,
@@ -536,7 +536,7 @@ mod tests {
536536
assert_eq!(message.epoch, Epoch(4));
537537
assert_eq!(
538538
message.signer_registration_protocol_parameters,
539-
ProtocolParameters::new(5, 100, 0.65)
539+
Some(ProtocolParameters::new(5, 100, 0.65))
540540
);
541541
assert_eq!(message.current_signers.len(), 3);
542542
assert_eq!(message.next_signers.len(), 3);
@@ -620,7 +620,7 @@ mod tests {
620620

621621
assert_eq!(
622622
message.signer_registration_protocol_parameters,
623-
signer_registration_epoch_settings.protocol_parameters
623+
Some(signer_registration_epoch_settings.protocol_parameters)
624624
);
625625
}
626626

mithril-aggregator/src/test/double/dummies.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,13 @@ mod entities {
6767
impl Dummy for LeaderAggregatorEpochSettings {
6868
/// Create a dummy `LeaderAggregatorEpochSettings`
6969
fn dummy() -> Self {
70-
// Beacon
7170
let beacon = fake_data::beacon();
72-
73-
// Registration protocol parameters
74-
let registration_protocol_parameters = fake_data::protocol_parameters();
75-
76-
// Signers
7771
let signers = fake_data::signers(5);
78-
let current_signers = signers[1..3].to_vec();
79-
let next_signers = signers[2..5].to_vec();
8072

81-
// Cardano transactions signing configuration
82-
let cardano_transactions_signing_config =
83-
Some(CardanoTransactionsSigningConfig::dummy());
84-
85-
// Signer Epoch settings
8673
LeaderAggregatorEpochSettings {
8774
epoch: beacon.epoch,
88-
registration_protocol_parameters,
89-
current_signers,
90-
next_signers,
91-
cardano_transactions_signing_config,
75+
current_signers: signers[1..3].to_vec(),
76+
next_signers: signers[2..5].to_vec(),
9277
}
9378
}
9479
}

mithril-common/src/messages/epoch_settings.rs

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ pub struct EpochSettingsMessage {
99
pub epoch: Epoch,
1010

1111
/// Signer Registration Protocol parameters
12-
#[serde(rename = "signer_registration_protocol")]
13-
pub signer_registration_protocol_parameters: ProtocolParameters,
12+
#[serde(
13+
rename = "signer_registration_protocol",
14+
skip_serializing_if = "Option::is_none"
15+
)]
16+
pub signer_registration_protocol_parameters: Option<ProtocolParameters>,
1417

1518
/// Current Signers
1619
pub current_signers: Vec<SignerMessagePart>,
@@ -25,7 +28,6 @@ pub struct EpochSettingsMessage {
2528

2629
#[cfg(test)]
2730
mod tests {
28-
2931
use crate::entities::BlockNumber;
3032

3133
use super::*;
@@ -56,21 +58,27 @@ mod tests {
5658
#[derive(Debug, Serialize, Deserialize, PartialEq)]
5759
struct EpochSettingsMessageUntilV0_1_51 {
5860
pub epoch: Epoch,
59-
6061
#[serde(rename = "signer_registration_protocol")]
6162
pub signer_registration_protocol_parameters: ProtocolParameters,
62-
6363
pub current_signers: Vec<SignerMessagePart>,
64-
6564
pub next_signers: Vec<SignerMessagePart>,
66-
6765
#[serde(skip_serializing_if = "Option::is_none")]
6866
pub cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,
69-
7067
#[serde(skip_serializing_if = "Option::is_none")]
7168
pub next_cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,
7269
}
7370

71+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
72+
pub struct EpochSettingsMessageUntilV0_1_55 {
73+
pub epoch: Epoch,
74+
#[serde(rename = "signer_registration_protocol")]
75+
pub signer_registration_protocol_parameters: ProtocolParameters,
76+
pub current_signers: Vec<SignerMessagePart>,
77+
pub next_signers: Vec<SignerMessagePart>,
78+
#[serde(skip_serializing_if = "Option::is_none")]
79+
pub cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,
80+
}
81+
7482
fn golden_message_until_open_api_0_1_51() -> EpochSettingsMessageUntilV0_1_51 {
7583
EpochSettingsMessageUntilV0_1_51 {
7684
epoch: Epoch(10),
@@ -101,8 +109,8 @@ mod tests {
101109
}
102110
}
103111

104-
fn golden_current_message() -> EpochSettingsMessage {
105-
EpochSettingsMessage {
112+
fn golden_message_until_open_api_0_1_55() -> EpochSettingsMessageUntilV0_1_55 {
113+
EpochSettingsMessageUntilV0_1_55 {
106114
epoch: Epoch(10),
107115
signer_registration_protocol_parameters: ProtocolParameters {
108116
k: 500,
@@ -130,6 +138,35 @@ mod tests {
130138
}
131139
}
132140

141+
fn golden_current_message() -> EpochSettingsMessage {
142+
EpochSettingsMessage {
143+
epoch: Epoch(10),
144+
signer_registration_protocol_parameters: Some(ProtocolParameters {
145+
k: 500,
146+
m: 10000,
147+
phi_f: 0.65,
148+
}),
149+
current_signers: vec![SignerMessagePart {
150+
party_id: "123".to_string(),
151+
verification_key: "key_123".to_string(),
152+
verification_key_signature: Some("signature_123".to_string()),
153+
operational_certificate: Some("certificate_123".to_string()),
154+
kes_period: Some(12),
155+
}],
156+
next_signers: vec![SignerMessagePart {
157+
party_id: "456".to_string(),
158+
verification_key: "key_456".to_string(),
159+
verification_key_signature: Some("signature_456".to_string()),
160+
operational_certificate: Some("certificate_456".to_string()),
161+
kes_period: Some(45),
162+
}],
163+
cardano_transactions_signing_config: Some(CardanoTransactionsSigningConfig {
164+
security_parameter: BlockNumber(70),
165+
step: BlockNumber(20),
166+
}),
167+
}
168+
}
169+
133170
#[test]
134171
fn test_current_json_deserialized_into_message_supported_until_open_api_0_1_51() {
135172
let json = CURRENT_JSON;
@@ -138,6 +175,14 @@ mod tests {
138175
assert_eq!(golden_message_until_open_api_0_1_51(), message);
139176
}
140177

178+
#[test]
179+
fn test_current_json_deserialized_into_message_supported_until_open_api_0_1_55() {
180+
let json = CURRENT_JSON;
181+
let message: EpochSettingsMessageUntilV0_1_55 = serde_json::from_str(json).unwrap();
182+
183+
assert_eq!(golden_message_until_open_api_0_1_55(), message);
184+
}
185+
141186
#[test]
142187
fn test_current_json_deserialized_into_current_message() {
143188
let json = CURRENT_JSON;

mithril-common/src/test/double/dummies.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,11 @@ mod messages {
408408
fn dummy() -> Self {
409409
Self {
410410
epoch: Epoch(10),
411-
signer_registration_protocol_parameters: ProtocolParameters {
411+
signer_registration_protocol_parameters: Some(ProtocolParameters {
412412
k: 5,
413413
m: 100,
414414
phi_f: 0.65,
415-
},
415+
}),
416416
current_signers: [SignerMessagePart::dummy()].to_vec(),
417417
next_signers: [SignerMessagePart::dummy()].to_vec(),
418418
cardano_transactions_signing_config: Some(CardanoTransactionsSigningConfig::dummy()),

0 commit comments

Comments
 (0)