Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delayed_miner_triggers_tenure_extend test #5529

Closed
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/bitcoin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- tests::signer::v0::end_of_tenure
- tests::signer::v0::forked_tenure_okay
- tests::signer::v0::forked_tenure_invalid
- tests::signer::v0::empty_sortition
- tests::signer::v0::delayed_miner_marked_malicious
- tests::signer::v0::empty_sortition_before_approval
- tests::signer::v0::empty_sortition_before_proposal
- tests::signer::v0::bitcoind_forking_test
Expand Down
14 changes: 11 additions & 3 deletions testnet/stacks-node/src/nakamoto_node/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::time::{Duration, Instant};

use clarity::boot_util::boot_code_id;
use clarity::vm::types::PrincipalData;
use lazy_static::lazy_static;
use libsigner::v0::messages::{MinerSlotID, SignerMessage};
use libsigner::StackerDBSession;
use rand::{thread_rng, Rng};
Expand Down Expand Up @@ -50,14 +51,21 @@ use super::relayer::RelayerThread;
use super::sign_coordinator::SignCoordinator;
use super::{Config, Error as NakamotoNodeError, EventDispatcher, Keychain};
use crate::nakamoto_node::VRF_MOCK_MINER_KEY;
#[cfg(test)]
use crate::neon::TestFlag;
use crate::neon_node;
use crate::run_loop::nakamoto::Globals;
use crate::run_loop::RegisteredKey;

#[cfg(test)]
pub static TEST_MINE_STALL: std::sync::Mutex<Option<bool>> = std::sync::Mutex::new(None);

#[cfg(test)]
pub static TEST_BROADCAST_STALL: std::sync::Mutex<Option<bool>> = std::sync::Mutex::new(None);
lazy_static! {
/// Stall miner block proposals broadcast while this flag is set.
pub static ref TEST_BROADCAST_STALL: TestFlag = TestFlag::default();
}

#[cfg(test)]
pub static TEST_BLOCK_ANNOUNCE_STALL: std::sync::Mutex<Option<bool>> = std::sync::Mutex::new(None);
#[cfg(test)]
Expand Down Expand Up @@ -185,15 +193,15 @@ impl BlockMinerThread {

#[cfg(test)]
fn fault_injection_block_broadcast_stall(new_block: &NakamotoBlock) {
if *TEST_BROADCAST_STALL.lock().unwrap() == Some(true) {
if TEST_BROADCAST_STALL.get() {
// Do an extra check just so we don't log EVERY time.
warn!("Fault injection: Broadcasting is stalled due to testing directive.";
"stacks_block_id" => %new_block.block_id(),
"stacks_block_hash" => %new_block.header.block_hash(),
"height" => new_block.header.chain_length,
"consensus_hash" => %new_block.header.consensus_hash
);
while *TEST_BROADCAST_STALL.lock().unwrap() == Some(true) {
while TEST_BROADCAST_STALL.get() {
std::thread::sleep(std::time::Duration::from_millis(10));
}
info!("Fault injection: Broadcasting is no longer stalled due to testing directive.";
Expand Down
4 changes: 2 additions & 2 deletions testnet/stacks-node/src/tests/nakamoto_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4973,7 +4973,7 @@ fn forked_tenure_is_ignored() {

// For the next tenure, submit the commit op but do not allow any stacks blocks to be broadcasted.
// Stall the miner thread; only wait until the number of submitted commits increases.
TEST_BROADCAST_STALL.lock().unwrap().replace(true);
TEST_BROADCAST_STALL.set(true);
TEST_BLOCK_ANNOUNCE_STALL.lock().unwrap().replace(true);
let blocks_before = mined_blocks.load(Ordering::SeqCst);
let commits_before = commits_submitted.load(Ordering::SeqCst);
Expand All @@ -4991,7 +4991,7 @@ fn forked_tenure_is_ignored() {
// Unpause the broadcast of Tenure B's block, do not submit commits, and do not allow blocks to
// be processed
test_skip_commit_op.set(true);
TEST_BROADCAST_STALL.lock().unwrap().replace(false);
TEST_BROADCAST_STALL.set(false);

// Wait for a stacks block to be broadcasted.
// However, it will not be processed.
Expand Down
Loading
Loading