mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-06-17 02:24:48 +08:00
fix: address #2713 by starting processing from the first burnchain block of the reward cycle in which the canonical Stacks chain state starts
This commit is contained in:
@@ -314,7 +314,27 @@ impl RunLoop {
|
||||
};
|
||||
|
||||
// TODO (hack) instantiate the sortdb in the burnchain
|
||||
let _ = burnchain.sortdb_mut();
|
||||
let sortdb = burnchain.sortdb_mut();
|
||||
let mut block_height = {
|
||||
let (stacks_ch, _) = SortitionDB::get_canonical_stacks_chain_tip_hash(sortdb.conn())
|
||||
.expect("BUG: failed to load canonical stacks chain tip hash");
|
||||
|
||||
match SortitionDB::get_block_snapshot_consensus(sortdb.conn(), &stacks_ch)
|
||||
.expect("BUG: failed to query sortition DB")
|
||||
{
|
||||
Some(sn) => burnchain_config.reward_cycle_to_block_height(
|
||||
burnchain_config
|
||||
.block_height_to_reward_cycle(sn.block_height)
|
||||
.expect("BUG: snapshot preceeds first reward cycle"),
|
||||
),
|
||||
None => {
|
||||
let sn = SortitionDB::get_first_block_snapshot(&sortdb.conn())
|
||||
.expect("BUG: failed to get first-ever block snapshot");
|
||||
|
||||
sn.block_height
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Start the runloop
|
||||
trace!("Begin run loop");
|
||||
@@ -330,8 +350,6 @@ impl RunLoop {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let mut block_height = 1.max(burnchain_config.first_block_height);
|
||||
|
||||
let mut burnchain_height = block_height;
|
||||
let mut num_sortitions_in_last_cycle = 1;
|
||||
let mut learned_burnchain_height = false;
|
||||
@@ -339,6 +357,11 @@ impl RunLoop {
|
||||
// prepare to fetch the first reward cycle!
|
||||
target_burnchain_block_height = burnchain_height + pox_constants.reward_cycle_length as u64;
|
||||
|
||||
debug!(
|
||||
"Begin main runloop starting a burnchain block {}",
|
||||
block_height
|
||||
);
|
||||
|
||||
loop {
|
||||
// Orchestrating graceful termination
|
||||
if !should_keep_running.load(Ordering::SeqCst) {
|
||||
|
||||
Reference in New Issue
Block a user