-
Notifications
You must be signed in to change notification settings - Fork 146
fix(l2): remove used checkpoints #5120
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
Changes from 3 commits
4fb5325
9b8b415
28a458c
248856d
65dc698
d5318a6
5d1627c
11b607a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| use std::collections::{BTreeMap, HashMap}; | ||
| use std::{ | ||
| collections::{BTreeMap, HashMap}, | ||
| fs::remove_dir_all, | ||
| path::PathBuf, | ||
| }; | ||
|
|
||
| use ethrex_common::{Address, U256}; | ||
| use ethrex_l2_common::{ | ||
|
|
@@ -71,6 +75,8 @@ pub struct L1ProofSender { | |
| l1_chain_id: u64, | ||
| network: Network, | ||
| fee_estimate: FeeEstimationType, | ||
| /// Directory where checkpoints are stored. | ||
| checkpoints_dir: PathBuf, | ||
| aligned_mode: bool, | ||
| } | ||
|
|
||
|
|
@@ -89,6 +95,7 @@ pub struct L1ProofSenderHealth { | |
| } | ||
|
|
||
| impl L1ProofSender { | ||
| #[allow(clippy::too_many_arguments)] | ||
| async fn new( | ||
| cfg: &ProofCoordinatorConfig, | ||
| committer_cfg: &CommitterConfig, | ||
|
|
@@ -97,6 +104,7 @@ impl L1ProofSender { | |
| aligned_cfg: &AlignedConfig, | ||
| rollup_store: StoreRollup, | ||
| needed_proof_types: Vec<ProverType>, | ||
| checkpoints_dir: PathBuf, | ||
| ) -> Result<Self, ProofSenderError> { | ||
| let eth_client = EthClient::new_with_config( | ||
| eth_cfg.rpc_url.clone(), | ||
|
|
@@ -123,6 +131,7 @@ impl L1ProofSender { | |
| l1_chain_id, | ||
| network: aligned_cfg.network.clone(), | ||
| fee_estimate, | ||
| checkpoints_dir, | ||
| aligned_mode: aligned_cfg.aligned_mode, | ||
| }) | ||
| } | ||
|
|
@@ -132,6 +141,7 @@ impl L1ProofSender { | |
| sequencer_state: SequencerState, | ||
| rollup_store: StoreRollup, | ||
| needed_proof_types: Vec<ProverType>, | ||
| checkpoints_dir: PathBuf, | ||
| ) -> Result<GenServerHandle<L1ProofSender>, ProofSenderError> { | ||
| let state = Self::new( | ||
| &cfg.proof_coordinator, | ||
|
|
@@ -141,6 +151,7 @@ impl L1ProofSender { | |
| &cfg.aligned, | ||
| rollup_store, | ||
| needed_proof_types, | ||
| checkpoints_dir, | ||
| ) | ||
| .await?; | ||
| let mut l1_proof_sender = L1ProofSender::start(state); | ||
|
|
@@ -200,6 +211,16 @@ impl L1ProofSender { | |
| self.rollup_store | ||
| .set_latest_sent_batch_proof(batch_to_send) | ||
| .await?; | ||
| let checkpoint_path = self | ||
| .checkpoints_dir | ||
| .join(format!("checkpoint_batch_{}", batch_to_send - 1)); | ||
|
||
| if checkpoint_path.exists() { | ||
| let _ = remove_dir_all(&checkpoint_path).inspect_err(|e| { | ||
|
||
| error!( | ||
| "Failed to remove checkpoint directory at path {checkpoint_path:?}. Should be removed manually. Error: {}", e.to_string() | ||
ManuelBilbao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| }); | ||
| } | ||
| } else { | ||
| let missing_proof_types: Vec<String> = missing_proof_types | ||
| .iter() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.