Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add payload_size to ExplorerTransaction impl #2433

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 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 @@ -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" }
Expand Down
5 changes: 4 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand Down
3 changes: 2 additions & 1 deletion sequencer-sqlite/Cargo.lock

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

64 changes: 43 additions & 21 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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",
)?)?
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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<String> {
// 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
Expand Down
2 changes: 1 addition & 1 deletion tests/upgrades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
4 changes: 4 additions & 0 deletions types/src/v0/impls/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Loading