diff --git a/src/chainstate/stacks/boot/mod.rs b/src/chainstate/stacks/boot/mod.rs index 84080c4af30..ae75d3f00b6 100644 --- a/src/chainstate/stacks/boot/mod.rs +++ b/src/chainstate/stacks/boot/mod.rs @@ -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 { @@ -1070,13 +1071,15 @@ pub mod test { peer.process_stacks_epoch_at_tip(&stacks_block, µblocks); 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; } } @@ -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(); @@ -1377,10 +1381,12 @@ pub mod test { peer.next_burnchain_block(burn_ops.clone()); peer.process_stacks_epoch_at_tip(&stacks_block, µblocks); - 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; @@ -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); @@ -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)) @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index 5cbca66ba06..eb132b3c55b 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -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() }; diff --git a/testnet/stacks-node/src/tests/neon_integrations.rs b/testnet/stacks-node/src/tests/neon_integrations.rs index 6dfad874d17..0a0e1174a4e 100644 --- a/testnet/stacks-node/src/tests/neon_integrations.rs +++ b/testnet/stacks-node/src/tests/neon_integrations.rs @@ -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; @@ -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() { @@ -1569,7 +1550,6 @@ 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" { @@ -1577,24 +1557,25 @@ fn pox_integration_test() { } 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 = + >::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 = >::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... @@ -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, @@ -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();