Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement rollback buffer #49

Merged
merged 6 commits into from
Feb 16, 2022
Merged

feat: Implement rollback buffer #49

merged 6 commits into from
Feb 16, 2022

Conversation

scarmuega
Copy link
Member

@scarmuega scarmuega commented Feb 16, 2022

This PR introduces a memory buffer to handle chain rollbacks.

This structure is intended to facilitate the process of managing rollbacks in a chain sync process. The goal is to keep points in memory until they reach a certain depth (# of confirmations). If a rollback happens, the buffer will try to find the intersection, clear the orphaned points and keep the remaining still in memory. Further forward rolls will accumulate from the intersection.

It works by keeping a VecDeque data structure of points, where roll-forward operations accumulate at the end of the deque and retrieving confirmed points means to pop from the front of the deque.

Notice that it works by keeping track of points, not blocks. It is meant to be used as a lightweight index where blocks can then be retrieved from a more suitable memory structure / persistent storage.

@scarmuega scarmuega added the enhancement New feature or request label Feb 16, 2022
@scarmuega scarmuega self-assigned this Feb 16, 2022
@scarmuega scarmuega marked this pull request as ready for review February 16, 2022 02:52
@scarmuega scarmuega merged commit 9082577 into main Feb 16, 2022
@scarmuega scarmuega deleted the feat/rollback-buffer branch February 16, 2022 03:03
@@ -7,7 +7,7 @@ pub const TESTNET_MAGIC: u64 = 1097911063;
pub const MAINNET_MAGIC: u64 = 764824073;

/// A point within a chain
#[derive(Clone)]
#[derive(Clone, Eq, PartialEq)]
pub struct Point(pub u64, pub Vec<u8>);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the Vec<u8> here ? is it a block hash ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is the hash. This struct was there before the introduction of pallas-crypto. We should turn it into a Hash<>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants