@@ -1026,18 +1026,18 @@ impl LocalStateMachine {
1026
1026
1027
1027
/// Retrieves the set of transactions that were part of a Bitcoin fork within the same reward cycle.
1028
1028
///
1029
- /// This method identifies the range of Tenures affected by a fork, from the `tip ` down to the `fork_origin`
1029
+ /// This method identifies the range of Tenures affected by a fork, from the `fork_tip ` down to the `fork_origin`
1030
1030
///
1031
- /// It then verifies whether the fork occurred entirely within the current reward cycle. If so,
1032
- /// collect the relevant transactions (skipping TenureChange, Coinbase, and Microblocks ).
1031
+ /// It then verifies whether the fork occurred entirely within the reward cycle related to the `fork_tip` . If so,
1032
+ /// collect the relevant transactions (skipping TenureChange, Coinbase, and PoisonMicroblock ).
1033
1033
/// Otherwise, if fork involve a different reward cycle cancel the search.
1034
1034
///
1035
1035
/// # Arguments
1036
1036
///
1037
1037
/// * `db` - A reference to the SignerDb, used to fetch burn block information.
1038
1038
/// * `client` - A reference to a `StacksClient`, used to query chain state and fork information.
1039
1039
/// * `fork_origin` - The burn block that originated the fork.
1040
- /// * `tip ` - The burn block tip in the fork sequence.
1040
+ /// * `fork_tip ` - The burn block tip in the fork sequence.
1041
1041
///
1042
1042
/// # Returns
1043
1043
///
@@ -1050,33 +1050,29 @@ impl LocalStateMachine {
1050
1050
db : & SignerDb ,
1051
1051
client : & StacksClient ,
1052
1052
fork_origin : & NewBurnBlock ,
1053
- tip : & NewBurnBlock ,
1053
+ fork_tip : & NewBurnBlock ,
1054
1054
) -> Result < Option < Vec < StacksTransaction > > , SignerChainstateError > {
1055
1055
// Determine the tenures that were forked
1056
- let mut parent_burn_block_info = db. get_burn_block_by_ch ( & tip. consensus_hash ) ?;
1057
- let last_forked_tenure = tip. consensus_hash ;
1058
- let mut first_forked_tenure = tip. consensus_hash ;
1059
- let mut forked_tenures = vec ! [ ( tip. consensus_hash, tip. burn_block_height) ] ;
1056
+ let mut parent_burn_block_info = db. get_burn_block_by_ch ( & fork_tip. consensus_hash ) ?;
1057
+ let last_forked_tenure = fork_tip. consensus_hash ;
1058
+ let mut first_forked_tenure = fork_tip. consensus_hash ;
1060
1059
while parent_burn_block_info. block_height > fork_origin. burn_block_height {
1061
1060
parent_burn_block_info =
1062
1061
db. get_burn_block_by_hash ( & parent_burn_block_info. parent_burn_block_hash ) ?;
1063
1062
first_forked_tenure = parent_burn_block_info. consensus_hash ;
1064
- forked_tenures. push ( (
1065
- parent_burn_block_info. consensus_hash ,
1066
- parent_burn_block_info. block_height ,
1067
- ) ) ;
1068
1063
}
1069
1064
let fork_info =
1070
1065
client. get_tenure_forking_info ( & first_forked_tenure, & last_forked_tenure) ?;
1071
1066
1072
1067
// Check if fork occurred within current reward cycle. Reject tx replay otherwise.
1073
1068
let reward_cycle_info = client. get_current_reward_cycle_info ( ) ?;
1074
1069
1075
- let current_reward_cycle = reward_cycle_info. reward_cycle ;
1070
+ //let target_reward_cycle = reward_cycle_info.reward_cycle;
1071
+ let target_reward_cycle = reward_cycle_info. get_reward_cycle ( fork_tip. burn_block_height ) ;
1076
1072
let is_fork_in_current_reward_cycle = fork_info. iter ( ) . all ( |fork_info| {
1077
1073
let block_height = fork_info. burn_block_height ;
1078
1074
let block_rc = reward_cycle_info. get_reward_cycle ( block_height) ;
1079
- block_rc == current_reward_cycle
1075
+ block_rc == target_reward_cycle
1080
1076
} ) ;
1081
1077
1082
1078
if !is_fork_in_current_reward_cycle {
0 commit comments