Skip to content

Commit fb306ea

Browse files
committed
chore: fix #5502 by reducing the PoX sync watchdog
1 parent ea7f7cd commit fb306ea

File tree

3 files changed

+48
-554
lines changed

3 files changed

+48
-554
lines changed

testnet/stacks-node/src/run_loop/neon.rs

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,19 +1156,8 @@ impl RunLoop {
11561156

11571157
let mut sortition_db_height = rc_aligned_height;
11581158
let mut burnchain_height = sortition_db_height;
1159-
let mut num_sortitions_in_last_cycle = 1;
11601159

11611160
// prepare to fetch the first reward cycle!
1162-
let mut target_burnchain_block_height = cmp::min(
1163-
burnchain_config.reward_cycle_to_block_height(
1164-
burnchain_config
1165-
.block_height_to_reward_cycle(burnchain_height)
1166-
.expect("BUG: block height is not in a reward cycle")
1167-
+ 1,
1168-
),
1169-
burnchain.get_headers_height() - 1,
1170-
);
1171-
11721161
debug!("Runloop: Begin main runloop starting a burnchain block {sortition_db_height}");
11731162

11741163
let mut last_tenure_sortition_height = 0;
@@ -1196,17 +1185,13 @@ impl RunLoop {
11961185

11971186
let remote_chain_height = burnchain.get_headers_height() - 1;
11981187

1199-
// wait for the p2p state-machine to do at least one pass
1200-
debug!("Runloop: Wait until Stacks block downloads reach a quiescent state before processing more burnchain blocks"; "remote_chain_height" => remote_chain_height, "local_chain_height" => burnchain_height);
1201-
1202-
// wait until it's okay to process the next reward cycle's sortitions
1203-
let ibd = match self.get_pox_watchdog().pox_sync_wait(
1188+
// wait until it's okay to process the next reward cycle's sortitions.
1189+
let (ibd, target_burnchain_block_height) = match self.get_pox_watchdog().pox_sync_wait(
12041190
&burnchain_config,
12051191
&burnchain_tip,
12061192
remote_chain_height,
1207-
num_sortitions_in_last_cycle,
12081193
) {
1209-
Ok(ibd) => ibd,
1194+
Ok(x) => x,
12101195
Err(e) => {
12111196
debug!("Runloop: PoX sync wait routine aborted: {e:?}");
12121197
continue;
@@ -1220,9 +1205,6 @@ impl RunLoop {
12201205
0.0
12211206
};
12221207

1223-
// will recalculate this in the following loop
1224-
num_sortitions_in_last_cycle = 0;
1225-
12261208
// Download each burnchain block and process their sortitions. This, in turn, will
12271209
// cause the node's p2p and relayer threads to go fetch and download Stacks blocks and
12281210
// process them. This loop runs for one reward cycle, so that the next pass of the
@@ -1270,8 +1252,6 @@ impl RunLoop {
12701252
"Runloop: New burnchain block height {next_sortition_height} > {sortition_db_height}"
12711253
);
12721254

1273-
let mut sort_count = 0;
1274-
12751255
debug!("Runloop: block mining until we process all sortitions");
12761256
signal_mining_blocked(globals.get_miner_status());
12771257

@@ -1289,9 +1269,6 @@ impl RunLoop {
12891269
"Failed to find block in fork processed by burnchain indexer",
12901270
)
12911271
};
1292-
if block.sortition {
1293-
sort_count += 1;
1294-
}
12951272

12961273
let sortition_id = &block.sortition_id;
12971274

@@ -1338,9 +1315,8 @@ impl RunLoop {
13381315
debug!("Runloop: enable miner after processing sortitions");
13391316
signal_mining_ready(globals.get_miner_status());
13401317

1341-
num_sortitions_in_last_cycle = sort_count;
13421318
debug!(
1343-
"Runloop: Synchronized sortitions up to block height {next_sortition_height} from {sortition_db_height} (chain tip height is {burnchain_height}); {num_sortitions_in_last_cycle} sortitions"
1319+
"Runloop: Synchronized sortitions up to block height {next_sortition_height} from {sortition_db_height} (chain tip height is {burnchain_height})"
13441320
);
13451321

13461322
sortition_db_height = next_sortition_height;
@@ -1359,22 +1335,6 @@ impl RunLoop {
13591335
}
13601336
}
13611337

1362-
// advance one reward cycle at a time.
1363-
// If we're still downloading, then this is simply target_burnchain_block_height + reward_cycle_len.
1364-
// Otherwise, this is burnchain_tip + reward_cycle_len
1365-
let next_target_burnchain_block_height = cmp::min(
1366-
burnchain_config.reward_cycle_to_block_height(
1367-
burnchain_config
1368-
.block_height_to_reward_cycle(target_burnchain_block_height)
1369-
.expect("FATAL: burnchain height before system start")
1370-
+ 1,
1371-
),
1372-
remote_chain_height,
1373-
);
1374-
1375-
debug!("Runloop: Advance target burnchain block height from {target_burnchain_block_height} to {next_target_burnchain_block_height} (sortition height {sortition_db_height})");
1376-
target_burnchain_block_height = next_target_burnchain_block_height;
1377-
13781338
if sortition_db_height >= burnchain_height && !ibd {
13791339
let canonical_stacks_tip_height =
13801340
SortitionDB::get_canonical_burn_chain_tip(burnchain.sortdb_ref().conn())

0 commit comments

Comments
 (0)