Skip to content

Commit fd71c6a

Browse files
author
Aaron Blankstein
authored
Merge pull request #2235 from blockstack/feat/reset-xe-2
Update Xenon magic bytes for reset
2 parents dcd6ce3 + bea3467 commit fd71c6a

File tree

3 files changed

+38
-92
lines changed

3 files changed

+38
-92
lines changed

src/chainstate/stacks/boot/mod.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,7 @@ pub mod test {
10191019

10201020
let num_blocks = 10;
10211021
let mut expected_liquid_ustx = 1024 * POX_THRESHOLD_STEPS_USTX * (keys.len() as u128);
1022+
let mut prior_liquid_ustx = expected_liquid_ustx;
10221023
let mut missed_initial_blocks = 0;
10231024

10241025
for tenure_id in 0..num_blocks {
@@ -1070,13 +1071,15 @@ pub mod test {
10701071
peer.process_stacks_epoch_at_tip(&stacks_block, &microblocks);
10711072

10721073
let liquid_ustx = get_liquid_ustx(&mut peer);
1073-
assert_eq!(liquid_ustx, expected_liquid_ustx);
1074+
// get_liquid_ustx is "off by one", i.e., it loads the parents liquid ustx
1075+
assert_eq!(liquid_ustx, prior_liquid_ustx);
10741076

10751077
if tenure_id >= MINER_REWARD_MATURITY as usize {
10761078
let block_reward = 1_000 * MICROSTACKS_PER_STACKS as u128;
1077-
let expected_bonus = (missed_initial_blocks as u128) * block_reward
1079+
let expected_bonus = (missed_initial_blocks as u128 * block_reward)
10781080
/ (INITIAL_MINING_BONUS_WINDOW as u128);
10791081
// add mature coinbases
1082+
prior_liquid_ustx = expected_liquid_ustx;
10801083
expected_liquid_ustx += block_reward + expected_bonus;
10811084
}
10821085
}
@@ -1317,6 +1320,7 @@ pub mod test {
13171320

13181321
let num_blocks = 10;
13191322
let mut expected_liquid_ustx = 1024 * POX_THRESHOLD_STEPS_USTX * (keys.len() as u128);
1323+
let mut prior_liquid_ustx = expected_liquid_ustx;
13201324
let mut missed_initial_blocks = 0;
13211325

13221326
let alice = keys.pop().unwrap();
@@ -1377,10 +1381,12 @@ pub mod test {
13771381
peer.next_burnchain_block(burn_ops.clone());
13781382
peer.process_stacks_epoch_at_tip(&stacks_block, &microblocks);
13791383

1380-
expected_liquid_ustx -= 1;
1381-
13821384
let liquid_ustx = get_liquid_ustx(&mut peer);
1383-
assert_eq!(liquid_ustx, expected_liquid_ustx);
1385+
// get_liquid_ustx is "off by one", i.e., it loads the parents liquid ustx
1386+
assert_eq!(liquid_ustx, prior_liquid_ustx);
1387+
1388+
expected_liquid_ustx -= 1;
1389+
prior_liquid_ustx = expected_liquid_ustx;
13841390

13851391
if tenure_id >= MINER_REWARD_MATURITY as usize {
13861392
let block_reward = 1_000 * MICROSTACKS_PER_STACKS as u128;
@@ -1815,7 +1821,7 @@ pub mod test {
18151821

18161822
if cur_reward_cycle >= lockup_reward_cycle {
18171823
// this will grow as more miner rewards are unlocked, so be wary
1818-
if tenure_id >= (MINER_REWARD_MATURITY + 1) as usize {
1824+
if tenure_id >= (MINER_REWARD_MATURITY + 2) as usize {
18191825
// miner rewards increased liquid supply, so less than 25% is locked.
18201826
// minimum participation decreases.
18211827
assert!(total_liquid_ustx > 4 * 1024 * POX_THRESHOLD_STEPS_USTX);
@@ -2404,7 +2410,7 @@ pub mod test {
24042410
"(define-data-var test-run bool false)
24052411
(define-data-var test-result int -1)
24062412
(let ((result
2407-
(contract-call? '{}.pox stack-stx u256000000 (tuple (version 0x00) (hashbytes 0xae1593226f85e49a7eaff5b633ff687695438cc9)) burn-block-height u12)))
2413+
(contract-call? '{}.pox stack-stx u10240000000000 (tuple (version 0x00) (hashbytes 0xae1593226f85e49a7eaff5b633ff687695438cc9)) burn-block-height u12)))
24082414
(var-set test-result
24092415
(match result ok_value -1 err_value err_value))
24102416
(var-set test-run true))
@@ -2703,7 +2709,7 @@ pub mod test {
27032709

27042710
if cur_reward_cycle >= alice_reward_cycle {
27052711
// this will grow as more miner rewards are unlocked, so be wary
2706-
if tenure_id >= (MINER_REWARD_MATURITY + 1) as usize {
2712+
if tenure_id >= (MINER_REWARD_MATURITY + 2) as usize {
27072713
// miner rewards increased liquid supply, so less than 25% is locked.
27082714
// minimum participation decreases.
27092715
assert!(total_liquid_ustx > 4 * 1024 * POX_THRESHOLD_STEPS_USTX);
@@ -3017,7 +3023,7 @@ pub mod test {
30173023
eprintln!("\ntenure: {}\nreward cycle: {}\nmin-uSTX: {}\naddrs: {:?}\ntotal_liquid_ustx: {}\ntotal-stacked: {}\n", tenure_id, cur_reward_cycle, min_ustx, &reward_addrs, total_liquid_ustx, total_stacked);
30183024

30193025
// this will grow as more miner rewards are unlocked, so be wary
3020-
if tenure_id >= (MINER_REWARD_MATURITY + 1) as usize {
3026+
if tenure_id >= (MINER_REWARD_MATURITY + 2) as usize {
30213027
// miner rewards increased liquid supply, so less than 25% is locked.
30223028
// minimum participation decreases.
30233029
assert!(total_liquid_ustx > 4 * 1024 * POX_THRESHOLD_STEPS_USTX);
@@ -3817,7 +3823,7 @@ pub mod test {
38173823
// Note: this behavior is a bug in the miner and block processor: see issue #?
38183824
let charlie_stack = make_bare_contract(&charlie, 2, 0, "charlie-try-stack",
38193825
&format!(
3820-
"(asserts! (not (is-eq (print (contract-call? '{}.pox stack-stx u1 {{ version: 0x01, hashbytes: 0x1111111111111111111111111111111111111111 }} burn-block-height u1)) (err 17))) (err 1))",
3826+
"(asserts! (not (is-eq (print (contract-call? '{}.pox stack-stx u10240000000000 {{ version: 0x01, hashbytes: 0x1111111111111111111111111111111111111111 }} burn-block-height u1)) (err 17))) (err 1))",
38213827
boot_code_addr()));
38223828

38233829
block_txs.push(charlie_stack);
@@ -3961,7 +3967,7 @@ pub mod test {
39613967

39623968
if cur_reward_cycle >= alice_reward_cycle {
39633969
// this will grow as more miner rewards are unlocked, so be wary
3964-
if tenure_id >= (MINER_REWARD_MATURITY + 1) as usize {
3970+
if tenure_id >= (MINER_REWARD_MATURITY + 2) as usize {
39653971
// miner rewards increased liquid supply, so less than 25% is locked.
39663972
// minimum participation decreases.
39673973
assert!(total_liquid_ustx > 4 * 1024 * POX_THRESHOLD_STEPS_USTX);

testnet/stacks-node/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl ConfigFile {
239239
rpc_port: Some(18332),
240240
peer_port: Some(18333),
241241
peer_host: Some("bitcoind.xenon.blockstack.org".to_string()),
242-
magic_bytes: Some("X2".into()),
242+
magic_bytes: Some("X3".into()),
243243
..BurnchainConfigFile::default()
244244
};
245245

testnet/stacks-node/src/tests/neon_integrations.rs

Lines changed: 20 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn neon_integration_test_conf() -> (Config, StacksAddress) {
6262
let magic_bytes = Config::from_config_file(ConfigFile::xenon())
6363
.burnchain
6464
.magic_bytes;
65-
assert_eq!(magic_bytes.as_bytes(), &['X' as u8, '2' as u8]);
65+
assert_eq!(magic_bytes.as_bytes(), &['X' as u8, '3' as u8]);
6666
conf.burnchain.magic_bytes = magic_bytes;
6767
conf.burnchain.poll_time_secs = 1;
6868
conf.node.pox_sync_sample_secs = 1;
@@ -1523,30 +1523,11 @@ fn pox_integration_test() {
15231523
);
15241524

15251525
// okay, let's push that stacking transaction!
1526-
let path = format!("{}/v2/transactions", &http_origin);
1527-
let res = client
1528-
.post(&path)
1529-
.header("Content-Type", "application/octet-stream")
1530-
.body(tx.clone())
1531-
.send()
1532-
.unwrap();
1533-
eprintln!("{:#?}", res);
1534-
if res.status().is_success() {
1535-
let res: String = res.json().unwrap();
1536-
assert_eq!(
1537-
res,
1538-
StacksTransaction::consensus_deserialize(&mut &tx[..])
1539-
.unwrap()
1540-
.txid()
1541-
.to_string()
1542-
);
1543-
} else {
1544-
eprintln!("{}", res.text().unwrap());
1545-
panic!("");
1546-
}
1526+
submit_tx(&http_origin, &tx);
15471527

15481528
let mut sort_height = channel.get_sortitions_processed();
15491529
eprintln!("Sort height: {}", sort_height);
1530+
test_observer::clear();
15501531

15511532
// now let's mine until the next reward cycle starts ...
15521533
while sort_height < ((14 * pox_constants.reward_cycle_length) + 1).into() {
@@ -1569,32 +1550,32 @@ fn pox_integration_test() {
15691550
break;
15701551
}
15711552
let transactions = block.get("transactions").unwrap().as_array().unwrap();
1572-
eprintln!("{}", transactions.len());
15731553
for tx in transactions.iter() {
15741554
let raw_tx = tx.get("raw_tx").unwrap().as_str().unwrap();
15751555
if raw_tx == "0x00" {
15761556
continue;
15771557
}
15781558
let tx_bytes = hex_bytes(&raw_tx[2..]).unwrap();
15791559
let parsed = StacksTransaction::consensus_deserialize(&mut &tx_bytes[..]).unwrap();
1580-
if let TransactionPayload::ContractCall(_) = parsed.payload {
1581-
} else {
1582-
continue;
1560+
if let TransactionPayload::ContractCall(contract_call) = parsed.payload {
1561+
eprintln!("{}", contract_call.function_name.as_str());
1562+
if contract_call.function_name.as_str() == "stack-stx" {
1563+
let raw_result = tx.get("raw_result").unwrap().as_str().unwrap();
1564+
let parsed =
1565+
<Value as ClarityDeserializable<Value>>::deserialize(&raw_result[2..]);
1566+
// should unlock at height 300 (we're in reward cycle 13, lockup starts in reward cycle
1567+
// 14, and goes for 6 blocks, so we unlock in reward cycle 20, which with a reward
1568+
// cycle length of 15 blocks, is a burnchain height of 300)
1569+
assert_eq!(parsed.to_string(),
1570+
format!("(ok (tuple (lock-amount u1000000000000000) (stacker {}) (unlock-burn-height u300)))",
1571+
&spender_addr));
1572+
tested = true;
1573+
}
15831574
}
1584-
1585-
let raw_result = tx.get("raw_result").unwrap().as_str().unwrap();
1586-
let parsed = <Value as ClarityDeserializable<Value>>::deserialize(&raw_result[2..]);
1587-
// should unlock at height 300 (we're in reward cycle 13, lockup starts in reward cycle
1588-
// 14, and goes for 6 blocks, so we unlock in reward cycle 20, which with a reward
1589-
// cycle length of 15 blocks, is a burnchain height of 300)
1590-
assert_eq!(parsed.to_string(),
1591-
format!("(ok (tuple (lock-amount u1000000000000000) (stacker {}) (unlock-burn-height u300)))",
1592-
&spender_addr));
1593-
tested = true;
15941575
}
15951576
}
15961577

1597-
assert!(tested);
1578+
assert!(tested, "Should have observed stack-stx transaction");
15981579

15991580
// let's stack with spender 2 and spender 3...
16001581

@@ -1622,27 +1603,7 @@ fn pox_integration_test() {
16221603
);
16231604

16241605
// okay, let's push that stacking transaction!
1625-
let path = format!("{}/v2/transactions", &http_origin);
1626-
let res = client
1627-
.post(&path)
1628-
.header("Content-Type", "application/octet-stream")
1629-
.body(tx.clone())
1630-
.send()
1631-
.unwrap();
1632-
eprintln!("{:#?}", res);
1633-
if res.status().is_success() {
1634-
let res: String = res.json().unwrap();
1635-
assert_eq!(
1636-
res,
1637-
StacksTransaction::consensus_deserialize(&mut &tx[..])
1638-
.unwrap()
1639-
.txid()
1640-
.to_string()
1641-
);
1642-
} else {
1643-
eprintln!("{}", res.text().unwrap());
1644-
panic!("");
1645-
}
1606+
submit_tx(&http_origin, &tx);
16461607

16471608
let tx = make_contract_call(
16481609
&spender_3_sk,
@@ -1664,28 +1625,7 @@ fn pox_integration_test() {
16641625
],
16651626
);
16661627

1667-
// okay, let's push that stacking transaction!
1668-
let path = format!("{}/v2/transactions", &http_origin);
1669-
let res = client
1670-
.post(&path)
1671-
.header("Content-Type", "application/octet-stream")
1672-
.body(tx.clone())
1673-
.send()
1674-
.unwrap();
1675-
eprintln!("{:#?}", res);
1676-
if res.status().is_success() {
1677-
let res: String = res.json().unwrap();
1678-
assert_eq!(
1679-
res,
1680-
StacksTransaction::consensus_deserialize(&mut &tx[..])
1681-
.unwrap()
1682-
.txid()
1683-
.to_string()
1684-
);
1685-
} else {
1686-
eprintln!("{}", res.text().unwrap());
1687-
panic!("");
1688-
}
1628+
submit_tx(&http_origin, &tx);
16891629

16901630
// mine until the end of the current reward cycle.
16911631
sort_height = channel.get_sortitions_processed();

0 commit comments

Comments
 (0)