mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-28 19:55:20 +08:00
Cleanup reward cycle transitions test
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
This commit is contained in:
@@ -2059,7 +2059,7 @@ impl Default for MinerConfig {
|
||||
filter_origins: HashSet::new(),
|
||||
max_reorg_depth: 3,
|
||||
// TODO: update to a sane value based on stackerdb benchmarking
|
||||
wait_on_signers: Duration::from_secs(20),
|
||||
wait_on_signers: Duration::from_secs(200),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,11 @@ impl BlockMinerThread {
|
||||
test_debug!("Miner: ignoring transaction ({:?}) with nonce {nonce} from address {address}", transaction.txid());
|
||||
continue;
|
||||
}
|
||||
test_debug!("Miner: including transaction ({:?}) with nonce {nonce} from address {address}", transaction.txid());
|
||||
debug!("Miner: including signer transaction.";
|
||||
"nonce" => {nonce},
|
||||
"origin_address" => %address,
|
||||
"txid" => %transaction.txid()
|
||||
);
|
||||
// TODO : filter out transactions that are not valid votes. Do not include transactions with invalid/duplicate nonces for the same address.
|
||||
transactions_to_include.push(transaction);
|
||||
}
|
||||
@@ -392,6 +396,7 @@ impl BlockMinerThread {
|
||||
let mut rejections = HashSet::new();
|
||||
let mut rejections_weight: u64 = 0;
|
||||
let now = Instant::now();
|
||||
debug!("Miner: waiting for block response from reward cycle {reward_cycle } signers...");
|
||||
while now.elapsed() < self.config.miner.wait_on_signers {
|
||||
// Get the block responses from the signers for the block we just proposed
|
||||
let signer_chunks = stackerdbs
|
||||
|
||||
@@ -1156,15 +1156,14 @@ fn stackerdb_reward_cycle_transitions() {
|
||||
.btc_regtest_controller
|
||||
.get_headers_height();
|
||||
let next_reward_cycle = curr_reward_cycle.saturating_add(1);
|
||||
let next_reward_cycle_boundary = signer_test
|
||||
let next_reward_cycle_height = signer_test
|
||||
.running_nodes
|
||||
.btc_regtest_controller
|
||||
.get_burnchain()
|
||||
.reward_cycle_to_block_height(next_reward_cycle)
|
||||
.saturating_sub(1);
|
||||
let next_reward_cycle_reward_set_calculation = next_reward_cycle_boundary
|
||||
.reward_cycle_to_block_height(next_reward_cycle);
|
||||
let next_reward_cycle_reward_set_calculation = next_reward_cycle_height
|
||||
.saturating_sub(prepare_phase_len)
|
||||
.saturating_add(2); // +2 since second block of the prepare phase is where the reward set is calculated
|
||||
.saturating_add(1); // +1 since second block of the prepare phase is where the reward set is calculated
|
||||
|
||||
info!("------------------------- Test Nakamoto Block Mining in Reward Cycle {curr_reward_cycle} -------------------------");
|
||||
|
||||
@@ -1176,7 +1175,8 @@ fn stackerdb_reward_cycle_transitions() {
|
||||
"Mining {} Nakamoto blocks to reach next reward cycle reward set calculation at block height {next_reward_cycle_reward_set_calculation}",
|
||||
nmb_blocks_to_mine
|
||||
);
|
||||
for _ in 0..nmb_blocks_to_mine {
|
||||
for i in 1..=nmb_blocks_to_mine {
|
||||
info!("Mining Nakamoto block #{i} of {nmb_blocks_to_mine}");
|
||||
signer_test.mine_nakamoto_block(timeout);
|
||||
signer_test.wait_for_validate_ok_response(timeout);
|
||||
signer_test.wait_for_frost_signatures(timeout);
|
||||
@@ -1196,30 +1196,31 @@ fn stackerdb_reward_cycle_transitions() {
|
||||
|
||||
info!("DKG has been calculated for the next reward cycle {next_reward_cycle}");
|
||||
|
||||
let current_block_height = signer_test
|
||||
.running_nodes
|
||||
.btc_regtest_controller
|
||||
.get_headers_height();
|
||||
|
||||
let nmb_blocks_to_mine = next_reward_cycle_boundary.saturating_sub(current_block_height);
|
||||
|
||||
info!(
|
||||
"Mining {} Nakamoto blocks to reach next reward cycle {next_reward_cycle} boundary block height {next_reward_cycle_boundary}",
|
||||
nmb_blocks_to_mine
|
||||
);
|
||||
for _ in 0..nmb_blocks_to_mine {
|
||||
info!("Mining Nakamoto blocks to reach next reward cycle {next_reward_cycle}.",);
|
||||
let mut i = 1u32;
|
||||
while signer_test.get_current_reward_cycle() != next_reward_cycle {
|
||||
info!("Mining Nakamoto block #{i} to reach next reward cycle {next_reward_cycle}...");
|
||||
signer_test.mine_nakamoto_block(timeout);
|
||||
signer_test.wait_for_validate_ok_response(timeout);
|
||||
signer_test.wait_for_frost_signatures(timeout);
|
||||
i = i.wrapping_add(1);
|
||||
}
|
||||
|
||||
info!("------------------------- Test Nakamoto Block Mining in Reward Cycle {next_reward_cycle} -------------------------");
|
||||
// First make sure that the aggregate key was actually mined.
|
||||
let set_dkg = signer_test
|
||||
.stacks_client
|
||||
.get_approved_aggregate_key(next_reward_cycle)
|
||||
.expect("Failed to get approved aggregate key")
|
||||
.expect("No approved aggregate key found");
|
||||
assert_eq!(set_dkg, set_dkg_2);
|
||||
|
||||
let current_block_height = signer_test
|
||||
.running_nodes
|
||||
.btc_regtest_controller
|
||||
.get_headers_height();
|
||||
|
||||
debug!("At block height {current_block_height} in reward cycle {next_reward_cycle}");
|
||||
debug!("At block height {current_block_height}");
|
||||
info!(
|
||||
"Mining first Nakamoto block of reward cycle {}...",
|
||||
next_reward_cycle
|
||||
|
||||
Reference in New Issue
Block a user