Skip to content
Draft
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
7 changes: 3 additions & 4 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions crates/espresso/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ committable = { workspace = true }
csv = { workspace = true }
derivative = { workspace = true }
derive_more = { workspace = true }
disco-types = { workspace = true }
dotenvy = { workspace = true }
dyn-clone = { workspace = true }
either = { workspace = true }
Expand Down Expand Up @@ -97,7 +98,6 @@ request-response = { workspace = true }
reqwest = { workspace = true }
rstest = { workspace = true }
rstest_reuse = { workspace = true }
semver = { workspace = true }
serde = { workspace = true }
serde_bytes = { workspace = true }
serde_json = { workspace = true }
Expand All @@ -112,7 +112,6 @@ tagged-base64 = { workspace = true }
tempfile = { workspace = true }
test-utils = { workspace = true }
thiserror = { workspace = true }
tide-disco = { workspace = true }
time = { workspace = true }
tokio = { workspace = true }
tokio-tungstenite = { workspace = true }
Expand Down
83 changes: 8 additions & 75 deletions crates/espresso/node/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ use crate::{
};

pub mod data_source;
pub mod endpoints;
pub mod fs;
pub mod light_client;
pub mod options;
Expand Down Expand Up @@ -1883,10 +1882,7 @@ pub mod test_helpers {
MOCK_SEQUENCER_VERSIONS, NamespaceId, ValidatedState,
v0::traits::{NullEventConsumer, PersistenceOptions, StateCatchup},
};
use futures::{
future::{FutureExt, join_all},
stream::StreamExt,
};
use futures::{future::join_all, stream::StreamExt};
use hotshot::types::{Event, EventType};
use hotshot_contract_adapter::stake_table::StakeTableContractVersion;
use hotshot_types::{
Expand All @@ -1899,10 +1895,8 @@ pub mod test_helpers {
use staking_cli::demo::{DelegationConfig, StakingTransactions};
use tempfile::TempDir;
use test_utils::reserve_tcp_port;
use tide_disco::{Api, App, Error, StatusCode};
use tokio::{spawn, task::JoinHandle, time::sleep};
use url::Url;
use vbs::version::{StaticVersion, StaticVersionType};
use tokio::time::sleep;
use vbs::version::StaticVersion;
use versions::{EPOCH_VERSION, Upgrade};

use super::*;
Expand Down Expand Up @@ -2524,70 +2518,6 @@ pub mod test_helpers {
.unwrap()
.unwrap();
}

pub async fn spawn_dishonest_peer_catchup_api() -> anyhow::Result<(Url, JoinHandle<()>)> {
let toml = toml::from_str::<toml::Value>(include_str!("../api/catchup.toml")).unwrap();
let mut api =
Api::<(), hotshot_query_service::Error, SequencerApiVersion>::new(toml).unwrap();

api.get("account", |_req, _state: &()| {
async move {
Result::<AccountQueryData, _>::Err(hotshot_query_service::Error::catch_all(
StatusCode::BAD_REQUEST,
"no account found".to_string(),
))
}
.boxed()
})?
.get("blocks", |_req, _state| {
async move {
Result::<BlocksFrontier, _>::Err(hotshot_query_service::Error::catch_all(
StatusCode::BAD_REQUEST,
"no block found".to_string(),
))
}
.boxed()
})?
.get("chainconfig", |_req, _state| {
async move {
Result::<ChainConfig, _>::Ok(ChainConfig {
max_block_size: 300.into(),
base_fee: 1.into(),
fee_recipient: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
.parse()
.unwrap(),
..Default::default()
})
}
.boxed()
})?
.get("leafchain", |_req, _state| {
async move {
Result::<Vec<Leaf2>, _>::Err(hotshot_query_service::Error::catch_all(
StatusCode::BAD_REQUEST,
"No leafchain found".to_string(),
))
}
.boxed()
})?;

let mut app = App::<_, hotshot_query_service::Error>::with_state(());
app.with_version(env!("CARGO_PKG_VERSION").parse().unwrap());

app.register_module::<_, _>("catchup", api).unwrap();

let port = reserve_tcp_port().expect("OS should have ephemeral ports available");
let url: Url = Url::parse(&format!("http://localhost:{port}")).unwrap();

let handle = spawn({
let url = url.clone();
async move {
let _ = app.serve(url, SequencerApiVersion::instance()).await;
}
});

Ok((url, handle))
}
}

#[cfg(test)]
Expand Down Expand Up @@ -3242,7 +3172,11 @@ mod test {
utils::epoch_from_block_number,
x25519,
};
use http_client::{Client, StatusCode, error::ClientErr};
use http_client::{
Client, StatusCode,
error::ClientErr,
healthcheck::{AppHealth, HealthStatus},
};
use jf_merkle_tree_compat::{
MerkleTreeScheme,
prelude::{MerkleProof, Sha3Node},
Expand All @@ -3259,7 +3193,6 @@ mod test {
status_test_helper, submit_test_helper,
};
use test_utils::reserve_tcp_port;
use tide_disco::{app::AppHealth, healthcheck::HealthStatus};
use tokio::time::sleep;
use vbs::version::StaticVersion;
use versions::{
Expand Down
2 changes: 1 addition & 1 deletion crates/espresso/node/src/api/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use hotshot_types::{
use indexmap::IndexMap;
use light_client::{state::LightClientOptions, storage::LightClientSqliteOptions};
use serde::{Deserialize, Serialize};
use tide_disco::Url;
use url::Url;

use super::{
AccountQueryData, BlocksFrontier, fs,
Expand Down
Loading
Loading