1
- use crate :: entities:: { Epoch , ProtocolParameters } ;
1
+ use crate :: entities:: { CardanoTransactionsSigningConfig , Epoch , ProtocolParameters } ;
2
2
use crate :: messages:: SignerMessagePart ;
3
3
use serde:: { Deserialize , Serialize } ;
4
4
@@ -21,6 +21,10 @@ pub struct EpochSettingsMessage {
21
21
22
22
/// Signers that will be able to sign on the next epoch
23
23
pub next_signers : Vec < SignerMessagePart > ,
24
+
25
+ /// Cardano transactions signing configuration for the current epoch
26
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
27
+ pub current_cardano_transactions_signing_config : Option < CardanoTransactionsSigningConfig > ,
24
28
}
25
29
26
30
impl EpochSettingsMessage {
@@ -41,6 +45,7 @@ impl EpochSettingsMessage {
41
45
} ,
42
46
current_signers: [ SignerMessagePart :: dummy( ) ] . to_vec( ) ,
43
47
next_signers: [ SignerMessagePart :: dummy( ) ] . to_vec( ) ,
48
+ current_cardano_transactions_signing_config: None ,
44
49
}
45
50
}
46
51
}
@@ -49,6 +54,8 @@ impl EpochSettingsMessage {
49
54
#[ cfg( test) ]
50
55
mod tests {
51
56
57
+ use crate :: entities:: BlockNumber ;
58
+
52
59
use super :: * ;
53
60
54
61
const ACTUAL_JSON : & str = r#"{
@@ -68,10 +75,28 @@ mod tests {
68
75
"verification_key_signature":"signature_456",
69
76
"operational_certificate":"certificate_456",
70
77
"kes_period":45
71
- }]
78
+ }],
79
+ "current_cardano_transactions_signing_config": {
80
+ "security_parameter": 70,
81
+ "step": 20
82
+ }
72
83
73
84
}"# ;
74
85
86
+ #[ derive( Clone , Debug , PartialEq , Default , Serialize , Deserialize ) ]
87
+ pub struct EpochSettingsMessageLegacyVersion {
88
+ /// Current Epoch
89
+ pub epoch : Epoch ,
90
+
91
+ /// Current Protocol parameters
92
+ #[ serde( rename = "protocol" ) ]
93
+ pub protocol_parameters : ProtocolParameters ,
94
+
95
+ /// Next Protocol parameters
96
+ #[ serde( rename = "next_protocol" ) ]
97
+ pub next_protocol_parameters : ProtocolParameters ,
98
+ }
99
+
75
100
#[ derive( Clone , Debug , PartialEq , Default , Serialize , Deserialize ) ]
76
101
pub struct EpochSettingsMessagePreviousVersion {
77
102
/// Current Epoch
@@ -84,6 +109,28 @@ mod tests {
84
109
/// Next Protocol parameters
85
110
#[ serde( rename = "next_protocol" ) ]
86
111
pub next_protocol_parameters : ProtocolParameters ,
112
+
113
+ /// Current Signers
114
+ pub current_signers : Vec < SignerMessagePart > ,
115
+
116
+ /// Signers that will be able to sign on the next epoch
117
+ pub next_signers : Vec < SignerMessagePart > ,
118
+ }
119
+
120
+ fn golden_legacy_message ( ) -> EpochSettingsMessageLegacyVersion {
121
+ EpochSettingsMessageLegacyVersion {
122
+ epoch : Epoch ( 10 ) ,
123
+ protocol_parameters : ProtocolParameters {
124
+ k : 5 ,
125
+ m : 100 ,
126
+ phi_f : 0.65 ,
127
+ } ,
128
+ next_protocol_parameters : ProtocolParameters {
129
+ k : 50 ,
130
+ m : 1000 ,
131
+ phi_f : 0.65 ,
132
+ } ,
133
+ }
87
134
}
88
135
89
136
fn golden_previous_message ( ) -> EpochSettingsMessagePreviousVersion {
@@ -99,6 +146,20 @@ mod tests {
99
146
m : 1000 ,
100
147
phi_f : 0.65 ,
101
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
+ } ] ,
102
163
}
103
164
}
104
165
@@ -129,9 +190,24 @@ mod tests {
129
190
operational_certificate: Some ( "certificate_456" . to_string( ) ) ,
130
191
kes_period: Some ( 45 ) ,
131
192
} ] ,
193
+ current_cardano_transactions_signing_config : Some ( CardanoTransactionsSigningConfig {
194
+ security_parameter : BlockNumber ( 70 ) ,
195
+ step : BlockNumber ( 20 ) ,
196
+ } ) ,
132
197
}
133
198
}
134
199
200
+ // Test the backward compatibility with legacy structure.
201
+ #[ test]
202
+ fn test_actual_json_deserialized_into_legacy_message ( ) {
203
+ let json = ACTUAL_JSON ;
204
+ let message: EpochSettingsMessageLegacyVersion = serde_json:: from_str ( json) . expect (
205
+ "This JSON is expected to be successfully parsed into a EpochSettingsMessageLegacyVersion instance." ,
206
+ ) ;
207
+
208
+ assert_eq ! ( golden_legacy_message( ) , message) ;
209
+ }
210
+
135
211
// Test the backward compatibility with previous structure.
136
212
#[ test]
137
213
fn test_actual_json_deserialized_into_previous_message ( ) {
0 commit comments