Skip to content

Commit 9936174

Browse files
committed
node: add notes to outofsync
1 parent 3644225 commit 9936174

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

node/src/chain/fsm.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,13 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network> InSyncImpl<DB, VM, N> {
485485
/// performed when entering the state
486486
async fn on_entering(&mut self, blk: &Block) -> anyhow::Result<()> {
487487
let mut acc = self.acc.write().await;
488+
489+
// NOTE: If we switched to InSync because of a timeout handled in the
490+
// OutOfSync's on_block_event, we need to handle `blk` as usual.
491+
// However, given the current implementation, we only handle the tip+1
492+
// case, at the risk of losing this block. This should be improved in
493+
// the future
494+
488495
let curr_h = acc.get_curr_height().await;
489496

490497
if blk.header().height == curr_h + 1 {

node/src/chain/fsm/outofsync.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network>
240240
return Ok(false);
241241
}
242242

243+
// If we receive a block higher than the current target, we "extend" the
244+
// range of the syncing process
245+
//
246+
// NOTE: the block could be coming from a different peer than the one we
247+
// are currently syncing with. This means the current peer could
248+
// actually not have blocks up to the new target. We might want to
249+
// handle this update differently in the future, e.g. by also updating
250+
// the sync peer.
243251
if block_height > self.range.1 {
244252
debug!(
245253
event = "update sync target",
@@ -329,7 +337,6 @@ impl<DB: database::DB, VM: vm::VMExecution, N: Network>
329337
return Ok(false);
330338
}
331339

332-
let block_height = blk.header().height;
333340
let pool_len = self.pool.len();
334341

335342
if self.pool.contains_key(&block_height) {

0 commit comments

Comments
 (0)