@@ -113,8 +113,11 @@ fn create_event_info_data_code(
113
113
) -> String {
114
114
// If a given burn block height is in a prepare phase, then the stacker will be in the _next_ reward cycle, so bump the cycle by 1
115
115
// `prepare_offset` is 1 or 0, depending on whether current execution is in a prepare phase or not
116
- let prepare_offset = r#"
117
- (prepare-offset (if (<
116
+ //
117
+ // "is-in-next-pox-set" == effective-height <= (reward-length - prepare-length)
118
+ // "<=" since the txs of the first block of the prepare phase are considered in the pox-set
119
+ let pox_set_offset = r#"
120
+ (pox-set-offset (if (<=
118
121
(mod (- %height% (var-get first-burnchain-block-height)) (var-get pox-reward-cycle-length))
119
122
(- (var-get pox-reward-cycle-length) (var-get pox-prepare-cycle-length))
120
123
) u0 u1))
@@ -126,7 +129,7 @@ fn create_event_info_data_code(
126
129
r#"
127
130
(let (
128
131
(unlock-burn-height (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period})))
129
- {prepare_offset }
132
+ {pox_set_offset }
130
133
)
131
134
{{
132
135
data: {{
@@ -156,7 +159,7 @@ fn create_event_info_data_code(
156
159
;; Get end cycle ID
157
160
end-cycle-id: (some (burn-height-to-reward-cycle unlock-burn-height)),
158
161
;; Get start cycle ID
159
- start-cycle-id: (+ (current-pox-reward-cycle) u1 prepare -offset),
162
+ start-cycle-id: (+ (current-pox-reward-cycle) u1 pox-set -offset),
160
163
}}
161
164
}})
162
165
"# ,
@@ -168,15 +171,15 @@ fn create_event_info_data_code(
168
171
signer_key = & args. get( 5 ) . unwrap_or( & Value :: none( ) ) ,
169
172
max_amount = & args. get( 6 ) . unwrap_or( & Value :: none( ) ) ,
170
173
auth_id = & args. get( 7 ) . unwrap_or( & Value :: none( ) ) ,
171
- prepare_offset = prepare_offset . replace( "%height%" , "burn-block-height" ) ,
174
+ pox_set_offset = pox_set_offset . replace( "%height%" , "burn-block-height" ) ,
172
175
)
173
176
}
174
177
"delegate-stack-stx" => {
175
178
format ! (
176
179
r#"
177
180
(let (
178
181
(unlock-burn-height (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period})))
179
- {prepare_offset }
182
+ {pox_set_offset }
180
183
)
181
184
{{
182
185
data: {{
@@ -203,7 +206,7 @@ fn create_event_info_data_code(
203
206
;; Get end cycle ID
204
207
end-cycle-id: (some (burn-height-to-reward-cycle unlock-burn-height)),
205
208
;; Get start cycle ID
206
- start-cycle-id: (+ (current-pox-reward-cycle) u1 prepare -offset),
209
+ start-cycle-id: (+ (current-pox-reward-cycle) u1 pox-set -offset),
207
210
}}
208
211
}})
209
212
"# ,
@@ -212,15 +215,15 @@ fn create_event_info_data_code(
212
215
pox_addr = & args[ 2 ] ,
213
216
start_burn_height = & args[ 3 ] ,
214
217
lock_period = & args[ 4 ] ,
215
- prepare_offset = prepare_offset . replace( "%height%" , "burn-block-height" ) ,
218
+ pox_set_offset = pox_set_offset . replace( "%height%" , "burn-block-height" ) ,
216
219
)
217
220
}
218
221
"stack-increase" => {
219
222
format ! (
220
223
r#"
221
224
(let (
222
225
(unlock-height (get unlock-height (stx-account tx-sender)))
223
- {prepare_offset }
226
+ {pox_set_offset }
224
227
)
225
228
{{
226
229
data: {{
@@ -244,7 +247,7 @@ fn create_event_info_data_code(
244
247
;; Get end cycle ID
245
248
end-cycle-id: (some (burn-height-to-reward-cycle unlock-height)),
246
249
;; Get start cycle ID
247
- start-cycle-id: (+ (current-pox-reward-cycle) u1 prepare -offset),
250
+ start-cycle-id: (+ (current-pox-reward-cycle) u1 pox-set -offset),
248
251
}}
249
252
}})
250
253
"# ,
@@ -253,15 +256,15 @@ fn create_event_info_data_code(
253
256
signer_key = & args. get( 2 ) . unwrap_or( & Value :: none( ) ) ,
254
257
max_amount = & args. get( 3 ) . unwrap_or( & Value :: none( ) ) ,
255
258
auth_id = & args. get( 4 ) . unwrap_or( & Value :: none( ) ) ,
256
- prepare_offset = prepare_offset . replace( "%height%" , "burn-block-height" ) ,
259
+ pox_set_offset = pox_set_offset . replace( "%height%" , "burn-block-height" ) ,
257
260
)
258
261
}
259
262
"delegate-stack-increase" => {
260
263
format ! (
261
264
r#"
262
265
(let (
263
266
(unlock-height (get unlock-height (stx-account '{stacker})))
264
- {prepare_offset }
267
+ {pox_set_offset }
265
268
)
266
269
{{
267
270
data: {{
@@ -283,14 +286,14 @@ fn create_event_info_data_code(
283
286
;; Get end cycle ID
284
287
end-cycle-id: (some (burn-height-to-reward-cycle unlock-height)),
285
288
;; Get start cycle ID
286
- start-cycle-id: (+ (current-pox-reward-cycle) u1 prepare -offset),
289
+ start-cycle-id: (+ (current-pox-reward-cycle) u1 pox-set -offset),
287
290
}}
288
291
}}
289
292
"# ,
290
293
stacker = & args[ 0 ] ,
291
294
pox_addr = & args[ 1 ] ,
292
295
increase_by = & args[ 2 ] ,
293
- prepare_offset = prepare_offset . replace( "%height%" , "burn-block-height" ) ,
296
+ pox_set_offset = pox_set_offset . replace( "%height%" , "burn-block-height" ) ,
294
297
)
295
298
}
296
299
"stack-extend" => {
@@ -307,7 +310,7 @@ fn create_event_info_data_code(
307
310
unlock-in-cycle))
308
311
(last-extend-cycle (- (+ first-extend-cycle {extend_count}) u1))
309
312
(new-unlock-ht (reward-cycle-to-burn-height (+ u1 last-extend-cycle)))
310
- {prepare_offset }
313
+ {pox_set_offset }
311
314
)
312
315
{{
313
316
data: {{
@@ -330,7 +333,7 @@ fn create_event_info_data_code(
330
333
;; Get end cycle ID
331
334
end-cycle-id: (some (burn-height-to-reward-cycle new-unlock-ht)),
332
335
;; Get start cycle ID
333
- start-cycle-id: (+ (current-pox-reward-cycle) u1 prepare -offset),
336
+ start-cycle-id: (+ (current-pox-reward-cycle) u1 pox-set -offset),
334
337
}}
335
338
}})
336
339
"# ,
@@ -340,7 +343,7 @@ fn create_event_info_data_code(
340
343
signer_key = & args. get( 3 ) . map_or( "none" . to_string( ) , |v| v. to_string( ) ) ,
341
344
max_amount = & args. get( 4 ) . unwrap_or( & Value :: none( ) ) ,
342
345
auth_id = & args. get( 5 ) . unwrap_or( & Value :: none( ) ) ,
343
- prepare_offset = prepare_offset . replace( "%height%" , "burn-block-height" ) ,
346
+ pox_set_offset = pox_set_offset . replace( "%height%" , "burn-block-height" ) ,
344
347
)
345
348
}
346
349
"delegate-stack-extend" => {
@@ -356,7 +359,7 @@ fn create_event_info_data_code(
356
359
unlock-in-cycle))
357
360
(last-extend-cycle (- (+ first-extend-cycle {extend_count}) u1))
358
361
(new-unlock-ht (reward-cycle-to-burn-height (+ u1 last-extend-cycle)))
359
- {prepare_offset }
362
+ {pox_set_offset }
360
363
)
361
364
{{
362
365
data: {{
@@ -376,19 +379,26 @@ fn create_event_info_data_code(
376
379
;; Get end cycle ID
377
380
end-cycle-id: (some (burn-height-to-reward-cycle new-unlock-ht)),
378
381
;; Get start cycle ID
379
- start-cycle-id: (+ (current-pox-reward-cycle) u1 prepare -offset),
382
+ start-cycle-id: (+ (current-pox-reward-cycle) u1 pox-set -offset),
380
383
}}
381
384
}})
382
385
"# ,
383
386
stacker = & args[ 0 ] ,
384
387
pox_addr = & args[ 1 ] ,
385
388
extend_count = & args[ 2 ] ,
386
- prepare_offset = prepare_offset . replace( "%height%" , "burn-block-height" ) ,
389
+ pox_set_offset = pox_set_offset . replace( "%height%" , "burn-block-height" ) ,
387
390
)
388
391
}
389
392
"stack-aggregation-commit" | "stack-aggregation-commit-indexed" => {
390
393
format ! (
391
394
r#"
395
+ (let (
396
+ (next-cycle (+ (current-pox-reward-cycle) u1))
397
+ {pox_set_offset}
398
+ (start-cycle (if (is-eq {reward_cycle} next-cycle)
399
+ (+ {reward_cycle} pox-set-offset)
400
+ {reward_cycle}))
401
+ )
392
402
{{
393
403
data: {{
394
404
;; pox addr locked up
@@ -412,23 +422,31 @@ fn create_event_info_data_code(
412
422
;; equal to args[5]
413
423
auth-id: {auth_id},
414
424
;; Get end cycle ID
415
- end-cycle-id: (some {reward_cycle}),
425
+ end-cycle-id: (some (+ {reward_cycle} u1) ),
416
426
;; Get start cycle ID
417
- start-cycle-id: {reward_cycle} ,
427
+ start-cycle-id: start-cycle ,
418
428
}}
419
- }}
429
+ }})
420
430
"# ,
421
431
pox_addr = & args[ 0 ] ,
422
432
reward_cycle = & args[ 1 ] ,
423
433
signer_sig = & args. get( 2 ) . unwrap_or( & Value :: none( ) ) ,
424
434
signer_key = & args. get( 3 ) . unwrap_or( & Value :: none( ) ) ,
425
435
max_amount = & args. get( 4 ) . unwrap_or( & Value :: none( ) ) ,
426
436
auth_id = & args. get( 5 ) . unwrap_or( & Value :: none( ) ) ,
437
+ pox_set_offset = pox_set_offset. replace( "%height%" , "burn-block-height" ) ,
427
438
)
428
439
}
429
440
"stack-aggregation-increase" => {
430
441
format ! (
431
442
r#"
443
+ (let (
444
+ (next-cycle (+ (current-pox-reward-cycle) u1))
445
+ {pox_set_offset}
446
+ (start-cycle (if (is-eq {reward_cycle} next-cycle)
447
+ (+ {reward_cycle} pox-set-offset)
448
+ {reward_cycle}))
449
+ )
432
450
{{
433
451
data: {{
434
452
;; pox addr locked up
@@ -446,22 +464,23 @@ fn create_event_info_data_code(
446
464
;; equal to args[2]
447
465
reward-cycle-index: {reward_cycle_index},
448
466
;; Get end cycle ID
449
- end-cycle-id: (some {reward_cycle}),
467
+ end-cycle-id: (some (+ {reward_cycle} u1) ),
450
468
;; Get start cycle ID
451
- start-cycle-id: {reward_cycle} ,
469
+ start-cycle-id: start-cycle ,
452
470
}}
453
- }}
471
+ }})
454
472
"# ,
455
473
pox_addr = & args[ 0 ] ,
456
474
reward_cycle = & args[ 1 ] ,
457
475
reward_cycle_index = & args. get( 2 ) . unwrap_or( & Value :: none( ) ) ,
476
+ pox_set_offset = pox_set_offset. replace( "%height%" , "burn-block-height" ) ,
458
477
)
459
478
}
460
479
"delegate-stx" => {
461
480
format ! (
462
481
r#"
463
482
(let (
464
- {prepare_offset }
483
+ {pox_set_offset }
465
484
)
466
485
{{
467
486
data: {{
@@ -483,15 +502,15 @@ fn create_event_info_data_code(
483
502
none
484
503
),
485
504
;; Get start cycle ID
486
- start-cycle-id: (+ (current-pox-reward-cycle) u1 prepare -offset),
505
+ start-cycle-id: (+ (current-pox-reward-cycle) u1 pox-set -offset),
487
506
}}
488
507
}})
489
508
"# ,
490
509
amount_ustx = & args[ 0 ] ,
491
510
delegate_to = & args[ 1 ] ,
492
511
until_burn_height = & args[ 2 ] ,
493
512
pox_addr = & args[ 3 ] ,
494
- prepare_offset = prepare_offset . replace( "%height%" , "burn-block-height" ) ,
513
+ pox_set_offset = pox_set_offset . replace( "%height%" , "burn-block-height" ) ,
495
514
)
496
515
}
497
516
"revoke-delegate-stx" => {
0 commit comments