Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Reset provider #449

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Reset provider #449

wants to merge 5 commits into from

Conversation

cryptoAtwill
Copy link
Contributor

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.


pub fn reset(&mut self, head: BlockHeight) {
self.tail = None;
self.head = head;
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor

@adlrocha adlrocha left a 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.
Copy link
Contributor

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 at parent_block right?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants