diff --git a/Cargo.lock b/Cargo.lock index b4a98898d..29cff4ef6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1303,7 +1303,6 @@ dependencies = [ "cld", "committable", "dotenvy", - "es-version", "espresso-types 0.1.0", "ethers", "futures", @@ -2020,7 +2019,7 @@ dependencies = [ [[package]] name = "contract-bindings" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "ethers", "serde", @@ -2928,7 +2927,6 @@ dependencies = [ "committable", "contract-bindings 0.1.0", "derive_more", - "es-version", "ethers", "fluent-asserter", "futures", @@ -2964,7 +2962,7 @@ dependencies = [ [[package]] name = "espresso-types" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "anyhow", "ark-serialize", @@ -4226,7 +4224,7 @@ dependencies = [ [[package]] name = "hotshot-contract-adapter" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "anyhow", "ark-bn254", @@ -4457,7 +4455,7 @@ dependencies = [ "cld", "contract-bindings 0.1.0", "displaydoc", - "es-version", + "espresso-types 0.1.0", "ethers", "futures", "hotshot-contract-adapter 0.1.0", @@ -8504,7 +8502,6 @@ dependencies = [ "derivative", "derive_more", "dotenvy", - "es-version", "escargot", "espresso-macros", "espresso-types 0.1.0", @@ -8586,7 +8583,7 @@ dependencies = [ [[package]] name = "sequencer-utils" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#6d52a7e331a5517d9c19ea459ee18947f6c567cc" +source = "git+https://github.com/EspressoSystems/espresso-sequencer.git?branch=main#ac42ca041b6ab41f12417fa8e3d8cd9f1b7e22b8" dependencies = [ "anyhow", "ark-serialize", diff --git a/sequencer/src/api.rs b/sequencer/src/api.rs index a1ccafaa2..e31cfbb1d 100644 --- a/sequencer/src/api.rs +++ b/sequencer/src/api.rs @@ -360,7 +360,7 @@ pub mod test_helpers { use async_std::task::sleep; use committable::Committable; - use es_version::{SequencerVersion, SEQUENCER_VERSION}; + use espresso_types::{ mock::MockStateCatchup, v0::traits::{PersistenceOptions, StateCatchup}, @@ -373,6 +373,7 @@ pub mod test_helpers { }; use hotshot::types::{Event, EventType}; use hotshot_contract_adapter::light_client::ParsedLightClientState; + use hotshot_types::traits::node_implementation::NodeType; use hotshot_types::{ event::LeafInfo, traits::{metrics::NoMetrics, node_implementation::ConsensusTime}, @@ -392,9 +393,13 @@ pub mod test_helpers { pub const STAKE_TABLE_CAPACITY_FOR_TEST: u64 = 10; - pub struct TestNetwork { - pub server: SequencerContext, - pub peers: Vec>, + pub struct TestNetwork< + P: PersistenceOptions, + const NUM_NODES: usize, + Ver: StaticVersionType + 'static, + > { + pub server: SequencerContext, + pub peers: Vec>, pub cfg: TestConfig<{ NUM_NODES }>, } @@ -507,9 +512,12 @@ pub mod test_helpers { } } - impl TestNetwork { + impl + TestNetwork + { pub async fn new( cfg: TestNetworkConfig<{ NUM_NODES }, P, C>, + _bind_ver: Ver, ) -> Self { let mut cfg = cfg; let (builder_task, builder_url) = @@ -538,14 +546,14 @@ pub mod test_helpers { catchup, &*metrics, STAKE_TABLE_CAPACITY_FOR_TEST, - SEQUENCER_VERSION, + Ver::instance(), upgrades_map, ) .await } .boxed() }, - SEQUENCER_VERSION, + Ver::instance(), ) .await .unwrap() @@ -557,7 +565,7 @@ pub mod test_helpers { catchup, &NoMetrics, STAKE_TABLE_CAPACITY_FOR_TEST, - SEQUENCER_VERSION, + Ver::instance(), upgrades_map, ) .await @@ -612,7 +620,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port).status(Default::default())); let anvil = Anvil::new().spawn(); @@ -622,7 +630,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let _network = TestNetwork::new(config).await; + let _network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; // The status API is well tested in the query service repo. Here we are just smoke testing @@ -664,7 +672,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port).submit(Default::default())); let anvil = Anvil::new().spawn(); @@ -674,7 +682,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; let mut events = network.server.event_stream().await; client.connect(None).await; @@ -699,7 +707,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port)); let anvil = Anvil::new().spawn(); @@ -709,7 +717,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; let mut height: u64; // Wait for block >=2 appears @@ -741,7 +749,7 @@ pub mod test_helpers { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = opt(Options::with_port(port).catchup(Default::default())); let anvil = Anvil::new().spawn(); @@ -751,7 +759,7 @@ pub mod test_helpers { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; // Wait for a few blocks to be decided. @@ -831,11 +839,12 @@ mod api_tests { use committable::Committable; use data_source::testing::TestableSequencerDataSource; use endpoints::NamespaceProofQueryData; - use es_version::SequencerVersion; + use espresso_types::{Header, NamespaceId}; use ethers::utils::Anvil; use futures::stream::StreamExt; use hotshot_query_service::availability::{LeafQueryData, VidCommonQueryData}; + use hotshot_types::traits::node_implementation::NodeType; use portpicker::pick_unused_port; use sequencer_utils::test_utils::setup_test; use surf_disco::Client; @@ -885,11 +894,11 @@ mod api_tests { .api_config(D::options(&storage, Options::with_port(port)).submit(Default::default())) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; let mut events = network.server.event_stream().await; // Connect client. - let client: Client = + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; @@ -988,7 +997,7 @@ mod api_tests { events_service_port: hotshot_event_streaming_port, }; - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = Options::with_port(query_service_port).hotshot_events(hotshot_events); @@ -999,7 +1008,7 @@ mod api_tests { .api_config(options) .network_config(network_config) .build(); - let _network = TestNetwork::new(config).await; + let _network = TestNetwork::new(config, ::Base::instance()).await; let mut subscribed_events = client .socket("hotshot-events/events") @@ -1032,7 +1041,7 @@ mod test { use async_std::task::sleep; use committable::{Commitment, Committable}; - use es_version::{SequencerVersion, SEQUENCER_VERSION}; + use espresso_types::{ mock::MockStateCatchup, v0_1::{UpgradeMode, ViewBasedUpgrade}, @@ -1065,7 +1074,6 @@ mod test { TestNetwork, TestNetworkConfigBuilder, }; use tide_disco::{app::AppHealth, error::ServerError, healthcheck::HealthStatus}; - use vbs::version::Version; use self::{ data_source::{testing::TestableSequencerDataSource, PublicHotShotConfig}, @@ -1084,7 +1092,7 @@ mod test { let port = pick_unused_port().expect("No ports free"); let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); let options = Options::with_port(port); let anvil = Anvil::new().spawn(); let l1 = anvil.endpoint().parse().unwrap(); @@ -1093,7 +1101,7 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let _network = TestNetwork::new(config).await; + let _network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; let health = client.get::("healthcheck").send().await.unwrap(); @@ -1141,9 +1149,9 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; let url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url); + let client: Client::Base> = Client::new(url); client.connect(None).await; @@ -1206,13 +1214,13 @@ mod test { .api_config(Options::with_port(port).catchup(Default::default())) .network_config(TestConfigBuilder::default().l1_url(l1).build()) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) })) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Wait for replica 0 to reach a (non-genesis) decide, before disconnecting it. let mut events = network.peers[0].event_stream().await; @@ -1250,13 +1258,13 @@ mod test { 1, ValidatedState::default(), no_storage::Options, - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ), &NoMetrics, test_helpers::STAKE_TABLE_CAPACITY_FOR_TEST, - SEQUENCER_VERSION, + ::Base::instance(), Default::default(), ) .await; @@ -1313,7 +1321,7 @@ mod test { .api_config(Options::with_port(port).catchup(Default::default())) .states(states) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1321,7 +1329,7 @@ mod test { .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Wait for few blocks to be decided. network @@ -1390,7 +1398,7 @@ mod test { ) .states(states) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1398,7 +1406,7 @@ mod test { .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Wait for a few blocks to be decided. network @@ -1463,7 +1471,7 @@ mod test { .status(Default::default()), ) .catchups(std::array::from_fn(|_| { - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) @@ -1476,7 +1484,7 @@ mod test { ) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; let mut events = network.server.event_stream().await; loop { @@ -1486,14 +1494,14 @@ mod test { EventType::UpgradeProposal { proposal, .. } => { let upgrade = proposal.data.upgrade_proposal; let new_version = upgrade.new_version; - assert_eq!(new_version, Version { major: 0, minor: 2 }); + assert_eq!(new_version, ::Upgrade::VERSION); break; } _ => continue, } } - let client: Client = + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1551,10 +1559,10 @@ mod test { .persistences(persistence) .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let mut network = TestNetwork::new(config).await; + let mut network = TestNetwork::new(config, ::Base::instance()).await; // Connect client. - let client: Client = + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1621,15 +1629,15 @@ mod test { // Catchup using node 0 as a peer. Node 0 was running the archival state service // before the restart, so it should be able to resume without catching up by loading // state from storage. - StatePeers::::from_urls( + StatePeers::<::Base>::from_urls( vec![format!("http://localhost:{port}").parse().unwrap()], Default::default(), ) })) .network_config(TestConfigBuilder::default().l1_url(l1).build()) .build(); - let _network = TestNetwork::new(config).await; - let client: Client = + let _network = TestNetwork::new(config, ::Base::instance()).await; + let client: Client::Base> = Client::new(format!("http://localhost:{port}").parse().unwrap()); client.connect(None).await; tracing::info!(port, "server running"); @@ -1670,7 +1678,7 @@ mod test { let port = pick_unused_port().expect("No ports free"); let url: surf_disco::Url = format!("http://localhost:{port}").parse().unwrap(); - let client: Client = Client::new(url.clone()); + let client: Client::Base> = Client::new(url.clone()); let options = Options::with_port(port).config(Default::default()); let anvil = Anvil::new().spawn(); @@ -1680,12 +1688,12 @@ mod test { .api_config(options) .network_config(network_config) .build(); - let network = TestNetwork::new(config).await; + let network = TestNetwork::new(config, ::Base::instance()).await; client.connect(None).await; // Fetch a network config from the API server. The first peer URL is bogus, to test the // failure/retry case. - let peers = StatePeers::::from_urls( + let peers = StatePeers::<::Base>::from_urls( vec!["https://notarealnode.network".parse().unwrap(), url], Default::default(), ); diff --git a/sequencer/src/message_compat_tests.rs b/sequencer/src/message_compat_tests.rs index 1ddfe19a7..85cf2e54d 100644 --- a/sequencer/src/message_compat_tests.rs +++ b/sequencer/src/message_compat_tests.rs @@ -17,8 +17,7 @@ use std::path::Path; use committable::Committable; -use es_version::SequencerVersion; -use espresso_types::{Leaf, NodeState, PubKey, ValidatedState}; +use espresso_types::{Leaf, NodeState, PubKey, SeqTypes, ValidatedState}; use hotshot::traits::election::static_committee::GeneralStaticCommittee; use hotshot_types::{ data::{ @@ -39,7 +38,9 @@ use hotshot_types::{ ViewSyncFinalizeVote, ViewSyncPreCommitData, ViewSyncPreCommitVote, }, traits::{ - node_implementation::ConsensusTime, signature_key::SignatureKey, BlockPayload, EncodeBytes, + node_implementation::{ConsensusTime, NodeType}, + signature_key::SignatureKey, + BlockPayload, EncodeBytes, }, vid::vid_scheme, }; @@ -48,7 +49,7 @@ use pretty_assertions::assert_eq; use serde_json::Value; use vbs::{version::Version, BinarySerializer}; -type Serializer = vbs::Serializer; +type Serializer = vbs::Serializer<::Base>; #[async_std::test] #[cfg(feature = "testing")]