diff --git a/Cargo.lock b/Cargo.lock index 2f94f5740..51e381bc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1235,7 +1235,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "thiserror", "tokio", "tracing", @@ -1744,13 +1744,13 @@ dependencies = [ "sha2", "soft-confirmation-rule-enforcer", "sov-db", - "sov-ledger-rpc 0.5.0-rc.1", + "sov-ledger-rpc", "sov-mock-da", "sov-modules-api", "sov-modules-rollup-blueprint", "sov-modules-stf-blueprint", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "sov-stf-runner", "sp1-helper", @@ -1790,7 +1790,7 @@ dependencies = [ "sov-modules-core", "sov-modules-rollup-blueprint", "sov-modules-stf-blueprint", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-stf-runner", "tempfile", "tokio", @@ -1817,7 +1817,7 @@ dependencies = [ "serde_json", "sov-db", "sov-mock-da", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-stf-runner", "tempfile", "tokio", @@ -1830,7 +1830,7 @@ dependencies = [ [[package]] name = "citrea-e2e" version = "0.1.0" -source = "git+https://github.com/chainwayxyz/citrea-e2e?rev=ca36ceb#ca36ceb87aed6f1421c47b09b025fdf227346660" +source = "git+https://github.com/chainwayxyz/citrea-e2e?rev=5b3e127#5b3e127cd0ceae4b11a4ac92e9782013abcddd01" dependencies = [ "anyhow", "async-trait", @@ -1843,8 +1843,6 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sov-ledger-rpc 0.5.0-rc.1 (git+https://github.com/chainwayxyz/citrea?rev=962e125)", - "sov-rollup-interface 0.5.0-rc.1 (git+https://github.com/chainwayxyz/citrea?rev=962e125)", "tempfile", "tokio", "toml", @@ -1891,7 +1889,7 @@ dependencies = [ "serde_json", "sov-modules-api", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "sov-stf-runner", "tempfile", @@ -1927,7 +1925,7 @@ dependencies = [ "sov-modules-rollup-blueprint", "sov-modules-stf-blueprint", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "sov-stf-runner", "tempfile", @@ -1951,7 +1949,7 @@ dependencies = [ "sov-db", "sov-modules-api", "sov-modules-rollup-blueprint", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-stf-runner", "tokio", "tokio-util", @@ -1968,7 +1966,7 @@ dependencies = [ "brotli", "reth-primitives", "serde", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "tokio", "tracing", ] @@ -2002,7 +2000,7 @@ dependencies = [ "risc0-zkvm", "serde", "sov-db", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "tracing", ] @@ -2048,7 +2046,7 @@ dependencies = [ "sov-modules-api", "sov-modules-rollup-blueprint", "sov-modules-stf-blueprint", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "sov-stf-runner", "tempfile", @@ -2078,7 +2076,7 @@ dependencies = [ "sov-accounts", "sov-modules-api", "sov-modules-stf-blueprint", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "sov-stf-runner", "tracing", @@ -2833,7 +2831,7 @@ dependencies = [ "serde_json", "sov-db", "sov-modules-api", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "tokio", "tracing", ] @@ -3659,7 +3657,7 @@ dependencies = [ "serde", "sov-modules-api", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-schema-db", "sov-state", "tempfile", @@ -5008,7 +5006,7 @@ dependencies = [ "sha2", "sov-db", "sov-modules-api", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-stf-runner", "tempfile", "tokio", @@ -6947,7 +6945,7 @@ dependencies = [ "reth-rpc-types", "serde", "serde_json", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "tokio", "tracing", ] @@ -7215,7 +7213,7 @@ dependencies = [ "sov-mock-da", "sov-modules-api", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "tempfile", "tracing", @@ -7297,7 +7295,7 @@ dependencies = [ "rocksdb", "serde", "sha2", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-schema-db", "tempfile", "tokio", @@ -7315,21 +7313,11 @@ dependencies = [ "serde_json", "sov-db", "sov-modules-api", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "tempfile", "tokio", ] -[[package]] -name = "sov-ledger-rpc" -version = "0.5.0-rc.1" -source = "git+https://github.com/chainwayxyz/citrea?rev=962e125#962e1252c6589e75fafaa0f4f32b81b5a51e9e49" -dependencies = [ - "jsonrpsee", - "serde", - "sov-rollup-interface 0.5.0-rc.1 (git+https://github.com/chainwayxyz/citrea?rev=962e125)", -] - [[package]] name = "sov-mock-da" version = "0.5.0-rc.1" @@ -7346,7 +7334,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "tempfile", "tokio", "tokio-stream", @@ -7362,7 +7350,7 @@ dependencies = [ "bincode", "borsh", "serde", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", ] [[package]] @@ -7393,7 +7381,7 @@ dependencies = [ "sov-modules-core", "sov-modules-macros", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "tempfile", "thiserror", @@ -7421,7 +7409,7 @@ dependencies = [ "sov-modules-api", "sov-modules-core", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "tempfile", "thiserror", @@ -7441,7 +7429,7 @@ dependencies = [ "serde_json", "sov-modules-api", "sov-modules-core", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "syn 1.0.109", "trybuild", @@ -7456,10 +7444,10 @@ dependencies = [ "citrea-common", "jsonrpsee", "sov-db", - "sov-ledger-rpc 0.5.0-rc.1", + "sov-ledger-rpc", "sov-modules-api", "sov-modules-stf-blueprint", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-stf-runner", "tokio", "tracing", @@ -7478,7 +7466,7 @@ dependencies = [ "rs_merkle", "serde", "sov-modules-api", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "tracing", ] @@ -7493,7 +7481,7 @@ dependencies = [ "sha2", "sov-db", "sov-mock-da", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-schema-db", "sov-state", "tempfile", @@ -7522,26 +7510,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "sov-rollup-interface" -version = "0.5.0-rc.1" -source = "git+https://github.com/chainwayxyz/citrea?rev=962e125#962e1252c6589e75fafaa0f4f32b81b5a51e9e49" -dependencies = [ - "anyhow", - "async-trait", - "borsh", - "bytes", - "digest 0.10.7", - "futures", - "hex", - "proptest", - "serde", - "sha2", - "thiserror", - "tokio", - "tracing", -] - [[package]] name = "sov-schema-db" version = "0.5.0-rc.1" @@ -7575,7 +7543,7 @@ dependencies = [ "sha2", "sov-db", "sov-modules-core", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "tempfile", ] @@ -7597,7 +7565,7 @@ dependencies = [ "sov-db", "sov-modules-api", "sov-prover-storage-manager", - "sov-rollup-interface 0.5.0-rc.1", + "sov-rollup-interface", "sov-state", "tempfile", "thiserror", diff --git a/bin/citrea/Cargo.toml b/bin/citrea/Cargo.toml index 471ef9dfc..e8d009895 100644 --- a/bin/citrea/Cargo.toml +++ b/bin/citrea/Cargo.toml @@ -89,7 +89,7 @@ rustc_version_runtime = { workspace = true } # bitcoin-e2e dependencies bitcoin.workspace = true bitcoincore-rpc.workspace = true -citrea-e2e = { git = "https://github.com/chainwayxyz/citrea-e2e", rev = "ca36ceb" } +citrea-e2e = { git = "https://github.com/chainwayxyz/citrea-e2e", rev = "5b3e127" } [build-dependencies] sp1-helper = { version = "3.0.0", default-features = false } diff --git a/bin/citrea/tests/bitcoin_e2e/batch_prover_test.rs b/bin/citrea/tests/bitcoin_e2e/batch_prover_test.rs index c4ac7a1db..d42de50cc 100644 --- a/bin/citrea/tests/bitcoin_e2e/batch_prover_test.rs +++ b/bin/citrea/tests/bitcoin_e2e/batch_prover_test.rs @@ -1,5 +1,5 @@ use std::sync::Arc; -use std::time::Duration; +use std::time::{Duration, Instant}; use anyhow::bail; use async_trait::async_trait; @@ -10,16 +10,45 @@ use citrea_e2e::config::{ BatchProverConfig, ProverGuestRunConfig, SequencerConfig, TestCaseConfig, TestCaseEnv, }; use citrea_e2e::framework::TestFramework; +use citrea_e2e::full_node::FullNode; use citrea_e2e::node::NodeKind; use citrea_e2e::test_case::{TestCase, TestCaseRunner}; use citrea_e2e::Result; use citrea_primitives::{TO_BATCH_PROOF_PREFIX, TO_LIGHT_CLIENT_PREFIX}; +use sov_ledger_rpc::client::RpcClient; use sov_rollup_interface::da::{DaData, SequencerCommitment}; +use sov_rollup_interface::rpc::VerifiedBatchProofResponse; use sov_rollup_interface::services::da::SenderWithNotifier; use tokio::sync::mpsc::UnboundedSender; +use tokio::time::sleep; use super::get_citrea_path; +pub async fn wait_for_zkproofs( + full_node: &FullNode, + height: u64, + timeout: Option, +) -> Result> { + let start = Instant::now(); + let timeout = timeout.unwrap_or(Duration::from_secs(30)); + + loop { + if start.elapsed() >= timeout { + bail!("FullNode failed to get zkproofs within the specified timeout"); + } + + match full_node + .client + .http_client() + .get_verified_batch_proofs_by_slot_height(height) + .await? + { + Some(proofs) => return Ok(proofs), + None => sleep(Duration::from_millis(500)).await, + } + } +} + /// This is a basic prover test showcasing spawning a bitcoin node as DA, a sequencer and a prover. /// It generates soft confirmations and wait until it reaches the first commitment. /// It asserts that the blob inscribe txs have been sent. @@ -83,13 +112,13 @@ impl TestCase for BasicProverTest { .await?; da.generate(FINALITY_DEPTH, None).await?; - let proofs = full_node - .wait_for_zkproofs( - finalized_height + FINALITY_DEPTH, - Some(Duration::from_secs(120)), - ) - .await - .unwrap(); + let proofs = wait_for_zkproofs( + full_node, + finalized_height + FINALITY_DEPTH, + Some(Duration::from_secs(120)), + ) + .await + .unwrap(); { // print some debug info about state diff @@ -220,13 +249,13 @@ impl TestCase for SkipPreprovenCommitmentsTest { .await?; da.generate(FINALITY_DEPTH, None).await?; - let proofs = full_node - .wait_for_zkproofs( - finalized_height + FINALITY_DEPTH, - Some(Duration::from_secs(120)), - ) - .await - .unwrap(); + let proofs = wait_for_zkproofs( + full_node, + finalized_height + FINALITY_DEPTH, + Some(Duration::from_secs(120)), + ) + .await + .unwrap(); assert!(proofs .first() @@ -241,7 +270,8 @@ impl TestCase for SkipPreprovenCommitmentsTest { // Fetch the commitment created from the previous L1 range let commitments: Vec = full_node .client - .ledger_get_sequencer_commitments_on_slot_by_number(finalized_height) + .http_client() + .get_sequencer_commitments_on_slot_by_number(finalized_height) .await .unwrap_or_else(|_| { panic!( @@ -290,13 +320,13 @@ impl TestCase for SkipPreprovenCommitmentsTest { da.generate(FINALITY_DEPTH, None).await?; - let proofs = full_node - .wait_for_zkproofs( - finalized_height + FINALITY_DEPTH, - Some(Duration::from_secs(120)), - ) - .await - .unwrap(); + let proofs = wait_for_zkproofs( + full_node, + finalized_height + FINALITY_DEPTH, + Some(Duration::from_secs(120)), + ) + .await + .unwrap(); assert_eq!( proofs @@ -402,10 +432,10 @@ impl TestCase for LocalProvingTest { let finalized_height = da.get_finalized_height().await?; // Wait for full node to see zkproofs - let proofs = full_node - .wait_for_zkproofs(finalized_height, Some(Duration::from_secs(7200))) - .await - .unwrap(); + let proofs = + wait_for_zkproofs(full_node, finalized_height, Some(Duration::from_secs(7200))) + .await + .unwrap(); assert_eq!(proofs.len(), 1); diff --git a/bin/citrea/tests/bitcoin_e2e/light_client_test.rs b/bin/citrea/tests/bitcoin_e2e/light_client_test.rs index bb236784e..d6a4d7147 100644 --- a/bin/citrea/tests/bitcoin_e2e/light_client_test.rs +++ b/bin/citrea/tests/bitcoin_e2e/light_client_test.rs @@ -9,6 +9,7 @@ use citrea_e2e::config::{ use citrea_e2e::framework::TestFramework; use citrea_e2e::test_case::{TestCase, TestCaseRunner}; use citrea_e2e::Result; +use sov_ledger_rpc::client::RpcClient; use super::get_citrea_path; @@ -82,7 +83,8 @@ impl TestCase for LightClientProvingTest { // Assert that commitment is queryable let commitments = batch_prover .client - .ledger_get_sequencer_commitments_on_slot_by_number(commitment_l1_height) + .http_client() + .get_sequencer_commitments_on_slot_by_number(commitment_l1_height) .await .unwrap() .unwrap(); diff --git a/bin/citrea/tests/bitcoin_e2e/sequencer_commitments.rs b/bin/citrea/tests/bitcoin_e2e/sequencer_commitments.rs index 253e56943..c084d56c2 100644 --- a/bin/citrea/tests/bitcoin_e2e/sequencer_commitments.rs +++ b/bin/citrea/tests/bitcoin_e2e/sequencer_commitments.rs @@ -1,3 +1,6 @@ +use std::time::{Duration, Instant}; + +use anyhow::bail; use async_trait::async_trait; use bitcoin::hashes::Hash; use bitcoin_da::service::{get_relevant_blobs_from_txs, FINALITY_DEPTH}; @@ -6,15 +9,46 @@ use borsh::BorshDeserialize; use citrea_e2e::bitcoin::BitcoinNode; use citrea_e2e::config::{SequencerConfig, TestCaseConfig}; use citrea_e2e::framework::TestFramework; +use citrea_e2e::full_node::FullNode; use citrea_e2e::sequencer::Sequencer; use citrea_e2e::test_case::{TestCase, TestCaseRunner}; use citrea_e2e::Result; use citrea_primitives::TO_BATCH_PROOF_PREFIX; use rs_merkle::algorithms::Sha256; use rs_merkle::MerkleTree; +use sov_ledger_rpc::client::RpcClient; use sov_rollup_interface::da::{BlobReaderTrait, DaData}; +use sov_rollup_interface::rpc::SequencerCommitmentResponse; +use tokio::time::sleep; use super::get_citrea_path; + +pub async fn wait_for_sequencer_commitments( + full_node: &FullNode, + height: u64, + timeout: Option, +) -> Result> { + let start = Instant::now(); + let timeout = timeout.unwrap_or(Duration::from_secs(30)); + + loop { + if start.elapsed() >= timeout { + bail!("FullNode failed to get sequencer commitments within the specified timeout"); + } + + match full_node + .client + .http_client() + .get_sequencer_commitments_on_slot_by_number(height) + .await + { + Ok(Some(commitments)) => return Ok(commitments), + Ok(None) => sleep(Duration::from_millis(500)).await, + Err(e) => bail!("Error fetching sequencer commitments: {}", e), + } + } +} + struct LedgerGetCommitmentsProverTest; #[async_trait] @@ -58,7 +92,8 @@ impl TestCase for LedgerGetCommitmentsProverTest { let commitments = prover .client - .ledger_get_sequencer_commitments_on_slot_by_number(finalized_height) + .http_client() + .get_sequencer_commitments_on_slot_by_number(finalized_height) .await .unwrap() .unwrap(); @@ -74,7 +109,8 @@ impl TestCase for LedgerGetCommitmentsProverTest { let commitments_hash = prover .client - .ledger_get_sequencer_commitments_on_slot_by_hash(hash.as_raw_hash().to_byte_array()) + .http_client() + .get_sequencer_commitments_on_slot_by_hash(hash.as_raw_hash().to_byte_array()) .await .unwrap() .unwrap(); @@ -130,9 +166,7 @@ impl TestCase for LedgerGetCommitmentsTest { let finalized_height = da.get_finalized_height().await?; - let commitments = full_node - .wait_for_sequencer_commitments(finalized_height, None) - .await?; + let commitments = wait_for_sequencer_commitments(full_node, finalized_height, None).await?; assert_eq!(commitments.len(), 1); @@ -145,7 +179,8 @@ impl TestCase for LedgerGetCommitmentsTest { let commitments_node = full_node .client - .ledger_get_sequencer_commitments_on_slot_by_hash(hash.as_raw_hash().to_byte_array()) + .http_client() + .get_sequencer_commitments_on_slot_by_hash(hash.as_raw_hash().to_byte_array()) .await .unwrap() .unwrap(); @@ -291,7 +326,8 @@ impl SequencerSendCommitmentsToDaTest { soft_confirmations.push( sequencer .client - .ledger_get_soft_confirmation_by_number(i) + .http_client() + .get_soft_confirmation_by_number(i) .await? .unwrap(), ); diff --git a/bin/citrea/tests/bitcoin_e2e/sequencer_test.rs b/bin/citrea/tests/bitcoin_e2e/sequencer_test.rs index 2528725c7..9f9de882e 100644 --- a/bin/citrea/tests/bitcoin_e2e/sequencer_test.rs +++ b/bin/citrea/tests/bitcoin_e2e/sequencer_test.rs @@ -6,6 +6,7 @@ use citrea_e2e::framework::TestFramework; use citrea_e2e::test_case::{TestCase, TestCaseRunner}; use citrea_e2e::traits::Restart; use citrea_e2e::Result; +use sov_ledger_rpc::client::RpcClient; use super::get_citrea_path; @@ -26,7 +27,8 @@ impl TestCase for BasicSequencerTest { let head_batch0 = sequencer .client - .ledger_get_head_soft_confirmation() + .http_client() + .get_head_soft_confirmation() .await? .unwrap(); assert_eq!(head_batch0.l2_height, 1); @@ -38,7 +40,8 @@ impl TestCase for BasicSequencerTest { sequencer.client.wait_for_l2_block(1, None).await?; let head_batch1 = sequencer .client - .ledger_get_head_soft_confirmation() + .http_client() + .get_head_soft_confirmation() .await? .unwrap(); assert_eq!(head_batch1.l2_height, 2); @@ -110,7 +113,8 @@ impl TestCase for SequencerMissedDaBlocksTest { for i in 1..=head_soft_confirmation_height { let soft_confirmation = sequencer .client - .ledger_get_soft_confirmation_by_number(i) + .http_client() + .get_soft_confirmation_by_number(i) .await? .unwrap();