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: use permanent backoff when stacker set not found #5104

Merged
merged 9 commits into from
Sep 17, 2024
2 changes: 1 addition & 1 deletion stacks-signer/src/client/stacks_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ impl StacksClient {
backoff::Error::permanent(e.into())
})?;
if error_data.err_type == GetStackersErrors::NOT_AVAILABLE_ERR_TYPE {
Err(backoff::Error::transient(ClientError::NoSortitionOnChain))
Err(backoff::Error::permanent(ClientError::NoSortitionOnChain))
} else {
warn!("Got error response ({status}): {}", error_data.err_msg);
Err(backoff::Error::permanent(ClientError::RequestFailure(
Expand Down
28 changes: 14 additions & 14 deletions testnet/stacks-node/src/tests/signer/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,31 +831,31 @@ fn reloads_signer_set_in() {
);

info!("Waiting for signer set calculation.");
let mut reward_set_calculated = false;
let short_timeout = Duration::from_secs(30);
let now = std::time::Instant::now();
// Make sure the signer set is calculated before continuing or signers may not
// recognize that they are registered signers in the subsequent burn block event
let reward_cycle = signer_test.get_current_reward_cycle() + 1;
signer_test
.running_nodes
.btc_regtest_controller
.build_next_block(1);
while !reward_set_calculated {
let reward_set = signer_test
wait_for(short_timeout.as_secs(), || {
let reward_set = match signer_test
.stacks_client
.get_reward_set_signers(reward_cycle)
.expect("Failed to check if reward set is calculated");
reward_set_calculated = reward_set.is_some();
if reward_set_calculated {
info!("Signer set: {:?}", reward_set.unwrap());
{
Ok(x) => x,
Err(e) => {
warn!("Failed to check if reward set is calculated yet: {e:?}. Will try again");
return Ok(false);
}
};
if let Some(ref set) = reward_set {
info!("Signer set: {:?}", set);
}
std::thread::sleep(Duration::from_secs(1));
assert!(
now.elapsed() < short_timeout,
"Timed out waiting for reward set calculation"
);
}
Ok(reward_set.is_some())
})
.expect("Timed out waiting for reward set to be calculated");
info!("Signer set calculated");

// Manually consume one more block to ensure signers refresh their state
Expand Down