Skip to content

Commit cd385ae

Browse files
authored
Merge pull request #6160 from rdeioris/fix/mark_miner_as_invalid_on_capitulation
Mark current miner as invalid on capitulation
2 parents 9789f0b + 8a1dfb0 commit cd385ae

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-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: 17 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,21 @@ 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+
} => {
691+
if let Some(sortition_state) = 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+
}
699+
StateMachineUpdateMinerState::NoValidMiner => (),
700+
}
685701
}
686702
}
687703

0 commit comments

Comments
 (0)