-
Notifications
You must be signed in to change notification settings - Fork 10
Reset provider #449
base: main
Are you sure you want to change the base?
Reset provider #449
Conversation
|
||
pub fn reset(&mut self, head: BlockHeight) { | ||
self.tail = None; | ||
self.head = head; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed sync, I think with the new model where we enforced the defer execution of side-effects for top-down there is no need to use a head
and a tail
here.
@@ -31,6 +31,11 @@ impl SyncPointers { | |||
pub fn set_tail(&mut self, height: BlockHeight, hash: BlockHash) { | |||
self.tail = Some((height, hash)); | |||
} | |||
|
|||
pub fn reset(&mut self, head: BlockHeight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are just resetting the pointers. Is there no need to clean the content from the cache? We may be leaking outdated information by just changing the pointers, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you for simplifying the cache logic a lot 🙏
.await | ||
} | ||
|
||
/// Poll the next block height. Returns finalized and executed block data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is worth adding a comment here and be explicit about the height and data returned.
- We get
height
and return the state atparent_block
right?
We should reset provider, i.e. clean cache, reset last committed and polling trackers after syncing with peer and also a potential reorg.
For potential reorg, we had this for block height check but not after block hashes are different. We should reset syncer and try from scratch (what else can we do beside crashing app).
After peer syncing, we need to reset provider because with peer syncing, we might have the last committed finality way ahead of the cache polled heights. Clean cache and restart syncer will make sure syncer is up to date.