Skip to content

Commit 93ff0e8

Browse files
authored
Merge pull request #4611 from stacks-network/fix/4609
Fix/4609
2 parents c26e00c + 09ac58c commit 93ff0e8

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

stackslib/src/chainstate/nakamoto/mod.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,7 @@ impl NakamotoChainState {
17731773
chainstate: &mut StacksChainState,
17741774
for_burn_block_height: u64,
17751775
at_block_id: &StacksBlockId,
1776+
warn_if_not_found: bool,
17761777
) -> Result<Point, ChainstateError> {
17771778
// Get the current reward cycle
17781779
let Some(rc) = sort_handle.pox_constants().block_height_to_reward_cycle(
@@ -1788,18 +1789,22 @@ impl NakamotoChainState {
17881789
return Err(ChainstateError::InvalidStacksBlock(msg));
17891790
};
17901791

1791-
debug!(
1792+
test_debug!(
17921793
"get-approved-aggregate-key at block {}, cycle {}",
1793-
at_block_id, rc
1794+
at_block_id,
1795+
rc
17941796
);
17951797
match chainstate.get_aggregate_public_key_pox_4(sortdb, at_block_id, rc)? {
17961798
Some(key) => Ok(key),
17971799
None => {
1798-
warn!(
1799-
"Failed to get aggregate public key";
1800-
"block_id" => %at_block_id,
1801-
"reward_cycle" => rc,
1802-
);
1800+
// this can happen for a whole host of reasons
1801+
if warn_if_not_found {
1802+
warn!(
1803+
"Failed to get aggregate public key";
1804+
"block_id" => %at_block_id,
1805+
"reward_cycle" => rc,
1806+
);
1807+
}
18031808
Err(ChainstateError::InvalidStacksBlock(
18041809
"Failed to get aggregate public key".into(),
18051810
))
@@ -1828,6 +1833,7 @@ impl NakamotoChainState {
18281833
chainstate,
18291834
block_sn.block_height,
18301835
&aggregate_key_block_header.index_block_hash(),
1836+
true,
18311837
)?;
18321838
Ok(aggregate_public_key)
18331839
}

stackslib/src/net/p2p.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5388,7 +5388,7 @@ impl PeerNetwork {
53885388
.last_key_value()
53895389
.map(|(rc, _)| rc.saturating_add(1))
53905390
.unwrap_or(0);
5391-
let new_agg_pubkeys = (next_agg_pubkey_rc..=sort_tip_rc)
5391+
let mut new_agg_pubkeys: Vec<_> = (next_agg_pubkey_rc..=sort_tip_rc)
53925392
.filter_map(|key_rc| {
53935393
let ih = sortdb.index_handle(&tip_sn.sortition_id);
53945394
let agg_pubkey_opt = if self.get_current_epoch().epoch_id < StacksEpochId::Epoch25 {
@@ -5404,6 +5404,7 @@ impl PeerNetwork {
54045404
chainstate,
54055405
self.burnchain.reward_cycle_to_block_height(key_rc),
54065406
&stacks_tip_block_id,
5407+
false,
54075408
)
54085409
.ok()
54095410
};
@@ -5414,6 +5415,10 @@ impl PeerNetwork {
54145415
})
54155416
.collect();
54165417

5418+
if new_agg_pubkeys.len() == 0 && self.aggregate_public_keys.len() == 0 {
5419+
// special case -- we're before epoch 3.0, so don't waste time doing this again
5420+
new_agg_pubkeys.push((sort_tip_rc, None));
5421+
}
54175422
Ok(new_agg_pubkeys)
54185423
}
54195424

0 commit comments

Comments
 (0)