Skip to content

Commit

Permalink
Remove use_latest_elf (#1681)
Browse files Browse the repository at this point in the history
Co-authored-by: eyusufatik <esadyusufatik@gmail.com>
  • Loading branch information
jfldde and eyusufatik authored Jan 10, 2025
1 parent 775635c commit 44cbd0f
Show file tree
Hide file tree
Showing 28 changed files with 154 additions and 154 deletions.
2 changes: 1 addition & 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 = "ab88a607ca5aad2245d3c54f8822e02a1b71f50e" }
citrea-e2e = { git = "https://github.com/chainwayxyz/citrea-e2e", rev = "af85eae3010331df0e0cda5288f741b6d298813f" }

[patch.crates-io]
bitcoincore-rpc = { version = "0.18.0", git = "https://github.com/chainwayxyz/rust-bitcoincore-rpc.git", rev = "ca3cfa2" }
Expand Down
17 changes: 15 additions & 2 deletions bin/citrea/src/guests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ lazy_static! {
);
m
};
/// The following 2 are used as latest guest builds for tests that use Bitcoin DA.
pub(crate) static ref BATCH_PROOF_LATEST_BITCOIN_GUESTS: HashMap<SpecId, (Digest, Vec<u8>)> = {

pub(crate) static ref BATCH_PROOF_REGTEST_BITCOIN_GUESTS: HashMap<SpecId, (Digest, Vec<u8>)> = {
HashMap::from(
[
// this is ELF of genesis fork except for da namespace [1, 1] -> [1] and [2,2] -> [2]
Expand All @@ -61,6 +61,19 @@ lazy_static! {
]
)
};

/// The following 2 are used as latest guest builds for tests that use Bitcoin DA.
pub(crate) static ref BATCH_PROOF_LATEST_BITCOIN_GUESTS: HashMap<SpecId, (Digest, Vec<u8>)> = {
HashMap::from(
[
(SpecId::Fork1,
(Digest::new(citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ID),
citrea_risc0_batch_proof::BATCH_PROOF_BITCOIN_ELF.to_vec())
)
]
)
};

pub(crate) static ref LIGHT_CLIENT_LATEST_BITCOIN_GUESTS: HashMap<SpecId, (Digest, Vec<u8>)> = {
let mut m = HashMap::new();

Expand Down
2 changes: 1 addition & 1 deletion bin/citrea/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use rollup::*;

/// The network currently running.
#[derive(clap::ValueEnum, Copy, Clone, Default, Debug, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "lowercase")]
pub enum NetworkArg {
/// Mainnet
#[default]
Expand Down
8 changes: 8 additions & 0 deletions bin/citrea/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ struct Args {
#[arg(long, default_value_t)]
dev: bool,

/// Run the regtest chain
#[arg(long, default_value_t, conflicts_with = "dev")]
dev_all_forks: bool,

/// Path to the genesis configuration.
/// Defines the genesis of module states like evm.
#[arg(long)]
Expand Down Expand Up @@ -153,6 +157,10 @@ async fn main() -> Result<(), anyhow::Error> {
network = Network::Nightly;
}

if args.dev_all_forks {
network = Network::TestNetworkWithForks;
}

info!("Starting node on {network}");

match args.da_layer {
Expand Down
18 changes: 13 additions & 5 deletions bin/citrea/src/rollup/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use tracing::instrument;

use crate::guests::{
BATCH_PROOF_DEVNET_GUESTS, BATCH_PROOF_LATEST_BITCOIN_GUESTS, BATCH_PROOF_MAINNET_GUESTS,
BATCH_PROOF_TESTNET_GUESTS, LIGHT_CLIENT_DEVNET_GUESTS, LIGHT_CLIENT_LATEST_BITCOIN_GUESTS,
LIGHT_CLIENT_MAINNET_GUESTS, LIGHT_CLIENT_TESTNET_GUESTS,
BATCH_PROOF_REGTEST_BITCOIN_GUESTS, BATCH_PROOF_TESTNET_GUESTS, LIGHT_CLIENT_DEVNET_GUESTS,
LIGHT_CLIENT_LATEST_BITCOIN_GUESTS, LIGHT_CLIENT_MAINNET_GUESTS, LIGHT_CLIENT_TESTNET_GUESTS,
};
use crate::{CitreaRollupBlueprint, Network};

Expand Down Expand Up @@ -180,6 +180,10 @@ impl RollupBlueprint for BitcoinRollup {
.iter()
.map(|(k, (_, code))| (*k, code.clone()))
.collect(),
Network::TestNetworkWithForks => BATCH_PROOF_REGTEST_BITCOIN_GUESTS
.iter()
.map(|(k, (_, code))| (*k, code.clone()))
.collect(),
}
}

Expand All @@ -197,7 +201,7 @@ impl RollupBlueprint for BitcoinRollup {
.iter()
.map(|(k, (_, code))| (*k, code.clone()))
.collect(),
Network::Nightly => LIGHT_CLIENT_LATEST_BITCOIN_GUESTS
Network::Nightly | Network::TestNetworkWithForks => LIGHT_CLIENT_LATEST_BITCOIN_GUESTS
.iter()
.map(|(k, (_, code))| (*k, code.clone()))
.collect(),
Expand All @@ -224,6 +228,10 @@ impl RollupBlueprint for BitcoinRollup {
.iter()
.map(|(k, (id, _))| (*k, *id))
.collect(),
Network::TestNetworkWithForks => BATCH_PROOF_REGTEST_BITCOIN_GUESTS
.iter()
.map(|(k, (id, _))| (*k, *id))
.collect(),
}
}

Expand All @@ -243,7 +251,7 @@ impl RollupBlueprint for BitcoinRollup {
.iter()
.map(|(k, (id, _))| (*k, *id))
.collect(),
Network::Nightly => LIGHT_CLIENT_LATEST_BITCOIN_GUESTS
Network::Nightly | Network::TestNetworkWithForks => LIGHT_CLIENT_LATEST_BITCOIN_GUESTS
.iter()
.map(|(k, (id, _))| (*k, *id))
.collect(),
Expand All @@ -258,7 +266,7 @@ impl RollupBlueprint for BitcoinRollup {
ledger_db: LedgerDB,
proof_sampling_number: usize,
) -> Self::ProverService {
let vm = Risc0BonsaiHost::new(ledger_db.clone());
let vm = Risc0BonsaiHost::new(ledger_db.clone(), self.network);
// let vm = SP1Host::new(
// include_bytes!("../guests/sp1/batch-prover-bitcoin/elf/zkvm-elf"),
// ledger_db.clone(),
Expand Down
6 changes: 3 additions & 3 deletions bin/citrea/src/rollup/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{CitreaRollupBlueprint, Network};

/// Rollup with MockDa
pub struct MockDemoRollup {
_network: Network,
network: Network,
}

impl CitreaRollupBlueprint for MockDemoRollup {}
Expand All @@ -45,7 +45,7 @@ impl RollupBlueprint for MockDemoRollup {

fn new(network: Network) -> Self {
use_network_forks(network);
Self { _network: network }
Self { network }
}

fn create_rpc_methods(
Expand Down Expand Up @@ -134,7 +134,7 @@ impl RollupBlueprint for MockDemoRollup {
ledger_db: LedgerDB,
proof_sampling_number: usize,
) -> Self::ProverService {
let vm = Risc0BonsaiHost::new(ledger_db.clone());
let vm = Risc0BonsaiHost::new(ledger_db.clone(), self.network);

let proof_mode = match proving_mode {
ProverGuestRunConfig::Skip => ProofGenMode::Skip,
Expand Down
45 changes: 14 additions & 31 deletions bin/citrea/tests/bitcoin_e2e/batch_prover_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bitcoin_da::service::{BitcoinService, BitcoinServiceConfig, FINALITY_DEPTH};
use bitcoin_da::spec::RollupParams;
use citrea_common::tasks::manager::TaskManager;
use citrea_e2e::config::{
BatchProverConfig, LightClientProverConfig, ProverGuestRunConfig, SequencerConfig,
BatchProverConfig, CitreaMode, LightClientProverConfig, ProverGuestRunConfig, SequencerConfig,
SequencerMempoolConfig, TestCaseConfig, TestCaseEnv,
};
use citrea_e2e::framework::TestFramework;
Expand All @@ -19,13 +19,14 @@ use citrea_e2e::test_case::{TestCase, TestCaseRunner};
use citrea_e2e::traits::NodeT;
use citrea_e2e::Result;
use citrea_light_client_prover::rpc::LightClientProverRpcClient;
use citrea_primitives::forks::{fork_from_block_number, get_forks};
use citrea_primitives::forks::{fork_from_block_number, get_forks, use_network_forks};
use citrea_primitives::{TO_BATCH_PROOF_PREFIX, TO_LIGHT_CLIENT_PREFIX};
use sov_ledger_rpc::LedgerRpcClient;
use sov_modules_api::fork::ForkManager;
use sov_modules_api::SpecId;
use sov_rollup_interface::da::{DaTxRequest, SequencerCommitment};
use sov_rollup_interface::rpc::VerifiedBatchProofResponse;
use sov_rollup_interface::Network;
use tokio::time::sleep;

use super::get_citrea_path;
Expand Down Expand Up @@ -72,13 +73,6 @@ impl TestCase for BasicProverTest {
}
}

fn batch_prover_config() -> BatchProverConfig {
BatchProverConfig {
use_latest_elf: false,
..Default::default()
}
}

async fn run_test(&mut self, f: &mut TestFramework) -> Result<()> {
let da = f.bitcoin_nodes.get(0).unwrap();
let sequencer = f.sequencer.as_ref().unwrap();
Expand Down Expand Up @@ -165,13 +159,6 @@ impl TestCase for SkipPreprovenCommitmentsTest {
}
}

fn batch_prover_config() -> BatchProverConfig {
BatchProverConfig {
use_latest_elf: false,
..Default::default()
}
}

async fn run_test(&mut self, f: &mut TestFramework) -> Result<()> {
let da = f.bitcoin_nodes.get(0).unwrap();
let sequencer = f.sequencer.as_ref().unwrap();
Expand Down Expand Up @@ -551,6 +538,15 @@ impl TestCase for ForkElfSwitchingTest {
with_batch_prover: true,
with_full_node: true,
with_light_client_prover: true,
mode: CitreaMode::DevAllForks,
..Default::default()
}
}

fn light_client_prover_config() -> LightClientProverConfig {
LightClientProverConfig {
initial_da_height: 171,
enable_recovery: false,
..Default::default()
}
}
Expand All @@ -569,21 +565,6 @@ impl TestCase for ForkElfSwitchingTest {
}
}

fn batch_prover_config() -> BatchProverConfig {
BatchProverConfig {
use_latest_elf: false,
..Default::default()
}
}

fn light_client_prover_config() -> LightClientProverConfig {
LightClientProverConfig {
initial_da_height: 171,
enable_recovery: false,
..Default::default()
}
}

async fn run_test(&mut self, f: &mut TestFramework) -> Result<()> {
let da = f.bitcoin_nodes.get(0).unwrap();
let sequencer = f.sequencer.as_ref().unwrap();
Expand Down Expand Up @@ -693,6 +674,8 @@ impl TestCase for ForkElfSwitchingTest {

#[tokio::test]
async fn test_fork_elf_switching() -> Result<()> {
use_network_forks(Network::TestNetworkWithForks);

TestCaseRunner::new(ForkElfSwitchingTest)
.set_citrea_path(get_citrea_path())
.run()
Expand Down
22 changes: 7 additions & 15 deletions bin/citrea/tests/bitcoin_e2e/light_client_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use citrea_batch_prover::rpc::BatchProverRpcClient;
use citrea_batch_prover::GroupCommitments;
use citrea_common::tasks::manager::TaskManager;
use citrea_e2e::config::{
BatchProverConfig, LightClientProverConfig, SequencerConfig, SequencerMempoolConfig,
TestCaseConfig,
BatchProverConfig, CitreaMode, LightClientProverConfig, SequencerConfig,
SequencerMempoolConfig, TestCaseConfig,
};
use citrea_e2e::framework::TestFramework;
use citrea_e2e::node::NodeKind;
Expand Down Expand Up @@ -42,6 +42,7 @@ impl TestCase for LightClientProvingTest {
with_batch_prover: true,
with_light_client_prover: true,
with_full_node: true,
mode: CitreaMode::DevAllForks,
..Default::default()
}
}
Expand All @@ -57,7 +58,6 @@ impl TestCase for LightClientProvingTest {
fn batch_prover_config() -> BatchProverConfig {
BatchProverConfig {
enable_recovery: false,
use_latest_elf: false,
..Default::default()
}
}
Expand Down Expand Up @@ -172,6 +172,7 @@ impl TestCase for LightClientProvingTestMultipleProofs {
with_batch_prover: true,
with_light_client_prover: true,
with_full_node: true,
mode: CitreaMode::DevAllForks,
..Default::default()
}
}
Expand All @@ -193,7 +194,6 @@ impl TestCase for LightClientProvingTestMultipleProofs {
BatchProverConfig {
enable_recovery: false,
proof_sampling_number: 99999999,
use_latest_elf: false,
..Default::default()
}
}
Expand Down Expand Up @@ -245,11 +245,7 @@ impl TestCase for LightClientProvingTestMultipleProofs {
batch_prover
.client
.http_client()
.prove(
commitment_l1_height,
false,
Some(GroupCommitments::OneByOne),
)
.prove(commitment_l1_height, Some(GroupCommitments::OneByOne))
.await
.unwrap();

Expand Down Expand Up @@ -374,11 +370,7 @@ impl TestCase for LightClientProvingTestMultipleProofs {
batch_prover
.client
.http_client()
.prove(
commitment_l1_height,
false,
Some(GroupCommitments::OneByOne),
)
.prove(commitment_l1_height, Some(GroupCommitments::OneByOne))
.await
.unwrap();

Expand Down Expand Up @@ -467,6 +459,7 @@ impl TestCase for LightClientBatchProofMethodIdUpdateTest {
with_sequencer: true,
with_batch_prover: true,
with_light_client_prover: true,
mode: CitreaMode::DevAllForks,
..Default::default()
}
}
Expand All @@ -482,7 +475,6 @@ impl TestCase for LightClientBatchProofMethodIdUpdateTest {
fn batch_prover_config() -> BatchProverConfig {
BatchProverConfig {
enable_recovery: false,
use_latest_elf: false,
..Default::default()
}
}
Expand Down
1 change: 0 additions & 1 deletion bin/citrea/tests/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ async fn test_all_flow() {
proving_mode: sov_stf_runner::ProverGuestRunConfig::Execute,
proof_sampling_number: 0,
enable_recovery: true,
use_latest_elf: true,
}),
None,
rollup_config,
Expand Down
4 changes: 1 addition & 3 deletions bin/citrea/tests/e2e/proving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ async fn full_node_verify_proof_and_store() {
proving_mode: sov_stf_runner::ProverGuestRunConfig::Execute,
proof_sampling_number: 0,
enable_recovery: true,
use_latest_elf: true,
}),
None,
rollup_config,
Expand Down Expand Up @@ -247,7 +246,6 @@ async fn test_batch_prover_prove_rpc() {
// Make it impossible for proving to happen
proof_sampling_number: 1_000_000,
enable_recovery: true,
use_latest_elf: true,
}),
None,
rollup_config,
Expand Down Expand Up @@ -301,7 +299,7 @@ async fn test_batch_prover_prove_rpc() {

// Trigger proving via the RPC endpoint
prover_node_test_client
.batch_prover_prove(3, true, Some(GroupCommitments::Normal))
.batch_prover_prove(3, Some(GroupCommitments::Normal))
.await;

// wait here until we see from prover's rpc that it finished proving
Expand Down
Loading

0 comments on commit 44cbd0f

Please sign in to comment.