Skip to content

Commit c8cda29

Browse files
committed
fix: change pox-set-offset behavior to match the correct order
1 parent 0b4f3b2 commit c8cda29

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pox-locking/src/events.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ fn create_event_info_data_code(
117117
// `prepare_offset` is 1 or 0, depending on whether current execution is in a prepare phase or not
118118
//
119119
// "is-in-next-pox-set" == effective-height <= (reward-length - prepare-length)
120-
// "<=" since the txs of the first block of the prepare phase are considered in the pox-set
120+
// "<" since the txs of the first block of the prepare phase are NOT considered in the pox-set,
121+
// the pox-set is locked in the first block of the prepare phase, before the transactions of that block are run.
121122
let pox_set_offset = r#"
122-
(pox-set-offset (if (<=
123+
(pox-set-offset (if (<
123124
(mod (- %height% (var-get first-burnchain-block-height)) (var-get pox-reward-cycle-length))
124125
(- (var-get pox-reward-cycle-length) (var-get pox-prepare-cycle-length))
125126
) u0 u1))

stackslib/src/chainstate/stacks/boot/pox_4_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,7 @@ fn pox_4_check_cycle_id_range_in_print_events_before_prepare_phase() {
24622462
while get_tip(peer.sortdb.as_ref()).block_height < u64::from(target_height) {
24632463
latest_block = Some(peer.tenure_with_txs(&[], &mut coinbase_nonce));
24642464
}
2465-
// produce blocks until the we're 1 before the prepare phase (first block of prepare-phase not yet mined)
2465+
// produce blocks until the we're 1 before the prepare phase (first block of prepare-phase not yet mined, whatever txs we create now won't be included in the reward set)
24662466
while !burnchain.is_in_prepare_phase(get_tip(peer.sortdb.as_ref()).block_height + 1) {
24672467
latest_block = Some(peer.tenure_with_txs(&[], &mut coinbase_nonce));
24682468
}
@@ -2519,7 +2519,7 @@ fn pox_4_check_cycle_id_range_in_print_events_before_prepare_phase() {
25192519
let steph_stacking_receipt = txs.get(&steph_stacking.txid()).unwrap().clone();
25202520
assert_eq!(steph_stacking_receipt.events.len(), 2);
25212521
let steph_stacking_op_data = HashMap::from([
2522-
("start-cycle-id", Value::UInt(next_cycle)),
2522+
("start-cycle-id", Value::UInt(next_cycle + 1)), // +1 because steph stacked in the block before the prepare phase (too late)
25232523
(
25242524
"end-cycle-id",
25252525
Value::some(Value::UInt(next_cycle + steph_lock_period)).unwrap(),

0 commit comments

Comments
 (0)