From 99129e3d2c799602fc5c72282a44f4dbd3021d49 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 31 Jul 2024 12:30:04 +0500 Subject: [PATCH 1/3] remove es_version crate --- Cargo.toml | 1 - builder/Cargo.toml | 1 - builder/src/bin/permissioned-builder.rs | 4 +-- builder/src/bin/permissionless-builder.rs | 7 ++-- builder/src/lib.rs | 18 ++++++---- builder/src/non_permissioned.rs | 12 +++---- builder/src/permissioned.rs | 13 +++---- hotshot-state-prover/Cargo.toml | 2 +- hotshot-state-prover/src/bin/state-prover.rs | 9 +++-- sequencer/Cargo.toml | 1 - sequencer/src/bin/commitment-task.rs | 28 ++++++++++----- sequencer/src/bin/espresso-bridge.rs | 8 +++-- sequencer/src/bin/espresso-dev-node.rs | 24 +++++++------ sequencer/src/bin/nasty-client.rs | 36 ++++++++++++-------- sequencer/src/bin/state-relay-server.rs | 6 ++-- sequencer/src/bin/submit-transactions.rs | 8 ++--- sequencer/src/bin/verify-headers.rs | 5 +-- sequencer/src/lib.rs | 7 ++-- sequencer/src/main.rs | 35 +++++++++++++------ types/Cargo.toml | 1 - types/src/v0/impls/header.rs | 11 +++--- types/src/v0/impls/instance_state.rs | 5 +++ 22 files changed, 147 insertions(+), 95 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ee1c4118e..99ba5bbb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,6 @@ blake3 = "1.5" clap = { version = "4.4", features = ["derive", "env", "string"] } cld = "0.5" derive_more = "0.99.17" -es-version = { git = "https://github.com/EspressoSystems/es-version.git", branch = "main" } dotenvy = "0.15" ethers = { version = "2.0", features = ["solc"] } futures = "0.3" diff --git a/builder/Cargo.toml b/builder/Cargo.toml index ccf463ed7..3acb054c2 100644 --- a/builder/Cargo.toml +++ b/builder/Cargo.toml @@ -20,7 +20,6 @@ clap = { workspace = true } cld = { workspace = true } committable = { workspace = true } dotenvy = { workspace = true } -es-version = { workspace = true } espresso-types = { path = "../types", features = ["testing"] } ethers = { workspace = true } futures = { workspace = true } diff --git a/builder/src/bin/permissioned-builder.rs b/builder/src/bin/permissioned-builder.rs index 093191730..cd938bfb5 100644 --- a/builder/src/bin/permissioned-builder.rs +++ b/builder/src/bin/permissioned-builder.rs @@ -5,7 +5,6 @@ use std::{ use anyhow::{bail, Context}; use builder::permissioned::init_node; use clap::Parser; -use es_version::SEQUENCER_VERSION; use espresso_types::eth_signature_key::EthKeyPair; use ethers::types::Address; use hotshot_types::{ @@ -20,6 +19,7 @@ use sequencer::{ }; use sequencer_utils::logging; use url::Url; +use vbs::version::{StaticVersion, StaticVersionType}; #[derive(Parser, Clone, Debug)] pub struct PermissionedBuilderOptions { @@ -260,7 +260,7 @@ async fn main() -> anyhow::Result<()> { catchup_backoff: Default::default(), }; - let sequencer_version = SEQUENCER_VERSION; + let sequencer_version = StaticVersion::<0, 1>::instance(); let builder_server_url: Url = format!("http://0.0.0.0:{}", opt.port).parse().unwrap(); diff --git a/builder/src/bin/permissionless-builder.rs b/builder/src/bin/permissionless-builder.rs index 45326662a..e3310aaa6 100644 --- a/builder/src/bin/permissionless-builder.rs +++ b/builder/src/bin/permissionless-builder.rs @@ -3,15 +3,14 @@ use std::{num::NonZeroUsize, path::PathBuf, str::FromStr, time::Duration}; use builder::non_permissioned::{build_instance_state, BuilderConfig}; use clap::Parser; use cld::ClDuration; -use espresso_types::{eth_signature_key::EthKeyPair, SeqTypes}; +use espresso_types::eth_signature_key::EthKeyPair; use hotshot::traits::ValidatedState; -use hotshot_builder_core::testing::basic_test::NodeType; use hotshot_types::{data::ViewNumber, traits::node_implementation::ConsensusTime}; use sequencer::{Genesis, L1Params}; use sequencer_utils::logging; use snafu::Snafu; use url::Url; -use vbs::version::StaticVersionType; +use vbs::version::{StaticVersion, StaticVersionType}; #[derive(Parser, Clone, Debug)] struct NonPermissionedBuilderOptions { @@ -123,7 +122,7 @@ async fn main() -> anyhow::Result<()> { genesis.chain_config, l1_params, opt.state_peers, - ::Base::instance(), + StaticVersion::<0, 1>::instance(), ) .unwrap(); diff --git a/builder/src/lib.rs b/builder/src/lib.rs index 310b07b10..6a64f41bb 100755 --- a/builder/src/lib.rs +++ b/builder/src/lib.rs @@ -68,7 +68,7 @@ use sequencer::{ L1Params, NetworkParams, Node, }; use tide_disco::{app, method::ReadState, App, Url}; -use vbs::version::StaticVersionType; +use vbs::version::{StaticVersion, StaticVersionType}; pub mod non_permissioned; pub mod permissioned; @@ -86,7 +86,7 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState) { let private_mempool_api = hotshot_builder_api::v0_1::builder::submit_api::< ProxyGlobalState, SeqTypes, - ::Base, + StaticVersion<0, 1>, >(&HotshotBuilderApiOptions::default()) .expect("Failed to construct the builder API for private mempool txns"); @@ -98,7 +98,7 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState) { app.register_module("txn_submit", private_mempool_api) .expect("Failed to register the private mempool API"); - async_spawn(app.serve(url, ::Base::instance())); + async_spawn(app.serve(url, StaticVersion::<0, 1>::instance())); } #[cfg(test)] @@ -118,6 +118,7 @@ pub mod testing { use async_lock::RwLock; use async_trait::async_trait; use committable::Committable; + use espresso_types::{ mock::MockStateCatchup, v0_3::ChainConfig, Event, FeeAccount, L1Client, NodeState, PrivKey, PubKey, Transaction, ValidatedState, @@ -406,6 +407,7 @@ pub mod testing { L1Client::new(self.anvil.endpoint().parse().unwrap(), 1), MockStateCatchup::default(), ) + .with_current_version(Ver::VERSION) .with_genesis(ValidatedState::default()); tracing::info!("Before init hotshot"); @@ -448,7 +450,7 @@ pub mod testing { let hotshot_events_api = hotshot_events_service::events::define_api::< Arc>>, SeqTypes, - ::Base, + StaticVersion<0, 1>, >(&EventStreamingApiOptions::default()) .expect("Failed to define hotshot eventsAPI"); @@ -457,7 +459,7 @@ pub mod testing { app.register_module("hotshot-events", hotshot_events_api) .expect("Failed to register hotshot events API"); - async_spawn(app.serve(url, ::Base::instance())); + async_spawn(app.serve(url, StaticVersion::<0, 1>::instance())); } // enable hotshot event streaming pub fn enable_hotshot_node_event_streaming( @@ -547,6 +549,7 @@ pub mod testing { ), MockStateCatchup::default(), ) + .with_current_version(StaticVersion::<0, 1>::VERSION) .with_genesis(ValidatedState::default()); // generate builder keys @@ -615,6 +618,7 @@ pub mod testing { ), MockStateCatchup::default(), ) + .with_current_version(Ver::VERSION) .with_genesis(ValidatedState::default()); // generate builder keys @@ -670,7 +674,6 @@ pub mod testing { mod test { use async_std::stream::IntoStream; use clap::builder; - use es_version::SequencerVersion; use espresso_types::{Header, NodeState, Payload, ValidatedState}; use ethers::providers::Quorum; use futures::StreamExt; @@ -686,6 +689,7 @@ mod test { }; use sequencer_utils::test_utils::setup_test; use testing::{wait_for_decide_on_handle, HotShotTestConfig}; + use vbs::version::StaticVersion; use super::*; @@ -697,7 +701,7 @@ mod test { async fn test_non_voting_hotshot_node() { setup_test(); - let ver = SequencerVersion::instance(); + let ver = StaticVersion::<0, 1>::instance(); let success_height = 5; // Assign `config` so it isn't dropped early. diff --git a/builder/src/non_permissioned.rs b/builder/src/non_permissioned.rs index d1c7d076e..27df0d68a 100644 --- a/builder/src/non_permissioned.rs +++ b/builder/src/non_permissioned.rs @@ -229,7 +229,6 @@ mod test { }; use async_lock::RwLock; use async_std::task; - use es_version::SequencerVersion; use espresso_types::{FeeAccount, NamespaceId, Transaction}; use hotshot_builder_api::v0_1::{ block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo}, @@ -257,6 +256,7 @@ mod test { use sequencer::persistence::no_storage::{self, NoStorage}; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; + use vbs::version::StaticVersion; use super::*; use crate::testing::{ @@ -270,7 +270,7 @@ mod test { async fn test_non_permissioned_builder() { setup_test(); - let ver = SequencerVersion::instance(); + let ver = StaticVersion::<0, 1>::instance(); // Hotshot Test Config let hotshot_config = HotShotTestConfig::default(); @@ -316,10 +316,10 @@ mod test { let builder_pub_key = builder_config.fee_account; // Start a builder api client - let builder_client = Client::< - hotshot_builder_api::v0_1::builder::Error, - ::Base, - >::new(hotshot_builder_api_url.clone()); + let builder_client = + Client::>::new( + hotshot_builder_api_url.clone(), + ); assert!(builder_client.connect(Some(Duration::from_secs(60))).await); let seed = [207_u8; 32]; diff --git a/builder/src/permissioned.rs b/builder/src/permissioned.rs index 520f45f33..7a6fe9ef0 100644 --- a/builder/src/permissioned.rs +++ b/builder/src/permissioned.rs @@ -553,7 +553,7 @@ mod test { use async_compatibility_layer::art::{async_sleep, async_spawn}; use async_lock::RwLock; use async_std::task; - use es_version::SequencerVersion; + use espresso_types::{FeeAccount, NamespaceId, Transaction}; use hotshot_builder_api::v0_1::{ block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo}, @@ -581,6 +581,7 @@ mod test { use sequencer::persistence::no_storage::{self, NoStorage}; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; + use vbs::version::StaticVersion; use super::*; use crate::{ @@ -595,7 +596,7 @@ mod test { async fn test_permissioned_builder() { setup_test(); - let ver = SequencerVersion::instance(); + let ver = StaticVersion::<0, 1>::instance(); // Hotshot Test Config let hotshot_config = HotShotTestConfig::default(); @@ -629,10 +630,10 @@ mod test { let builder_pub_key = builder_config.fee_account; // Start a builder api client - let builder_client = Client::< - hotshot_builder_api::v0_1::builder::Error, - ::Base, - >::new(hotshot_builder_api_url.clone()); + let builder_client = + Client::>::new( + hotshot_builder_api_url.clone(), + ); assert!(builder_client.connect(Some(Duration::from_secs(60))).await); let seed = [207_u8; 32]; diff --git a/hotshot-state-prover/Cargo.toml b/hotshot-state-prover/Cargo.toml index a8e97d6bb..e0d89ecb4 100644 --- a/hotshot-state-prover/Cargo.toml +++ b/hotshot-state-prover/Cargo.toml @@ -19,7 +19,7 @@ clap = { workspace = true } cld = { workspace = true } contract-bindings = { path = "../contract-bindings" } displaydoc = { version = "0.2.3", default-features = false } -es-version = { workspace = true } +espresso-types = { path = "../types", features = ["testing"] } ethers = { workspace = true } futures = { workspace = true } hotshot-contract-adapter = { workspace = true } diff --git a/hotshot-state-prover/src/bin/state-prover.rs b/hotshot-state-prover/src/bin/state-prover.rs index 39a122e67..30405cee4 100644 --- a/hotshot-state-prover/src/bin/state-prover.rs +++ b/hotshot-state-prover/src/bin/state-prover.rs @@ -2,7 +2,7 @@ use std::{str::FromStr as _, time::Duration}; use clap::Parser; use cld::ClDuration; -use es_version::SEQUENCER_VERSION; +use espresso_types::SeqTypes; use ethers::{ providers::{Http, Middleware, Provider}, signers::{coins_bip39::English, MnemonicBuilder, Signer}, @@ -10,9 +10,11 @@ use ethers::{ }; use hotshot_stake_table::config::STAKE_TABLE_CAPACITY; use hotshot_state_prover::service::{run_prover_once, run_prover_service, StateProverConfig}; +use hotshot_types::traits::node_implementation::NodeType; use sequencer_utils::logging; use snafu::Snafu; use url::Url; +use vbs::version::StaticVersionType; #[derive(Parser)] struct Args { @@ -126,12 +128,13 @@ async fn main() { if args.daemon { // Launching the prover service daemon - if let Err(err) = run_prover_service(config, SEQUENCER_VERSION).await { + if let Err(err) = run_prover_service(config, ::Base::instance()).await + { tracing::error!("Error running prover service: {:?}", err); }; } else { // Run light client state update once - if let Err(err) = run_prover_once(config, SEQUENCER_VERSION).await { + if let Err(err) = run_prover_once(config, ::Base::instance()).await { tracing::error!("Error running prover once: {:?}", err); }; } diff --git a/sequencer/Cargo.toml b/sequencer/Cargo.toml index 1a58df7ba..de4a9bda4 100644 --- a/sequencer/Cargo.toml +++ b/sequencer/Cargo.toml @@ -52,7 +52,6 @@ csv = "1" derivative = "2.2" derive_more = { workspace = true } dotenvy = { workspace = true } -es-version = { workspace = true } espresso-types = { path = "../types", features = ["testing"] } ethers = { workspace = true } futures = { workspace = true } diff --git a/sequencer/src/bin/commitment-task.rs b/sequencer/src/bin/commitment-task.rs index d93c7abc4..2eee0937b 100644 --- a/sequencer/src/bin/commitment-task.rs +++ b/sequencer/src/bin/commitment-task.rs @@ -2,9 +2,10 @@ use std::{io, time::Duration}; use async_std::task::spawn; use clap::Parser; -use es_version::SEQUENCER_VERSION; +use espresso_types::SeqTypes; use ethers::prelude::*; use futures::FutureExt; +use hotshot_types::traits::node_implementation::NodeType; use sequencer::{ hotshot_commitment::{run_hotshot_commitment_task, CommitmentTaskOptions}, options::parse_duration, @@ -68,7 +69,12 @@ async fn main() { opt.logging.init(); if let Some(port) = opt.port { - start_http_server(port, opt.hotshot_address, SEQUENCER_VERSION).unwrap(); + start_http_server( + port, + opt.hotshot_address, + ::Base::instance(), + ) + .unwrap(); } let hotshot_contract_options = CommitmentTaskOptions { @@ -82,7 +88,7 @@ async fn main() { query_service_url: Some(opt.sequencer_url), }; tracing::info!("Launching HotShot commitment task.."); - run_hotshot_commitment_task::(&hotshot_contract_options).await; + run_hotshot_commitment_task::<::Base>(&hotshot_contract_options).await; } fn start_http_server( @@ -111,10 +117,12 @@ fn start_http_server( #[cfg(test)] mod test { - use es_version::{SequencerVersion, SEQUENCER_VERSION}; + use espresso_types::SeqTypes; + use hotshot_types::traits::node_implementation::NodeType; use portpicker::pick_unused_port; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; + use vbs::version::StaticVersionType; use super::{start_http_server, Address, ServerError}; @@ -126,10 +134,14 @@ mod test { let expected_addr = "0xED15E1FE0789c524398137a066ceb2EF9884E5D8" .parse::
() .unwrap(); - start_http_server(port, expected_addr, SEQUENCER_VERSION) - .expect("Failed to start the server"); - - let client: Client = + start_http_server( + port, + expected_addr, + ::Base::instance(), + ) + .expect("Failed to start the server"); + + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; diff --git a/sequencer/src/bin/espresso-bridge.rs b/sequencer/src/bin/espresso-bridge.rs index 2e8fe0367..feea5b7b8 100644 --- a/sequencer/src/bin/espresso-bridge.rs +++ b/sequencer/src/bin/espresso-bridge.rs @@ -4,14 +4,16 @@ use anyhow::{bail, ensure, Context}; use async_std::{sync::Arc, task::sleep}; use clap::{Parser, Subcommand}; use contract_bindings::fee_contract::FeeContract; -use es_version::SequencerVersion; -use espresso_types::{eth_signature_key::EthKeyPair, FeeAccount, FeeAmount, FeeMerkleTree, Header}; +use espresso_types::{ + eth_signature_key::EthKeyPair, FeeAccount, FeeAmount, FeeMerkleTree, Header, SeqTypes, +}; use ethers::{ middleware::{Middleware, SignerMiddleware}, providers::Provider, types::{Address, BlockId, U256}, }; use futures::stream::StreamExt; +use hotshot_types::traits::node_implementation::NodeType; use jf_merkle_tree::{ prelude::{MerkleProof, Sha3Node}, MerkleTreeScheme, @@ -19,7 +21,7 @@ use jf_merkle_tree::{ use sequencer_utils::logging; use surf_disco::{error::ClientError, Url}; -type EspressoClient = surf_disco::Client; +type EspressoClient = surf_disco::Client::Base>; type FeeMerkleProof = MerkleProof; diff --git a/sequencer/src/bin/espresso-dev-node.rs b/sequencer/src/bin/espresso-dev-node.rs index b1cd46a39..fcbfc17db 100644 --- a/sequencer/src/bin/espresso-dev-node.rs +++ b/sequencer/src/bin/espresso-dev-node.rs @@ -3,7 +3,7 @@ use std::{io, sync::Arc, time::Duration}; use async_std::task::spawn; use clap::Parser; use contract_bindings::light_client_mock::LightClientMock; -use es_version::SEQUENCER_VERSION; +use espresso_types::SeqTypes; use ethers::{ middleware::{MiddlewareBuilder, SignerMiddleware}, providers::{Http, Middleware, Provider}, @@ -14,7 +14,10 @@ use futures::FutureExt; use hotshot_state_prover::service::{ one_honest_threshold, run_prover_service_with_stake_table, StateProverConfig, }; -use hotshot_types::traits::stake_table::{SnapshotVersion, StakeTableScheme}; +use hotshot_types::traits::{ + node_implementation::NodeType, + stake_table::{SnapshotVersion, StakeTableScheme}, +}; use portpicker::pick_unused_port; use sequencer::{ api::{ @@ -130,7 +133,7 @@ async fn main() -> anyhow::Result<()> { .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; let config = network.cfg.hotshot_config(); tracing::info!("Hotshot config {config:?}"); @@ -161,7 +164,7 @@ async fn main() -> anyhow::Result<()> { format!("http://0.0.0.0:{relay_server_port}") .parse() .unwrap(), - SEQUENCER_VERSION, + ::Base::instance(), )); let provider = Provider::::try_from(url.as_str()).unwrap(); @@ -197,7 +200,7 @@ async fn main() -> anyhow::Result<()> { spawn(run_prover_service_with_stake_table( config, - SEQUENCER_VERSION, + ::Base::instance(), Arc::new(st), )); @@ -215,7 +218,7 @@ async fn main() -> anyhow::Result<()> { cli_params.dev_node_port, mock_contract, dev_info, - SEQUENCER_VERSION, + ::Base::instance(), ) .await?; @@ -303,7 +306,6 @@ mod tests { use async_std::{stream::StreamExt, task::sleep}; use committable::{Commitment, Committable}; use contract_bindings::light_client::LightClient; - use es_version::SequencerVersion; use escargot::CargoBuild; use espresso_types::{BlockMerkleTree, Header, SeqTypes, Transaction}; use ethers::{ @@ -315,12 +317,14 @@ mod tests { availability::{BlockQueryData, TransactionQueryData, VidCommonQueryData}, data_source::sql::testing::TmpDb, }; + use hotshot_types::traits::node_implementation::NodeType; use jf_merkle_tree::MerkleTreeScheme; use portpicker::pick_unused_port; use sequencer::api::endpoints::NamespaceProofQueryData; use sequencer_utils::{init_signer, test_utils::setup_test, AnvilOptions}; use surf_disco::Client; use tide_disco::error::ServerError; + use vbs::version::StaticVersion; use crate::{DevInfo, SetHotshotUpBody}; @@ -380,7 +384,7 @@ mod tests { let _process = BackgroundProcess(process); - let api_client: Client = + let api_client: Client::Base> = Client::new(format!("http://localhost:{api_port}").parse().unwrap()); api_client.connect(None).await; @@ -395,7 +399,7 @@ mod tests { .await .unwrap(); - let builder_api_client: Client = + let builder_api_client: Client> = Client::new(format!("http://localhost:{builder_port}").parse().unwrap()); builder_api_client.connect(None).await; @@ -576,7 +580,7 @@ mod tests { } } - let dev_node_client: Client = + let dev_node_client: Client::Base> = Client::new(format!("http://localhost:{dev_node_port}").parse().unwrap()); dev_node_client.connect(None).await; diff --git a/sequencer/src/bin/nasty-client.rs b/sequencer/src/bin/nasty-client.rs index 26b15b98f..d4c87698b 100644 --- a/sequencer/src/bin/nasty-client.rs +++ b/sequencer/src/bin/nasty-client.rs @@ -12,15 +12,6 @@ //! provides a healthcheck endpoint as well as a prometheus endpoint which provides metrics like the //! count of various types of actions performed and the number of open streams. -use std::{ - borrow::Cow, - collections::{BTreeMap, HashMap}, - fmt::Debug, - pin::Pin, - sync::Arc, - time::{Duration, Instant}, -}; - use anyhow::{bail, ensure, Context}; use async_std::{ sync::RwLock, @@ -29,7 +20,6 @@ use async_std::{ use clap::Parser; use committable::Committable; use derivative::Derivative; -use es_version::{SequencerVersion, SEQUENCER_VERSION}; use espresso_types::{v0_3::IterableFeeInfo, BlockMerkleTree, FeeMerkleTree, Header, SeqTypes}; use futures::{ future::{FutureExt, TryFuture, TryFutureExt}, @@ -40,7 +30,10 @@ use hotshot_query_service::{ metrics::PrometheusMetrics, node::TimeWindowQueryData, }; -use hotshot_types::traits::metrics::{Counter, Gauge, Histogram, Metrics as _}; +use hotshot_types::traits::{ + metrics::{Counter, Gauge, Histogram, Metrics as _}, + node_implementation::NodeType, +}; use jf_merkle_tree::{ ForgetableMerkleTreeScheme, MerkleCommitment, MerkleTreeScheme, UniversalMerkleTreeScheme, }; @@ -48,12 +41,21 @@ use rand::{seq::SliceRandom, RngCore}; use sequencer::{api::endpoints::NamespaceProofQueryData, options::parse_duration}; use sequencer_utils::logging; use serde::de::DeserializeOwned; +use std::{ + borrow::Cow, + collections::{BTreeMap, HashMap}, + fmt::Debug, + pin::Pin, + sync::Arc, + time::{Duration, Instant}, +}; use strum::{EnumDiscriminants, VariantArray}; use surf_disco::{error::ClientError, socket, Error, StatusCode, Url}; use tide_disco::{error::ServerError, App}; use time::OffsetDateTime; use toml::toml; use tracing::info_span; +use vbs::version::StaticVersionType; /// An adversarial stress test for sequencer APIs. #[derive(Clone, Debug, Parser)] @@ -400,7 +402,8 @@ impl Queryable for PayloadQueryData { } } -type Connection = socket::Connection; +type Connection = + socket::Connection::Base>; #[derive(Derivative)] #[derivative(Debug)] @@ -413,7 +416,7 @@ struct Subscription { #[derive(Debug)] struct ResourceManager { - client: surf_disco::Client, + client: surf_disco::Client::Base>, open_streams: BTreeMap>, next_stream_id: u64, metrics: Arc, @@ -1258,14 +1261,17 @@ async fn serve(port: u16, metrics: PrometheusMetrics) { METHOD = "METRICS" }; let mut app = App::<_, ServerError>::with_state(RwLock::new(metrics)); - app.module::("status", api) + app.module::::Base>("status", api) .unwrap() .metrics("metrics", |_req, state| { async move { Ok(Cow::Borrowed(state)) }.boxed() }) .unwrap(); if let Err(err) = app - .serve(format!("0.0.0.0:{port}"), SEQUENCER_VERSION) + .serve( + format!("0.0.0.0:{port}"), + ::Base::instance(), + ) .await { tracing::error!("web server exited unexpectedly: {err:#}"); diff --git a/sequencer/src/bin/state-relay-server.rs b/sequencer/src/bin/state-relay-server.rs index 615e668f9..d5fa61c73 100644 --- a/sequencer/src/bin/state-relay-server.rs +++ b/sequencer/src/bin/state-relay-server.rs @@ -1,9 +1,11 @@ use clap::Parser; -use es_version::SEQUENCER_VERSION; +use espresso_types::SeqTypes; use ethers::types::U256; use hotshot_state_prover::service::one_honest_threshold; +use hotshot_types::traits::node_implementation::NodeType; use sequencer::state_signature::relay_server::run_relay_server; use sequencer_utils::logging; +use vbs::version::StaticVersionType; #[derive(Parser)] struct Args { @@ -45,7 +47,7 @@ async fn main() { None, threshold, format!("http://0.0.0.0:{}", args.port).parse().unwrap(), - SEQUENCER_VERSION, + ::Base::instance(), ) .await .unwrap(); diff --git a/sequencer/src/bin/submit-transactions.rs b/sequencer/src/bin/submit-transactions.rs index 183c5fe3d..2708149c1 100644 --- a/sequencer/src/bin/submit-transactions.rs +++ b/sequencer/src/bin/submit-transactions.rs @@ -8,7 +8,6 @@ use std::{ use async_std::task::{sleep, spawn}; use clap::Parser; use committable::{Commitment, Committable}; -use es_version::{SequencerVersion, SEQUENCER_VERSION}; use espresso_types::{SeqTypes, Transaction}; use futures::{ channel::mpsc::{self, Sender}, @@ -16,6 +15,7 @@ use futures::{ stream::StreamExt, }; use hotshot_query_service::{availability::BlockQueryData, types::HeightIndexed, Error}; +use hotshot_types::traits::node_implementation::NodeType; use rand::{Rng, RngCore, SeedableRng}; use rand_chacha::ChaChaRng; use rand_distr::Distribution; @@ -175,7 +175,7 @@ async fn main() { let mut rng = ChaChaRng::seed_from_u64(seed); // Subscribe to block stream so we can check that our transactions are getting sequenced. - let client = Client::::new(opt.url.clone()); + let client = Client::::Base>::new(opt.url.clone()); let block_height: usize = client.get("status/block-height").send().await.unwrap(); let mut blocks = client .socket(&format!("availability/stream/blocks/{}", block_height - 1)) @@ -190,13 +190,13 @@ async fn main() { opt.clone(), sender.clone(), ChaChaRng::from_rng(&mut rng).unwrap(), - SEQUENCER_VERSION, + ::Base::instance(), )); } // Start healthcheck endpoint once tasks are running. if let Some(port) = opt.port { - spawn(server(port, SEQUENCER_VERSION)); + spawn(server(port, ::Base::instance())); } // Keep track of the results. diff --git a/sequencer/src/bin/verify-headers.rs b/sequencer/src/bin/verify-headers.rs index fbaaaba41..98600a2a3 100644 --- a/sequencer/src/bin/verify-headers.rs +++ b/sequencer/src/bin/verify-headers.rs @@ -4,9 +4,10 @@ use std::{cmp::max, process::exit, time::Duration}; use async_std::{sync::Arc, task::sleep}; use clap::Parser; -use espresso_types::{Header, L1BlockInfo}; +use espresso_types::{Header, L1BlockInfo, SeqTypes}; use ethers::prelude::*; use futures::future::join_all; +use hotshot_types::traits::node_implementation::NodeType; use itertools::Itertools; use sequencer_utils::logging; use surf_disco::Url; @@ -169,7 +170,7 @@ async fn main() { let opt = Arc::new(Options::parse()); opt.logging.init(); - let seq = Arc::new(SequencerClient::::new( + let seq = Arc::new(SequencerClient::<::Base>::new( opt.url.clone(), )); diff --git a/sequencer/src/lib.rs b/sequencer/src/lib.rs index 1e78c9c8b..e930276a6 100644 --- a/sequencer/src/lib.rs +++ b/sequencer/src/lib.rs @@ -678,6 +678,7 @@ pub mod testing { L1Client::new(self.l1_url.clone(), 1000), catchup::local_and_remote(persistence_opt.clone(), catchup).await, ) + .with_current_version(Ver::version()) .with_genesis(state) .with_upgrades(upgrades); @@ -748,7 +749,7 @@ pub mod testing { #[cfg(test)] mod test { - use es_version::SequencerVersion; + use espresso_types::{Header, NamespaceId, Payload, Transaction}; use futures::StreamExt; use hotshot::types::EventType::Decide; @@ -767,7 +768,7 @@ mod test { #[async_std::test] async fn test_skeleton_instantiation() { setup_test(); - let ver = SequencerVersion::instance(); + let ver = ::Base::instance(); // Assign `config` so it isn't dropped early. let anvil = AnvilOptions::default().spawn().await; let url = anvil.url(); @@ -809,7 +810,7 @@ mod test { setup_test(); let success_height = 30; - let ver = SequencerVersion::instance(); + let ver = ::Base::instance(); // Assign `config` so it isn't dropped early. let anvil = AnvilOptions::default().spawn().await; let url = anvil.url(); diff --git a/sequencer/src/main.rs b/sequencer/src/main.rs index caf3be304..757e104ed 100644 --- a/sequencer/src/main.rs +++ b/sequencer/src/main.rs @@ -1,9 +1,9 @@ use std::net::ToSocketAddrs; use clap::Parser; -use es_version::SEQUENCER_VERSION; +use espresso_types::SeqTypes; use futures::future::FutureExt; -use hotshot_types::traits::metrics::NoMetrics; +use hotshot_types::traits::{metrics::NoMetrics, node_implementation::NodeType}; use sequencer::{ api::{self, data_source::DataSourceOptions}, init_node, @@ -21,16 +21,28 @@ async fn main() -> anyhow::Result<()> { tracing::warn!(?modules, "sequencer starting up"); if let Some(storage) = modules.storage_fs.take() { - init_with_storage(modules, opt, storage, SEQUENCER_VERSION).await + init_with_storage( + modules, + opt, + storage, + ::Base::instance(), + ) + .await } else if let Some(storage) = modules.storage_sql.take() { - init_with_storage(modules, opt, storage, SEQUENCER_VERSION).await + init_with_storage( + modules, + opt, + storage, + ::Base::instance(), + ) + .await } else { // Persistence is required. If none is provided, just use the local file system. init_with_storage( modules, opt, persistence::fs::Options::default(), - SEQUENCER_VERSION, + ::Base::instance(), ) .await } @@ -164,9 +176,12 @@ mod test { use std::time::Duration; use async_std::task::spawn; - use es_version::SequencerVersion; - use espresso_types::PubKey; - use hotshot_types::{light_client::StateKeyPair, traits::signature_key::SignatureKey}; + + use espresso_types::{PubKey, SeqTypes}; + use hotshot_types::{ + light_client::StateKeyPair, + traits::{node_implementation::NodeType, signature_key::SignatureKey}, + }; use portpicker::pick_unused_port; use sequencer::{ api::options::{Http, Status}, @@ -224,7 +239,7 @@ mod test { modules, opt, fs::Options::new(tmp.path().into()), - SEQUENCER_VERSION, + ::Base::instance(), ) .await { @@ -236,7 +251,7 @@ mod test { // orchestrator. tracing::info!("waiting for API to start"); let url: Url = format!("http://localhost:{port}").parse().unwrap(); - let client = Client::::new(url.clone()); + let client = Client::::Base>::new(url.clone()); assert!(client.connect(Some(Duration::from_secs(60))).await); client.get::<()>("healthcheck").send().await.unwrap(); diff --git a/types/Cargo.toml b/types/Cargo.toml index 0ac8d9131..806d8259a 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -23,7 +23,6 @@ cld = { workspace = true } committable = { workspace = true } contract-bindings = { path = "../contract-bindings" } derive_more = { workspace = true } -es-version = { workspace = true } ethers = { workspace = true } fluent-asserter = "0.1.9" futures = { workspace = true } diff --git a/types/src/v0/impls/header.rs b/types/src/v0/impls/header.rs index 1b1068b2e..070c7607e 100644 --- a/types/src/v0/impls/header.rs +++ b/types/src/v0/impls/header.rs @@ -1429,7 +1429,7 @@ mod test_headers { *parent_header.block_merkle_tree_root_mut() = block_merkle_tree_root; let mut proposal = parent_header.clone(); - let ver = StaticVersion::<1, 0>::version(); + let ver = StaticVersion::<0, 1>::version(); // Pass a different chain config to trigger a chain config validation error. let state = validated_state @@ -1508,8 +1508,9 @@ mod test_headers { setup_test(); let anvil = Anvil::new().block_time(1u32).spawn(); - let mut genesis_state = - NodeState::mock().with_l1(L1Client::new(anvil.endpoint().parse().unwrap(), 1)); + let mut genesis_state = NodeState::mock() + .with_l1(L1Client::new(anvil.endpoint().parse().unwrap(), 1)) + .with_current_version(StaticVersion::<0, 1>::version()); let genesis = GenesisForTest::default().await; let vid_common = vid_scheme(1).disperse([]).unwrap().common; @@ -1564,7 +1565,7 @@ mod test_headers { ns_table, builder_fee, vid_common.clone(), - ::Base::version(), + StaticVersion::<0, 1>::version(), ) .await .unwrap(); @@ -1586,7 +1587,7 @@ mod test_headers { &genesis_state, &parent_leaf, &proposal, - StaticVersion::<1, 0>::version(), + StaticVersion::<0, 1>::version(), ) .await .unwrap() diff --git a/types/src/v0/impls/instance_state.rs b/types/src/v0/impls/instance_state.rs index 89e78ddf6..65a658464 100644 --- a/types/src/v0/impls/instance_state.rs +++ b/types/src/v0/impls/instance_state.rs @@ -92,6 +92,11 @@ impl NodeState { self.upgrades = upgrades; self } + + pub fn with_current_version(mut self, ver: Version) -> Self { + self.current_version = ver; + self + } } // This allows us to turn on `Default` on InstanceState trait From 964117afd1f2451671d1590d3646c957ea6b11cb Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 31 Jul 2024 12:30:40 +0500 Subject: [PATCH 2/3] test all header versions in test_validate_builder_fee --- types/src/v0/impls/state.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/types/src/v0/impls/state.rs b/types/src/v0/impls/state.rs index 4596ae18c..76e64107c 100644 --- a/types/src/v0/impls/state.rs +++ b/types/src/v0/impls/state.rs @@ -10,6 +10,7 @@ use hotshot_types::{ }, vid::{VidCommon, VidSchemeType}, }; + use itertools::Itertools; use jf_merkle_tree::{ prelude::{MerkleProof, Sha3Digest, Sha3Node}, @@ -750,16 +751,15 @@ impl MerklizedState for FeeMerkleTree { mod test { use async_compatibility_layer::logging::{setup_backtrace, setup_logging}; use ethers::types::U256; - use hotshot_types::traits::{block_contents::BlockHeader, signature_key::BuilderSignatureKey}; - use hotshot_types::vid::vid_scheme; + use hotshot_types::{traits::signature_key::BuilderSignatureKey, vid::vid_scheme}; use jf_vid::VidScheme; use sequencer_utils::ser::FromStringOrInteger; use super::*; use crate::{ eth_signature_key::{BuilderSignature, EthKeyPair}, - v0_1, - v0_3::BidTx, + v0_1, v0_2, + v0_3::{self, BidTx}, BlockSize, FeeAccountProof, FeeMerkleProof, }; @@ -1048,7 +1048,16 @@ mod test { fee_info: FeeInfo::new(account, data), ..header }), - _ => unimplemented!(), + Header::V2(header) => Header::V2(v0_2::Header { + builder_signature: Some(sig), + fee_info: FeeInfo::new(account, data), + ..header + }), + Header::V3(header) => Header::V3(v0_3::Header { + builder_signature: vec![sig], + fee_info: vec![FeeInfo::new(account, data)], + ..header + }), }; validate_builder_fee(&header).unwrap(); @@ -1067,7 +1076,16 @@ mod test { fee_info: FeeInfo::new(account, data), ..header }), - _ => unimplemented!(), + Header::V2(header) => Header::V2(v0_2::Header { + builder_signature: Some(sig), + fee_info: FeeInfo::new(account, data), + ..header + }), + Header::V3(header) => Header::V3(v0_3::Header { + builder_signature: vec![sig], + fee_info: vec![FeeInfo::new(account, data)], + ..header + }), }; let sig: Vec = header.builder_signature(); From 852731f40532d985e7f76b54e7481221d55f7bde Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 31 Jul 2024 12:32:44 +0500 Subject: [PATCH 3/3] update TestNetwork to include Version generic param --- Cargo.lock | 13 ++-- sequencer/src/api.rs | 102 ++++++++++++++------------ sequencer/src/message_compat_tests.rs | 9 ++- 3 files changed, 65 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4a98898d..29cff4ef6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1303,7 +1303,6 @@ dependencies = [ "cld", "committable", "dotenvy", - "es-version", "espresso-types 0.1.0", "ethers", "futures", @@ -2020,7 +2019,7 @@ dependencies = [ [[package]] name = "contract-bindings" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "ethers", "serde", @@ -2928,7 +2927,6 @@ dependencies = [ "committable", "contract-bindings 0.1.0", "derive_more", - "es-version", "ethers", "fluent-asserter", "futures", @@ -2964,7 +2962,7 @@ dependencies = [ [[package]] name = "espresso-types" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "anyhow", "ark-serialize", @@ -4226,7 +4224,7 @@ dependencies = [ [[package]] name = "hotshot-contract-adapter" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "anyhow", "ark-bn254", @@ -4457,7 +4455,7 @@ dependencies = [ "cld", "contract-bindings 0.1.0", "displaydoc", - "es-version", + "espresso-types 0.1.0", "ethers", "futures", "hotshot-contract-adapter 0.1.0", @@ -8504,7 +8502,6 @@ dependencies = [ "derivative", "derive_more", "dotenvy", - "es-version", "escargot", "espresso-macros", "espresso-types 0.1.0", @@ -8586,7 +8583,7 @@ dependencies = [ [[package]] name = "sequencer-utils" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "anyhow", "ark-serialize", diff --git a/sequencer/src/api.rs b/sequencer/src/api.rs index a1ccafaa2..e31cfbb1d 100644 --- a/sequencer/src/api.rs +++ b/sequencer/src/api.rs @@ -360,7 +360,7 @@ pub mod test_helpers { use async_std::task::sleep; use committable::Committable; - use es_version::{SequencerVersion, SEQUENCER_VERSION}; + use espresso_types::{ mock::MockStateCatchup, v0::traits::{PersistenceOptions, StateCatchup}, @@ -373,6 +373,7 @@ pub mod test_helpers { }; use hotshot::types::{Event, EventType}; use hotshot_contract_adapter::light_client::ParsedLightClientState; + use hotshot_types::traits::node_implementation::NodeType; use hotshot_types::{ event::LeafInfo, traits::{metrics::NoMetrics, node_implementation::ConsensusTime}, @@ -392,9 +393,13 @@ pub mod test_helpers { pub const STAKE_TABLE_CAPACITY_FOR_TEST: u64 = 10; - pub struct TestNetwork { - pub server: SequencerContext, - pub peers: Vec>, + pub struct TestNetwork< + P: PersistenceOptions, + const NUM_NODES: usize, + Ver: StaticVersionType + 'static, + > { + pub server: SequencerContext, + pub peers: Vec>, pub cfg: TestConfig<{ NUM_NODES }>, } @@ -507,9 +512,12 @@ pub mod test_helpers { } } - impl TestNetwork { + impl + TestNetwork + { pub async fn new( cfg: TestNetworkConfig<{ NUM_NODES }, P, C>, + _bind_ver: Ver, ) -> Self { let mut cfg = cfg; let (builder_task, builder_url) = @@ -538,14 +546,14 @@ pub mod test_helpers { catchup, &*metrics, STAKE_TABLE_CAPACITY_FOR_TEST, - SEQUENCER_VERSION, + Ver::instance(), upgrades_map, ) .await } .boxed() }, - SEQUENCER_VERSION, + Ver::instance(), ) .await .unwrap() @@ -557,7 +565,7 @@ pub mod test_helpers { catchup, &NoMetrics, STAKE_TABLE_CAPACITY_FOR_TEST, - SEQUENCER_VERSION, + Ver::instance(), upgrades_map, ) .await @@ -612,7 +620,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port).status(Default::default())); let anvil = Anvil::new().spawn(); @@ -622,7 +630,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let _network = TestNetwork::new(config).await; + let _network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; // The status API is well tested in the query service repo. Here we are just smoke testing @@ -664,7 +672,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port).submit(Default::default())); let anvil = Anvil::new().spawn(); @@ -674,7 +682,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; let mut events = network.server.event_stream().await; client.connect(None).await; @@ -699,7 +707,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port)); let anvil = Anvil::new().spawn(); @@ -709,7 +717,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; let mut height: u64; // Wait for block >=2 appears @@ -741,7 +749,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port).catchup(Default::default())); let anvil = Anvil::new().spawn(); @@ -751,7 +759,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; // Wait for a few blocks to be decided. @@ -831,11 +839,12 @@ mod api_tests { use committable::Committable; use data_source::testing::TestableSequencerDataSource; use endpoints::NamespaceProofQueryData; - use es_version::SequencerVersion; + use espresso_types::{Header, NamespaceId}; use ethers::utils::Anvil; use futures::stream::StreamExt; use hotshot_query_service::availability::{LeafQueryData, VidCommonQueryData}; + use hotshot_types::traits::node_implementation::NodeType; use portpicker::pick_unused_port; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; @@ -885,11 +894,11 @@ mod api_tests { .api_config(D::options(&storage, Options::with_port(port)).submit(Default::default())) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; let mut events = network.server.event_stream().await; // Connect client. - let client: Client = + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; @@ -988,7 +997,7 @@ mod api_tests { events_service_port: hotshot_event_streaming_port, }; - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = Options::with_port(query_service_port).hotshot_events(hotshot_events); @@ -999,7 +1008,7 @@ mod api_tests { .api_config(options) .network_config(network_config) .build(); - let _network = TestNetwork::new(config).await; + let _network = TestNetwork::new(config, ::Base::instance()).await; let mut subscribed_events = client .socket("hotshot-events/events") @@ -1032,7 +1041,7 @@ mod test { use async_std::task::sleep; use committable::{Commitment, Committable}; - use es_version::{SequencerVersion, SEQUENCER_VERSION}; + use espresso_types::{ mock::MockStateCatchup, v0_1::{UpgradeMode, ViewBasedUpgrade}, @@ -1065,7 +1074,6 @@ mod test { TestNetwork, TestNetworkConfigBuilder, }; use tide_disco::{app::AppHealth, error::ServerError, healthcheck::HealthStatus}; - use vbs::version::Version; use self::{ data_source::{testing::TestableSequencerDataSource, PublicHotShotConfig}, @@ -1084,7 +1092,7 @@ mod test { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = Options::with_port(port); let anvil = Anvil::new().spawn(); let l1 = anvil.endpoint().parse().unwrap(); @@ -1093,7 +1101,7 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let _network = TestNetwork::new(config).await; + let _network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; let health = client.get::("healthcheck").send().await.unwrap(); @@ -1141,9 +1149,9 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); client.connect(None).await; @@ -1206,13 +1214,13 @@ mod test { .api_config(Options::with_port(port).catchup(Default::default())) .network_config(TestConfigBuilder::default().l1_url(l1).build()) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) })) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Wait for replica 0 to reach a (non-genesis) decide, before disconnecting it. let mut events = network.peers[0].event_stream().await; @@ -1250,13 +1258,13 @@ mod test { 1, ValidatedState::default(), no_storage::Options, - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ), &NoMetrics, test_helpers::STAKE_TABLE_CAPACITY_FOR_TEST, - SEQUENCER_VERSION, + ::Base::instance(), Default::default(), ) .await; @@ -1313,7 +1321,7 @@ mod test { .api_config(Options::with_port(port).catchup(Default::default())) .states(states) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1321,7 +1329,7 @@ mod test { .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Wait for few blocks to be decided. network @@ -1390,7 +1398,7 @@ mod test { ) .states(states) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1398,7 +1406,7 @@ mod test { .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Wait for a few blocks to be decided. network @@ -1463,7 +1471,7 @@ mod test { .status(Default::default()), ) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1476,7 +1484,7 @@ mod test { ) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; let mut events = network.server.event_stream().await; loop { @@ -1486,14 +1494,14 @@ mod test { EventType::UpgradeProposal { proposal, .. } => { let upgrade = proposal.data.upgrade_proposal; let new_version = upgrade.new_version; - assert_eq!(new_version, Version { major: 0, minor: 2 }); + assert_eq!(new_version, ::Upgrade::VERSION); break; } _ => continue, } } - let client: Client = + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1551,10 +1559,10 @@ mod test { .persistences(persistence) .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Connect client. - let client: Client = + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1621,15 +1629,15 @@ mod test { // Catchup using node 0 as a peer. Node 0 was running the archival state service // before the restart, so it should be able to resume without catching up by loading // state from storage. - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) })) .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let _network = TestNetwork::new(config).await; - let client: Client = + let _network = TestNetwork::new(config, ::Base::instance()).await; + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1670,7 +1678,7 @@ mod test { let port = pick_unused_port().expect("No ports free"); let url: surf_disco::Url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url.clone()); + let client: Client::Base> = Client::new(url.clone()); let options = Options::with_port(port).config(Default::default()); let anvil = Anvil::new().spawn(); @@ -1680,12 +1688,12 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; // Fetch a network config from the API server. The first peer URL is bogus, to test the // failure/retry case. - let peers = StatePeers::::from_urls( + let peers = StatePeers::<::Base>::from_urls( vec!["https://notarealnode.network".parse().unwrap(), url], Default::default(), ); diff --git a/sequencer/src/message_compat_tests.rs b/sequencer/src/message_compat_tests.rs index 1ddfe19a7..85cf2e54d 100644 --- a/sequencer/src/message_compat_tests.rs +++ b/sequencer/src/message_compat_tests.rs @@ -17,8 +17,7 @@ use std::path::Path; use committable::Committable; -use es_version::SequencerVersion; -use espresso_types::{Leaf, NodeState, PubKey, ValidatedState}; +use espresso_types::{Leaf, NodeState, PubKey, SeqTypes, ValidatedState}; use hotshot::traits::election::static_committee::GeneralStaticCommittee; use hotshot_types::{ data::{ @@ -39,7 +38,9 @@ use hotshot_types::{ ViewSyncFinalizeVote, ViewSyncPreCommitData, ViewSyncPreCommitVote, }, traits::{ - node_implementation::ConsensusTime, signature_key::SignatureKey, BlockPayload, EncodeBytes, + node_implementation::{ConsensusTime, NodeType}, + signature_key::SignatureKey, + BlockPayload, EncodeBytes, }, vid::vid_scheme, }; @@ -48,7 +49,7 @@ use pretty_assertions::assert_eq; use serde_json::Value; use vbs::{version::Version, BinarySerializer}; -type Serializer = vbs::Serializer; +type Serializer = vbs::Serializer<::Base>; #[async_std::test] #[cfg(feature = "testing")]