-
Notifications
You must be signed in to change notification settings - Fork 5
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: basic persistent storage #8
Conversation
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 👍
|
||
/// Struct containing the fields used for restoring the tree state. | ||
#[derive(Serialize, Deserialize)] | ||
pub struct StateSnapshot { |
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.
Idea for the future: Could we store the latest root hash here as well and use that to verify that tree & index key map are in sync?
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.
Great idea!
/// The latest l1 block number that was processed. | ||
pub current_l1_block_number: u64, |
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.
I just realized something: When we import state from other sources (e.g. file), there's no such thing as L1 block number, 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.
That might be the case, I'm not sure what the file format would look like at this point so I can't really answer that. Either way though, I think we can defer this issue to a later PR, what do you say?
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.
Yes, definitely. I'm actually working on async L1Fetcher
right now, based on your code here, so hence the thought. Let's see how this gets shape 🙂
d26d3b6
to
720a1b5
Compare
Allows for the restoration of the state when the tool was last used.
StateSnapshot
struct
that stores:state.rs
->types.rs
.Note: this PR does not implement graceful shutdown, so the snapshot file can in rare instances get out of sync with the local database.