Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 2 additions & 5 deletions crates/l2/sequencer/l1_committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::{
sequencer::{
errors::CommitterError,
utils::{
self, fetch_blocks_with_respective_fee_configs, get_git_commit_hash, system_now_ms,
self, batch_checkpoint_name, fetch_blocks_with_respective_fee_configs,
get_git_commit_hash, system_now_ms,
},
},
};
Expand Down Expand Up @@ -1313,7 +1314,3 @@ pub async fn regenerate_head_state(

Ok(())
}

fn batch_checkpoint_name(batch_number: u64) -> String {
format!("checkpoint_batch_{batch_number}")
}
29 changes: 27 additions & 2 deletions 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 @@ -30,7 +34,7 @@ use super::{
use crate::{
CommitterConfig, EthConfig, ProofCoordinatorConfig, SequencerConfig,
based::sequencer_state::{SequencerState, SequencerStatus},
sequencer::errors::ProofSenderError,
sequencer::{errors::ProofSenderError, utils::batch_checkpoint_name},
};
use aligned_sdk::{
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 {
#[expect(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,20 @@ impl L1ProofSender {
self.rollup_store
.set_latest_sent_batch_proof(batch_to_send)
.await?;

// Remove checkpoint from batch sent - 1.
// That checkpoint was needed to generate the proof for the batch we just sent.
// The checkpoint for the batch we have just sent is needed for the next batch.
let checkpoint_path = self
.checkpoints_dir
.join(batch_checkpoint_name(batch_to_send - 1));
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}"
)
});
}
} 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 @@ -105,7 +105,7 @@ pub async fn start_l2(
cfg.clone(),
shared_state.clone(),
genesis,
checkpoints_dir,
checkpoints_dir.clone(),
)
.await
.inspect_err(|err| {
Expand All @@ -126,6 +126,7 @@ pub async fn start_l2(
shared_state.clone(),
rollup_store.clone(),
needed_proof_types.clone(),
checkpoints_dir,
)
.await
.inspect_err(|err| {
Expand Down
4 changes: 4 additions & 0 deletions crates/l2/sequencer/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,7 @@ where
pub fn get_git_commit_hash() -> String {
env!("VERGEN_GIT_SHA").to_string()
}

pub fn batch_checkpoint_name(batch_number: u64) -> String {
format!("checkpoint_batch_{batch_number}")
}