mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-24 03:45:38 +08:00
fix: uncomment and finish the integration test that confirms that we can begin pox-2 at the end of a reward cycle and unlock pox-1 at the start of the next, and that stacking proceeds through the v1 unlock reward cycle
This commit is contained in:
@@ -68,6 +68,9 @@ use crate::Keychain;
|
||||
|
||||
use stacks::util::sleep_ms;
|
||||
|
||||
use stacks::util_lib::boot::boot_code_id;
|
||||
use stacks_common::types::chainstate::StacksBlockId;
|
||||
|
||||
const MINER_BURN_PUBLIC_KEY: &'static str =
|
||||
"03dc62fe0b8964d01fc9ca9a5eec0e22e557a12cc656919e648f04e0b26fea5faa";
|
||||
|
||||
@@ -4677,26 +4680,15 @@ fn test_sortition_divergence_pre_21() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
#[test]
|
||||
#[ignore]
|
||||
// fails with NoSuchContract: epoch_21 = 215, v1_unlock_height = 216
|
||||
// fails with NoSuchContract: epoch_21 = 214, v1_unlock_height = 215
|
||||
// fails with NoSuchContract: epoch_21 = 213, v1_unlock_height = 214
|
||||
// works: epoch_21 = 212, v1_unlock_height = 213
|
||||
// works: epoch_21 = 211, v1_unlock_height = 212
|
||||
// fails with NoSuchContract: epoch_21 = 211, v1_unlock_height = 211
|
||||
// fails with NoSuchContract: epoch_21 = 210, v1_unlock_height = 211
|
||||
// fails with NoSuchContract: epoch_21 = 209, v1_unlock_height = 211
|
||||
//
|
||||
// works: epoch_21 = 209, v1_unlock_height = 212
|
||||
// works: epoch_21 = 209, v1_unlock_height = 214
|
||||
// works: epoch_21 = 210, v1_unlock_height = 212
|
||||
// works: epoch_21 = 211, v1_unlock_height = 216
|
||||
// works: epoch_21 = 211, v1_unlock_height = 218
|
||||
// works: epoch_21 = 213, v1_unlock_height = 218
|
||||
// works: epoch_21 = 214, v1_unlock_height = 218
|
||||
fn test_v1_unlock_height() {
|
||||
/// Verify that it is acceptable to launch PoX-2 at the end of a reward cycle, and set v1 unlock
|
||||
/// height to be at the start of the subsequent reward cycle.
|
||||
///
|
||||
/// Verify that PoX-1 stackers continue to receive PoX payouts after v1 unlock height, and that
|
||||
/// PoX-2 stackers only begin receiving rewards at the start of the reward cycle following the one
|
||||
/// that contains v1 unlock height.
|
||||
fn test_v1_unlock_height_with_current_stackers() {
|
||||
if env::var("BITCOIND_TEST") != Ok("1".into()) {
|
||||
return;
|
||||
}
|
||||
@@ -4705,7 +4697,7 @@ fn test_v1_unlock_height() {
|
||||
let prepare_phase_len = 3;
|
||||
let epoch_2_05 = 205;
|
||||
let epoch_2_1 = 210;
|
||||
let v1_unlock_height = 212;
|
||||
let v1_unlock_height = 211;
|
||||
|
||||
let stacked = 100_000_000_000 * (core::MICROSTACKS_PER_STACKS as u64);
|
||||
|
||||
@@ -4718,12 +4710,22 @@ fn test_v1_unlock_height() {
|
||||
amount: stacked + 100_000,
|
||||
});
|
||||
|
||||
let pox_pubkey = Secp256k1PublicKey::from_hex(
|
||||
let pox_pubkey_1 = Secp256k1PublicKey::from_hex(
|
||||
"02f006a09b59979e2cb8449f58076152af6b124aa29b948a3714b8d5f15aa94ede",
|
||||
)
|
||||
.unwrap();
|
||||
let pox_pubkey_hash = bytes_to_hex(
|
||||
&Hash160::from_node_public_key(&pox_pubkey)
|
||||
let pox_pubkey_hash_1 = bytes_to_hex(
|
||||
&Hash160::from_node_public_key(&pox_pubkey_1)
|
||||
.to_bytes()
|
||||
.to_vec(),
|
||||
);
|
||||
|
||||
let pox_pubkey_2 = Secp256k1PublicKey::from_hex(
|
||||
"03cd91307e16c10428dd0120d0a4d37f14d4e0097b3b2ea1651d7bd0fb109cd44b",
|
||||
)
|
||||
.unwrap();
|
||||
let pox_pubkey_hash_2 = bytes_to_hex(
|
||||
&Hash160::from_node_public_key(&pox_pubkey_2)
|
||||
.to_bytes()
|
||||
.to_vec(),
|
||||
);
|
||||
@@ -4795,7 +4797,6 @@ fn test_v1_unlock_height() {
|
||||
let runloop_burnchain = burnchain_config.clone();
|
||||
|
||||
let blocks_processed = run_loop.get_blocks_processed_arc();
|
||||
let miner_status = run_loop.get_miner_status();
|
||||
|
||||
let channel = run_loop.get_coordinator_channel().unwrap();
|
||||
|
||||
@@ -4813,17 +4814,10 @@ fn test_v1_unlock_height() {
|
||||
// second block will be the first mined Stacks block
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
|
||||
loop {
|
||||
let tip_info = get_chain_info(&conf);
|
||||
if tip_info.stacks_tip_height >= epoch_2_1 {
|
||||
break;
|
||||
}
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
}
|
||||
|
||||
let sort_height = channel.get_sortitions_processed();
|
||||
let pox_addr_tuple = execute(
|
||||
&format!("{{ hashbytes: 0x{}, version: 0x00 }}", pox_pubkey_hash,),
|
||||
// stack right away
|
||||
let sort_height = channel.get_sortitions_processed() + 1;
|
||||
let pox_addr_tuple_1 = execute(
|
||||
&format!("{{ hashbytes: 0x{}, version: 0x00 }}", pox_pubkey_hash_1,),
|
||||
ClarityVersion::Clarity2,
|
||||
)
|
||||
.unwrap()
|
||||
@@ -4833,24 +4827,112 @@ fn test_v1_unlock_height() {
|
||||
0,
|
||||
3000,
|
||||
&StacksAddress::from_string("ST000000000000000000002AMW42H").unwrap(),
|
||||
"pox-2",
|
||||
"pox",
|
||||
"stack-stx",
|
||||
&[
|
||||
Value::UInt(stacked.into()),
|
||||
pox_addr_tuple.clone(),
|
||||
pox_addr_tuple_1.clone(),
|
||||
Value::UInt(sort_height as u128),
|
||||
Value::UInt(12),
|
||||
],
|
||||
);
|
||||
|
||||
eprintln!("Submit tx to {:?}", &http_origin);
|
||||
info!("Submit 2.05 stacking tx to {:?}", &http_origin);
|
||||
submit_tx(&http_origin, &tx);
|
||||
|
||||
for i in 0..20 {
|
||||
// wait until epoch 2.1
|
||||
loop {
|
||||
let tip_info = get_chain_info(&conf);
|
||||
if tip_info.burn_block_height >= epoch_2_1 {
|
||||
break;
|
||||
}
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
}
|
||||
|
||||
info!("Test passed processing 2.1");
|
||||
|
||||
let sort_height = channel.get_sortitions_processed() + 1;
|
||||
let pox_addr_tuple_2 = execute(
|
||||
&format!("{{ hashbytes: 0x{}, version: 0x00 }}", pox_pubkey_hash_2,),
|
||||
ClarityVersion::Clarity2,
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let tx = make_contract_call(
|
||||
&spender_sk,
|
||||
1,
|
||||
3000,
|
||||
&StacksAddress::from_string("ST000000000000000000002AMW42H").unwrap(),
|
||||
"pox-2",
|
||||
"stack-stx",
|
||||
&[
|
||||
Value::UInt(stacked.into()),
|
||||
pox_addr_tuple_2.clone(),
|
||||
Value::UInt(sort_height as u128),
|
||||
Value::UInt(12),
|
||||
],
|
||||
);
|
||||
|
||||
info!("Submit 2.1 stacking tx to {:?}", &http_origin);
|
||||
submit_tx(&http_origin, &tx);
|
||||
|
||||
// that it can mine _at all_ is a success criterion
|
||||
let mut last_block_height = get_chain_info(&conf).burn_block_height;
|
||||
for _i in 0..10 {
|
||||
next_block_and_wait(&mut btc_regtest_controller, &blocks_processed);
|
||||
let tip_info = get_chain_info(&conf);
|
||||
if tip_info.burn_block_height > last_block_height {
|
||||
last_block_height = tip_info.burn_block_height;
|
||||
} else {
|
||||
panic!("FATAL: failed to mine");
|
||||
}
|
||||
}
|
||||
|
||||
let tip_info = get_chain_info(&conf);
|
||||
let tip = StacksBlockId::new(&tip_info.stacks_tip_consensus_hash, &tip_info.stacks_tip);
|
||||
|
||||
let (mut chainstate, _) = StacksChainState::open(
|
||||
false,
|
||||
conf.burnchain.chain_id,
|
||||
&conf.get_chainstate_path_str(),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
let sortdb = btc_regtest_controller.sortdb_mut();
|
||||
|
||||
for height in 211..tip_info.burn_block_height {
|
||||
let iconn = sortdb.index_conn();
|
||||
let pox_addrs = chainstate
|
||||
.clarity_eval_read_only(
|
||||
&iconn,
|
||||
&tip,
|
||||
&boot_code_id("pox-2", false),
|
||||
&format!("(get-burn-block-info? pox-addrs u{})", height),
|
||||
)
|
||||
.expect_optional()
|
||||
.unwrap()
|
||||
.expect_tuple()
|
||||
.get_owned("addrs")
|
||||
.unwrap()
|
||||
.expect_list();
|
||||
|
||||
if height < 215 {
|
||||
if !burnchain_config.is_in_prepare_phase(height) {
|
||||
assert_eq!(pox_addrs.len(), 2);
|
||||
for addr_tuple in pox_addrs {
|
||||
assert_eq!(addr_tuple, pox_addr_tuple_1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if !burnchain_config.is_in_prepare_phase(height) {
|
||||
assert_eq!(pox_addrs.len(), 2);
|
||||
for addr_tuple in pox_addrs {
|
||||
assert_eq!(addr_tuple, pox_addr_tuple_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test_observer::clear();
|
||||
channel.stop_chains_coordinator();
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user