mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-29 23:43:02 +08:00
Have miners abort signing a block if the burn tip changes
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
This commit is contained in:
@@ -364,15 +364,13 @@ impl BlockMinerThread {
|
||||
|
||||
fn wait_for_signer_signature(
|
||||
&self,
|
||||
sortdb: &SortitionDB,
|
||||
stackerdbs: &StackerDBs,
|
||||
aggregate_public_key: &Point,
|
||||
signer_signature_hash: &Sha512Trunc256Sum,
|
||||
signer_weights: HashMap<StacksAddress, u64>,
|
||||
reward_cycle: u64,
|
||||
) -> Result<ThresholdSignature, NakamotoNodeError> {
|
||||
let reward_cycle = self
|
||||
.burnchain
|
||||
.block_height_to_reward_cycle(self.burn_block.block_height)
|
||||
.expect("FATAL: no reward cycle for burn block");
|
||||
let (signers_contract_id, slot_ids_addresses) =
|
||||
self.get_stackerdb_contract_and_slots(stackerdbs, BLOCK_MSG_ID, reward_cycle)?;
|
||||
let slot_ids = slot_ids_addresses.keys().cloned().collect::<Vec<_>>();
|
||||
@@ -384,6 +382,10 @@ impl BlockMinerThread {
|
||||
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 {
|
||||
if self.check_burn_tip_changed(&sortdb).is_err() {
|
||||
info!("Miner: burnchain tip changed while waiting for signer signature.");
|
||||
return Err(NakamotoNodeError::BurnchainTipChanged);
|
||||
}
|
||||
// Get the block responses from the signers for the block we just proposed
|
||||
let signer_chunks = stackerdbs
|
||||
.get_latest_chunks(&signers_contract_id, &slot_ids)
|
||||
@@ -513,10 +515,12 @@ impl BlockMinerThread {
|
||||
)?;
|
||||
let signature = self
|
||||
.wait_for_signer_signature(
|
||||
&sort_db,
|
||||
&stackerdbs,
|
||||
&aggregate_public_key,
|
||||
&block.header.signer_signature_hash(),
|
||||
signer_weights,
|
||||
reward_cycle,
|
||||
)
|
||||
.map_err(|e| {
|
||||
ChainstateError::InvalidStacksBlock(format!("Invalid Nakamoto block: {e:?}"))
|
||||
|
||||
Reference in New Issue
Block a user