@@ -348,10 +348,25 @@ pub enum StateMachineUpdate {
348
348
BurnBlock ( u64 ) ,
349
349
}
350
350
351
- impl TryInto < StateMachineUpdateMessage > for & LocalStateMachine {
352
- type Error = CodecError ;
351
+ impl LocalStateMachine {
352
+ /// Initialize a local state machine by querying the local stacks-node
353
+ /// and signerdb for the current sortition information
354
+ pub fn new (
355
+ db : & SignerDb ,
356
+ client : & StacksClient ,
357
+ proposal_config : & ProposalEvalConfig ,
358
+ ) -> Result < Self , SignerChainstateError > {
359
+ let mut instance = Self :: Uninitialized ;
360
+ instance. bitcoin_block_arrival ( db, client, proposal_config, None ) ?;
353
361
354
- fn try_into ( self ) -> Result < StateMachineUpdateMessage , Self :: Error > {
362
+ Ok ( instance)
363
+ }
364
+
365
+ /// Convert the local state machine into update message with the specificed supported protocol version
366
+ pub fn try_into_update_message_with_version (
367
+ & self ,
368
+ local_supported_signer_protocol_version : u64 ,
369
+ ) -> Result < StateMachineUpdateMessage , CodecError > {
355
370
let LocalStateMachine :: Initialized ( state_machine) = self else {
356
371
return Err ( CodecError :: SerializeError (
357
372
"Local state machine is not ready to be serialized into an update message" . into ( ) ,
@@ -395,25 +410,10 @@ impl TryInto<StateMachineUpdateMessage> for &LocalStateMachine {
395
410
} ;
396
411
StateMachineUpdateMessage :: new (
397
412
state_machine. active_signer_protocol_version ,
398
- SUPPORTED_SIGNER_PROTOCOL_VERSION ,
413
+ local_supported_signer_protocol_version ,
399
414
content,
400
415
)
401
416
}
402
- }
403
-
404
- impl LocalStateMachine {
405
- /// Initialize a local state machine by querying the local stacks-node
406
- /// and signerdb for the current sortition information
407
- pub fn new (
408
- db : & SignerDb ,
409
- client : & StacksClient ,
410
- proposal_config : & ProposalEvalConfig ,
411
- ) -> Result < Self , SignerChainstateError > {
412
- let mut instance = Self :: Uninitialized ;
413
- instance. bitcoin_block_arrival ( db, client, proposal_config, None ) ?;
414
-
415
- Ok ( instance)
416
- }
417
417
418
418
fn place_holder ( ) -> SignerStateMachine {
419
419
SignerStateMachine {
@@ -426,10 +426,16 @@ impl LocalStateMachine {
426
426
}
427
427
428
428
/// Send the local state machine as a signer update message to stackerdb
429
- pub fn send_signer_update_message ( & self , stackerdb : & mut StackerDB < MessageSlotID > ) {
430
- let update: Result < StateMachineUpdateMessage , _ > = self . try_into ( ) ;
429
+ pub fn send_signer_update_message (
430
+ & self ,
431
+ stackerdb : & mut StackerDB < MessageSlotID > ,
432
+ version : u64 ,
433
+ ) {
434
+ let update: Result < StateMachineUpdateMessage , _ > =
435
+ self . try_into_update_message_with_version ( version) ;
431
436
match update {
432
437
Ok ( update) => {
438
+ info ! ( "SENDING SIGNER UPDATE MESSAGE HERE: {update:?}" ) ;
433
439
if let Err ( e) = stackerdb. send_message_with_retry :: < SignerMessage > ( update. into ( ) ) {
434
440
warn ! ( "Failed to send signer update to stacker-db: {e:?}" , ) ;
435
441
}
@@ -815,10 +821,12 @@ impl LocalStateMachine {
815
821
signerdb : & mut SignerDb ,
816
822
eval : & mut GlobalStateEvaluator ,
817
823
local_address : StacksAddress ,
824
+ local_supported_signer_protocol_version : u64 ,
818
825
) {
819
826
// Before we ever access eval...we should make sure to include our own local state machine update message in the evaluation
820
- let local_update: Result < StateMachineUpdateMessage , _ > = ( & * self ) . try_into ( ) ;
821
- let Ok ( mut local_update) = local_update else {
827
+ let Ok ( mut local_update) =
828
+ self . try_into_update_message_with_version ( local_supported_signer_protocol_version)
829
+ else {
822
830
return ;
823
831
} ;
824
832
@@ -859,8 +867,9 @@ impl LocalStateMachine {
859
867
tx_replay_set : tx_replay_set. cloned ( ) ,
860
868
} ) ;
861
869
// Because we updated our active signer protocol version, update local_update so its included in the subsequent evaluations
862
- let update: Result < StateMachineUpdateMessage , _ > = ( & * self ) . try_into ( ) ;
863
- let Ok ( update) = update else {
870
+ let Ok ( update) =
871
+ self . try_into_update_message_with_version ( local_supported_signer_protocol_version)
872
+ else {
864
873
return ;
865
874
} ;
866
875
local_update = update;
0 commit comments