@@ -61,7 +61,8 @@ use stacks_common::codec::{
6161 StacksMessageCodec ,
6262} ;
6363use 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 } ;
6566use tiny_http:: {
6667 Method as HttpMethod , Request as HttpRequest , Response as HttpResponse , Server as HttpServer ,
6768} ;
@@ -122,7 +123,9 @@ SignerMessageTypePrefix {
122123 /// Mock block signature message from Epoch 2.5 signers
123124 MockSignature = 4 ,
124125 /// Mock block message from Epoch 2.5 miners
125- MockBlock = 5
126+ MockBlock = 5 ,
127+ /// State machine update
128+ StateMachineUpdate = 6
126129} ) ;
127130
128131#[ cfg_attr( test, mutants:: skip) ]
@@ -168,6 +171,7 @@ impl From<&SignerMessage> for SignerMessageTypePrefix {
168171 SignerMessage :: MockProposal ( _) => SignerMessageTypePrefix :: MockProposal ,
169172 SignerMessage :: MockSignature ( _) => SignerMessageTypePrefix :: MockSignature ,
170173 SignerMessage :: MockBlock ( _) => SignerMessageTypePrefix :: MockBlock ,
174+ SignerMessage :: StateMachineUpdate ( _) => SignerMessageTypePrefix :: StateMachineUpdate ,
171175 }
172176 }
173177}
@@ -187,6 +191,8 @@ pub enum SignerMessage {
187191 MockProposal ( MockProposal ) ,
188192 /// A mock block from the epoch 2.5 miners
189193 MockBlock ( MockBlock ) ,
194+ /// A state machine update
195+ StateMachineUpdate ( StateMachineUpdate ) ,
190196}
191197
192198impl SignerMessage {
@@ -199,7 +205,8 @@ impl SignerMessage {
199205 Self :: BlockProposal ( _)
200206 | Self :: BlockPushed ( _)
201207 | Self :: MockProposal ( _)
202- | Self :: MockBlock ( _) => None ,
208+ | Self :: MockBlock ( _)
209+ | Self :: StateMachineUpdate ( _) => None ,
203210 Self :: BlockResponse ( _) | Self :: MockSignature ( _) => Some ( MessageSlotID :: BlockResponse ) , // Mock signature uses the same slot as block response since its exclusively for epoch 2.5 testing
204211 }
205212 }
@@ -217,6 +224,9 @@ impl StacksMessageCodec for SignerMessage {
217224 SignerMessage :: MockSignature ( signature) => signature. consensus_serialize ( fd) ,
218225 SignerMessage :: MockProposal ( message) => message. consensus_serialize ( fd) ,
219226 SignerMessage :: MockBlock ( block) => block. consensus_serialize ( fd) ,
227+ SignerMessage :: StateMachineUpdate ( state_machine_update) => {
228+ state_machine_update. consensus_serialize ( fd)
229+ }
220230 } ?;
221231 Ok ( ( ) )
222232 }
@@ -250,6 +260,10 @@ impl StacksMessageCodec for SignerMessage {
250260 let block = StacksMessageCodec :: consensus_deserialize ( fd) ?;
251261 SignerMessage :: MockBlock ( block)
252262 }
263+ SignerMessageTypePrefix :: StateMachineUpdate => {
264+ let state_machine_update = StacksMessageCodec :: consensus_deserialize ( fd) ?;
265+ SignerMessage :: StateMachineUpdate ( state_machine_update)
266+ }
253267 } ;
254268 Ok ( message)
255269 }
@@ -525,6 +539,54 @@ impl StacksMessageCodec for MockBlock {
525539 }
526540}
527541
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+
528590define_u8_enum ! (
529591/// Enum representing the reject code type prefix
530592RejectCodeTypePrefix {
0 commit comments