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

Minor changes / clean up #4516

Merged
merged 3 commits into from Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions stacks-signer/src/runloop.rs
Expand Up @@ -229,7 +229,7 @@ impl RunLoop {
}

/// Refresh signer configuration for a specific reward cycle
fn refresh_signer_config(&mut self, reward_cycle: u64) {
fn refresh_signer_config(&mut self, reward_cycle: u64, current: bool) {
let reward_index = reward_cycle % 2;
let mut needs_refresh = false;
if let Some(signer) = self.stacks_signers.get_mut(&reward_index) {
Expand Down Expand Up @@ -266,7 +266,11 @@ impl RunLoop {
.insert(reward_index, Signer::from(new_signer_config));
debug!("Reward cycle #{reward_cycle} Signer #{signer_id} initialized.");
} else {
warn!("Signer is not registered for reward cycle {reward_cycle}. Waiting for confirmed registration...");
if current {
warn!("Signer is not registered for the current reward cycle ({reward_cycle}). Waiting for confirmed registration...");
obycode marked this conversation as resolved.
Show resolved Hide resolved
} else {
debug!("Signer is not registered for reward cycle {reward_cycle}. Waiting for confirmed registration...");
}
}
}
}
Expand All @@ -275,8 +279,8 @@ impl RunLoop {
/// Note: this will trigger DKG if required
fn refresh_signers(&mut self, current_reward_cycle: u64) -> Result<(), ClientError> {
let next_reward_cycle = current_reward_cycle.saturating_add(1);
self.refresh_signer_config(current_reward_cycle);
self.refresh_signer_config(next_reward_cycle);
self.refresh_signer_config(current_reward_cycle, true);
self.refresh_signer_config(next_reward_cycle, false);
// TODO: do not use an empty consensus hash
let pox_consensus_hash = ConsensusHash::empty();
let mut to_delete = Vec::new();
Expand All @@ -286,6 +290,7 @@ impl RunLoop {
// We don't really need this state, but it's useful for debugging
signer.state = SignerState::TenureCompleted;
to_delete.push(*idx);
continue;
}
let old_coordinator_id = signer.coordinator_selector.get_coordinator().0;
let updated_coordinator_id = signer
Expand Down
25 changes: 0 additions & 25 deletions testnet/stacks-node/src/nakamoto_node/miner.rs
Expand Up @@ -39,7 +39,6 @@ use stacks::chainstate::stacks::{
TenureChangeCause, TenureChangePayload, ThresholdSignature, TransactionAnchorMode,
TransactionPayload, TransactionVersion,
};
use stacks::core::FIRST_BURNCHAIN_CONSENSUS_HASH;
use stacks::net::stackerdb::StackerDBs;
use stacks_common::codec::{read_next, StacksMessageCodec};
use stacks_common::types::chainstate::{StacksAddress, StacksBlockId};
Expand Down Expand Up @@ -83,8 +82,6 @@ struct ParentTenureInfo {
struct ParentStacksBlockInfo {
/// Header metadata for the Stacks block we're going to build on top of
stacks_parent_header: StacksHeaderInfo,
/// the total amount burned in the sortition that selected the Stacks block parent
parent_block_total_burn: u64,
/// nonce to use for this new block's coinbase transaction
coinbase_nonce: u64,
parent_tenure: Option<ParentTenureInfo>,
Expand Down Expand Up @@ -692,7 +689,6 @@ impl BlockMinerThread {
parent_tenure_blocks: 0,
}),
stacks_parent_header: chain_tip.metadata,
parent_block_total_burn: 0,
coinbase_nonce: 0,
});
};
Expand Down Expand Up @@ -915,26 +911,6 @@ impl ParentStacksBlockInfo {
.expect("Failed to look up block's parent snapshot")
.expect("Failed to look up block's parent snapshot");

let parent_sortition_id = &parent_snapshot.sortition_id;

let parent_block_total_burn =
if &stacks_tip_header.consensus_hash == &FIRST_BURNCHAIN_CONSENSUS_HASH {
0
} else {
let parent_burn_block =
SortitionDB::get_block_snapshot(burn_db.conn(), parent_sortition_id)
.expect("SortitionDB failure.")
.ok_or_else(|| {
error!(
"Failed to find block snapshot for the parent sortition";
"parent_sortition_id" => %parent_sortition_id
);
NakamotoNodeError::SnapshotNotFoundForChainTip
})?;

parent_burn_block.total_burn
};

// don't mine off of an old burnchain block
let burn_chain_tip = SortitionDB::get_canonical_burn_chain_tip(burn_db.conn())
.expect("FATAL: failed to query sortition DB for canonical burn chain tip");
Expand Down Expand Up @@ -1029,7 +1005,6 @@ impl ParentStacksBlockInfo {

Ok(ParentStacksBlockInfo {
stacks_parent_header: stacks_tip_header,
parent_block_total_burn,
coinbase_nonce,
parent_tenure: parent_tenure_info,
})
Expand Down