Skip to content

Commit df200e9

Browse files
committed
mark current miner as invalid on capitulation
1 parent 174d69f commit df200e9

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

stacks-signer/src/v0/signer.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,12 @@ impl Signer {
427427
sortition_state,
428428
),
429429
SignerMessage::StateMachineUpdate(update) => self
430-
.handle_state_machine_update(signer_public_key, update, received_time),
430+
.handle_state_machine_update(
431+
signer_public_key,
432+
update,
433+
received_time,
434+
sortition_state,
435+
),
431436
_ => {}
432437
}
433438
}
@@ -756,6 +761,7 @@ impl Signer {
756761
signer_public_key: &Secp256k1PublicKey,
757762
update: &StateMachineUpdate,
758763
received_time: &SystemTime,
764+
sortition_state: &mut Option<SortitionsView>,
759765
) {
760766
let address = StacksAddress::p2pkh(self.mainnet, signer_public_key);
761767
// Store the state machine update so we can reload it if we crash
@@ -778,6 +784,7 @@ impl Signer {
778784
self.stacks_address,
779785
version,
780786
self.reward_cycle,
787+
sortition_state,
781788
);
782789
}
783790

stacks-signer/src/v0/signer_state.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use stacks_common::util::secp256k1::MessageSignature;
3434
use stacks_common::{debug, info, warn};
3535

3636
use crate::chainstate::{
37-
ProposalEvalConfig, SignerChainstateError, SortitionState, SortitionsView,
37+
ProposalEvalConfig, SignerChainstateError, SortitionMinerStatus, SortitionState, SortitionsView,
3838
};
3939
use crate::client::{ClientError, CurrentAndLastSortition, StackerDB, StacksClient};
4040
use crate::signerdb::SignerDb;
@@ -579,6 +579,7 @@ impl LocalStateMachine {
579579
local_address: StacksAddress,
580580
local_supported_signer_protocol_version: u64,
581581
reward_cycle: u64,
582+
sortition_state: &mut Option<SortitionsView>,
582583
) {
583584
// Before we ever access eval...we should make sure to include our own local state machine update message in the evaluation
584585
let Ok(mut local_update) =
@@ -682,6 +683,22 @@ impl LocalStateMachine {
682683
active_signer_protocol_version,
683684
tx_replay_set,
684685
});
686+
687+
match new_miner {
688+
StateMachineUpdateMinerState::ActiveMiner {
689+
current_miner_pkh, ..
690+
} => match sortition_state {
691+
Some(sortition_state) => {
692+
// if there is a mismatch between the new_miner ad the current sortition view, mark the current miner as invalid
693+
if current_miner_pkh != sortition_state.cur_sortition.miner_pkh {
694+
sortition_state.cur_sortition.miner_status =
695+
SortitionMinerStatus::InvalidatedBeforeFirstBlock
696+
}
697+
}
698+
None => (),
699+
},
700+
StateMachineUpdateMinerState::NoValidMiner => {}
701+
}
685702
}
686703
}
687704

0 commit comments

Comments
 (0)