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

Database BackupManager #1711

Open
wants to merge 21 commits into
base: nightly
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ alloy-eips = { version = "0.4.2", default-features = false }
alloy-consensus = { version = "0.4.2", default-features = false, features = ["serde", "serde-bincode-compat"] }
alloy-network = { version = "0.4.2", default-features = false }

citrea-e2e = { git = "https://github.com/chainwayxyz/citrea-e2e", rev = "af85eae3010331df0e0cda5288f741b6d298813f" }
citrea-e2e = { git = "https://github.com/chainwayxyz/citrea-e2e", rev = "7a08605" }

[patch.crates-io]
bitcoincore-rpc = { version = "0.18.0", git = "https://github.com/chainwayxyz/rust-bitcoincore-rpc.git", rev = "ca3cfa2" }
Expand Down
18 changes: 17 additions & 1 deletion bin/citrea/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use core::fmt::Debug as DebugTrait;
use std::net::SocketAddr;
use std::path::PathBuf;
use std::time::Duration;

use anyhow::{anyhow, Context as _};
Expand Down Expand Up @@ -75,6 +76,10 @@ struct Args {
/// Logging verbosity
#[arg(long, short = 'q', action)]
quiet: bool,

/// Logging verbosity
#[arg(long)]
restore_db: Option<PathBuf>,
}

#[derive(clap::ValueEnum, Clone, Debug)]
Expand Down Expand Up @@ -172,6 +177,7 @@ async fn main() -> Result<(), anyhow::Error> {
batch_prover_config,
light_client_prover_config,
sequencer_config,
args.restore_db,
)
.await?;
}
Expand All @@ -183,6 +189,7 @@ async fn main() -> Result<(), anyhow::Error> {
batch_prover_config,
light_client_prover_config,
sequencer_config,
args.restore_db,
)
.await?;
}
Expand All @@ -202,6 +209,7 @@ async fn start_rollup<S, DaC>(
batch_prover_config: Option<BatchProverConfig>,
light_client_prover_config: Option<LightClientProverConfig>,
sequencer_config: Option<SequencerConfig>,
restore_db: Option<PathBuf>,
) -> Result<(), anyhow::Error>
where
DaC: serde::de::DeserializeOwned + DebugTrait + Clone + FromEnv,
Expand Down Expand Up @@ -238,7 +246,12 @@ where

if let Some(sequencer_config) = sequencer_config {
let (mut sequencer, rpc_methods) = rollup_blueprint
.create_new_sequencer(rt_genesis_paths, rollup_config.clone(), sequencer_config)
.create_new_sequencer(
rt_genesis_paths,
rollup_config.clone(),
sequencer_config,
restore_db,
)
.await
.expect("Could not start sequencer");
sequencer.start_rpc_server(rpc_methods, None).await.unwrap();
Expand All @@ -252,6 +265,7 @@ where
rt_genesis_paths,
rollup_config,
batch_prover_config,
restore_db,
)
.await
.expect("Could not start batch prover");
Expand All @@ -269,6 +283,7 @@ where
&rollup_blueprint,
rollup_config,
light_client_prover_config,
restore_db,
)
.await
.expect("Could not start light client prover");
Expand All @@ -286,6 +301,7 @@ where
&rollup_blueprint,
rt_genesis_paths,
rollup_config,
restore_db,
)
.await
.expect("Could not start full-node");
Expand Down
5 changes: 5 additions & 0 deletions bin/citrea/src/rollup/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use bitcoin_da::rpc::create_rpc_module as create_da_rpc_module;
use bitcoin_da::service::{BitcoinService, BitcoinServiceConfig, TxidWrapper};
use bitcoin_da::spec::{BitcoinSpec, RollupParams};
use bitcoin_da::verifier::BitcoinVerifier;
use citrea_common::backup::{create_backup_rpc_module, BackupManager};
use citrea_common::rpc::register_healthcheck_rpc;
use citrea_common::tasks::manager::TaskManager;
use citrea_common::FullNodeConfig;
Expand Down Expand Up @@ -71,6 +72,7 @@ impl RollupBlueprint for BitcoinRollup {
da_service: &Arc<Self::DaService>,
sequencer_client_url: Option<String>,
soft_confirmation_rx: Option<broadcast::Receiver<u64>>,
backup_manager: &Arc<BackupManager>,
) -> Result<jsonrpsee::RpcModule<()>, anyhow::Error> {
// unused inside register RPC
let sov_sequencer = Address::new([0; 32]);
Expand All @@ -93,6 +95,9 @@ impl RollupBlueprint for BitcoinRollup {

register_healthcheck_rpc(&mut rpc_methods, ledger_db.clone())?;

let backup_methods = create_backup_rpc_module(ledger_db.clone(), backup_manager.clone());
rpc_methods.merge(backup_methods)?;

let da_methods = create_da_rpc_module(da_service.clone());
rpc_methods.merge(da_methods)?;

Expand Down
4 changes: 4 additions & 0 deletions bin/citrea/src/rollup/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::sync::Arc;

use async_trait::async_trait;
use citrea_common::backup::{create_backup_rpc_module, BackupManager};
use citrea_common::rpc::register_healthcheck_rpc;
use citrea_common::tasks::manager::TaskManager;
use citrea_common::FullNodeConfig;
Expand Down Expand Up @@ -55,6 +56,7 @@ impl RollupBlueprint for MockDemoRollup {
da_service: &Arc<Self::DaService>,
sequencer_client_url: Option<String>,
soft_confirmation_rx: Option<broadcast::Receiver<u64>>,
backup_manager: &Arc<BackupManager>,
) -> Result<jsonrpsee::RpcModule<()>, anyhow::Error> {
// TODO set the sequencer address
let sequencer = Address::new([0; 32]);
Expand All @@ -75,6 +77,8 @@ impl RollupBlueprint for MockDemoRollup {
)?;

register_healthcheck_rpc(&mut rpc_methods, ledger_db.clone())?;
let backup_methods = create_backup_rpc_module(ledger_db.clone(), backup_manager.clone());
rpc_methods.merge(backup_methods)?;

Ok(rpc_methods)
}
Expand Down
Loading
Loading