Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ pub mod test {

let num_blocks = 10;
let mut expected_liquid_ustx = 1024 * POX_THRESHOLD_STEPS_USTX * (keys.len() as u128);
let mut prior_liquid_ustx = expected_liquid_ustx;
let mut missed_initial_blocks = 0;

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

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

if tenure_id >= MINER_REWARD_MATURITY as usize {
let block_reward = 1_000 * MICROSTACKS_PER_STACKS as u128;
let expected_bonus = (missed_initial_blocks as u128) * block_reward
let expected_bonus = (missed_initial_blocks as u128 * block_reward)
/ (INITIAL_MINING_BONUS_WINDOW as u128);
// add mature coinbases
prior_liquid_ustx = expected_liquid_ustx;
expected_liquid_ustx += block_reward + expected_bonus;
}
}
Expand Down Expand Up @@ -1317,6 +1320,7 @@ pub mod test {

let num_blocks = 10;
let mut expected_liquid_ustx = 1024 * POX_THRESHOLD_STEPS_USTX * (keys.len() as u128);
let mut prior_liquid_ustx = expected_liquid_ustx;
let mut missed_initial_blocks = 0;

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

expected_liquid_ustx -= 1;

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

expected_liquid_ustx -= 1;
prior_liquid_ustx = expected_liquid_ustx;

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

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

if cur_reward_cycle >= alice_reward_cycle {
// this will grow as more miner rewards are unlocked, so be wary
if tenure_id >= (MINER_REWARD_MATURITY + 1) as usize {
if tenure_id >= (MINER_REWARD_MATURITY + 2) as usize {
// miner rewards increased liquid supply, so less than 25% is locked.
// minimum participation decreases.
assert!(total_liquid_ustx > 4 * 1024 * POX_THRESHOLD_STEPS_USTX);
Expand Down Expand Up @@ -3017,7 +3023,7 @@ pub mod test {
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);

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

block_txs.push(charlie_stack);
Expand Down Expand Up @@ -3961,7 +3967,7 @@ pub mod test {

if cur_reward_cycle >= alice_reward_cycle {
// this will grow as more miner rewards are unlocked, so be wary
if tenure_id >= (MINER_REWARD_MATURITY + 1) as usize {
if tenure_id >= (MINER_REWARD_MATURITY + 2) as usize {
// miner rewards increased liquid supply, so less than 25% is locked.
// minimum participation decreases.
assert!(total_liquid_ustx > 4 * 1024 * POX_THRESHOLD_STEPS_USTX);
Expand Down
2 changes: 1 addition & 1 deletion testnet/stacks-node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl ConfigFile {
rpc_port: Some(18332),
peer_port: Some(18333),
peer_host: Some("bitcoind.xenon.blockstack.org".to_string()),
magic_bytes: Some("X2".into()),
magic_bytes: Some("X3".into()),
..BurnchainConfigFile::default()
};

Expand Down
100 changes: 20 additions & 80 deletions testnet/stacks-node/src/tests/neon_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn neon_integration_test_conf() -> (Config, StacksAddress) {
let magic_bytes = Config::from_config_file(ConfigFile::xenon())
.burnchain
.magic_bytes;
assert_eq!(magic_bytes.as_bytes(), &['X' as u8, '2' as u8]);
assert_eq!(magic_bytes.as_bytes(), &['X' as u8, '3' as u8]);
conf.burnchain.magic_bytes = magic_bytes;
conf.burnchain.poll_time_secs = 1;
conf.node.pox_sync_sample_secs = 1;
Expand Down Expand Up @@ -1523,30 +1523,11 @@ fn pox_integration_test() {
);

// okay, let's push that stacking transaction!
let path = format!("{}/v2/transactions", &http_origin);
let res = client
.post(&path)
.header("Content-Type", "application/octet-stream")
.body(tx.clone())
.send()
.unwrap();
eprintln!("{:#?}", res);
if res.status().is_success() {
let res: String = res.json().unwrap();
assert_eq!(
res,
StacksTransaction::consensus_deserialize(&mut &tx[..])
.unwrap()
.txid()
.to_string()
);
} else {
eprintln!("{}", res.text().unwrap());
panic!("");
}
submit_tx(&http_origin, &tx);

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

// now let's mine until the next reward cycle starts ...
while sort_height < ((14 * pox_constants.reward_cycle_length) + 1).into() {
Expand All @@ -1569,32 +1550,32 @@ fn pox_integration_test() {
break;
}
let transactions = block.get("transactions").unwrap().as_array().unwrap();
eprintln!("{}", transactions.len());
for tx in transactions.iter() {
let raw_tx = tx.get("raw_tx").unwrap().as_str().unwrap();
if raw_tx == "0x00" {
continue;
}
let tx_bytes = hex_bytes(&raw_tx[2..]).unwrap();
let parsed = StacksTransaction::consensus_deserialize(&mut &tx_bytes[..]).unwrap();
if let TransactionPayload::ContractCall(_) = parsed.payload {
} else {
continue;
if let TransactionPayload::ContractCall(contract_call) = parsed.payload {
eprintln!("{}", contract_call.function_name.as_str());
if contract_call.function_name.as_str() == "stack-stx" {
let raw_result = tx.get("raw_result").unwrap().as_str().unwrap();
let parsed =
<Value as ClarityDeserializable<Value>>::deserialize(&raw_result[2..]);
// should unlock at height 300 (we're in reward cycle 13, lockup starts in reward cycle
// 14, and goes for 6 blocks, so we unlock in reward cycle 20, which with a reward
// cycle length of 15 blocks, is a burnchain height of 300)
assert_eq!(parsed.to_string(),
format!("(ok (tuple (lock-amount u1000000000000000) (stacker {}) (unlock-burn-height u300)))",
&spender_addr));
tested = true;
}
}

let raw_result = tx.get("raw_result").unwrap().as_str().unwrap();
let parsed = <Value as ClarityDeserializable<Value>>::deserialize(&raw_result[2..]);
// should unlock at height 300 (we're in reward cycle 13, lockup starts in reward cycle
// 14, and goes for 6 blocks, so we unlock in reward cycle 20, which with a reward
// cycle length of 15 blocks, is a burnchain height of 300)
assert_eq!(parsed.to_string(),
format!("(ok (tuple (lock-amount u1000000000000000) (stacker {}) (unlock-burn-height u300)))",
&spender_addr));
tested = true;
}
}

assert!(tested);
assert!(tested, "Should have observed stack-stx transaction");

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

Expand Down Expand Up @@ -1622,27 +1603,7 @@ fn pox_integration_test() {
);

// okay, let's push that stacking transaction!
let path = format!("{}/v2/transactions", &http_origin);
let res = client
.post(&path)
.header("Content-Type", "application/octet-stream")
.body(tx.clone())
.send()
.unwrap();
eprintln!("{:#?}", res);
if res.status().is_success() {
let res: String = res.json().unwrap();
assert_eq!(
res,
StacksTransaction::consensus_deserialize(&mut &tx[..])
.unwrap()
.txid()
.to_string()
);
} else {
eprintln!("{}", res.text().unwrap());
panic!("");
}
submit_tx(&http_origin, &tx);

let tx = make_contract_call(
&spender_3_sk,
Expand All @@ -1664,28 +1625,7 @@ fn pox_integration_test() {
],
);

// okay, let's push that stacking transaction!
let path = format!("{}/v2/transactions", &http_origin);
let res = client
.post(&path)
.header("Content-Type", "application/octet-stream")
.body(tx.clone())
.send()
.unwrap();
eprintln!("{:#?}", res);
if res.status().is_success() {
let res: String = res.json().unwrap();
assert_eq!(
res,
StacksTransaction::consensus_deserialize(&mut &tx[..])
.unwrap()
.txid()
.to_string()
);
} else {
eprintln!("{}", res.text().unwrap());
panic!("");
}
submit_tx(&http_origin, &tx);

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