Skip to content

Commit

Permalink
Merge branch 'nightly' of https://github.com/chainwayxyz/citrea into …
Browse files Browse the repository at this point in the history
…rocksdb-backup
  • Loading branch information
jfldde committed Feb 6, 2025
2 parents 70f6302 + 2f370e5 commit 19e8c40
Show file tree
Hide file tree
Showing 85 changed files with 1,815 additions and 1,153 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions bin/citrea/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ citrea-common = { path = "../../crates/common" }
citrea-fullnode = { path = "../../crates/fullnode" }
citrea-light-client-prover = { path = "../../crates/light-client-prover", features = ["native"] }
citrea-primitives = { path = "../../crates/primitives" }
citrea-pruning = { path = "../../crates/pruning" }
citrea-risc0-adapter = { path = "../../crates/risc0", features = ["native"] }
citrea-risc0-batch-proof = { path = "../../guests/risc0/batch-proof" }
citrea-risc0-light-client = { path = "../../guests/risc0/light-client-proof" }
Expand Down Expand Up @@ -80,6 +81,7 @@ alloy-rpc-types = { workspace = true }
alloy-rpc-types-trace = { workspace = true }
bincode = { workspace = true }
borsh = { workspace = true }
futures = { workspace = true }
jmt = { workspace = true }
rand = { workspace = true }
reqwest = { workspace = true }
Expand Down
23 changes: 21 additions & 2 deletions bin/citrea/src/guests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,21 @@ lazy_static! {
citrea_risc0_batch_proof::BATCH_PROOF_MOCK_ELF.to_vec(),
),
);

m.insert(
SpecId::Fork2,
(
Digest::new(citrea_risc0_batch_proof::BATCH_PROOF_MOCK_ID),
citrea_risc0_batch_proof::BATCH_PROOF_MOCK_ELF.to_vec(),
),
);
m
};
pub(crate) static ref LIGHT_CLIENT_LATEST_MOCK_GUESTS: HashMap<SpecId, (Digest, Vec<u8>)> = {
let mut m = HashMap::new();

m.insert(
SpecId::Kumquat,
SpecId::Fork2,
(
Digest::new(citrea_risc0_light_client::LIGHT_CLIENT_PROOF_MOCK_ID),
citrea_risc0_light_client::LIGHT_CLIENT_PROOF_MOCK_ELF.to_vec(),
Expand All @@ -57,6 +65,10 @@ lazy_static! {
(SpecId::Kumquat,
(Digest::new(citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ID),
citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ELF.to_vec())
),
(SpecId::Fork2,
(Digest::new(citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ID),
citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ELF.to_vec())
)
]
)
Expand All @@ -66,7 +78,7 @@ lazy_static! {
pub(crate) static ref BATCH_PROOF_LATEST_BITCOIN_GUESTS: HashMap<SpecId, (Digest, Vec<u8>)> = {
HashMap::from(
[
(SpecId::Kumquat,
(SpecId::Fork2,
(Digest::new(citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ID),
citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ELF.to_vec())
)
Expand All @@ -91,6 +103,13 @@ lazy_static! {
citrea_risc0_light_client::LIGHT_CLIENT_PROOF_BITCOIN_ELF.to_vec(),
)
);
m.insert(
SpecId::Fork2,
(
Digest::new(citrea_risc0_light_client::LIGHT_CLIENT_PROOF_BITCOIN_ID),
citrea_risc0_light_client::LIGHT_CLIENT_PROOF_BITCOIN_ELF.to_vec(),
)
);
m
};
/// Production guests
Expand Down
42 changes: 28 additions & 14 deletions bin/citrea/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@ where
da_service,
mut task_manager,
soft_confirmation_channel,
} = rollup_blueprint.setup_dependencies(&rollup_config).await?;
} = rollup_blueprint
.setup_dependencies(
&rollup_config,
matches!(node_type, NodeType::Sequencer(_))
|| matches!(node_type, NodeType::BatchProver(_)),
)
.await?;

let sequencer_client_url = rollup_config
.runner
Expand Down Expand Up @@ -339,19 +345,20 @@ where
});
}
_ => {
let (mut full_node, l1_block_handler) = CitreaRollupBlueprint::create_full_node(
&rollup_blueprint,
genesis_config,
rollup_config.clone(),
da_service,
ledger_db.clone(),
storage_manager,
prover_storage,
soft_confirmation_channel.0,
backup_manager,
)
.await
.expect("Could not start full-node");
let (mut full_node, l1_block_handler, pruner) =
CitreaRollupBlueprint::create_full_node(
&rollup_blueprint,
genesis_config,
rollup_config.clone(),
da_service,
ledger_db.clone(),
storage_manager,
prover_storage,
soft_confirmation_channel.0,
backup_manager,
)
.await
.expect("Could not start full-node");

start_rpc_server(
rollup_config.rpc.clone(),
Expand All @@ -371,6 +378,13 @@ where
.await
});

// Spawn pruner if configs are set
if let Some(pruner) = pruner {
task_manager.spawn(|cancellation_token| async move {
pruner.run(cancellation_token).await
});
}

task_manager.spawn(|cancellation_token| async move {
if let Err(e) = full_node.run(cancellation_token).await {
error!("Error: {}", e);
Expand Down
9 changes: 6 additions & 3 deletions bin/citrea/src/rollup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use citrea_fullnode::CitreaFullnode;
use citrea_light_client_prover::da_block_handler::L1BlockHandler as LightClientProverL1BlockHandler;
use citrea_light_client_prover::runner::CitreaLightClientProver;
use citrea_primitives::forks::get_forks;
use citrea_pruning::Pruner;
use citrea_sequencer::CitreaSequencer;
use jsonrpsee::RpcModule;
use sov_db::ledger_db::migrations::{LedgerDBMigrator, Migrations};
Expand Down Expand Up @@ -75,10 +76,11 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
async fn setup_dependencies(
&self,
rollup_config: &FullNodeConfig<Self::DaConfig>,
require_da_wallet: bool,
) -> Result<Dependencies<Self>> {
let mut task_manager = TaskManager::default();
let da_service = self
.create_da_service(rollup_config, true, &mut task_manager)
.create_da_service(rollup_config, require_da_wallet, &mut task_manager)
.await?;
let (soft_confirmation_tx, soft_confirmation_rx) = broadcast::channel(10);
// If subscriptions disabled, pass None
Expand Down Expand Up @@ -222,6 +224,7 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
StorageRootHash,
LedgerDB,
>,
Option<Pruner<LedgerDB>>,
)>
where
<Self::NativeContext as Spec>::Storage: NativeStorage,
Expand Down Expand Up @@ -437,17 +440,17 @@ pub trait CitreaRollupBlueprint: RollupBlueprint {
Self::DaSpec,
>,
> {
let genesis_root = prover_storage.get_root_hash(1);
if let Some((number, soft_confirmation)) = ledger_db.get_head_soft_confirmation()? {
// At least one soft confirmation was processed
info!("Initialize sequencer at batch number {:?}. State root: {:?}. Last soft confirmation hash: {:?}.", number, prover_storage.get_root_hash(number.0 + 1)?.as_ref(), soft_confirmation.hash);
info!("Initialize node at batch number {:?}. State root: {:?}. Last soft confirmation hash: {:?}.", number, prover_storage.get_root_hash(number.0 + 1)?.as_ref(), soft_confirmation.hash);

return Ok(InitParams {
state_root: prover_storage.get_root_hash(number.0 + 1)?,
batch_hash: soft_confirmation.hash,
});
}

let genesis_root = prover_storage.get_root_hash(1);
if let Ok(state_root) = genesis_root {
// Chain was initialized but no soft confirmations was processed
debug!("Chain is already initialized. Skipping initialization.");
Expand Down
4 changes: 2 additions & 2 deletions bin/citrea/tests/bitcoin_e2e/light_client_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use risc0_zkvm::{FakeReceipt, InnerReceipt, MaybePruned, Receipt, ReceiptClaim};
use sov_ledger_rpc::LedgerRpcClient;
use sov_rollup_interface::da::{BatchProofMethodId, DaTxRequest};
use sov_rollup_interface::rpc::BatchProofMethodIdRpcResponse;
use sov_rollup_interface::zk::BatchProofCircuitOutput;
use sov_rollup_interface::zk::batch_proof::output::v2::BatchProofCircuitOutputV2;

use super::batch_prover_test::wait_for_zkproofs;
use super::get_citrea_path;
Expand Down Expand Up @@ -1328,7 +1328,7 @@ fn create_serialized_fake_receipt_batch_proof(
32, 64, 64, 227, 100, 193, 15, 43, 236, 156, 31, 229, 0, 161, 205, 76, 36, 124, 137, 214,
80, 160, 30, 215, 232, 44, 171, 168, 103, 135, 124, 33,
];
let batch_proof_output = BatchProofCircuitOutput::<BitcoinSpec, [u8; 32]> {
let batch_proof_output = BatchProofCircuitOutputV2::<BitcoinSpec, [u8; 32]> {
initial_state_root,
final_state_root,
last_l2_height,
Expand Down
8 changes: 4 additions & 4 deletions bin/citrea/tests/bitcoin_e2e/sequencer_commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ impl TestCase for SequencerSendCommitmentsToDaTest {

let mut blobs = get_relevant_blobs_from_txs(block.txdata, TO_BATCH_PROOF_PREFIX);

for mut blob in blobs.drain(0..) {
let data = BlobReaderTrait::full_data(&mut blob);
for blob in blobs.drain(0..) {
let data = blob.full_data();

assert_eq!(data, &[] as &[u8]);
}
Expand Down Expand Up @@ -304,9 +304,9 @@ impl SequencerSendCommitmentsToDaTest {

assert_eq!(blobs.len(), 1);

let mut blob = blobs.pop().unwrap();
let blob = blobs.pop().unwrap();

let data = BlobReaderTrait::full_data(&mut blob);
let data = blob.full_data();

let commitment = DaTxRequest::try_from_slice(data).unwrap();

Expand Down
Loading

0 comments on commit 19e8c40

Please sign in to comment.