@@ -71,7 +71,9 @@ MessageSlotID {
71
71
/// Block Response message from signers
72
72
BlockResponse = 1 ,
73
73
/// Signer State Machine Update
74
- StateMachineUpdate = 2
74
+ StateMachineUpdate = 2 ,
75
+ /// Block Pre-commit message from signers before they commit to a block response
76
+ BlockPreCommit = 3
75
77
} ) ;
76
78
77
79
define_u8_enum ! (
@@ -114,7 +116,9 @@ SignerMessageTypePrefix {
114
116
/// Mock block message from Epoch 2.5 miners
115
117
MockBlock = 5 ,
116
118
/// State machine update
117
- StateMachineUpdate = 6
119
+ StateMachineUpdate = 6 ,
120
+ /// Block Pre-commit message
121
+ BlockPreCommit = 7
118
122
} ) ;
119
123
120
124
#[ cfg_attr( test, mutants:: skip) ]
@@ -137,7 +141,7 @@ impl MessageSlotID {
137
141
#[ cfg_attr( test, mutants:: skip) ]
138
142
impl Display for MessageSlotID {
139
143
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
140
- write ! ( f, "{:?}({})" , self , self . to_u8( ) )
144
+ write ! ( f, "{self :?}({})" , self . to_u8( ) )
141
145
}
142
146
}
143
147
@@ -161,6 +165,7 @@ impl From<&SignerMessage> for SignerMessageTypePrefix {
161
165
SignerMessage :: MockSignature ( _) => SignerMessageTypePrefix :: MockSignature ,
162
166
SignerMessage :: MockBlock ( _) => SignerMessageTypePrefix :: MockBlock ,
163
167
SignerMessage :: StateMachineUpdate ( _) => SignerMessageTypePrefix :: StateMachineUpdate ,
168
+ SignerMessage :: BlockPreCommit ( _) => SignerMessageTypePrefix :: BlockPreCommit ,
164
169
}
165
170
}
166
171
}
@@ -182,6 +187,8 @@ pub enum SignerMessage {
182
187
MockBlock ( MockBlock ) ,
183
188
/// A state machine update
184
189
StateMachineUpdate ( StateMachineUpdate ) ,
190
+ /// The pre commit message from signers for other signers to observe
191
+ BlockPreCommit ( Sha512Trunc256Sum ) ,
185
192
}
186
193
187
194
impl SignerMessage {
@@ -197,6 +204,7 @@ impl SignerMessage {
197
204
| Self :: MockBlock ( _) => None ,
198
205
Self :: BlockResponse ( _) | Self :: MockSignature ( _) => Some ( MessageSlotID :: BlockResponse ) , // Mock signature uses the same slot as block response since its exclusively for epoch 2.5 testing
199
206
Self :: StateMachineUpdate ( _) => Some ( MessageSlotID :: StateMachineUpdate ) ,
207
+ Self :: BlockPreCommit ( _) => Some ( MessageSlotID :: BlockPreCommit ) ,
200
208
}
201
209
}
202
210
}
@@ -216,6 +224,9 @@ impl StacksMessageCodec for SignerMessage {
216
224
SignerMessage :: StateMachineUpdate ( state_machine_update) => {
217
225
state_machine_update. consensus_serialize ( fd)
218
226
}
227
+ SignerMessage :: BlockPreCommit ( block_pre_commit) => {
228
+ block_pre_commit. consensus_serialize ( fd)
229
+ }
219
230
} ?;
220
231
Ok ( ( ) )
221
232
}
@@ -253,6 +264,10 @@ impl StacksMessageCodec for SignerMessage {
253
264
let state_machine_update = StacksMessageCodec :: consensus_deserialize ( fd) ?;
254
265
SignerMessage :: StateMachineUpdate ( state_machine_update)
255
266
}
267
+ SignerMessageTypePrefix :: BlockPreCommit => {
268
+ let signer_signature_hash = StacksMessageCodec :: consensus_deserialize ( fd) ?;
269
+ SignerMessage :: BlockPreCommit ( signer_signature_hash)
270
+ }
256
271
} ;
257
272
Ok ( message)
258
273
}
@@ -2604,4 +2619,14 @@ mod test {
2604
2619
2605
2620
assert_eq ! ( signer_message, signer_message_deserialized) ;
2606
2621
}
2622
+
2623
+ #[ test]
2624
+ fn serde_block_signer_message_pre_commit ( ) {
2625
+ let pre_commit = SignerMessage :: BlockPreCommit ( Sha512Trunc256Sum ( [ 0u8 ; 32 ] ) ) ;
2626
+ let serialized_pre_commit = pre_commit. serialize_to_vec ( ) ;
2627
+ let deserialized_pre_commit =
2628
+ read_next :: < SignerMessage , _ > ( & mut & serialized_pre_commit[ ..] )
2629
+ . expect ( "Failed to deserialize pre-commit" ) ;
2630
+ assert_eq ! ( pre_commit, deserialized_pre_commit) ;
2631
+ }
2607
2632
}
0 commit comments