diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 553510d2b..3703d295c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,7 +95,7 @@ jobs: run: | cargo build --locked --profile test --bins cargo build --manifest-path ./sequencer-sqlite/Cargo.toml --target-dir ./target - timeout-minutes: 30 + timeout-minutes: 45 - name: Upload archive to workflow uses: actions/upload-artifact@v4 diff --git a/Cargo.lock b/Cargo.lock index 315c0f751..342ee106e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4212,7 +4212,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.75" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=v0.1.75#dffefa160f441a663723a67bc54efedb11a88b02" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=v0.1.75-explorer-fixes#d36941606c1a7a9a488963f05e96515fa9cbc1c7" dependencies = [ "anyhow", "ark-serialize", @@ -4237,6 +4237,7 @@ dependencies = [ "itertools 0.12.1", "jf-merkle-tree", "jf-vid", + "lazy_static", "log", "portpicker", "prometheus", diff --git a/Cargo.toml b/Cargo.toml index 630d32d08..b648a093d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,7 +72,7 @@ marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketpla marketplace-builder-shared = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.1.57" } hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.56" } hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.82" } -hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "v0.1.75" } +hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "v0.1.75-explorer-fixes" } hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.82" } hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" } hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.82" } diff --git a/justfile b/justfile index 000051aa1..0287f563e 100644 --- a/justfile +++ b/justfile @@ -70,7 +70,10 @@ test-all: test-integration: @echo 'NOTE that demo-native must be running for this test to succeed.' - cargo nextest run --all-features --nocapture --profile integration + INTEGRATION_TEST_SEQUENCER_VERSION=2 cargo nextest run --all-features --nocapture --profile integration smoke +test-integration-mp: + @echo 'NOTE that demo-native-mp must be running for this test to succeed.' + INTEGRATION_TEST_SEQUENCER_VERSION=99 cargo nextest run --all-features --nocapture --profile integration clippy: @echo 'features: "embedded-db"' diff --git a/sequencer-sqlite/Cargo.lock b/sequencer-sqlite/Cargo.lock index 663dd21b5..95cf3cc22 100644 --- a/sequencer-sqlite/Cargo.lock +++ b/sequencer-sqlite/Cargo.lock @@ -4090,7 +4090,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.75" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=v0.1.75#dffefa160f441a663723a67bc54efedb11a88b02" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=v0.1.75-explorer-fixes#d36941606c1a7a9a488963f05e96515fa9cbc1c7" dependencies = [ "anyhow", "ark-serialize", @@ -4113,6 +4113,7 @@ dependencies = [ "itertools 0.12.1", "jf-merkle-tree", "jf-vid", + "lazy_static", "log", "prometheus", "refinery", diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 52afd6496..22b206cfb 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,11 +1,12 @@ use anyhow::{anyhow, Result}; use client::SequencerClient; -use espresso_types::FeeAmount; +use espresso_types::{FeeAmount, FeeVersion, MarketplaceVersion}; use ethers::prelude::*; use futures::future::join_all; use std::{fmt, str::FromStr, time::Duration}; use surf_disco::Url; use tokio::time::{sleep, timeout}; +use vbs::version::StaticVersionType; const L1_PROVIDER_RETRY_INTERVAL: Duration = Duration::from_secs(1); // TODO add to .env @@ -81,10 +82,10 @@ impl TestConfig { // which is the initial mainnet version without any upgrades. let sequencer_version: u8 = dotenvy::var("INTEGRATION_TEST_SEQUENCER_VERSION") .map(|v| v.parse().unwrap()) - .unwrap_or(2); + .unwrap_or(FeeVersion::version().minor as u8); // Varies between v0 and v3. - let load_generator_url = if sequencer_version >= 3 { + let load_generator_url = if sequencer_version >= MarketplaceVersion::version().minor as u8 { url_from_port(dotenvy::var( "ESPRESSO_SUBMIT_TRANSACTIONS_PRIVATE_RESERVE_PORT", )?)? @@ -93,17 +94,18 @@ impl TestConfig { }; // TODO test both builders (probably requires some refactoring). - let builder_url = if sequencer_version >= 3 { + let builder_url = if sequencer_version as u16 >= MarketplaceVersion::version().minor { let url = url_from_port(dotenvy::var("ESPRESSO_RESERVE_BUILDER_SERVER_PORT")?)?; + let url = Url::from_str(&url)?; + wait_for_service(url.clone(), 1000, 200).await.unwrap(); - Url::from_str(&url)? - .join("bundle_info/builderaddress") - .unwrap() + url.join("bundle_info/builderaddress").unwrap() } else { let url = url_from_port(dotenvy::var("ESPRESSO_BUILDER_SERVER_PORT")?)?; - Url::from_str(&url)? - .join("block_info/builderaddress") - .unwrap() + let url = Url::from_str(&url)?; + wait_for_service(url.clone(), 1000, 200).await.unwrap(); + + url.join("block_info/builderaddress").unwrap() }; let builder_address = get_builder_address(builder_url).await; @@ -222,9 +224,8 @@ impl TestConfig { } } -/// Get Address from builder after waiting for builder to become ready. +/// Get Address from builder pub async fn get_builder_address(url: Url) -> Address { - let _ = wait_for_service(url.clone(), 1000, 200).await; for _ in 0..5 { // Try to get builder address somehow if let Ok(body) = reqwest::get(url.clone()).await { @@ -236,20 +237,41 @@ pub async fn get_builder_address(url: Url) -> Address { panic!("Error: Failed to retrieve address from builder!"); } +/// [wait_for_service] will check to see if a service, identified by the given +/// Url, is available, by checking it's health check endpoint. If the health +/// check does not any time before the timeout, then the service will return +/// an [Err] with the relevant error. +/// +/// > Note: This function only waits for a single health check pass before +/// > returning an [Ok] result. async fn wait_for_service(url: Url, interval: u64, timeout_duration: u64) -> Result { + // utilize the correct path for the health check + let Ok(url) = url.join("/healthcheck") else { + return Err(anyhow!("Wait for service, could not join url: {}", url)); + }; + timeout(Duration::from_secs(timeout_duration), async { loop { - if let Ok(body) = reqwest::get(format!("{url}/healthcheck")).await { - return body.text().await.map_err(|e| { - anyhow!( - "Wait for service, could not decode response: ({}) {}", - url, - e - ) - }); - } else { + // Ensure that we get a response from the server + let Ok(response) = reqwest::get(url.clone()).await else { sleep(Duration::from_millis(interval)).await; + continue; + }; + + // Check the status code of the response + if !response.status().is_success() { + // The server did not return a success + sleep(Duration::from_millis(interval)).await; + continue; } + + return response.text().await.map_err(|e| { + anyhow!( + "Wait for service, could not decode response: ({}) {}", + url, + e + ) + }); } }) .await diff --git a/tests/upgrades.rs b/tests/upgrades.rs index 5d6893844..e680d904b 100644 --- a/tests/upgrades.rs +++ b/tests/upgrades.rs @@ -12,7 +12,7 @@ async fn test_upgrade() -> Result<()> { let testing = TestConfig::new().await.unwrap(); - let versions = if testing.sequencer_version >= 3 { + let versions = if testing.sequencer_version as u16 >= MarketplaceVersion::version().minor { (FeeVersion::version(), MarketplaceVersion::version()) } else { panic!("Invalid sequencer version provided for upgrade test."); diff --git a/types/src/v0/impls/transaction.rs b/types/src/v0/impls/transaction.rs index 663c0365c..cd473d039 100644 --- a/types/src/v0/impls/transaction.rs +++ b/types/src/v0/impls/transaction.rs @@ -119,4 +119,8 @@ impl ExplorerTransaction for Transaction { fn namespace_id(&self) -> Self::NamespaceId { self.namespace } + + fn payload_size(&self) -> u64 { + self.payload.len() as u64 + } }