-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
mod prune; | ||
|
||
pub(crate) use prune::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,36 @@ | ||
use std::path::PathBuf; | ||
use std::sync::Arc; | ||
|
||
use citrea_pruning::{Pruner, PruningConfig}; | ||
use sov_db::ledger_db::{LedgerDB, SharedLedgerOps}; | ||
use sov_db::native_db::NativeDB; | ||
use sov_db::rocks_db_config::RocksdbConfig; | ||
use sov_prover_storage_manager::SnapshotManager; | ||
use tracing::{debug, info}; | ||
|
||
pub(crate) fn prune(db_path: PathBuf, distance: u64) -> anyhow::Result<()> { | ||
pub(crate) async fn prune(db_path: PathBuf, distance: u64) -> anyhow::Result<()> { | ||
info!( | ||
"Pruning DB at {} with pruning distance of {}", | ||
db_path.display(), | ||
distance | ||
); | ||
let config = PruningConfig { distance }; | ||
|
||
let rocksdb_config = RocksdbConfig::new(&db_path, None, None); | ||
let ledger_db = LedgerDB::with_config(&rocksdb_config)?; | ||
let native_db = NativeDB::<SnapshotManager>::setup_schema_db(&rocksdb_config)?; | ||
|
||
let last_pruned_block = ledger_db.get_last_pruned_l2_height()?.unwrap_or(0); | ||
let pruner = Pruner::new(config, last_pruned_block, l2_receiver, ledger_db)?; | ||
let Some((soft_confirmation_number, _)) = ledger_db.get_head_soft_confirmation()? else { | ||
return Ok(()); | ||
}; | ||
|
||
debug!( | ||
"Pruning up to latest soft confirmation number: {}, taking into consideration the configured distance of {}", | ||
soft_confirmation_number.0, distance | ||
); | ||
|
||
let pruner = Pruner::new(config, ledger_db, Arc::new(native_db)); | ||
pruner.prune(soft_confirmation_number.0).await; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters