Skip to content

Commit d16ef8a

Browse files
authored
Merge branch 'develop' into feat/2.5-height
2 parents 93bacdc + b5a25f0 commit d16ef8a

File tree

22 files changed

+1970
-114
lines changed

22 files changed

+1970
-114
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ The changelog for this release is a high-level summary of these SIPs.
363363
### Added
364364

365365
- Added prometheus output for "transactions in last block" (#3138).
366-
- Added envrionement variable STACKS_LOG_FORMAT_TIME to set the time format
366+
- Added environment variable STACKS_LOG_FORMAT_TIME to set the time format
367367
stacks-node uses for logging. (#3219)
368368
Example: STACKS_LOG_FORMAT_TIME="%Y-%m-%d %H:%M:%S" cargo stacks-node
369369
- Added mock-miner sample config (#3225)

pox-locking/src/events.rs

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ fn create_event_info_data_code(
113113
) -> String {
114114
// 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
115115
// `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 (<=
118121
(mod (- %height% (var-get first-burnchain-block-height)) (var-get pox-reward-cycle-length))
119122
(- (var-get pox-reward-cycle-length) (var-get pox-prepare-cycle-length))
120123
) u0 u1))
@@ -126,7 +129,7 @@ fn create_event_info_data_code(
126129
r#"
127130
(let (
128131
(unlock-burn-height (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period})))
129-
{prepare_offset}
132+
{pox_set_offset}
130133
)
131134
{{
132135
data: {{
@@ -156,7 +159,7 @@ fn create_event_info_data_code(
156159
;; Get end cycle ID
157160
end-cycle-id: (some (burn-height-to-reward-cycle unlock-burn-height)),
158161
;; 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),
160163
}}
161164
}})
162165
"#,
@@ -168,15 +171,15 @@ fn create_event_info_data_code(
168171
signer_key = &args.get(5).unwrap_or(&Value::none()),
169172
max_amount = &args.get(6).unwrap_or(&Value::none()),
170173
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"),
172175
)
173176
}
174177
"delegate-stack-stx" => {
175178
format!(
176179
r#"
177180
(let (
178181
(unlock-burn-height (reward-cycle-to-burn-height (+ (current-pox-reward-cycle) u1 {lock_period})))
179-
{prepare_offset}
182+
{pox_set_offset}
180183
)
181184
{{
182185
data: {{
@@ -203,7 +206,7 @@ fn create_event_info_data_code(
203206
;; Get end cycle ID
204207
end-cycle-id: (some (burn-height-to-reward-cycle unlock-burn-height)),
205208
;; 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),
207210
}}
208211
}})
209212
"#,
@@ -212,15 +215,15 @@ fn create_event_info_data_code(
212215
pox_addr = &args[2],
213216
start_burn_height = &args[3],
214217
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"),
216219
)
217220
}
218221
"stack-increase" => {
219222
format!(
220223
r#"
221224
(let (
222225
(unlock-height (get unlock-height (stx-account tx-sender)))
223-
{prepare_offset}
226+
{pox_set_offset}
224227
)
225228
{{
226229
data: {{
@@ -244,7 +247,7 @@ fn create_event_info_data_code(
244247
;; Get end cycle ID
245248
end-cycle-id: (some (burn-height-to-reward-cycle unlock-height)),
246249
;; 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),
248251
}}
249252
}})
250253
"#,
@@ -253,15 +256,15 @@ fn create_event_info_data_code(
253256
signer_key = &args.get(2).unwrap_or(&Value::none()),
254257
max_amount = &args.get(3).unwrap_or(&Value::none()),
255258
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"),
257260
)
258261
}
259262
"delegate-stack-increase" => {
260263
format!(
261264
r#"
262265
(let (
263266
(unlock-height (get unlock-height (stx-account '{stacker})))
264-
{prepare_offset}
267+
{pox_set_offset}
265268
)
266269
{{
267270
data: {{
@@ -283,14 +286,14 @@ fn create_event_info_data_code(
283286
;; Get end cycle ID
284287
end-cycle-id: (some (burn-height-to-reward-cycle unlock-height)),
285288
;; 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),
287290
}}
288291
}}
289292
"#,
290293
stacker = &args[0],
291294
pox_addr = &args[1],
292295
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"),
294297
)
295298
}
296299
"stack-extend" => {
@@ -307,7 +310,7 @@ fn create_event_info_data_code(
307310
unlock-in-cycle))
308311
(last-extend-cycle (- (+ first-extend-cycle {extend_count}) u1))
309312
(new-unlock-ht (reward-cycle-to-burn-height (+ u1 last-extend-cycle)))
310-
{prepare_offset}
313+
{pox_set_offset}
311314
)
312315
{{
313316
data: {{
@@ -330,7 +333,7 @@ fn create_event_info_data_code(
330333
;; Get end cycle ID
331334
end-cycle-id: (some (burn-height-to-reward-cycle new-unlock-ht)),
332335
;; 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),
334337
}}
335338
}})
336339
"#,
@@ -340,7 +343,7 @@ fn create_event_info_data_code(
340343
signer_key = &args.get(3).map_or("none".to_string(), |v| v.to_string()),
341344
max_amount = &args.get(4).unwrap_or(&Value::none()),
342345
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"),
344347
)
345348
}
346349
"delegate-stack-extend" => {
@@ -356,7 +359,7 @@ fn create_event_info_data_code(
356359
unlock-in-cycle))
357360
(last-extend-cycle (- (+ first-extend-cycle {extend_count}) u1))
358361
(new-unlock-ht (reward-cycle-to-burn-height (+ u1 last-extend-cycle)))
359-
{prepare_offset}
362+
{pox_set_offset}
360363
)
361364
{{
362365
data: {{
@@ -376,19 +379,26 @@ fn create_event_info_data_code(
376379
;; Get end cycle ID
377380
end-cycle-id: (some (burn-height-to-reward-cycle new-unlock-ht)),
378381
;; 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),
380383
}}
381384
}})
382385
"#,
383386
stacker = &args[0],
384387
pox_addr = &args[1],
385388
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"),
387390
)
388391
}
389392
"stack-aggregation-commit" | "stack-aggregation-commit-indexed" => {
390393
format!(
391394
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+
)
392402
{{
393403
data: {{
394404
;; pox addr locked up
@@ -412,23 +422,31 @@ fn create_event_info_data_code(
412422
;; equal to args[5]
413423
auth-id: {auth_id},
414424
;; Get end cycle ID
415-
end-cycle-id: (some {reward_cycle}),
425+
end-cycle-id: (some (+ {reward_cycle} u1)),
416426
;; Get start cycle ID
417-
start-cycle-id: {reward_cycle},
427+
start-cycle-id: start-cycle,
418428
}}
419-
}}
429+
}})
420430
"#,
421431
pox_addr = &args[0],
422432
reward_cycle = &args[1],
423433
signer_sig = &args.get(2).unwrap_or(&Value::none()),
424434
signer_key = &args.get(3).unwrap_or(&Value::none()),
425435
max_amount = &args.get(4).unwrap_or(&Value::none()),
426436
auth_id = &args.get(5).unwrap_or(&Value::none()),
437+
pox_set_offset = pox_set_offset.replace("%height%", "burn-block-height"),
427438
)
428439
}
429440
"stack-aggregation-increase" => {
430441
format!(
431442
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+
)
432450
{{
433451
data: {{
434452
;; pox addr locked up
@@ -446,22 +464,23 @@ fn create_event_info_data_code(
446464
;; equal to args[2]
447465
reward-cycle-index: {reward_cycle_index},
448466
;; Get end cycle ID
449-
end-cycle-id: (some {reward_cycle}),
467+
end-cycle-id: (some (+ {reward_cycle} u1)),
450468
;; Get start cycle ID
451-
start-cycle-id: {reward_cycle},
469+
start-cycle-id: start-cycle,
452470
}}
453-
}}
471+
}})
454472
"#,
455473
pox_addr = &args[0],
456474
reward_cycle = &args[1],
457475
reward_cycle_index = &args.get(2).unwrap_or(&Value::none()),
476+
pox_set_offset = pox_set_offset.replace("%height%", "burn-block-height"),
458477
)
459478
}
460479
"delegate-stx" => {
461480
format!(
462481
r#"
463482
(let (
464-
{prepare_offset}
483+
{pox_set_offset}
465484
)
466485
{{
467486
data: {{
@@ -483,15 +502,15 @@ fn create_event_info_data_code(
483502
none
484503
),
485504
;; 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),
487506
}}
488507
}})
489508
"#,
490509
amount_ustx = &args[0],
491510
delegate_to = &args[1],
492511
until_burn_height = &args[2],
493512
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"),
495514
)
496515
}
497516
"revoke-delegate-stx" => {

stackslib/src/burnchains/burnchain.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use crate::chainstate::burn::operations::{
5757
};
5858
use crate::chainstate::burn::{BlockSnapshot, Opcodes};
5959
use crate::chainstate::coordinator::comm::CoordinatorChannels;
60+
use crate::chainstate::coordinator::SortitionDBMigrator;
6061
use crate::chainstate::stacks::address::{PoxAddress, StacksAddressExtensions};
6162
use crate::chainstate::stacks::boot::{POX_2_MAINNET_CODE, POX_2_TESTNET_CODE};
6263
use crate::chainstate::stacks::StacksPublicKey;
@@ -634,6 +635,8 @@ impl Burnchain {
634635
}
635636

636637
/// Connect to the burnchain databases. They may or may not already exist.
638+
/// NOTE: this will _not_ perform a chainstate migration! Use
639+
/// coordinator::migrate_chainstate_dbs() for that.
637640
pub fn connect_db(
638641
&self,
639642
readwrite: bool,
@@ -653,6 +656,7 @@ impl Burnchain {
653656
first_block_header_timestamp,
654657
&epochs,
655658
self.pox_constants.clone(),
659+
None,
656660
readwrite,
657661
)?;
658662
let burnchaindb = BurnchainDB::connect(&burnchain_db_path, self, readwrite)?;

0 commit comments

Comments
 (0)