Skip to content

Commit

Permalink
Rename da fns (#1403)
Browse files Browse the repository at this point in the history
Co-authored-by: eyusufatik <[email protected]>
  • Loading branch information
kpp and eyusufatik authored Nov 4, 2024
1 parent d3a6f5f commit 060cbf7
Show file tree
Hide file tree
Showing 20 changed files with 555 additions and 889 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_main]
use bitcoin_da::spec::RollupParams;
use bitcoin_da::verifier::BitcoinVerifier;
use citrea_primitives::{REVEAL_BATCH_PROOF_PREFIX, REVEAL_LIGHT_CLIENT_PREFIX};
use citrea_primitives::{TO_BATCH_PROOF_PREFIX, TO_LIGHT_CLIENT_PREFIX};
use citrea_stf::runtime::Runtime;
use citrea_stf::StfVerifier;
use sov_modules_api::default_context::ZkDefaultContext;
Expand All @@ -21,8 +21,8 @@ pub fn main() {
let mut stf_verifier = StfVerifier::new(
stf,
BitcoinVerifier::new(RollupParams {
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use bitcoin_da::spec::RollupParams;
use bitcoin_da::verifier::BitcoinVerifier;
use citrea_light_client_prover::circuit::run_circuit;
use citrea_primitives::{REVEAL_BATCH_PROOF_PREFIX, REVEAL_LIGHT_CLIENT_PREFIX};
use citrea_primitives::{TO_BATCH_PROOF_PREFIX, TO_LIGHT_CLIENT_PREFIX};
use sov_risc0_adapter::guest::Risc0Guest;
use sov_rollup_interface::da::DaVerifier;
use sov_rollup_interface::zk::ZkvmGuest;
Expand All @@ -13,8 +13,8 @@ pub fn main() {
let guest = Risc0Guest::new();

let da_verifier = BitcoinVerifier::new(RollupParams {
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
});

let output = run_circuit::<BitcoinVerifier, Risc0Guest>(da_verifier, &guest).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions bin/citrea/provers/sp1/batch-prover-bitcoin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sp1_zkvm::entrypoint!(main);

use bitcoin_da::spec::RollupParams;
use bitcoin_da::verifier::BitcoinVerifier;
use citrea_primitives::{REVEAL_BATCH_PROOF_PREFIX, REVEAL_LIGHT_CLIENT_PREFIX};
use citrea_primitives::{TO_BATCH_PROOF_PREFIX, TO_LIGHT_CLIENT_PREFIX};
use citrea_sp1::guest::SP1Guest;
use citrea_stf::runtime::Runtime;
use citrea_stf::StfVerifier;
Expand All @@ -21,8 +21,8 @@ pub fn main() {
let mut stf_verifier = StfVerifier::new(
stf,
BitcoinVerifier::new(RollupParams {
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
}),
);

Expand Down
18 changes: 9 additions & 9 deletions bin/citrea/src/rollup/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bitcoin_da::spec::{BitcoinSpec, RollupParams};
use bitcoin_da::verifier::BitcoinVerifier;
use citrea_common::rpc::register_healthcheck_rpc;
use citrea_common::{BatchProverConfig, FullNodeConfig, LightClientProverConfig};
use citrea_primitives::{REVEAL_BATCH_PROOF_PREFIX, REVEAL_LIGHT_CLIENT_PREFIX};
use citrea_primitives::{TO_BATCH_PROOF_PREFIX, TO_LIGHT_CLIENT_PREFIX};
use citrea_risc0_bonsai_adapter::host::Risc0BonsaiHost;
use citrea_risc0_bonsai_adapter::Digest;
// use citrea_sp1::host::SP1Host;
Expand Down Expand Up @@ -137,8 +137,8 @@ impl RollupBlueprint for BitcoinRollup {
BitcoinService::new_with_wallet_check(
rollup_config.da.clone(),
RollupParams {
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
},
tx,
)
Expand All @@ -147,8 +147,8 @@ impl RollupBlueprint for BitcoinRollup {
BitcoinService::new_without_wallet_check(
rollup_config.da.clone(),
RollupParams {
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
},
tx,
)
Expand Down Expand Up @@ -187,8 +187,8 @@ impl RollupBlueprint for BitcoinRollup {
let zk_storage = ZkStorage::new();

let da_verifier = BitcoinVerifier::new(RollupParams {
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
});

ParallelProverService::new_with_default_workers(
Expand Down Expand Up @@ -220,8 +220,8 @@ impl RollupBlueprint for BitcoinRollup {
let zk_storage = ZkStorage::new();

let da_verifier = BitcoinVerifier::new(RollupParams {
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
});

ParallelProverService::new_with_default_workers(
Expand Down
6 changes: 3 additions & 3 deletions bin/citrea/tests/bitcoin_e2e/batch_prover_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use citrea_e2e::framework::TestFramework;
use citrea_e2e::node::NodeKind;
use citrea_e2e::test_case::{TestCase, TestCaseRunner};
use citrea_e2e::Result;
use citrea_primitives::{REVEAL_BATCH_PROOF_PREFIX, REVEAL_LIGHT_CLIENT_PREFIX};
use citrea_primitives::{TO_BATCH_PROOF_PREFIX, TO_LIGHT_CLIENT_PREFIX};
use sov_rollup_interface::da::{DaData, SequencerCommitment};
use sov_rollup_interface::services::da::SenderWithNotifier;
use tokio::sync::mpsc::UnboundedSender;
Expand Down Expand Up @@ -187,8 +187,8 @@ impl TestCase for SkipPreprovenCommitmentsTest {
BitcoinService::new_with_wallet_check(
bitcoin_da_service_config,
RollupParams {
reveal_light_client_prefix: REVEAL_LIGHT_CLIENT_PREFIX.to_vec(),
reveal_batch_prover_prefix: REVEAL_BATCH_PROOF_PREFIX.to_vec(),
to_light_client_prefix: TO_LIGHT_CLIENT_PREFIX.to_vec(),
to_batch_proof_prefix: TO_BATCH_PROOF_PREFIX.to_vec(),
},
tx.clone(),
)
Expand Down
6 changes: 3 additions & 3 deletions bin/citrea/tests/bitcoin_e2e/sequencer_commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use citrea_e2e::framework::TestFramework;
use citrea_e2e::sequencer::Sequencer;
use citrea_e2e::test_case::{TestCase, TestCaseRunner};
use citrea_e2e::Result;
use citrea_primitives::REVEAL_BATCH_PROOF_PREFIX;
use citrea_primitives::TO_BATCH_PROOF_PREFIX;
use rs_merkle::algorithms::Sha256;
use rs_merkle::MerkleTree;
use sov_rollup_interface::da::{BlobReaderTrait, DaData};
Expand Down Expand Up @@ -198,7 +198,7 @@ impl TestCase for SequencerSendCommitmentsToDaTest {
let hash = da.get_block_hash(height).await?;
let block = da.get_block(&hash).await?;

let mut blobs = get_relevant_blobs_from_txs(block.txdata, REVEAL_BATCH_PROOF_PREFIX);
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);
Expand Down Expand Up @@ -269,7 +269,7 @@ impl SequencerSendCommitmentsToDaTest {
let hash = da.get_block_hash(finalized_height).await?;
let block = da.get_block(&hash).await?;

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

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

Expand Down
13 changes: 5 additions & 8 deletions crates/batch-prover/src/proving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use serde::Serialize;
use sov_db::ledger_db::BatchProverLedgerOps;
use sov_db::schema::types::{BatchNumber, StoredProof, StoredStateTransition};
use sov_modules_api::{BlobReaderTrait, SlotData, SpecId, Zkvm};
use sov_rollup_interface::da::{BlockHeaderTrait, DaSpec, SequencerCommitment};
use sov_rollup_interface::da::{BlockHeaderTrait, DaNamespace, DaSpec, SequencerCommitment};
use sov_rollup_interface::rpc::SoftConfirmationStatus;
use sov_rollup_interface::services::da::DaService;
use sov_rollup_interface::zk::{Proof, StateTransitionData, ZkvmHost};
Expand Down Expand Up @@ -56,8 +56,8 @@ where
{
let l1_height = l1_block.header().height();

let mut da_data: Vec<<<Da as DaService>::Spec as DaSpec>::BlobTransaction> =
da_service.extract_relevant_blobs(&l1_block);
let (mut da_data, inclusion_proof, completeness_proof) =
da_service.extract_relevant_blobs_with_proof(&l1_block, DaNamespace::ToBatchProver);

// if we don't do this, the zk circuit can't read the sequencer commitments
da_data.iter_mut().for_each(|blob| {
Expand Down Expand Up @@ -162,18 +162,15 @@ where
})?
.expect("There should be a state root");

let (inclusion_proof, completeness_proof) =
da_service.get_extraction_proof(&l1_block, &da_data).await;

let state_transition_data: StateTransitionData<StateRoot, Witness, Da::Spec> =
StateTransitionData {
initial_state_root,
final_state_root,
initial_batch_hash,
da_data: da_data.clone(),
da_block_header_of_commitments: da_block_header_of_commitments.clone(),
inclusion_proof,
completeness_proof,
inclusion_proof: inclusion_proof.clone(),
completeness_proof: completeness_proof.clone(),
soft_confirmations,
state_transition_witnesses,
da_block_headers_of_soft_confirmations,
Expand Down
Loading

0 comments on commit 060cbf7

Please sign in to comment.