Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion crates/l2/sequencer/l1_proof_sender.rs
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::{
Expand Down Expand Up @@ -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,
}

Expand All @@ -89,6 +95,7 @@ pub struct L1ProofSenderHealth {
}

impl L1ProofSender {
#[allow(clippy::too_many_arguments)]
async fn new(
cfg: &ProofCoordinatorConfig,
committer_cfg: &CommitterConfig,
Expand All @@ -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(),
Expand All @@ -123,6 +131,7 @@ impl L1ProofSender {
l1_chain_id,
network: aligned_cfg.network.clone(),
fee_estimate,
checkpoints_dir,
aligned_mode: aligned_cfg.aligned_mode,
})
}
Expand All @@ -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,
Expand All @@ -141,6 +151,7 @@ impl L1ProofSender {
&cfg.aligned,
rollup_store,
needed_proof_types,
checkpoints_dir,
)
.await?;
let mut l1_proof_sender = L1ProofSender::start(state);
Expand Down Expand Up @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

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

Document why batch_to_send - 1.

Copy link
Contributor

Choose a reason for hiding this comment

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

if checkpoint_path.exists() {
let _ = remove_dir_all(&checkpoint_path).inspect_err(|e| {
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

Using std::fs::remove_dir_all is a blocking file system operation being called in an async context. This can block the async executor thread. Consider using tokio::fs::remove_dir_all instead for non-blocking async file operations.

Copilot uses AI. Check for mistakes.
error!(
"Failed to remove checkpoint directory at path {checkpoint_path:?}. Should be removed manually. Error: {}", e.to_string()
)
});
}
} else {
let missing_proof_types: Vec<String> = missing_proof_types
.iter()
Expand Down
3 changes: 2 additions & 1 deletion crates/l2/sequencer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub async fn start_l2(
cfg.clone(),
shared_state.clone(),
genesis,
checkpoints_dir,
checkpoints_dir.clone(),
)
.await
.inspect_err(|err| {
Expand All @@ -127,6 +127,7 @@ pub async fn start_l2(
shared_state.clone(),
rollup_store.clone(),
needed_proof_types.clone(),
checkpoints_dir,
)
.await
.inspect_err(|err| {
Expand Down