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

Persist most recent safe block #11644

Closed
mattsse opened this issue Oct 10, 2024 · 3 comments · Fixed by #11648
Closed

Persist most recent safe block #11644

mattsse opened this issue Oct 10, 2024 · 3 comments · Fixed by #11648
Labels
C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Oct 10, 2024

Describe the feature

same as

/// Last finalized block key
LastFinalizedBlock,

but for the safe block

TODO

  • add variant
  • extend and rename trait:

/// Functionality to read the last known finalized block from the database.
pub trait FinalizedBlockReader: Send + Sync {
/// Returns the last finalized block number.
///
/// If no finalized block has been written yet, this returns `None`.
fn last_finalized_block_number(&self) -> ProviderResult<Option<BlockNumber>>;
}
/// Functionality to write the last known finalized block to the database.
pub trait FinalizedBlockWriter: Send + Sync {
/// Saves the given finalized block number in the DB.
fn save_finalized_block_number(&self, block_number: BlockNumber) -> ProviderResult<()>;
}

store safe block same as

if Some(finalized.num_hash()) !=
self.canonical_in_memory_state.get_finalized_num_hash()
{
// we're also persisting the finalized block on disk so we can reload it on
// restart this is required by optimism which queries the finalized block: <https://github.com/ethereum-optimism/optimism/blob/c383eb880f307caa3ca41010ec10f30f08396b2e/op-node/rollup/sync/start.go#L65-L65>
let _ = self.persistence.save_finalized_block_number(finalized.number);
self.canonical_in_memory_state.set_finalized(finalized);
}

but for

Ok(Some(finalized)) => {
self.canonical_in_memory_state.set_safe(finalized);
}

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Oct 10, 2024
@mattsse mattsse added D-good-first-issue Nice and easy! A great choice to get started and removed S-needs-triage This issue needs to be labelled labels Oct 10, 2024
@Benjtalkshow
Copy link

@mattsse
Can I be assigned to this issue? I will tackle it as soon as possible. Thanks

@0xdevcollins
Copy link

Can I be assigned this issue?

@mattsse
Copy link
Collaborator Author

mattsse commented Oct 10, 2024

this was more urgent, so I took it, ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants