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

Fix multiple_miners* tests #5237

Merged
merged 23 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8ddddae
Add positive integer for pox_sync_sample_secs and wait_on_interim_blo…
jferrant Sep 24, 2024
082fc51
Merge branch 'develop' into chore/fix-multiple-miners
jcnelson Sep 24, 2024
9360397
Do not use a test_observer in boot_to_epoch_3 to enable use with mult…
jferrant Sep 25, 2024
369bc78
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jferrant Sep 25, 2024
257e7ec
Merge branch 'chore/fix-multiple-miners' of https://github.com/stacks…
jferrant Sep 25, 2024
1f53fac
Do not blanket set pox_sync_sample_secs to a postiive integer
jferrant Sep 25, 2024
b126d17
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jferrant Sep 25, 2024
cd49977
Do not advance unless the bootstrapped or follower node also hits epo…
jferrant Sep 26, 2024
db564e9
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jferrant Sep 26, 2024
c60e4a6
Test: try increasing a timeout to see what CI does
jferrant Sep 27, 2024
28d06b7
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jferrant Sep 30, 2024
9c89e46
Do not wait for an exact number of block rejections
jferrant Sep 30, 2024
065a89b
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jferrant Sep 30, 2024
fdcfcdf
Add some logging to bitcoind test
jferrant Sep 30, 2024
51d6000
Fix microblocks disabled test to allow at least one rather than stric…
jferrant Sep 30, 2024
4c311bb
Convert logs to info in test
jferrant Sep 30, 2024
836a97a
CRC: remove dead code
jferrant Oct 1, 2024
4d1f9a9
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jferrant Oct 1, 2024
61eab90
Change vec to hashset in wait_for_block_rejections
jferrant Oct 1, 2024
4752a90
Do not attempt to process a block validation response for an already …
jferrant Oct 1, 2024
b9d3b90
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jferrant Oct 1, 2024
9eb4e05
test: remove `signer_vote_if_needed`
obycode Oct 1, 2024
db105e0
Increase pox_sync_sample_secs to 5 to be on the safe side when waitin…
jferrant Oct 2, 2024
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
3 changes: 0 additions & 3 deletions stacks-signer/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ pub enum ClientError {
/// Invalid response from the stacks node
#[error("Invalid response from the stacks node: {0}")]
InvalidResponse(String),
/// A successful sortition has not occurred yet
#[error("The Stacks chain has not processed any successful sortitions yet")]
NoSortitionOnChain,
/// A successful sortition's info response should be parseable into a SortitionState
#[error("A successful sortition's info response should be parseable into a SortitionState")]
UnexpectedSortitionInfo,
Expand Down
16 changes: 6 additions & 10 deletions stacks-signer/src/client/stacks_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use blockstack_lib::net::api::get_tenures_fork_info::{
use blockstack_lib::net::api::getaccount::AccountEntryResponse;
use blockstack_lib::net::api::getpoxinfo::RPCPoxInfoData;
use blockstack_lib::net::api::getsortition::{SortitionInfo, RPC_SORTITION_INFO_PATH};
use blockstack_lib::net::api::getstackers::{GetStackersErrors, GetStackersResponse};
use blockstack_lib::net::api::getstackers::GetStackersResponse;
use blockstack_lib::net::api::postblock::StacksBlockAcceptedData;
use blockstack_lib::net::api::postblock_proposal::NakamotoBlockProposal;
use blockstack_lib::net::api::postblock_v3;
Expand Down Expand Up @@ -78,7 +78,6 @@ pub struct StacksClient {

#[derive(Deserialize)]
struct GetStackersErrorResp {
err_type: String,
err_msg: String,
}

Expand Down Expand Up @@ -483,14 +482,11 @@ impl StacksClient {
warn!("Failed to parse the GetStackers error response: {e}");
backoff::Error::permanent(e.into())
})?;
if error_data.err_type == GetStackersErrors::NOT_AVAILABLE_ERR_TYPE {
Err(backoff::Error::permanent(ClientError::NoSortitionOnChain))
} else {
warn!("Got error response ({status}): {}", error_data.err_msg);
Err(backoff::Error::permanent(ClientError::RequestFailure(
status,
)))
}

warn!("Got error response ({status}): {}", error_data.err_msg);
Err(backoff::Error::permanent(ClientError::RequestFailure(
status,
)))
};
let stackers_response =
retry_with_exponential_backoff::<_, ClientError, GetStackersResponse>(send_request)?;
Expand Down
13 changes: 7 additions & 6 deletions testnet/stacks-node/src/tests/epoch_25.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@ fn microblocks_disabled() {
);
assert_eq!(account.nonce, 1);

info!(
"Microblocks assembled: {}",
test_observer::get_microblocks().len()
let microblocks_assembled = test_observer::get_microblocks().len();
jferrant marked this conversation as resolved.
Show resolved Hide resolved
info!("Microblocks assembled: {microblocks_assembled}",);
assert!(
microblocks_assembled > 0,
"There should be at least 1 microblock assembled"
);
assert_eq!(test_observer::get_microblocks().len(), 1);

let miner_nonce_before_microblock_assembly = get_account(&http_origin, &miner_account).nonce;

Expand Down Expand Up @@ -244,8 +245,8 @@ fn microblocks_disabled() {
);
assert_eq!(account.nonce, 1);

// but we should have assembled and announced at least 1 to the observer
assert!(test_observer::get_microblocks().len() >= 2);
// but we should have assembled and announced at least 1 more block to the observer
assert!(test_observer::get_microblocks().len() > microblocks_assembled);
info!(
"Microblocks assembled: {}",
test_observer::get_microblocks().len()
Expand Down
1 change: 1 addition & 0 deletions testnet/stacks-node/src/tests/nakamoto_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,7 @@ fn multiple_miners() {
let node_2_p2p = 51025;
let http_origin = format!("http://{}", &naka_conf.node.rpc_bind);
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(1);
naka_conf.node.pox_sync_sample_secs = 1;
obycode marked this conversation as resolved.
Show resolved Hide resolved
let sender_sk = Secp256k1PrivateKey::new();
let sender_signer_sk = Secp256k1PrivateKey::new();
let sender_signer_addr = tests::to_addr(&sender_signer_sk);
Expand Down
20 changes: 8 additions & 12 deletions testnet/stacks-node/src/tests/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ use stacks_signer::{Signer, SpawnedSigner};

use super::nakamoto_integrations::wait_for;
use crate::config::{Config as NeonConfig, EventKeyType, EventObserverConfig, InitialBalance};
use crate::event_dispatcher::MinedNakamotoBlockEvent;
use crate::neon::{Counters, TestFlag};
use crate::run_loop::boot_nakamoto;
use crate::tests::bitcoin_regtest::BitcoinCoreController;
Expand Down Expand Up @@ -312,9 +311,10 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
output
}

fn mine_nakamoto_block(&mut self, timeout: Duration) -> MinedNakamotoBlockEvent {
fn mine_nakamoto_block(&mut self, timeout: Duration) {
let commits_submitted = self.running_nodes.commits_submitted.clone();
let mined_block_time = Instant::now();
let info_before = self.stacks_client.get_peer_info().unwrap();
next_block_and_mine_commit(
&mut self.running_nodes.btc_regtest_controller,
timeout.as_secs(),
Expand All @@ -323,20 +323,16 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
)
.unwrap();

let t_start = Instant::now();
while test_observer::get_mined_nakamoto_blocks().is_empty() {
assert!(
t_start.elapsed() < timeout,
"Timed out while waiting for mined nakamoto block event"
);
thread::sleep(Duration::from_secs(1));
}
wait_for(timeout.as_secs(), || {
jferrant marked this conversation as resolved.
Show resolved Hide resolved
let info_after = self.stacks_client.get_peer_info().unwrap();
Ok(info_after.stacks_tip_height > info_before.stacks_tip_height)
})
.unwrap();
let mined_block_elapsed_time = mined_block_time.elapsed();
info!(
"Nakamoto block mine time elapsed: {:?}",
mined_block_elapsed_time
);
test_observer::get_mined_nakamoto_blocks().pop().unwrap()
}

fn mine_block_wait_on_processing(
Expand Down Expand Up @@ -630,7 +626,7 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
}
})
.collect::<Vec<_>>();
Ok(block_rejections.len() == expected_signers.len())
Ok(block_rejections.len() >= expected_signers.len())
jferrant marked this conversation as resolved.
Show resolved Hide resolved
})
}
}
Expand Down
Loading