@@ -61,7 +61,8 @@ use stacks_common::codec::{
61
61
StacksMessageCodec ,
62
62
} ;
63
63
use stacks_common:: consts:: SIGNER_SLOTS_PER_USER ;
64
- use stacks_common:: util:: hash:: Sha512Trunc256Sum ;
64
+ use stacks_common:: types:: chainstate:: StacksBlockId ;
65
+ use stacks_common:: util:: hash:: { Hash160 , Sha512Trunc256Sum } ;
65
66
use tiny_http:: {
66
67
Method as HttpMethod , Request as HttpRequest , Response as HttpResponse , Server as HttpServer ,
67
68
} ;
@@ -122,7 +123,9 @@ SignerMessageTypePrefix {
122
123
/// Mock block signature message from Epoch 2.5 signers
123
124
MockSignature = 4 ,
124
125
/// Mock block message from Epoch 2.5 miners
125
- MockBlock = 5
126
+ MockBlock = 5 ,
127
+ /// State machine update
128
+ StateMachineUpdate = 6
126
129
} ) ;
127
130
128
131
#[ cfg_attr( test, mutants:: skip) ]
@@ -168,6 +171,7 @@ impl From<&SignerMessage> for SignerMessageTypePrefix {
168
171
SignerMessage :: MockProposal ( _) => SignerMessageTypePrefix :: MockProposal ,
169
172
SignerMessage :: MockSignature ( _) => SignerMessageTypePrefix :: MockSignature ,
170
173
SignerMessage :: MockBlock ( _) => SignerMessageTypePrefix :: MockBlock ,
174
+ SignerMessage :: StateMachineUpdate ( _) => SignerMessageTypePrefix :: StateMachineUpdate ,
171
175
}
172
176
}
173
177
}
@@ -187,6 +191,8 @@ pub enum SignerMessage {
187
191
MockProposal ( MockProposal ) ,
188
192
/// A mock block from the epoch 2.5 miners
189
193
MockBlock ( MockBlock ) ,
194
+ /// A state machine update
195
+ StateMachineUpdate ( StateMachineUpdate ) ,
190
196
}
191
197
192
198
impl SignerMessage {
@@ -199,7 +205,8 @@ impl SignerMessage {
199
205
Self :: BlockProposal ( _)
200
206
| Self :: BlockPushed ( _)
201
207
| Self :: MockProposal ( _)
202
- | Self :: MockBlock ( _) => None ,
208
+ | Self :: MockBlock ( _)
209
+ | Self :: StateMachineUpdate ( _) => None ,
203
210
Self :: BlockResponse ( _) | Self :: MockSignature ( _) => Some ( MessageSlotID :: BlockResponse ) , // Mock signature uses the same slot as block response since its exclusively for epoch 2.5 testing
204
211
}
205
212
}
@@ -217,6 +224,9 @@ impl StacksMessageCodec for SignerMessage {
217
224
SignerMessage :: MockSignature ( signature) => signature. consensus_serialize ( fd) ,
218
225
SignerMessage :: MockProposal ( message) => message. consensus_serialize ( fd) ,
219
226
SignerMessage :: MockBlock ( block) => block. consensus_serialize ( fd) ,
227
+ SignerMessage :: StateMachineUpdate ( state_machine_update) => {
228
+ state_machine_update. consensus_serialize ( fd)
229
+ }
220
230
} ?;
221
231
Ok ( ( ) )
222
232
}
@@ -250,6 +260,10 @@ impl StacksMessageCodec for SignerMessage {
250
260
let block = StacksMessageCodec :: consensus_deserialize ( fd) ?;
251
261
SignerMessage :: MockBlock ( block)
252
262
}
263
+ SignerMessageTypePrefix :: StateMachineUpdate => {
264
+ let state_machine_update = StacksMessageCodec :: consensus_deserialize ( fd) ?;
265
+ SignerMessage :: StateMachineUpdate ( state_machine_update)
266
+ }
253
267
} ;
254
268
Ok ( message)
255
269
}
@@ -525,6 +539,54 @@ impl StacksMessageCodec for MockBlock {
525
539
}
526
540
}
527
541
542
+ /// Message for update the Signer State infos
543
+ #[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
544
+ pub struct StateMachineUpdate {
545
+ burn_block : ConsensusHash ,
546
+ burn_block_height : u64 ,
547
+ current_miner_pkh : Hash160 ,
548
+ parent_tenure_id : ConsensusHash ,
549
+ parent_tenure_last_block : StacksBlockId ,
550
+ parent_tenure_last_block_height : u64 ,
551
+ active_signer_protocol_version : u64 ,
552
+ local_supported_signer_protocol_version : u64 ,
553
+ }
554
+
555
+ impl StacksMessageCodec for StateMachineUpdate {
556
+ fn consensus_serialize < W : Write > ( & self , fd : & mut W ) -> Result < ( ) , CodecError > {
557
+ write_next ( fd, & self . burn_block ) ?;
558
+ write_next ( fd, & self . burn_block_height ) ?;
559
+ write_next ( fd, & self . current_miner_pkh ) ?;
560
+ write_next ( fd, & self . parent_tenure_id ) ?;
561
+ write_next ( fd, & self . parent_tenure_last_block ) ?;
562
+ write_next ( fd, & self . parent_tenure_last_block_height ) ?;
563
+ write_next ( fd, & self . active_signer_protocol_version ) ?;
564
+ write_next ( fd, & self . local_supported_signer_protocol_version ) ?;
565
+ Ok ( ( ) )
566
+ }
567
+
568
+ fn consensus_deserialize < R : Read > ( fd : & mut R ) -> Result < Self , CodecError > {
569
+ let burn_block = read_next :: < ConsensusHash , _ > ( fd) ?;
570
+ let burn_block_height = read_next :: < u64 , _ > ( fd) ?;
571
+ let current_miner_pkh = read_next :: < Hash160 , _ > ( fd) ?;
572
+ let parent_tenure_id = read_next :: < ConsensusHash , _ > ( fd) ?;
573
+ let parent_tenure_last_block = read_next :: < StacksBlockId , _ > ( fd) ?;
574
+ let parent_tenure_last_block_height = read_next :: < u64 , _ > ( fd) ?;
575
+ let active_signer_protocol_version = read_next :: < u64 , _ > ( fd) ?;
576
+ let local_supported_signer_protocol_version = read_next :: < u64 , _ > ( fd) ?;
577
+ Ok ( Self {
578
+ burn_block,
579
+ burn_block_height,
580
+ current_miner_pkh,
581
+ parent_tenure_id,
582
+ parent_tenure_last_block,
583
+ parent_tenure_last_block_height,
584
+ active_signer_protocol_version,
585
+ local_supported_signer_protocol_version,
586
+ } )
587
+ }
588
+ }
589
+
528
590
define_u8_enum ! (
529
591
/// Enum representing the reject code type prefix
530
592
RejectCodeTypePrefix {
0 commit comments