From 443f817cf0f03576a66c532cf051d26ec77e291d Mon Sep 17 00:00:00 2001 From: rob-maron <132852777+rob-maron@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:04:25 -0400 Subject: [PATCH] [WEEKLY RELEASE] HotShot - rc-0.5.71 (#1872) * bump HS * versions * update MP builder * update mp builder * fix MP builder test * bump HS * update MP builder core * Merge * correct builder timeout * update MP builder core * Fix marketplace test * update all tags * `seq` -> `sequencer` * format * rustsec * Fix the builder tests --------- Co-authored-by: Artemii Gerasimovich --- .cargo/audit.toml | 2 + Cargo.lock | 68 +++-- Cargo.toml | 24 +- builder/Cargo.toml | 1 + builder/src/lib.rs | 207 ++++++++++---- builder/src/non_permissioned.rs | 254 ++++++----------- builder/src/permissioned.rs | 257 ++++++------------ hotshot-state-prover/src/bin/state-prover.rs | 11 +- .../src/bin/marketplace-builder.rs | 9 +- marketplace-builder/src/builder.rs | 82 ++++-- marketplace-builder/src/hooks.rs | 8 +- marketplace-builder/src/lib.rs | 6 +- marketplace-solver/src/events.rs | 8 +- marketplace-solver/src/main.rs | 5 +- marketplace-solver/src/testing.rs | 37 +-- .../src/api/node_validator/v0/cdn/mod.rs | 56 ++-- node-metrics/src/lib.rs | 4 +- sequencer/src/api.rs | 123 ++++----- sequencer/src/bin/commitment-task.rs | 28 +- sequencer/src/bin/espresso-bridge.rs | 5 +- sequencer/src/bin/espresso-dev-node.rs | 26 +- sequencer/src/bin/nasty-client.rs | 21 +- sequencer/src/bin/state-relay-server.rs | 5 +- sequencer/src/bin/submit-transactions.rs | 12 +- sequencer/src/bin/verify-headers.rs | 6 +- sequencer/src/external_event_handler.rs | 10 +- sequencer/src/lib.rs | 24 +- sequencer/src/main.rs | 26 +- sequencer/src/message_compat_tests.rs | 8 +- types/src/v0/impls/auction.rs | 8 +- types/src/v0/impls/header.rs | 6 +- types/src/v0/impls/instance_state.rs | 5 +- types/src/v0/mod.rs | 14 +- 33 files changed, 607 insertions(+), 759 deletions(-) diff --git a/.cargo/audit.toml b/.cargo/audit.toml index 8e8db94f3..63d863895 100644 --- a/.cargo/audit.toml +++ b/.cargo/audit.toml @@ -11,4 +11,6 @@ ignore = [ "RUSTSEC-2023-0071", # rustls is busted, dependency of unmaintained tide "RUSTSEC-2024-0336", + # sqlx is only used for CDN tests. No newer version available yet + "RUSTSEC-2024-0363", ] diff --git a/Cargo.lock b/Cargo.lock index 30cb704ba..cb4f1055b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1325,6 +1325,7 @@ dependencies = [ "serde", "surf", "surf-disco", + "tempfile", "tide-disco", "tracing", "url", @@ -2430,6 +2431,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "delegate" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e018fccbeeb50ff26562ece792ed06659b9c2dae79ece77c4456bb10d9bf79b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + [[package]] name = "der" version = "0.7.9" @@ -4063,8 +4075,8 @@ dependencies = [ [[package]] name = "hotshot" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-broadcast", @@ -4111,7 +4123,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "async-trait", "clap", @@ -4130,7 +4142,7 @@ dependencies = [ [[package]] name = "hotshot-builder-core" version = "0.1.39" -source = "git+https://github.com/EspressoSystems/hotshot-builder-core?tag=0.1.41#9fdf32825ec363f5783648781b582bb35c319f2e" +source = "git+https://github.com/EspressoSystems/hotshot-builder-core?tag=0.1.42#31545442d5118e50d9f0fb2e451ecbd111fa74d0" dependencies = [ "anyhow", "async-broadcast", @@ -4138,6 +4150,7 @@ dependencies = [ "async-lock 2.8.0", "async-std", "async-trait", + "bincode", "clap", "committable", "derivative", @@ -4182,7 +4195,7 @@ dependencies = [ [[package]] name = "hotshot-events-service" version = "0.1.38" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.41#6812369e20eb2972851690f080a117cae0282a6f" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.42#9dbd231ee4492dd037a31d4b4f29cb721c6fd0e5" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4207,8 +4220,8 @@ dependencies = [ [[package]] name = "hotshot-example-types" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-broadcast", @@ -4240,8 +4253,8 @@ dependencies = [ [[package]] name = "hotshot-fakeapi" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-lock 2.8.0", @@ -4259,8 +4272,8 @@ dependencies = [ [[package]] name = "hotshot-macros" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "derive_builder", "proc-macro2", @@ -4270,8 +4283,8 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4301,7 +4314,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=0.1.52#432444e27f2883d69f3563964b7ff01b09d31df6" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=0.1.53#316258fdcd8c495bd4cba41cde9c7c84abeb9de2" dependencies = [ "anyhow", "ark-serialize", @@ -4356,8 +4369,8 @@ dependencies = [ [[package]] name = "hotshot-stake-table" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "ark-bn254", "ark-ed-on-bn254", @@ -4421,8 +4434,8 @@ dependencies = [ [[package]] name = "hotshot-task" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-broadcast", @@ -4436,8 +4449,8 @@ dependencies = [ [[package]] name = "hotshot-task-impls" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-broadcast", @@ -4473,8 +4486,8 @@ dependencies = [ [[package]] name = "hotshot-testing" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-broadcast", @@ -4520,7 +4533,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "ark-bn254", @@ -4553,11 +4566,13 @@ dependencies = [ "jf-utils", "jf-vid", "lazy_static", + "libp2p", "memoize", "rand 0.8.5", "rand_chacha 0.3.1", "reqwest 0.12.5", "serde", + "serde_bytes", "sha2 0.10.8", "snafu 0.8.4", "tagged-base64", @@ -5885,8 +5900,8 @@ dependencies = [ [[package]] name = "libp2p-networking" -version = "0.5.69" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.70#3e38cdf852816d73a3b4ffc58c5ccd3a0c6e8028" +version = "0.5.71" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.71#4058349be9bd021f8e78f4e1b71327ee61c588de" dependencies = [ "anyhow", "async-compatibility-layer", @@ -5896,6 +5911,7 @@ dependencies = [ "bincode", "blake3", "custom_debug 0.5.1", + "delegate", "derive_builder", "either", "futures", @@ -6304,7 +6320,7 @@ dependencies = [ [[package]] name = "marketplace-builder-core" version = "0.0.2" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?tag=0.0.5#0135f166dc007776a41aecc6d68de1dd6859136d" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?tag=0.0.6#d6cd8aac934580b897856951aa4c249040ea222d" dependencies = [ "anyhow", "async-broadcast", diff --git a/Cargo.toml b/Cargo.toml index bbf16820a..70a4cccd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,22 +52,22 @@ dotenvy = "0.15" ethers = { version = "2.0", features = ["solc"] } futures = "0.3" -hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.70" } +hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.71" } # Hotshot imports -hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.70" } -hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.41" } -marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.0.5" } -hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.41" } -hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.70" } -hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.52" } -hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.70" } +hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.71" } +hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.42" } +marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.0.6" } +hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.42" } +hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.71" } +hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.53" } +hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.71" } hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" } -hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.70" } -hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.70" } -hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.70" } +hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.71" } +hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.71" } +hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.71" } hotshot-contract-adapter = { version = "0.1.0", path = "contracts/rust/adapter" } # Temporary, used to pull in the mock auction results provider -hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.70" } +hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.71" } # Push CDN imports cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [ diff --git a/builder/Cargo.toml b/builder/Cargo.toml index 38d81e3ce..b71599636 100644 --- a/builder/Cargo.toml +++ b/builder/Cargo.toml @@ -50,3 +50,4 @@ vec1 = { workspace = true } [dev-dependencies] sequencer = { path = "../sequencer", features = ["testing"] } +tempfile = "3.10.1" diff --git a/builder/src/lib.rs b/builder/src/lib.rs index 8d2b9bee2..810928d2a 100755 --- a/builder/src/lib.rs +++ b/builder/src/lib.rs @@ -104,7 +104,11 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState) { #[cfg(test)] pub mod testing { use core::num; - use std::{collections::HashSet, num::NonZeroUsize, time::Duration}; + use std::{ + collections::HashSet, + num::NonZeroUsize, + time::{Duration, Instant}, + }; //use sequencer::persistence::NoStorage; use async_broadcast::{ @@ -120,8 +124,8 @@ pub mod testing { use committable::Committable; use espresso_types::{ - mock::MockStateCatchup, v0_3::ChainConfig, Event, FeeAccount, L1Client, NodeState, PrivKey, - PubKey, SequencerVersions, Transaction, ValidatedState, + mock::MockStateCatchup, v0_3::ChainConfig, Event, FeeAccount, L1Client, NamespaceId, + NodeState, PrivKey, PubKey, Transaction, ValidatedState, }; use ethers::{ types::spoof::State, @@ -136,10 +140,16 @@ pub mod testing { implementations::{MasterMap, MemoryNetwork}, BlockPayload, }, - types::{EventType::Decide, Message}, + types::{ + EventType::{self, Decide}, + Message, + }, }; - use hotshot_builder_api::v0_1::builder::{ - BuildError, Error as BuilderApiError, Options as HotshotBuilderApiOptions, + use hotshot_builder_api::{ + v0_1::builder::{ + BuildError, Error as BuilderApiError, Options as HotshotBuilderApiOptions, + }, + v0_2::block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo}, }; use hotshot_builder_core::{ builder_state::{BuildBlockInfo, BuilderState, MessageType, ResponseMessage}, @@ -163,8 +173,9 @@ pub mod testing { ExecutionType, HotShotConfig, PeerConfig, ValidatorConfig, }; use portpicker::pick_unused_port; - use sequencer::state_signature::StateSignatureMemStorage; + use sequencer::{state_signature::StateSignatureMemStorage, testing::TestConfig}; use serde::{Deserialize, Serialize}; + use surf_disco::Client; use vbs::version::StaticVersion; use super::*; @@ -338,10 +349,7 @@ pub mod testing { &self, bind_version: Ver, options: impl PersistenceOptions, - ) -> Vec<( - Arc, SequencerVersions>>, - Option>, - )> { + ) -> Vec<(Arc>, Option>)> { let num_staked_nodes = self.num_staked_nodes(); let mut is_staked = false; let stake_table_commit = static_stake_table_commitment( @@ -379,10 +387,7 @@ pub mod testing { metrics: &dyn Metrics, bind_version: Ver, persistence: P, - ) -> ( - SystemContextHandle, SequencerVersions>, - StateSigner, - ) { + ) -> (Consensus, StateSigner) { let mut config = self.config.clone(); let num_staked_nodes = self.num_staked_nodes(); @@ -465,9 +470,7 @@ pub mod testing { hotshot_events_api_url: Url, known_nodes_with_stake: Vec>, num_non_staking_nodes: usize, - hotshot_context_handle: Arc< - SystemContextHandle, SequencerVersions>, - >, + hotshot_context_handle: Arc>, ) { // create a event streamer let events_streamer = Arc::new(RwLock::new(EventsStreamer::new( @@ -536,23 +539,10 @@ pub mod testing { pub const SUBSCRIBED_DA_NODE_ID: usize = 5; pub async fn init_non_permissioned_builder( - hotshot_test_config: &HotShotTestConfig, hotshot_events_streaming_api_url: Url, hotshot_builder_api_url: Url, + num_nodes: usize, ) -> Self { - // setup the instance state - let node_state = NodeState::new( - u64::MAX, - ChainConfig::default(), - L1Client::new( - hotshot_test_config.get_anvil().endpoint().parse().unwrap(), - 1, - ), - MockStateCatchup::default(), - ) - .with_current_version(StaticVersion::<0, 1>::VERSION) - .with_genesis(ValidatedState::default()); - // generate builder keys let seed = [201_u8; 32]; let (fee_account, key_pair) = FeeAccount::generated_from_seed_indexed(seed, 2011_u64); @@ -564,7 +554,7 @@ pub mod testing { // A new builder can use this view number to start building blocks from this view number let bootstrapped_view = ViewNumber::new(0); - let node_count = NonZeroUsize::new(HotShotTestConfig::total_nodes()).unwrap(); + let node_count = NonZeroUsize::new(num_nodes).unwrap(); let builder_config = BuilderConfig::init( key_pair, @@ -572,7 +562,7 @@ pub mod testing { tx_channel_capacity, event_channel_capacity, node_count, - node_state, + NodeState::default(), ValidatedState::default(), hotshot_events_streaming_api_url, hotshot_builder_api_url, @@ -603,26 +593,13 @@ pub mod testing { PermissionedBuilderTestConfig { pub async fn init_permissioned_builder( - hotshot_test_config: HotShotTestConfig, - hotshot_handle: Arc< - SystemContextHandle, SequencerVersions>, - >, + hotshot_handle: Arc>, node_id: u64, - state_signer: StateSigner, + state_signer: Arc>, hotshot_builder_api_url: Url, ) -> Self { // setup the instance state - let node_state = NodeState::new( - node_id, - ChainConfig::default(), - L1Client::new( - hotshot_test_config.get_anvil().endpoint().parse().unwrap(), - 1, - ), - MockStateCatchup::default(), - ) - .with_current_version(Ver::VERSION) - .with_genesis(ValidatedState::default()); + let node_state = NodeState::default(); // generate builder keys let seed = [201_u8; 32]; @@ -671,6 +648,136 @@ pub mod testing { hotshot_builder_api_url } + + pub async fn test_builder_impl( + hotshot_builder_api_url: Url, + mut subscribed_events: impl Stream + Unpin, + builder_pub_key: FeeAccount, + ) { + // Start a builder api client + let builder_client = + Client::>::new( + hotshot_builder_api_url.clone(), + ); + assert!(builder_client.connect(Some(Duration::from_secs(60))).await); + + // Test submitting transactions + let txn = Transaction::new(NamespaceId::from(1_u32), vec![1, 2, 3]); + match builder_client + .post::<()>("txn_submit/submit") + .body_json(&txn) + .unwrap() + .send() + .await + { + Ok(response) => { + tracing::info!("Received txn submitted response : {:?}", response); + } + Err(e) => { + panic!("Error submitting private transaction {:?}", e); + } + } + + let seed = [207_u8; 32]; + + // Hotshot client Public, Private key + let (hotshot_client_pub_key, hotshot_client_private_key) = + ::generated_from_seed_indexed(seed, 2011_u64); + + let start = Instant::now(); + let (available_block_info, view_num) = loop { + if start.elapsed() > Duration::from_secs(10) { + panic!("Didn't get a quorum proposal in 10 seconds"); + } + + let event = subscribed_events.next().await.unwrap(); + tracing::warn!("Event: {:?}", event.event); + if let EventType::QuorumProposal { proposal, .. } = event.event { + let parent_view_number = *proposal.data.view_number; + let parent_commitment = + Leaf::from_quorum_proposal(&proposal.data).payload_commitment(); + let encoded_signature = ::SignatureKey::sign( + &hotshot_client_private_key, + parent_commitment.as_ref(), + ) + .expect("Claim block signing failed"); + let available_blocks = builder_client + .get::>>(&format!( + "block_info/availableblocks/{parent_commitment}/{parent_view_number}/{hotshot_client_pub_key}/{encoded_signature}" + )) + .send() + .await.expect("Error getting available blocks"); + assert!(!available_blocks.is_empty()); + break (available_blocks, parent_view_number); + } + }; + + let builder_commitment = available_block_info[0].block_hash.clone(); + + // sign the builder_commitment using the client_private_key + let encoded_signature = ::SignatureKey::sign( + &hotshot_client_private_key, + builder_commitment.as_ref(), + ) + .expect("Claim block signing failed"); + + // Test claiming blocks + let available_block_data = match builder_client + .get::>(&format!( + "block_info/claimblock/{builder_commitment}/{view_num}/{hotshot_client_pub_key}/{encoded_signature}" + )) + .send() + .await + { + Ok(response) => { + tracing::info!("Received Block Data: {:?}", response); + response + } + Err(e) => { + panic!("Error while claiming block {:?}", e); + } + }; + + assert_eq!( + available_block_data + .block_payload + .transactions(&available_block_data.metadata) + .collect::>(), + vec![txn] + ); + + // Test claiming block header input + let _available_block_header = match builder_client + .get::>(&format!( + "block_info/claimheaderinput/{builder_commitment}/{view_num}/{hotshot_client_pub_key}/{encoded_signature}" + )) + .send() + .await + { + Ok(response) => { + tracing::info!("Received Block Header : {:?}", response); + response + } + Err(e) => { + panic!("Error getting claiming block header {:?}", e); + } + }; + + // test getting builder key + match builder_client + .get::("block_info/builderaddress") + .send() + .await + { + Ok(response) => { + tracing::info!("Received Builder Key : {:?}", response); + assert_eq!(response, builder_pub_key); + } + Err(e) => { + panic!("Error getting builder key {:?}", e); + } + } + } } #[cfg(test)] diff --git a/builder/src/non_permissioned.rs b/builder/src/non_permissioned.rs index dd273e64b..15d77c458 100644 --- a/builder/src/non_permissioned.rs +++ b/builder/src/non_permissioned.rs @@ -1,4 +1,4 @@ -use std::{num::NonZeroUsize, time::Duration}; +use std::{collections::VecDeque, num::NonZeroUsize, time::Duration}; use anyhow::Context; use async_broadcast::{ @@ -164,7 +164,7 @@ impl BuilderConfig { qc_receiver, req_receiver, tx_receiver, - Vec::new() /* tx_queue */, + VecDeque::new() /* tx_queue */, global_state_clone, node_count, maximize_txns_count_timeout_duration, @@ -193,20 +193,17 @@ impl BuilderConfig { // spawn the builder service let events_url = hotshot_events_api_url.clone(); + let global_state_clone = global_state.clone(); tracing::info!("Running permissionless builder against hotshot events API at {events_url}",); async_spawn(async move { - // TODO this is proabably a mistake in builder-core. These - // generic params can be removed and the concrete types - // used instead. - let res = - run_non_permissioned_standalone_builder_service::( - da_sender, - qc_sender, - decide_sender, - tx_sender, - events_url, - ) - .await; + let res = run_non_permissioned_standalone_builder_service::<_, SequencerVersions>( + da_sender, + qc_sender, + decide_sender, + events_url, + global_state_clone, + ) + .await; tracing::error!(?res, "builder service exited"); if res.is_err() { panic!("Builder should restart."); @@ -224,15 +221,18 @@ impl BuilderConfig { #[cfg(test)] mod test { - use std::time::Duration; + use std::time::{Duration, Instant}; use async_compatibility_layer::{ art::{async_sleep, async_spawn}, logging::{setup_backtrace, setup_logging}, }; use async_lock::RwLock; - use async_std::task; - use espresso_types::{FeeAccount, NamespaceId, Transaction}; + use async_std::{stream::StreamExt, task}; + use espresso_types::{BaseVersion, Event, FeeAccount, NamespaceId, Transaction}; + use ethers::utils::Anvil; + use futures::Stream; + use hotshot::types::EventType; use hotshot_builder_api::v0_1::{ block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo}, builder::BuildError, @@ -253,14 +253,27 @@ mod test { signature_key::SignatureKey, }, }; - use sequencer::persistence::no_storage::{self, NoStorage}; + use portpicker::pick_unused_port; + use sequencer::{ + api::{ + options::HotshotEvents, + test_helpers::{TestNetwork, TestNetworkConfigBuilder}, + Options, + }, + persistence::{ + self, + no_storage::{self, NoStorage}, + }, + testing::TestConfigBuilder, + }; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; + use tempfile::TempDir; use vbs::version::StaticVersion; use super::*; use crate::testing::{ - hotshot_builder_url, HotShotTestConfig, NonPermissionedBuilderTestConfig, + hotshot_builder_url, test_builder_impl, HotShotTestConfig, NonPermissionedBuilderTestConfig, }; /// Test the non-permissioned builder core @@ -270,169 +283,62 @@ mod test { async fn test_non_permissioned_builder() { setup_test(); - let ver = StaticVersion::<0, 1>::instance(); - // Hotshot Test Config - let hotshot_config = HotShotTestConfig::default(); - - // Get the handle for all the nodes, including both the non-builder and builder nodes - let handles = hotshot_config.init_nodes(ver, no_storage::Options).await; - - // start consensus for all the nodes - for (handle, ..) in handles.iter() { - handle.hotshot.start_consensus().await; - } - - // get the required stuff for the election config - let known_nodes_with_stake = hotshot_config.config.known_nodes_with_stake.clone(); - - // get count of non-staking nodes - let num_non_staking_nodes = hotshot_config.config.num_nodes_without_stake; - - // non-staking node handle - let hotshot_context_handle = - &handles[NonPermissionedBuilderTestConfig::SUBSCRIBED_DA_NODE_ID].0; - - // hotshot event streaming api url - let hotshot_events_streaming_api_url = HotShotTestConfig::hotshot_event_streaming_api_url(); - - // enable a hotshot node event streaming - HotShotTestConfig::enable_hotshot_node_event_streaming::( - hotshot_events_streaming_api_url.clone(), - known_nodes_with_stake, - num_non_staking_nodes, - Arc::clone(hotshot_context_handle), - ); - - // builder api url - let hotshot_builder_api_url = hotshot_config.config.builder_urls[0].clone(); + let query_port = pick_unused_port().expect("No ports free"); + + let event_port = pick_unused_port().expect("No ports free"); + let event_service_url: Url = format!("http://localhost:{event_port}").parse().unwrap(); + + let builder_port = pick_unused_port().expect("No ports free"); + let builder_api_url: Url = format!("http://localhost:{builder_port}").parse().unwrap(); + + // Set up and start the network + let anvil = Anvil::new().spawn(); + let l1 = anvil.endpoint().parse().unwrap(); + let network_config = TestConfigBuilder::default().l1_url(l1).build(); + + let tmpdir = TempDir::new().unwrap(); + + let config = TestNetworkConfigBuilder::default() + .api_config( + Options::with_port(query_port) + .submit(Default::default()) + .query_fs( + Default::default(), + persistence::fs::Options::new(tmpdir.path().to_owned()), + ) + .hotshot_events(HotshotEvents { + events_service_port: event_port, + }), + ) + .network_config(network_config) + .build(); + let network = TestNetwork::new(config, BaseVersion::instance()).await; let builder_config = NonPermissionedBuilderTestConfig::init_non_permissioned_builder( - &hotshot_config, - hotshot_events_streaming_api_url.clone(), - hotshot_builder_api_url.clone(), + event_service_url.clone(), + builder_api_url.clone(), + network.cfg.num_nodes(), ) .await; - let builder_pub_key = builder_config.fee_account; - - // Start a builder api client - 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]; + let events_service_client = Client::< + hotshot_events_service::events::Error, + StaticVersion<0, 1>, + >::new(event_service_url.clone()); + events_service_client.connect(None).await; - // Hotshot client Public, Private key - let (hotshot_client_pub_key, hotshot_client_private_key) = - BLSPubKey::generated_from_seed_indexed(seed, 2011_u64); - - let parent_commitment = vid_commitment(&[], GENESIS_VID_NUM_STORAGE_NODES); - - // sign the parent_commitment using the client_private_key - let encoded_signature = ::SignatureKey::sign( - &hotshot_client_private_key, - parent_commitment.as_ref(), - ) - .expect("Claim block signing failed"); - - // sleep and wait for builder service to startup - async_sleep(Duration::from_millis(500)).await; - - let test_view_num = 0; - - // test getting available blocks - let available_block_info = match builder_client - .get::>>(&format!( - "block_info/availableblocks/{parent_commitment}/{test_view_num}/{hotshot_client_pub_key}/{encoded_signature}" - )) - .send() + let subscribed_events = events_service_client + .socket("hotshot-events/events") + .subscribe::>() .await - { - Ok(response) => { - tracing::info!("Received Available Blocks: {:?}", response); - assert!(!response.is_empty()); - response - } - Err(e) => { - panic!("Error getting available blocks {:?}", e); - } - }; - - let builder_commitment = available_block_info[0].block_hash.clone(); + .unwrap() + .map(|item| item.expect("Failed to get event from event service")); - // sign the builder_commitment using the client_private_key - let encoded_signature = ::SignatureKey::sign( - &hotshot_client_private_key, - builder_commitment.as_ref(), + test_builder_impl( + builder_api_url, + subscribed_events, + builder_config.fee_account, ) - .expect("Claim block signing failed"); - - // Test claiming blocks - let _available_block_data = match builder_client - .get::>(&format!( - "block_info/claimblock/{builder_commitment}/{test_view_num}/{hotshot_client_pub_key}/{encoded_signature}" - )) - .send() - .await - { - Ok(response) => { - tracing::info!("Received Block Data: {:?}", response); - response - } - Err(e) => { - panic!("Error while claiming block {:?}", e); - } - }; - - // Test claiming block header input - let _available_block_header = match builder_client - .get::>(&format!( - "block_info/claimheaderinput/{builder_commitment}/{test_view_num}/{hotshot_client_pub_key}/{encoded_signature}" - )) - .send() - .await - { - Ok(response) => { - tracing::info!("Received Block Header : {:?}", response); - response - } - Err(e) => { - panic!("Error getting claiming block header {:?}", e); - } - }; - - // test getting builder key - match builder_client - .get::("block_info/builderaddress") - .send() - .await - { - Ok(response) => { - tracing::info!("Received Builder Key : {:?}", response); - assert_eq!(response, builder_pub_key); - } - Err(e) => { - panic!("Error getting builder key {:?}", e); - } - } - - let txn = Transaction::new(NamespaceId::from(1_u32), vec![1, 2, 3]); - match builder_client - .post::<()>("txn_submit/submit") - .body_json(&txn) - .unwrap() - .send() - .await - { - Ok(response) => { - tracing::info!("Received txn submitted response : {:?}", response); - return; - } - Err(e) => { - panic!("Error submitting private transaction {:?}", e); - } - } + .await; } } diff --git a/builder/src/permissioned.rs b/builder/src/permissioned.rs index 05fce1488..76048a2b7 100644 --- a/builder/src/permissioned.rs +++ b/builder/src/permissioned.rs @@ -1,6 +1,7 @@ use std::{ alloc::System, any, + collections::VecDeque, fmt::{Debug, Display}, marker::PhantomData, mem, @@ -26,8 +27,8 @@ use async_std::{ use espresso_types::{ eth_signature_key::EthKeyPair, v0::traits::{PersistenceOptions, SequencerPersistence, StateCatchup}, - FeeAmount, L1Client, NodeState, Payload, PubKey, SeqTypes, SequencerVersions, - SolverAuctionResultsProvider, ValidatedState, + FeeAmount, L1Client, NodeState, Payload, PubKey, SeqTypes, SolverAuctionResultsProvider, + ValidatedState, }; use ethers::{ core::k256::ecdsa::SigningKey, @@ -302,7 +303,7 @@ pub async fn init_node ( - SystemContextHandle, SequencerVersions>, - StateSigner, -) { +) -> (Consensus, StateSigner) { let combined_known_nodes_with_stake = match stake_table_entries_for_non_voting_nodes { Some(stake_table_entries) => { let combined_entries = config @@ -416,7 +414,7 @@ impl, P: SequencerPersistence, Ver: StaticVersionTyp #[allow(clippy::too_many_arguments)] pub async fn init( hotshot_handle: Arc>, - state_signer: StateSigner, + state_signer: Arc>, node_index: u64, eth_key_pair: EthKeyPair, bootstrapped_view: ViewNumber, @@ -490,7 +488,7 @@ impl, P: SequencerPersistence, Ver: StaticVersionTyp qc_receiver, req_receiver, tx_receiver, - Vec::new() /* tx_queue */, + VecDeque::new() /* tx_queue */, global_state_clone, NonZeroUsize::new(1).unwrap(), maximize_txns_count_timeout_duration, @@ -503,14 +501,15 @@ impl, P: SequencerPersistence, Ver: StaticVersionTyp ); let hotshot_handle_clone = Arc::clone(&hotshot_handle); + let global_state_clone = global_state.clone(); // spawn the builder service async_spawn(async move { run_permissioned_standalone_builder_service( - tx_sender, da_sender, qc_sender, decide_sender, hotshot_handle_clone, + global_state_clone, ) .await; }); @@ -533,7 +532,7 @@ impl, P: SequencerPersistence, Ver: StaticVersionTyp let ctx = Self { hotshot_handle: Arc::clone(&hotshot_handle), node_index, - state_signer: Arc::new(state_signer), + state_signer, wait_for_orchestrator: None, global_state, hotshot_builder_api_url, @@ -562,7 +561,8 @@ mod test { use async_lock::RwLock; use async_std::task; - use espresso_types::{FeeAccount, NamespaceId, Transaction}; + use espresso_types::{BaseVersion, FeeAccount, NamespaceId, Transaction}; + use ethers::utils::Anvil; use hotshot_builder_api::v0_1::{ block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo}, builder::BuildError, @@ -583,176 +583,87 @@ mod test { signature_key::SignatureKey, }, }; - use sequencer::persistence::no_storage::{self, NoStorage}; + use portpicker::pick_unused_port; + use sequencer::{ + api::{ + options::HotshotEvents, + test_helpers::{TestNetwork, TestNetworkConfigBuilder}, + Options, + }, + persistence::{ + self, + no_storage::{self, NoStorage}, + }, + testing::TestConfigBuilder, + }; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; + use tempfile::TempDir; use vbs::version::StaticVersion; use super::*; use crate::{ non_permissioned, testing::{ - hotshot_builder_url, HotShotTestConfig, NonPermissionedBuilderTestConfig, - PermissionedBuilderTestConfig, + hotshot_builder_url, test_builder_impl, HotShotTestConfig, + NonPermissionedBuilderTestConfig, PermissionedBuilderTestConfig, }, }; - #[async_std::test] - async fn test_permissioned_builder() { - setup_test(); - - let ver = StaticVersion::<0, 1>::instance(); - - // Hotshot Test Config - let hotshot_config = HotShotTestConfig::default(); - - // Get the handle for all the nodes, including both the non-builder and builder nodes - let mut handles = hotshot_config.init_nodes(ver, no_storage::Options).await; - - // start consensus for all the nodes - for (handle, ..) in handles.iter() { - handle.hotshot.start_consensus().await; - } - - let total_nodes = HotShotTestConfig::total_nodes(); - - let node_id = total_nodes - 1; - // non-staking node handle - let hotshot_context_handle = Arc::clone(&handles[node_id].0); - let state_signer = handles[node_id].1.take().unwrap(); - - // builder api url - let hotshot_builder_api_url = hotshot_config.config.builder_urls[0].clone(); - let builder_config = PermissionedBuilderTestConfig::init_permissioned_builder( - hotshot_config, - hotshot_context_handle, - node_id as u64, - state_signer, - hotshot_builder_api_url.clone(), - ) - .await; - - let builder_pub_key = builder_config.fee_account; - - // Start a builder api client - 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]; - - // Hotshot client Public, Private key - let (hotshot_client_pub_key, hotshot_client_private_key) = - BLSPubKey::generated_from_seed_indexed(seed, 2011_u64); - - let parent_commitment = vid_commitment(&[], GENESIS_VID_NUM_STORAGE_NODES); - - // sign the parent_commitment using the client_private_key - let encoded_signature = ::SignatureKey::sign( - &hotshot_client_private_key, - parent_commitment.as_ref(), - ) - .expect("Claim block signing failed"); - - let test_view_num = 0; - // test getting available blocks - tracing::info!( - "block_info/availableblocks/{parent_commitment}/{test_view_num}/{hotshot_client_pub_key}/{encoded_signature}" - ); - // sleep and wait for builder service to startup - async_sleep(Duration::from_millis(3000)).await; - let available_block_info = match builder_client - .get::>>(&format!( - "block_info/availableblocks/{parent_commitment}/{test_view_num}/{hotshot_client_pub_key}/{encoded_signature}" - )) - .send() - .await - { - Ok(response) => { - tracing::info!("Received Available Blocks: {:?}", response); - assert!(!response.is_empty()); - response - } - Err(e) => { - panic!("Error getting available blocks {:?}", e); - } - }; - - let builder_commitment = available_block_info[0].block_hash.clone(); - - // sign the builder_commitment using the client_private_key - let encoded_signature = ::SignatureKey::sign( - &hotshot_client_private_key, - builder_commitment.as_ref(), - ) - .expect("Claim block signing failed"); - - // Test claiming blocks - let _available_block_data = match builder_client - .get::>(&format!( - "block_info/claimblock/{builder_commitment}/{test_view_num}/{hotshot_client_pub_key}/{encoded_signature}" - )) - .send() - .await - { - Ok(response) => { - tracing::info!("Received Block Data: {:?}", response); - response - } - Err(e) => { - panic!("Error while claiming block {:?}", e); - } - }; - - // Test claiming block header input - let _available_block_header = match builder_client - .get::>(&format!( - "block_info/claimheaderinput/{builder_commitment}/{test_view_num}/{hotshot_client_pub_key}/{encoded_signature}" - )) - .send() - .await - { - Ok(response) => { - tracing::info!("Received Block Header : {:?}", response); - response - } - Err(e) => { - panic!("Error getting claiming block header {:?}", e); - } - }; - - // test getting builder key - match builder_client - .get::("block_info/builderaddress") - .send() - .await - { - Ok(response) => { - tracing::info!("Received Builder Key : {:?}", response); - assert_eq!(response, builder_pub_key); - } - Err(e) => { - panic!("Error getting builder key {:?}", e); - } - } - - let txn = Transaction::new(NamespaceId::from(1_u32), vec![1, 2, 3]); - match builder_client - .post::<()>("txn_submit/submit") - .body_json(&txn) - .unwrap() - .send() - .await - { - Ok(response) => { - tracing::info!("Received txn submitted response : {:?}", response); - return; - } - Err(e) => { - panic!("Error submitting private transaction {:?}", e); - } - } - } + // TODO: Re-enable when permissioned builder accepts Arc> instead of Arc + // #[async_std::test] + // async fn test_permissioned_builder() { + // setup_test(); + + // let query_port = pick_unused_port().expect("No ports free"); + + // let event_port = pick_unused_port().expect("No ports free"); + // let event_service_url: Url = format!("http://localhost:{event_port}").parse().unwrap(); + + // let builder_port = pick_unused_port().expect("No ports free"); + // let builder_api_url: Url = format!("http://localhost:{builder_port}").parse().unwrap(); + + // // Set up and start the network + // let anvil = Anvil::new().spawn(); + // let l1 = anvil.endpoint().parse().unwrap(); + // let network_config = TestConfigBuilder::default().l1_url(l1).build(); + + // let tmpdir = TempDir::new().unwrap(); + + // let config = TestNetworkConfigBuilder::default() + // .api_config( + // Options::with_port(query_port) + // .submit(Default::default()) + // .query_fs( + // Default::default(), + // persistence::fs::Options::new(tmpdir.path().to_owned()), + // ) + // .hotshot_events(HotshotEvents { + // events_service_port: event_port, + // }), + // ) + // .network_config(network_config) + // .build(); + // let network = TestNetwork::new(config, BaseVersion::instance()).await; + // let consensus_handle = network.peers[0].consensus(); + // let node_id = network.peers[0].config().node_index; + // let state_signer = network.peers[0].state_signer(); + + // let builder_config = PermissionedBuilderTestConfig::init_permissioned_builder( + // consensus_handle, + // node_id, + // state_signer, + // builder_api_url.clone(), + // ) + // .await; + + // let subscribed_events = consensus_handle.event_stream(); + + // test_builder_impl( + // builder_api_url, + // subscribed_events, + // builder_config.fee_account, + // ) + // .await; + // } } diff --git a/hotshot-state-prover/src/bin/state-prover.rs b/hotshot-state-prover/src/bin/state-prover.rs index 2c5a7f169..a55b21cb9 100644 --- a/hotshot-state-prover/src/bin/state-prover.rs +++ b/hotshot-state-prover/src/bin/state-prover.rs @@ -1,7 +1,7 @@ use std::time::Duration; use clap::Parser; -use espresso_types::{parse_duration, SequencerVersions}; +use espresso_types::{parse_duration, BaseVersion}; use ethers::{ providers::{Http, Middleware, Provider}, signers::{coins_bip39::English, MnemonicBuilder, Signer}, @@ -9,7 +9,6 @@ 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::Versions; use sequencer_utils::logging; use url::Url; use vbs::version::StaticVersionType; @@ -114,16 +113,12 @@ async fn main() { if args.daemon { // Launching the prover service daemon - if let Err(err) = - run_prover_service(config, ::Base::instance()).await - { + if let Err(err) = run_prover_service(config, BaseVersion::instance()).await { tracing::error!("Error running prover service: {:?}", err); }; } else { // Run light client state update once - if let Err(err) = - run_prover_once(config, ::Base::instance()).await - { + if let Err(err) = run_prover_once(config, BaseVersion::instance()).await { tracing::error!("Error running prover once: {:?}", err); }; } diff --git a/marketplace-builder/src/bin/marketplace-builder.rs b/marketplace-builder/src/bin/marketplace-builder.rs index 948664a70..2fe23ff6a 100644 --- a/marketplace-builder/src/bin/marketplace-builder.rs +++ b/marketplace-builder/src/bin/marketplace-builder.rs @@ -3,13 +3,10 @@ use std::{num::NonZeroUsize, path::PathBuf, time::Duration}; use async_compatibility_layer::logging::{setup_backtrace, setup_logging}; use clap::Parser; use espresso_types::{ - eth_signature_key::EthKeyPair, parse_duration, FeeAmount, NamespaceId, SequencerVersions, + eth_signature_key::EthKeyPair, parse_duration, BaseVersion, FeeAmount, NamespaceId, }; use hotshot::traits::ValidatedState; -use hotshot_types::{ - data::ViewNumber, - traits::node_implementation::{ConsensusTime, Versions}, -}; +use hotshot_types::{data::ViewNumber, traits::node_implementation::ConsensusTime}; use marketplace_builder::{ builder::{build_instance_state, BuilderConfig}, hooks::BidConfig, @@ -152,7 +149,7 @@ async fn main() -> anyhow::Result<()> { genesis.chain_config, l1_params, opt.state_peers, - ::Base::instance(), + BaseVersion::instance(), ) .unwrap(); diff --git a/marketplace-builder/src/builder.rs b/marketplace-builder/src/builder.rs index 2f8448bf1..67e34153a 100644 --- a/marketplace-builder/src/builder.rs +++ b/marketplace-builder/src/builder.rs @@ -181,6 +181,7 @@ impl BuilderConfig { let proxy_global_state = ProxyGlobalState::new( global_state.clone(), (builder_key_pair.fee_account(), builder_key_pair.clone()), + max_api_timeout_duration, ); // start the hotshot api service @@ -203,10 +204,9 @@ impl BuilderConfig { }; async_spawn(async move { - let res = run_non_permissioned_standalone_builder_service::< - SeqTypes, - SequencerVersions, - >(hooks, senders, events_url) + let res = run_non_permissioned_standalone_builder_service::<_, SequencerVersions>( + hooks, senders, events_url, + ) .await; tracing::error!(?res, "Reserve builder service exited"); if res.is_err() { @@ -219,10 +219,9 @@ impl BuilderConfig { let hooks = hooks::EspressoFallbackHooks { solver_api_url }; async_spawn(async move { - let res = run_non_permissioned_standalone_builder_service::< - SeqTypes, - SequencerVersions, - >(hooks, senders, events_url) + let res = run_non_permissioned_standalone_builder_service::<_, SequencerVersions>( + hooks, senders, events_url, + ) .await; tracing::error!(?res, "Fallback builder service exited"); if res.is_err() { @@ -243,7 +242,7 @@ impl BuilderConfig { #[cfg(test)] mod test { - use std::time::Duration; + use std::time::{Duration, Instant}; use async_compatibility_layer::{ art::{async_sleep, async_spawn}, @@ -253,17 +252,17 @@ mod test { use async_std::{stream::StreamExt, task}; use committable::Commitment; use espresso_types::{ - mock::MockStateCatchup, FeeAccount, NamespaceId, PubKey, SeqTypes, SequencerVersions, - Transaction, + mock::MockStateCatchup, BaseVersion, FeeAccount, MarketplaceVersion, NamespaceId, PubKey, + SeqTypes, Transaction, }; use ethers::utils::Anvil; - use hotshot::types::BLSPrivKey; + use hotshot::types::{BLSPrivKey, Event, EventType}; use hotshot_builder_api::v0_3::builder::BuildError; use hotshot_events_service::{ events::{Error as EventStreamApiError, Options as EventStreamingApiOptions}, events_source::{EventConsumer, EventsStreamer}, }; - use hotshot_query_service::availability::LeafQueryData; + use hotshot_query_service::{availability::LeafQueryData, VidCommitment}; use hotshot_types::{ bundle::Bundle, light_client::StateKeyPair, @@ -329,8 +328,7 @@ mod test { ) .network_config(network_config) .build(); - let network = - TestNetwork::new(config, ::Base::instance()).await; + let network = TestNetwork::new(config, BaseVersion::instance()).await; // Start the builder let init = BuilderConfig::init( @@ -357,8 +355,7 @@ mod test { let _builder_config = init.await; // Wait for at least one empty block to be sequenced (after consensus starts VID). - let sequencer_client: Client::Base> = - Client::new(query_api_url); + let sequencer_client: Client = Client::new(query_api_url); sequencer_client.connect(None).await; sequencer_client .socket("availability/stream/leaves/0") @@ -371,22 +368,14 @@ mod test { .unwrap(); // Connect to builder - let builder_client: Client::Marketplace> = + let builder_client: Client = Client::new(builder_api_url.clone()); builder_client.connect(None).await; // TODO(AG): workaround for version mismatch between bundle and submit APIs - let submission_client: Client::Base> = - Client::new(builder_api_url); + let submission_client: Client = Client::new(builder_api_url); submission_client.connect(None).await; - // Test getting a bundle - let _bundle = builder_client - .get::>("block_info/bundle/1") - .send() - .await - .unwrap(); - // Test submitting transactions let transactions = (0..10) .map(|i| Transaction::new(0u32.into(), vec![1, 1, 1, i])) @@ -398,5 +387,44 @@ mod test { .send() .await .unwrap(); + + let events_service_client = + Client::::new( + event_service_url.clone(), + ); + events_service_client.connect(None).await; + + let mut subscribed_events = events_service_client + .socket("hotshot-events/events") + .subscribe::>() + .await + .unwrap(); + + let start = Instant::now(); + loop { + if start.elapsed() > Duration::from_secs(10) { + panic!("Didn't get a quorum proposal in 10 seconds"); + } + + let event = subscribed_events.next().await.unwrap().unwrap(); + if let EventType::QuorumProposal { proposal, .. } = event.event { + let parent_view_number = *proposal.data.view_number; + let parent_commitment = + Leaf::from_quorum_proposal(&proposal.data).payload_commitment(); + let bundle = builder_client + .get::>( + format!( + "block_info/bundle/{parent_view_number}/{parent_commitment}/{}", + parent_view_number + 1 + ) + .as_str(), + ) + .send() + .await + .unwrap(); + assert_eq!(bundle.transactions, transactions); + break; + } + } } } diff --git a/marketplace-builder/src/hooks.rs b/marketplace-builder/src/hooks.rs index 47d26af58..467a92ec4 100644 --- a/marketplace-builder/src/hooks.rs +++ b/marketplace-builder/src/hooks.rs @@ -4,8 +4,8 @@ use async_trait::async_trait; use espresso_types::v0_3::BidTxBody; use espresso_types::v0_3::RollupRegistration; +use espresso_types::BaseVersion; use espresso_types::SeqTypes; -use espresso_types::SequencerVersions; use hotshot::types::EventType; use hotshot::types::Event; @@ -36,10 +36,8 @@ pub struct BidConfig { pub amount: FeeAmount, } -pub async fn connect_to_solver( - solver_api_url: Url, -) -> Option::Base>> { - let client = Client::::Base>::new( +pub async fn connect_to_solver(solver_api_url: Url) -> Option> { + let client = Client::::new( solver_api_url.join("marketplace-solver/").unwrap(), ); diff --git a/marketplace-builder/src/lib.rs b/marketplace-builder/src/lib.rs index 4a2e22d18..486455055 100755 --- a/marketplace-builder/src/lib.rs +++ b/marketplace-builder/src/lib.rs @@ -19,7 +19,7 @@ use espresso_types::{ eth_signature_key::EthKeyPair, v0::traits::{PersistenceOptions, SequencerPersistence, StateCatchup}, v0_3::BidTxBody, - SeqTypes, SequencerVersions, + BaseVersion, SeqTypes, }; use ethers::{ core::k256::ecdsa::SigningKey, @@ -92,7 +92,7 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState) { let private_mempool_api = hotshot_builder_api::v0_3::builder::submit_api::< ProxyGlobalState, SeqTypes, - ::Base, + BaseVersion, >(&HotshotBuilderApiOptions::default()) .expect("Failed to construct the builder API for private mempool txns"); @@ -104,5 +104,5 @@ 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, BaseVersion::instance())); } diff --git a/marketplace-solver/src/events.rs b/marketplace-solver/src/events.rs index f94841cd0..4dd32375a 100644 --- a/marketplace-solver/src/events.rs +++ b/marketplace-solver/src/events.rs @@ -2,22 +2,20 @@ use std::{pin::Pin, sync::Arc}; use anyhow::Context; use async_std::sync::RwLock; -use espresso_types::{SeqTypes, SequencerVersions}; +use espresso_types::{BaseVersion, SeqTypes}; use futures::{Stream, StreamExt as _}; use hotshot::types::Event; use hotshot_events_service::{events, events_source::StartupInfo}; -use hotshot_types::traits::node_implementation::Versions; use surf_disco::Client; use tide_disco::Url; use crate::state::GlobalState; -pub struct EventsServiceClient(Client::Base>); +pub struct EventsServiceClient(Client); impl EventsServiceClient { pub async fn new(url: Url) -> Self { - let client = - Client::::Base>::new(url.clone()); + let client = Client::::new(url.clone()); client.connect(None).await; diff --git a/marketplace-solver/src/main.rs b/marketplace-solver/src/main.rs index 6d5936b38..881067088 100644 --- a/marketplace-solver/src/main.rs +++ b/marketplace-solver/src/main.rs @@ -4,8 +4,7 @@ use anyhow::Context; use async_compatibility_layer::logging::{setup_backtrace, setup_logging}; use async_std::{sync::RwLock, task::spawn}; use clap::Parser; -use espresso_types::SequencerVersions; -use hotshot_types::traits::node_implementation::Versions; +use espresso_types::BaseVersion; use marketplace_solver::{ define_api, handle_events, state::{GlobalState, SolverState, StakeTable}, @@ -14,7 +13,7 @@ use marketplace_solver::{ use tide_disco::App; use vbs::version::StaticVersionType; -type Version = ::Base; +type Version = BaseVersion; #[async_std::main] async fn main() -> anyhow::Result<()> { diff --git a/marketplace-solver/src/testing.rs b/marketplace-solver/src/testing.rs index dda545965..cb60ec99a 100755 --- a/marketplace-solver/src/testing.rs +++ b/marketplace-solver/src/testing.rs @@ -4,9 +4,8 @@ use std::sync::Arc; use async_compatibility_layer::art::async_spawn; use async_std::{sync::RwLock, task::JoinHandle}; -use espresso_types::SequencerVersions; +use espresso_types::BaseVersion; use hotshot_query_service::data_source::sql::testing::TmpDb; -use hotshot_types::traits::node_implementation::Versions; use portpicker::pick_unused_port; use tide_disco::{App, Url}; use vbs::version::StaticVersionType; @@ -81,11 +80,8 @@ impl MockSolver { let mut api = define_api(Default::default()).unwrap(); api.with_version(env!("CARGO_PKG_VERSION").parse().unwrap()); - app.register_module::::Base>( - "solver_api", - api, - ) - .unwrap(); + app.register_module::("solver_api", api) + .unwrap(); let solver_api_port = pick_unused_port().expect("no free port"); let solver_url: Url = Url::parse(&format!("http://localhost:{solver_api_port}")).unwrap(); @@ -93,12 +89,7 @@ impl MockSolver { let solver_api_handle = async_spawn({ let solver_url = solver_url.clone(); async move { - let _ = app - .serve( - solver_url, - ::Base::instance(), - ) - .await; + let _ = app.serve(solver_url, BaseVersion::instance()).await; } }); @@ -128,10 +119,10 @@ mod test { use committable::Committable; use espresso_types::{ v0_3::{RollupRegistration, RollupRegistrationBody, RollupUpdate, RollupUpdatebody}, - SeqTypes, SequencerVersions, + BaseVersion, SeqTypes, }; use hotshot::types::{BLSPubKey, SignatureKey}; - use hotshot_types::traits::node_implementation::{NodeType, Versions}; + use hotshot_types::traits::node_implementation::NodeType; use std::str::FromStr; use tide_disco::Url; @@ -141,9 +132,7 @@ mod test { async fn test_rollup_registration() { let mock_solver = MockSolver::init().await; let solver_api = mock_solver.solver_api(); - let client = surf_disco::Client::::Base>::new( - solver_api, - ); + let client = surf_disco::Client::::new(solver_api); // Create a list of signature keys for rollup registration data let mut signature_keys = Vec::new(); @@ -291,9 +280,7 @@ mod test { async fn test_update_rollup_not_registered() { let mock_solver = MockSolver::init().await; let solver_api = mock_solver.solver_api(); - let client = surf_disco::Client::::Base>::new( - solver_api, - ); + let client = surf_disco::Client::::new(solver_api); let private_key = ::PrivateKey::generate(&mut rand::thread_rng()); @@ -344,9 +331,7 @@ mod test { let mock_solver = MockSolver::init().await; let solver_api = mock_solver.solver_api(); - let client = surf_disco::Client::::Base>::new( - solver_api, - ); + let client = surf_disco::Client::::new(solver_api); // Create a list of signature keys for rollup registration data let mut signature_keys = Vec::new(); @@ -492,9 +477,7 @@ mod test { let solver_api = mock_solver.solver_api(); - let client = surf_disco::Client::::Base>::new( - solver_api, - ); + let client = surf_disco::Client::::new(solver_api); let result: String = client.post("submit_bid").send().await.unwrap(); assert_eq!(result, "Bid Submitted".to_string()); diff --git a/node-metrics/src/api/node_validator/v0/cdn/mod.rs b/node-metrics/src/api/node_validator/v0/cdn/mod.rs index 6d8a3ce98..227cfe3b3 100644 --- a/node-metrics/src/api/node_validator/v0/cdn/mod.rs +++ b/node-metrics/src/api/node_validator/v0/cdn/mod.rs @@ -1,13 +1,13 @@ use crate::api::node_validator::v0::create_node_validator_api::ExternalMessage; use async_std::task::JoinHandle; -use espresso_types::{v0::SequencerVersions, PubKey, SeqTypes}; +use espresso_types::{PubKey, SeqTypes}; use futures::{channel::mpsc::SendError, Sink, SinkExt}; use hotshot::{ traits::NetworkError, types::{Message, SignatureKey}, }; use hotshot_types::{ - message::{MessageKind, UpgradeLock}, + message::MessageKind, traits::{ network::{BroadcastDelay, ConnectedNetwork, Topic}, node_implementation::NodeType, @@ -87,7 +87,6 @@ impl CdnReceiveMessagesTask { { network.wait_for_ready().await; let mut url_sender = url_sender; - let upgrade_lock = UpgradeLock::::new(); loop { let messages_result = network.recv_msgs().await; @@ -101,9 +100,8 @@ impl CdnReceiveMessagesTask { for message in messages { // We want to try and decode this message. - let message_deserialize_result = upgrade_lock - .deserialize::>(&message) - .await; + let message_deserialize_result: Result, _> = + bincode::deserialize(&message); let message = match message_deserialize_result { Ok(message) => message, @@ -234,7 +232,6 @@ impl BroadcastRollCallTask { N: ConnectedNetworkPublisher<::SignatureKey> + Send + 'static, { network.wait_for_ready().await; - let upgrade_lock = UpgradeLock::::new(); // We want to send the Roll Call Request let rollcall_request = ExternalMessage::RollCallRequest(public_key); @@ -251,7 +248,7 @@ impl BroadcastRollCallTask { kind: MessageKind::External(rollcall_request_serialized), }; - let hotshot_message_serialized = match upgrade_lock.serialize(&hotshot_message).await { + let hotshot_message_serialized = match bincode::serialize(&hotshot_message) { Ok(hotshot_message_serialized) => hotshot_message_serialized, Err(err) => { tracing::error!("error serializing hotshot message: {:?}", err); @@ -292,7 +289,7 @@ mod test { use async_std::future::TimeoutError; use async_std::prelude::FutureExt; use core::panic; - use espresso_types::{v0::SequencerVersions, SeqTypes}; + use espresso_types::SeqTypes; use futures::channel::mpsc::Sender; use futures::SinkExt; use futures::{ @@ -304,7 +301,7 @@ mod test { traits::NetworkError, types::{BLSPubKey, Message}, }; - use hotshot_types::message::{DataMessage, MessageKind, UpgradeLock}; + use hotshot_types::message::{DataMessage, MessageKind}; use hotshot_types::traits::network::{BroadcastDelay, ResponseMessage}; use std::time::Duration; use url::Url; @@ -344,8 +341,6 @@ mod test { /// url_sender appropriately. #[async_std::test] async fn test_cdn_receive_messages_task() { - let upgrade_lock = UpgradeLock::::new(); - let test_hotshot_message_serialized = { let test_url = Url::parse("http://localhost:8080/").unwrap(); @@ -360,7 +355,7 @@ mod test { kind: MessageKind::External(external_message_encoded), }; - upgrade_lock.serialize(&test_message).await.unwrap() + bincode::serialize(&test_message).unwrap() }; let (url_sender, url_receiver) = mpsc::channel(1); @@ -437,15 +432,12 @@ mod test { /// This really shouldn't happen in practice. #[async_std::test] async fn test_cdn_receive_messages_task_fails_unexpected_hotshot_message_variant() { - let upgrade_lock = UpgradeLock::::new(); let (url_sender, url_receiver) = mpsc::channel(1); - let bytes = upgrade_lock - .serialize(&Message:: { - sender: BLSPubKey::generated_from_seed_indexed([0; 32], 0).0, - kind: MessageKind::Data(DataMessage::DataResponse(ResponseMessage::NotFound)), - }) - .await - .unwrap(); + let bytes = bincode::serialize(&Message:: { + sender: BLSPubKey::generated_from_seed_indexed([0; 32], 0).0, + kind: MessageKind::Data(DataMessage::DataResponse(ResponseMessage::NotFound)), + }) + .unwrap(); let task = CdnReceiveMessagesTask::new(TestConnectedNetworkConsumer(Ok(vec![bytes])), url_sender); @@ -468,15 +460,12 @@ mod test { /// it encounters an error from the deserialization of the external message. #[async_std::test] async fn test_cdn_receive_messages_task_fails_decoding_external_message() { - let upgrade_lock = UpgradeLock::::new(); let (url_sender, url_receiver) = mpsc::channel(1); - let bytes = upgrade_lock - .serialize(&Message:: { - sender: BLSPubKey::generated_from_seed_indexed([0; 32], 0).0, - kind: MessageKind::External(vec![0]), - }) - .await - .unwrap(); + let bytes = bincode::serialize(&Message:: { + sender: BLSPubKey::generated_from_seed_indexed([0; 32], 0).0, + kind: MessageKind::External(vec![0]), + }) + .unwrap(); let task = CdnReceiveMessagesTask::new(TestConnectedNetworkConsumer(Ok(vec![bytes])), url_sender); @@ -501,7 +490,6 @@ mod test { /// really have a point in existing. #[async_std::test] async fn test_cdn_receive_messages_tasks_exits_when_url_receiver_closed() { - let upgrade_lock = UpgradeLock::::new(); let (url_sender, url_receiver) = mpsc::channel(1); let test_hotshot_message_serialized = { @@ -518,7 +506,7 @@ mod test { kind: MessageKind::External(external_message_encoded), }; - upgrade_lock.serialize(&test_message).await.unwrap() + bincode::serialize(&test_message).unwrap() }; drop(url_receiver); @@ -561,7 +549,6 @@ mod test { /// beyond it's initial request. #[async_std::test] async fn test_cdn_broadcast_roll_call_task() { - let upgrade_lock = UpgradeLock::::new(); let (message_sender, message_receiver) = mpsc::channel(1); let task = BroadcastRollCallTask::new( @@ -571,10 +558,7 @@ mod test { let mut message_receiver = message_receiver; let next_message = message_receiver.next().await.unwrap(); - let next_message = upgrade_lock - .deserialize::>(&next_message) - .await - .unwrap(); + let next_message: Message = bincode::deserialize(&next_message).unwrap(); let external_message = match next_message.kind { MessageKind::External(external_message) => external_message, diff --git a/node-metrics/src/lib.rs b/node-metrics/src/lib.rs index bc5f498f8..d3d74d72b 100644 --- a/node-metrics/src/lib.rs +++ b/node-metrics/src/lib.rs @@ -115,7 +115,7 @@ use hotshot::traits::implementations::{ CdnMetricsValue, CdnTopic, PushCdnNetwork, WrappedSignatureKey, }; use hotshot_query_service::metrics::PrometheusMetrics; -use hotshot_types::traits::signature_key::BuilderSignatureKey; +use hotshot_types::traits::{node_implementation::NodeType, signature_key::BuilderSignatureKey}; use tide_disco::App; use url::Url; @@ -264,7 +264,7 @@ pub async fn run_standalone_service(options: Options) { let _cdn_tasks = if let Some(cdn_broker_url_string) = options.cdn_marshal_endpoint() { let (public_key, private_key) = PubKey::generated_from_seed_indexed([1; 32], 0); - let cdn_network_result = PushCdnNetwork::::new( + let cdn_network_result = PushCdnNetwork::<::SignatureKey>::new( cdn_broker_url_string.to_string(), vec![CdnTopic::Global], hotshot::traits::implementations::KeyPair { diff --git a/sequencer/src/api.rs b/sequencer/src/api.rs index 20d6b46d9..367dedb72 100644 --- a/sequencer/src/api.rs +++ b/sequencer/src/api.rs @@ -9,14 +9,14 @@ use data_source::{CatchupDataSource, SubmitDataSource}; use derivative::Derivative; use espresso_types::{ v0::traits::SequencerPersistence, v0_3::ChainConfig, AccountQueryData, BlockMerkleTree, - FeeAccountProof, NodeState, PubKey, SequencerVersions, Transaction, + FeeAccountProof, NodeState, PubKey, Transaction, }; use ethers::prelude::Address; use futures::{ future::{BoxFuture, Future, FutureExt}, stream::{BoxStream, Stream}, }; -use hotshot::types::{Event, SystemContextHandle}; +use hotshot::types::Event; use hotshot_events_service::events_source::{ EventFilterSet, EventsSource, EventsStreamer, StartupInfo, }; @@ -24,17 +24,15 @@ use hotshot_orchestrator::config::NetworkConfig; use hotshot_query_service::data_source::ExtensibleDataSource; use hotshot_state_prover::service::light_client_genesis_from_stake_table; use hotshot_types::{ - data::ViewNumber, - light_client::StateSignatureRequestBody, - traits::{network::ConnectedNetwork, node_implementation::Versions}, + data::ViewNumber, light_client::StateSignatureRequestBody, traits::network::ConnectedNetwork, }; use jf_merkle_tree::MerkleTreeScheme; use vbs::version::StaticVersionType; use self::data_source::{HotShotConfigDataSource, PublicNetworkConfig, StateSignatureDataSource}; use crate::{ - network, persistence::ChainConfigPersistence, state_signature::StateSigner, Node, SeqTypes, - SequencerContext, + context::Consensus, network, persistence::ChainConfigPersistence, state_signature::StateSigner, + SeqTypes, SequencerContext, }; pub mod data_source; @@ -49,8 +47,6 @@ pub use options::Options; pub type BlocksFrontier = ::MembershipProof; type BoxLazy = Pin>>>; -type HotshotSystemContextHandle = - Arc>>; #[derive(Derivative)] #[derivative(Debug(bound = ""))] @@ -62,7 +58,7 @@ struct ConsensusState, P: SequencerPersistence, Ver: config: NetworkConfig, #[derivative(Debug = "ignore")] - handle: HotshotSystemContextHandle>, + handle: Arc>>, } impl, P: SequencerPersistence, Ver: StaticVersionType + 'static> @@ -114,9 +110,7 @@ impl, P: SequencerPersistence, Ver: StaticVersionTyp &self.consensus.as_ref().get().await.get_ref().event_streamer } - async fn consensus( - &self, - ) -> Arc, SequencerVersions>>> { + async fn consensus(&self) -> Arc>> { Arc::clone(&self.consensus.as_ref().get().await.get_ref().handle) } @@ -394,7 +388,7 @@ pub mod test_helpers { use espresso_types::{ mock::MockStateCatchup, v0::traits::{PersistenceOptions, StateCatchup}, - NamespaceId, SequencerVersions, ValidatedState, + BaseVersion, NamespaceId, ValidatedState, }; use ethers::{prelude::Address, utils::Anvil}; use futures::{ @@ -403,7 +397,6 @@ pub mod test_helpers { }; use hotshot::types::{Event, EventType}; use hotshot_contract_adapter::light_client::ParsedLightClientState; - use hotshot_types::{ event::LeafInfo, traits::{metrics::NoMetrics, node_implementation::ConsensusTime}, @@ -650,7 +643,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::Base> = Client::new(url); + let client: Client = Client::new(url); let options = opt(Options::with_port(port).status(Default::default())); let anvil = Anvil::new().spawn(); @@ -660,8 +653,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let _network = - TestNetwork::new(config, ::Base::instance()).await; + let _network = TestNetwork::new(config, BaseVersion::instance()).await; client.connect(None).await; // The status API is well tested in the query service repo. Here we are just smoke testing @@ -703,7 +695,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::Base> = Client::new(url); + let client: Client = Client::new(url); let options = opt(Options::with_port(port).submit(Default::default())); let anvil = Anvil::new().spawn(); @@ -713,8 +705,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = - TestNetwork::new(config, ::Base::instance()).await; + let network = TestNetwork::new(config, BaseVersion::instance()).await; let mut events = network.server.event_stream().await; client.connect(None).await; @@ -739,7 +730,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::Base> = Client::new(url); + let client: Client = Client::new(url); let options = opt(Options::with_port(port)); let anvil = Anvil::new().spawn(); @@ -749,8 +740,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = - TestNetwork::new(config, ::Base::instance()).await; + let network = TestNetwork::new(config, BaseVersion::instance()).await; let mut height: u64; // Wait for block >=2 appears @@ -782,7 +772,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::Base> = Client::new(url); + let client: Client = Client::new(url); let options = opt(Options::with_port(port).catchup(Default::default())); let anvil = Anvil::new().spawn(); @@ -792,8 +782,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = - TestNetwork::new(config, ::Base::instance()).await; + let network = TestNetwork::new(config, BaseVersion::instance()).await; client.connect(None).await; // Wait for a few blocks to be decided. @@ -874,11 +863,10 @@ mod api_tests { use data_source::testing::TestableSequencerDataSource; use endpoints::NamespaceProofQueryData; - use espresso_types::{Header, NamespaceId, SequencerVersions}; + use espresso_types::{BaseVersion, Header, NamespaceId}; use ethers::utils::Anvil; use futures::stream::StreamExt; use hotshot_query_service::availability::{LeafQueryData, VidCommonQueryData}; - use portpicker::pick_unused_port; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; @@ -928,12 +916,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, ::Base::instance()).await; + let network = TestNetwork::new(config, BaseVersion::instance()).await; let mut events = network.server.event_stream().await; // Connect client. - let client: Client::Base> = + let client: Client = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; @@ -1032,7 +1019,7 @@ mod api_tests { events_service_port: hotshot_event_streaming_port, }; - let client: Client::Base> = Client::new(url); + let client: Client = Client::new(url); let options = Options::with_port(query_service_port).hotshot_events(hotshot_events); @@ -1043,8 +1030,7 @@ mod api_tests { .api_config(options) .network_config(network_config) .build(); - let _network = - TestNetwork::new(config, ::Base::instance()).await; + let _network = TestNetwork::new(config, BaseVersion::instance()).await; let mut subscribed_events = client .socket("hotshot-events/events") @@ -1081,8 +1067,8 @@ mod test { use espresso_types::{ mock::MockStateCatchup, v0_1::{UpgradeMode, ViewBasedUpgrade}, - FeeAccount, FeeAmount, Header, SequencerVersions, TimeBasedUpgrade, Timestamp, Upgrade, - UpgradeType, ValidatedState, + BaseVersion, FeeAccount, FeeAmount, Header, TimeBasedUpgrade, Timestamp, Upgrade, + UpgradeType, UpgradeVersion, ValidatedState, }; use ethers::utils::Anvil; use futures::{ @@ -1127,7 +1113,7 @@ mod test { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client::Base> = Client::new(url); + let client: Client = Client::new(url); let options = Options::with_port(port); let anvil = Anvil::new().spawn(); let l1 = anvil.endpoint().parse().unwrap(); @@ -1136,8 +1122,7 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let _network = - TestNetwork::new(config, ::Base::instance()).await; + let _network = TestNetwork::new(config, BaseVersion::instance()).await; client.connect(None).await; let health = client.get::("healthcheck").send().await.unwrap(); @@ -1185,10 +1170,9 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let mut network = - TestNetwork::new(config, ::Base::instance()).await; + let mut network = TestNetwork::new(config, BaseVersion::instance()).await; let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client::Base> = Client::new(url); + let client: Client = Client::new(url); client.connect(None).await; @@ -1251,14 +1235,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::<::Base>::from_urls( + StatePeers::::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) })) .build(); - let mut network = - TestNetwork::new(config, ::Base::instance()).await; + let mut network = TestNetwork::new(config, BaseVersion::instance()).await; // Wait for replica 0 to reach a (non-genesis) decide, before disconnecting it. let mut events = network.peers[0].event_stream().await; @@ -1296,13 +1279,13 @@ mod test { 1, ValidatedState::default(), no_storage::Options, - StatePeers::<::Base>::from_urls( + StatePeers::::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ), &NoMetrics, test_helpers::STAKE_TABLE_CAPACITY_FOR_TEST, - ::Base::instance(), + BaseVersion::instance(), Default::default(), ) .await; @@ -1359,7 +1342,7 @@ mod test { .api_config(Options::with_port(port).catchup(Default::default())) .states(states) .catchups(std::array::from_fn(|_| { - StatePeers::<::Base>::from_urls( + StatePeers::::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1367,8 +1350,7 @@ mod test { .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = - TestNetwork::new(config, ::Base::instance()).await; + let mut network = TestNetwork::new(config, BaseVersion::instance()).await; // Wait for few blocks to be decided. network @@ -1437,7 +1419,7 @@ mod test { ) .states(states) .catchups(std::array::from_fn(|_| { - StatePeers::<::Base>::from_urls( + StatePeers::::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1445,8 +1427,7 @@ mod test { .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = - TestNetwork::new(config, ::Base::instance()).await; + let mut network = TestNetwork::new(config, BaseVersion::instance()).await; // Wait for a few blocks to be decided. network @@ -1508,7 +1489,7 @@ mod test { let mut upgrades = std::collections::BTreeMap::new(); upgrades.insert( - ::Upgrade::VERSION, + UpgradeVersion::VERSION, Upgrade { mode, upgrade_type: UpgradeType::Fee { @@ -1530,7 +1511,7 @@ mod test { .status(Default::default()), ) .catchups(std::array::from_fn(|_| { - StatePeers::<::Base>::from_urls( + StatePeers::::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1543,8 +1524,7 @@ mod test { ) .build(); - let mut network = - TestNetwork::new(config, ::Base::instance()).await; + let mut network = TestNetwork::new(config, BaseVersion::instance()).await; let mut events = network.server.event_stream().await; loop { @@ -1554,17 +1534,14 @@ mod test { EventType::UpgradeProposal { proposal, .. } => { let upgrade = proposal.data.upgrade_proposal; let new_version = upgrade.new_version; - assert_eq!( - new_version, - ::Upgrade::VERSION - ); + assert_eq!(new_version, UpgradeVersion::VERSION); break; } _ => continue, } } - let client: Client::Base> = + let client: Client = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1622,11 +1599,10 @@ mod test { .persistences(persistence) .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = - TestNetwork::new(config, ::Base::instance()).await; + let mut network = TestNetwork::new(config, BaseVersion::instance()).await; // Connect client. - let client: Client::Base> = + let client: Client = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1693,16 +1669,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::<::Base>::from_urls( + StatePeers::::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, ::Base::instance()).await; - let client: Client::Base> = + let _network = TestNetwork::new(config, BaseVersion::instance()).await; + let client: Client = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1743,8 +1718,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::Base> = - Client::new(url.clone()); + let client: Client = Client::new(url.clone()); let options = Options::with_port(port).config(Default::default()); let anvil = Anvil::new().spawn(); @@ -1754,13 +1728,12 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let network = - TestNetwork::new(config, ::Base::instance()).await; + let network = TestNetwork::new(config, BaseVersion::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::<::Base>::from_urls( + let peers = StatePeers::::from_urls( vec!["https://notarealnode.network".parse().unwrap(), url], Default::default(), ); diff --git a/sequencer/src/bin/commitment-task.rs b/sequencer/src/bin/commitment-task.rs index 3cfd16977..8955f26bd 100644 --- a/sequencer/src/bin/commitment-task.rs +++ b/sequencer/src/bin/commitment-task.rs @@ -2,10 +2,9 @@ use std::{io, time::Duration}; use async_std::task::spawn; use clap::Parser; -use espresso_types::{parse_duration, SequencerVersions}; +use espresso_types::{parse_duration, BaseVersion}; use ethers::prelude::*; use futures::FutureExt; -use hotshot_types::traits::node_implementation::Versions; use sequencer::hotshot_commitment::{run_hotshot_commitment_task, CommitmentTaskOptions}; use sequencer_utils::logging; use tide_disco::{error::ServerError, Api}; @@ -66,12 +65,7 @@ async fn main() { opt.logging.init(); if let Some(port) = opt.port { - start_http_server( - port, - opt.hotshot_address, - ::Base::instance(), - ) - .unwrap(); + start_http_server(port, opt.hotshot_address, BaseVersion::instance()).unwrap(); } let hotshot_contract_options = CommitmentTaskOptions { @@ -85,8 +79,7 @@ async fn main() { query_service_url: Some(opt.sequencer_url), }; tracing::info!("Launching HotShot commitment task.."); - run_hotshot_commitment_task::<::Base>(&hotshot_contract_options) - .await; + run_hotshot_commitment_task::(&hotshot_contract_options).await; } fn start_http_server( @@ -115,8 +108,7 @@ fn start_http_server( #[cfg(test)] mod test { - use espresso_types::SequencerVersions; - use hotshot_types::traits::node_implementation::Versions; + use espresso_types::BaseVersion; use portpicker::pick_unused_port; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; @@ -132,14 +124,10 @@ mod test { let expected_addr = "0xED15E1FE0789c524398137a066ceb2EF9884E5D8" .parse::
() .unwrap(); - start_http_server( - port, - expected_addr, - ::Base::instance(), - ) - .expect("Failed to start the server"); - - let client: Client::Base> = + start_http_server(port, expected_addr, BaseVersion::instance()) + .expect("Failed to start the server"); + + let client: Client = 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 2ecdda578..8de5d0279 100644 --- a/sequencer/src/bin/espresso-bridge.rs +++ b/sequencer/src/bin/espresso-bridge.rs @@ -5,7 +5,7 @@ use async_std::{sync::Arc, task::sleep}; use clap::{Parser, Subcommand}; use contract_bindings::fee_contract::FeeContract; use espresso_types::{ - eth_signature_key::EthKeyPair, FeeAccount, FeeAmount, FeeMerkleTree, Header, SequencerVersions, + eth_signature_key::EthKeyPair, BaseVersion, FeeAccount, FeeAmount, FeeMerkleTree, Header, }; use ethers::{ middleware::{Middleware, SignerMiddleware}, @@ -13,7 +13,6 @@ use ethers::{ types::{Address, BlockId, U256}, }; use futures::stream::StreamExt; -use hotshot_types::traits::node_implementation::Versions; use jf_merkle_tree::{ prelude::{MerkleProof, Sha3Node}, MerkleTreeScheme, @@ -21,7 +20,7 @@ use jf_merkle_tree::{ use sequencer_utils::logging; use surf_disco::{error::ClientError, Url}; -type EspressoClient = surf_disco::Client::Base>; +type EspressoClient = surf_disco::Client; type FeeMerkleProof = MerkleProof; diff --git a/sequencer/src/bin/espresso-dev-node.rs b/sequencer/src/bin/espresso-dev-node.rs index 7a5dee494..1e018b0ff 100644 --- a/sequencer/src/bin/espresso-dev-node.rs +++ b/sequencer/src/bin/espresso-dev-node.rs @@ -4,7 +4,7 @@ use async_std::task::spawn; use async_trait::async_trait; use clap::Parser; use contract_bindings::light_client_mock::LightClientMock; -use espresso_types::{parse_duration, SequencerVersions}; +use espresso_types::{parse_duration, BaseVersion}; use ethers::{ middleware::{MiddlewareBuilder, SignerMiddleware}, providers::{Http, Middleware, Provider}, @@ -15,10 +15,7 @@ use futures::{future::BoxFuture, stream::FuturesUnordered, FutureExt, StreamExt} use hotshot_state_prover::service::{ one_honest_threshold, run_prover_service_with_stake_table, StateProverConfig, }; -use hotshot_types::traits::{ - node_implementation::Versions, - stake_table::{SnapshotVersion, StakeTableScheme}, -}; +use hotshot_types::traits::stake_table::{SnapshotVersion, StakeTableScheme}; use portpicker::pick_unused_port; use sequencer::{ api::{ @@ -190,7 +187,7 @@ async fn main() -> anyhow::Result<()> { .network_config(network_config) .build(); - let network = TestNetwork::new(config, ::Base::instance()).await; + let network = TestNetwork::new(config, BaseVersion::instance()).await; let st = network.cfg.stake_table(); let total_stake = st.total_stake(SnapshotVersion::LastEpochStart).unwrap(); let config = network.cfg.hotshot_config(); @@ -288,7 +285,7 @@ async fn main() -> anyhow::Result<()> { let prover_handle = spawn(run_prover_service_with_stake_table( prover_config, - ::Base::instance(), + BaseVersion::instance(), Arc::new(st.clone()), )); handles.push(prover_handle); @@ -301,7 +298,7 @@ async fn main() -> anyhow::Result<()> { format!("http://0.0.0.0:{relay_server_port}") .parse() .unwrap(), - ::Base::instance(), + BaseVersion::instance(), ) .await; @@ -340,7 +337,7 @@ async fn main() -> anyhow::Result<()> { dev_node_port, mock_contracts, dev_info, - ::Base::instance(), + BaseVersion::instance(), )); handles.push(dev_node_handle); @@ -503,14 +500,13 @@ mod tests { use committable::{Commitment, Committable}; use contract_bindings::light_client::LightClient; use escargot::CargoBuild; - use espresso_types::{BlockMerkleTree, Header, SeqTypes, SequencerVersions, Transaction}; + use espresso_types::{BaseVersion, BlockMerkleTree, Header, SeqTypes, Transaction}; use ethers::{providers::Middleware, types::U256}; use futures::TryStreamExt; use hotshot_query_service::{ availability::{BlockQueryData, TransactionQueryData, VidCommonQueryData}, data_source::sql::testing::TmpDb, }; - use hotshot_types::traits::node_implementation::Versions; use jf_merkle_tree::MerkleTreeScheme; use portpicker::pick_unused_port; use rand::Rng; @@ -581,7 +577,7 @@ mod tests { let process = BackgroundProcess(process); - let api_client: Client::Base> = + let api_client: Client = Client::new(format!("http://localhost:{api_port}").parse().unwrap()); api_client.connect(None).await; @@ -755,7 +751,7 @@ mod tests { } } - let dev_node_client: Client::Base> = + let dev_node_client: Client = Client::new(format!("http://localhost:{dev_node_port}").parse().unwrap()); dev_node_client.connect(None).await; @@ -899,7 +895,7 @@ mod tests { let process = BackgroundProcess(process); - let api_client: Client::Base> = + let api_client: Client = Client::new(format!("http://localhost:{api_port}").parse().unwrap()); api_client.connect(None).await; @@ -914,7 +910,7 @@ mod tests { .await .unwrap(); - let dev_node_client: Client::Base> = + let dev_node_client: Client = 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 e60decc67..f9f0bbee3 100644 --- a/sequencer/src/bin/nasty-client.rs +++ b/sequencer/src/bin/nasty-client.rs @@ -21,8 +21,8 @@ use clap::Parser; use committable::Committable; use derivative::Derivative; use espresso_types::{ - parse_duration, v0_3::IterableFeeInfo, BlockMerkleTree, FeeMerkleTree, Header, SeqTypes, - SequencerVersions, + parse_duration, v0_3::IterableFeeInfo, BaseVersion, BlockMerkleTree, FeeMerkleTree, Header, + SeqTypes, }; use futures::{ future::{FutureExt, TryFuture, TryFutureExt}, @@ -33,10 +33,7 @@ use hotshot_query_service::{ metrics::PrometheusMetrics, node::TimeWindowQueryData, }; -use hotshot_types::traits::{ - metrics::{Counter, Gauge, Histogram, Metrics as _}, - node_implementation::Versions, -}; +use hotshot_types::traits::metrics::{Counter, Gauge, Histogram, Metrics as _}; use jf_merkle_tree::{ ForgetableMerkleTreeScheme, MerkleCommitment, MerkleTreeScheme, UniversalMerkleTreeScheme, }; @@ -405,8 +402,7 @@ impl Queryable for PayloadQueryData { } } -type Connection = - socket::Connection::Base>; +type Connection = socket::Connection; #[derive(Derivative)] #[derivative(Debug)] @@ -419,7 +415,7 @@ struct Subscription { #[derive(Debug)] struct ResourceManager { - client: surf_disco::Client::Base>, + client: surf_disco::Client, open_streams: BTreeMap>, next_stream_id: u64, metrics: Arc, @@ -1264,17 +1260,14 @@ async fn serve(port: u16, metrics: PrometheusMetrics) { METHOD = "METRICS" }; let mut app = App::<_, ServerError>::with_state(RwLock::new(metrics)); - app.module::::Base>("status", api) + app.module::("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}"), - ::Base::instance(), - ) + .serve(format!("0.0.0.0:{port}"), BaseVersion::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 da5ad7ca9..b29ec02e9 100644 --- a/sequencer/src/bin/state-relay-server.rs +++ b/sequencer/src/bin/state-relay-server.rs @@ -1,8 +1,7 @@ use clap::Parser; -use espresso_types::SequencerVersions; +use espresso_types::BaseVersion; use ethers::types::U256; use hotshot_state_prover::service::one_honest_threshold; -use hotshot_types::traits::node_implementation::Versions; use sequencer::state_signature::relay_server::run_relay_server; use sequencer_utils::logging; use vbs::version::StaticVersionType; @@ -47,7 +46,7 @@ async fn main() { None, threshold, format!("http://0.0.0.0:{}", args.port).parse().unwrap(), - ::Base::instance(), + BaseVersion::instance(), ) .await .unwrap(); diff --git a/sequencer/src/bin/submit-transactions.rs b/sequencer/src/bin/submit-transactions.rs index 04fb5dae2..6385f34c3 100644 --- a/sequencer/src/bin/submit-transactions.rs +++ b/sequencer/src/bin/submit-transactions.rs @@ -8,14 +8,13 @@ use std::{ use async_std::task::{sleep, spawn}; use clap::Parser; use committable::{Commitment, Committable}; -use espresso_types::{parse_duration, parse_size, SeqTypes, SequencerVersions, Transaction}; +use espresso_types::{parse_duration, parse_size, BaseVersion, SeqTypes, Transaction}; use futures::{ channel::mpsc::{self, Sender}, sink::SinkExt, stream::StreamExt, }; use hotshot_query_service::{availability::BlockQueryData, types::HeightIndexed, Error}; -use hotshot_types::traits::node_implementation::Versions; use rand::{Rng, RngCore, SeedableRng}; use rand_chacha::ChaChaRng; use rand_distr::Distribution; @@ -174,7 +173,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::::Base>::new(opt.url.clone()); + let client = Client::::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)) @@ -189,16 +188,13 @@ async fn main() { opt.clone(), sender.clone(), ChaChaRng::from_rng(&mut rng).unwrap(), - ::Base::instance(), + BaseVersion::instance(), )); } // Start healthcheck endpoint once tasks are running. if let Some(port) = opt.port { - spawn(server( - port, - ::Base::instance(), - )); + spawn(server(port, BaseVersion::instance())); } // Keep track of the results. diff --git a/sequencer/src/bin/verify-headers.rs b/sequencer/src/bin/verify-headers.rs index dd06f8605..a6bc3cf24 100644 --- a/sequencer/src/bin/verify-headers.rs +++ b/sequencer/src/bin/verify-headers.rs @@ -4,10 +4,9 @@ use std::{cmp::max, process::exit, time::Duration}; use async_std::{sync::Arc, task::sleep}; use clap::Parser; -use espresso_types::{Header, L1BlockInfo, SequencerVersions}; +use espresso_types::{BaseVersion, Header, L1BlockInfo}; use ethers::prelude::*; use futures::future::join_all; -use hotshot_types::traits::node_implementation::Versions; use itertools::Itertools; use sequencer_utils::logging; use surf_disco::Url; @@ -170,8 +169,7 @@ async fn main() { let opt = Arc::new(Options::parse()); opt.logging.init(); - let seq = - Arc::new(SequencerClient::<::Base>::new(opt.url.clone())); + let seq = Arc::new(SequencerClient::::new(opt.url.clone())); let block_height: usize = seq.get("status/latest_block_height").send().await.unwrap(); let from = opt.from.unwrap_or(0); diff --git a/sequencer/src/external_event_handler.rs b/sequencer/src/external_event_handler.rs index 05f707310..3e1b23c46 100644 --- a/sequencer/src/external_event_handler.rs +++ b/sequencer/src/external_event_handler.rs @@ -3,10 +3,10 @@ use crate::context::TaskList; use anyhow::{Context, Result}; use async_compatibility_layer::channel::{Receiver, Sender}; -use espresso_types::{PubKey, SeqTypes, SequencerVersions}; +use espresso_types::{PubKey, SeqTypes}; use hotshot::types::{BLSPubKey, Message}; use hotshot_types::{ - message::{MessageKind, UpgradeLock}, + message::MessageKind, traits::network::{BroadcastDelay, ConnectedNetwork, Topic}, }; use serde::{Deserialize, Serialize}; @@ -146,11 +146,7 @@ impl ExternalEventHandler { kind: MessageKind::::External(response_bytes), }; - let upgrade_lock = UpgradeLock::::new(); - - let response_bytes = upgrade_lock - .serialize(&message) - .await + let response_bytes = bincode::serialize(&message) .with_context(|| "Failed to serialize roll call response")?; Ok(response_bytes) diff --git a/sequencer/src/lib.rs b/sequencer/src/lib.rs index 0a55f5258..b91684f5d 100644 --- a/sequencer/src/lib.rs +++ b/sequencer/src/lib.rs @@ -15,8 +15,8 @@ use async_std::sync::RwLock; use catchup::StatePeers; use context::SequencerContext; use espresso_types::{ - BackoffParams, L1Client, NodeState, PubKey, SeqTypes, SequencerVersions, - SolverAuctionResultsProvider, ValidatedState, + BackoffParams, L1Client, NodeState, PubKey, SeqTypes, SolverAuctionResultsProvider, + UpgradeVersion, ValidatedState, }; use ethers::types::U256; #[cfg(feature = "libp2p")] @@ -59,7 +59,7 @@ use hotshot_types::{ traits::{ metrics::Metrics, network::{ConnectedNetwork, Topic}, - node_implementation::{NodeImplementation, NodeType, Versions}, + node_implementation::{NodeImplementation, NodeType}, signature_key::{BuilderSignatureKey, StakeTableEntryType}, }, utils::BuilderCommitment, @@ -272,10 +272,7 @@ pub async fn init_node( } }; - if let Some(upgrade) = genesis - .upgrades - .get(&::Upgrade::VERSION) - { + if let Some(upgrade) = genesis.upgrades.get(&UpgradeVersion::VERSION) { upgrade.set_hotshot_config_parameters(&mut config.config); } @@ -431,7 +428,7 @@ pub mod testing { eth_signature_key::EthKeyPair, mock::MockStateCatchup, v0::traits::{PersistenceOptions, StateCatchup}, - Event, FeeAccount, PubKey, SeqTypes, Transaction, Upgrade, + Event, FeeAccount, PubKey, SeqTypes, Transaction, Upgrade, UpgradeVersion, }; use futures::{ future::join_all, @@ -519,10 +516,7 @@ pub mod testing { } pub fn build(mut self) -> TestConfig { - if let Some(upgrade) = self - .upgrades - .get(&::Upgrade::VERSION) - { + if let Some(upgrade) = self.upgrades.get(&UpgradeVersion::VERSION) { upgrade.set_hotshot_config_parameters(&mut self.config) } @@ -813,7 +807,7 @@ pub mod testing { #[cfg(test)] mod test { - use espresso_types::{Header, NamespaceId, Payload, Transaction}; + use espresso_types::{BaseVersion, Header, NamespaceId, Payload, Transaction}; use futures::StreamExt; use hotshot::types::EventType::Decide; use hotshot_types::{ @@ -831,7 +825,7 @@ mod test { #[async_std::test] async fn test_skeleton_instantiation() { setup_test(); - let ver = ::Base::instance(); + let ver = BaseVersion::instance(); // Assign `config` so it isn't dropped early. let anvil = AnvilOptions::default().spawn().await; let url = anvil.url(); @@ -873,7 +867,7 @@ mod test { setup_test(); let success_height = 30; - let ver = ::Base::instance(); + let ver = BaseVersion::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 a56e551fb..762bbc6fc 100644 --- a/sequencer/src/main.rs +++ b/sequencer/src/main.rs @@ -1,10 +1,10 @@ use std::{net::ToSocketAddrs, sync::Arc}; use clap::Parser; -use espresso_types::{SequencerVersions, SolverAuctionResultsProvider}; +use espresso_types::{BaseVersion, SolverAuctionResultsProvider}; use futures::future::FutureExt; use hotshot::MarketplaceConfig; -use hotshot_types::traits::{metrics::NoMetrics, node_implementation::Versions}; +use hotshot_types::traits::metrics::NoMetrics; use sequencer::{ api::{self, data_source::DataSourceOptions}, init_node, @@ -22,28 +22,16 @@ 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, - ::Base::instance(), - ) - .await + init_with_storage(modules, opt, storage, BaseVersion::instance()).await } else if let Some(storage) = modules.storage_sql.take() { - init_with_storage( - modules, - opt, - storage, - ::Base::instance(), - ) - .await + init_with_storage(modules, opt, storage, BaseVersion::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(), - ::Base::instance(), + BaseVersion::instance(), ) .await } @@ -252,7 +240,7 @@ mod test { modules, opt, fs::Options::new(tmp.path().into()), - ::Base::instance(), + BaseVersion::instance(), ) .await { @@ -264,7 +252,7 @@ mod test { // orchestrator. tracing::info!("waiting for API to start"); let url: Url = format!("http://localhost:{port}").parse().unwrap(); - let client = Client::::Base>::new(url.clone()); + let client = Client::::new(url.clone()); assert!(client.connect(Some(Duration::from_secs(60))).await); client.get::<()>("healthcheck").send().await.unwrap(); diff --git a/sequencer/src/message_compat_tests.rs b/sequencer/src/message_compat_tests.rs index bd0dc2544..884896cda 100755 --- a/sequencer/src/message_compat_tests.rs +++ b/sequencer/src/message_compat_tests.rs @@ -17,7 +17,7 @@ use std::path::Path; use committable::Committable; -use espresso_types::{Leaf, NodeState, PubKey, SequencerVersions, ValidatedState}; +use espresso_types::{BaseVersion, Leaf, NodeState, PubKey, ValidatedState}; use hotshot::traits::election::static_committee::GeneralStaticCommittee; use hotshot_types::{ data::{ @@ -38,9 +38,7 @@ use hotshot_types::{ ViewSyncFinalizeVote, ViewSyncPreCommitData, ViewSyncPreCommitVote, }, traits::{ - node_implementation::{ConsensusTime, Versions}, - signature_key::SignatureKey, - BlockPayload, EncodeBytes, + node_implementation::ConsensusTime, signature_key::SignatureKey, BlockPayload, EncodeBytes, }, vid::vid_scheme, }; @@ -49,7 +47,7 @@ use pretty_assertions::assert_eq; use serde_json::Value; use vbs::{version::Version, BinarySerializer}; -type Serializer = vbs::Serializer<::Base>; +type Serializer = vbs::Serializer; #[async_std::test] #[cfg(feature = "testing")] diff --git a/types/src/v0/impls/auction.rs b/types/src/v0/impls/auction.rs index 4527ff999..17e94d11b 100644 --- a/types/src/v0/impls/auction.rs +++ b/types/src/v0/impls/auction.rs @@ -1,8 +1,8 @@ -use super::state::ValidatedState; +use super::{state::ValidatedState, BaseVersion}; use crate::{ eth_signature_key::{EthKeyPair, SigningError}, v0_3::{BidTx, BidTxBody, FullNetworkTx, SolverAuctionResults}, - FeeAccount, FeeAmount, FeeError, FeeInfo, NamespaceId, SequencerVersions, + FeeAccount, FeeAmount, FeeError, FeeInfo, NamespaceId, }; use anyhow::Context; use async_trait::async_trait; @@ -11,7 +11,7 @@ use hotshot_types::{ data::ViewNumber, traits::{ auction_results_provider::AuctionResultsProvider, - node_implementation::{ConsensusTime, HasUrls, NodeType, Versions}, + node_implementation::{ConsensusTime, HasUrls, NodeType}, signature_key::BuilderSignatureKey, }, }; @@ -279,7 +279,7 @@ impl HasUrls for SolverAuctionResults { } } -type SurfClient = surf_disco::Client::Base>; +type SurfClient = surf_disco::Client; #[derive(Debug, Clone, Eq, PartialEq, Hash)] /// Auction Results provider holding the Url of the solver in order to fetch auction results. diff --git a/types/src/v0/impls/header.rs b/types/src/v0/impls/header.rs index 3edb6b270..7c6cdfb2f 100644 --- a/types/src/v0/impls/header.rs +++ b/types/src/v0/impls/header.rs @@ -5,7 +5,7 @@ use hotshot_query_service::{availability::QueryableHeader, explorer::ExplorerHea use hotshot_types::{ traits::{ block_contents::{BlockHeader, BuilderFee}, - node_implementation::{NodeType, Versions}, + node_implementation::NodeType, signature_key::BuilderSignatureKey, BlockPayload, ValidatedState as _, }, @@ -28,7 +28,7 @@ use crate::{ v0_1, v0_2, v0_3::{self, ChainConfig, IterableFeeInfo, SolverAuctionResults}, BlockMerkleCommitment, BuilderSignature, FeeAccount, FeeAmount, FeeInfo, FeeMerkleCommitment, - Header, L1BlockInfo, L1Snapshot, Leaf, NamespaceId, NsTable, SeqTypes, SequencerVersions, + Header, L1BlockInfo, L1Snapshot, Leaf, MarketplaceVersion, NamespaceId, NsTable, SeqTypes, UpgradeType, }; @@ -425,7 +425,7 @@ impl Header { fee_amount, } in &builder_fee { - if version < ::Marketplace::version() { + if version < MarketplaceVersion::version() { ensure!( fee_account.validate_fee_signature( fee_signature, diff --git a/types/src/v0/impls/instance_state.rs b/types/src/v0/impls/instance_state.rs index ad66d4a7c..5ff664c16 100644 --- a/types/src/v0/impls/instance_state.rs +++ b/types/src/v0/impls/instance_state.rs @@ -1,15 +1,14 @@ -use crate::SequencerVersions; use crate::{ v0::traits::StateCatchup, v0_3::ChainConfig, GenesisHeader, L1BlockInfo, L1Client, PubKey, Timestamp, Upgrade, UpgradeMode, }; -use hotshot_types::traits::node_implementation::Versions; use hotshot_types::traits::states::InstanceState; use hotshot_types::HotShotConfig; use std::{collections::BTreeMap, sync::Arc}; use vbs::version::{StaticVersionType, Version}; use super::state::ValidatedState; +use super::BaseVersion; /// Represents the immutable state of a node. /// @@ -61,7 +60,7 @@ impl NodeState { }, l1_genesis: None, upgrades: Default::default(), - current_version: ::Base::version(), + current_version: BaseVersion::version(), } } diff --git a/types/src/v0/mod.rs b/types/src/v0/mod.rs index 57582eeca..1ee0b0c38 100644 --- a/types/src/v0/mod.rs +++ b/types/src/v0/mod.rs @@ -135,20 +135,26 @@ impl NodeType for SeqTypes { type BuilderSignatureKey = FeeAccount; type AuctionResult = SolverAuctionResults; } -#[derive(Clone, Debug, Copy)] -pub struct SequencerVersions {} + +#[derive(Debug, Copy, Clone)] +pub struct SequencerVersions; impl Versions for SequencerVersions { type Base = StaticVersion<0, 1>; type Upgrade = StaticVersion<0, 2>; + type Marketplace = StaticVersion<0, 3>; + const UPGRADE_HASH: [u8; 32] = [ 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, ]; - - type Marketplace = StaticVersion<0, 3>; } +/// Type aliases for readability +pub type BaseVersion = ::Base; +pub type UpgradeVersion = ::Upgrade; +pub type MarketplaceVersion = ::Marketplace; + pub type Leaf = hotshot_types::data::Leaf; pub type Event = hotshot::types::Event;