Skip to content

Commit

Permalink
remove es_version crate
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit committed Jul 31, 2024
1 parent ac42ca0 commit 99129e3
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 95 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ blake3 = "1.5"
clap = { version = "4.4", features = ["derive", "env", "string"] }
cld = "0.5"
derive_more = "0.99.17"
es-version = { git = "https://github.com/EspressoSystems/es-version.git", branch = "main" }
dotenvy = "0.15"
ethers = { version = "2.0", features = ["solc"] }
futures = "0.3"
Expand Down
1 change: 0 additions & 1 deletion builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ clap = { workspace = true }
cld = { workspace = true }
committable = { workspace = true }
dotenvy = { workspace = true }
es-version = { workspace = true }
espresso-types = { path = "../types", features = ["testing"] }
ethers = { workspace = true }
futures = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions builder/src/bin/permissioned-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
use anyhow::{bail, Context};
use builder::permissioned::init_node;
use clap::Parser;
use es_version::SEQUENCER_VERSION;
use espresso_types::eth_signature_key::EthKeyPair;
use ethers::types::Address;
use hotshot_types::{
Expand All @@ -20,6 +19,7 @@ use sequencer::{
};
use sequencer_utils::logging;
use url::Url;
use vbs::version::{StaticVersion, StaticVersionType};

#[derive(Parser, Clone, Debug)]
pub struct PermissionedBuilderOptions {
Expand Down Expand Up @@ -260,7 +260,7 @@ async fn main() -> anyhow::Result<()> {
catchup_backoff: Default::default(),
};

let sequencer_version = SEQUENCER_VERSION;
let sequencer_version = StaticVersion::<0, 1>::instance();

let builder_server_url: Url = format!("http://0.0.0.0:{}", opt.port).parse().unwrap();

Expand Down
7 changes: 3 additions & 4 deletions builder/src/bin/permissionless-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ use std::{num::NonZeroUsize, path::PathBuf, str::FromStr, time::Duration};
use builder::non_permissioned::{build_instance_state, BuilderConfig};
use clap::Parser;
use cld::ClDuration;
use espresso_types::{eth_signature_key::EthKeyPair, SeqTypes};
use espresso_types::eth_signature_key::EthKeyPair;
use hotshot::traits::ValidatedState;
use hotshot_builder_core::testing::basic_test::NodeType;
use hotshot_types::{data::ViewNumber, traits::node_implementation::ConsensusTime};
use sequencer::{Genesis, L1Params};
use sequencer_utils::logging;
use snafu::Snafu;
use url::Url;
use vbs::version::StaticVersionType;
use vbs::version::{StaticVersion, StaticVersionType};

#[derive(Parser, Clone, Debug)]
struct NonPermissionedBuilderOptions {
Expand Down Expand Up @@ -123,7 +122,7 @@ async fn main() -> anyhow::Result<()> {
genesis.chain_config,
l1_params,
opt.state_peers,
<SeqTypes as NodeType>::Base::instance(),
StaticVersion::<0, 1>::instance(),
)
.unwrap();

Expand Down
18 changes: 11 additions & 7 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use sequencer::{
L1Params, NetworkParams, Node,
};
use tide_disco::{app, method::ReadState, App, Url};
use vbs::version::StaticVersionType;
use vbs::version::{StaticVersion, StaticVersionType};

pub mod non_permissioned;
pub mod permissioned;
Expand All @@ -86,7 +86,7 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState<SeqTypes>) {
let private_mempool_api = hotshot_builder_api::v0_1::builder::submit_api::<
ProxyGlobalState<SeqTypes>,
SeqTypes,
<SeqTypes as NodeType>::Base,
StaticVersion<0, 1>,
>(&HotshotBuilderApiOptions::default())
.expect("Failed to construct the builder API for private mempool txns");

Expand All @@ -98,7 +98,7 @@ pub fn run_builder_api_service(url: Url, source: ProxyGlobalState<SeqTypes>) {
app.register_module("txn_submit", private_mempool_api)
.expect("Failed to register the private mempool API");

async_spawn(app.serve(url, <SeqTypes as NodeType>::Base::instance()));
async_spawn(app.serve(url, StaticVersion::<0, 1>::instance()));
}

#[cfg(test)]
Expand All @@ -118,6 +118,7 @@ pub mod testing {
use async_lock::RwLock;
use async_trait::async_trait;
use committable::Committable;

use espresso_types::{
mock::MockStateCatchup, v0_3::ChainConfig, Event, FeeAccount, L1Client, NodeState, PrivKey,
PubKey, Transaction, ValidatedState,
Expand Down Expand Up @@ -406,6 +407,7 @@ pub mod testing {
L1Client::new(self.anvil.endpoint().parse().unwrap(), 1),
MockStateCatchup::default(),
)
.with_current_version(Ver::VERSION)
.with_genesis(ValidatedState::default());

tracing::info!("Before init hotshot");
Expand Down Expand Up @@ -448,7 +450,7 @@ pub mod testing {
let hotshot_events_api = hotshot_events_service::events::define_api::<
Arc<RwLock<EventsStreamer<SeqTypes>>>,
SeqTypes,
<SeqTypes as NodeType>::Base,
StaticVersion<0, 1>,
>(&EventStreamingApiOptions::default())
.expect("Failed to define hotshot eventsAPI");

Expand All @@ -457,7 +459,7 @@ pub mod testing {
app.register_module("hotshot-events", hotshot_events_api)
.expect("Failed to register hotshot events API");

async_spawn(app.serve(url, <SeqTypes as NodeType>::Base::instance()));
async_spawn(app.serve(url, StaticVersion::<0, 1>::instance()));
}
// enable hotshot event streaming
pub fn enable_hotshot_node_event_streaming<P: SequencerPersistence>(
Expand Down Expand Up @@ -547,6 +549,7 @@ pub mod testing {
),
MockStateCatchup::default(),
)
.with_current_version(StaticVersion::<0, 1>::VERSION)
.with_genesis(ValidatedState::default());

// generate builder keys
Expand Down Expand Up @@ -615,6 +618,7 @@ pub mod testing {
),
MockStateCatchup::default(),
)
.with_current_version(Ver::VERSION)
.with_genesis(ValidatedState::default());

// generate builder keys
Expand Down Expand Up @@ -670,7 +674,6 @@ pub mod testing {
mod test {
use async_std::stream::IntoStream;
use clap::builder;
use es_version::SequencerVersion;
use espresso_types::{Header, NodeState, Payload, ValidatedState};
use ethers::providers::Quorum;
use futures::StreamExt;
Expand All @@ -686,6 +689,7 @@ mod test {
};
use sequencer_utils::test_utils::setup_test;
use testing::{wait_for_decide_on_handle, HotShotTestConfig};
use vbs::version::StaticVersion;

use super::*;

Expand All @@ -697,7 +701,7 @@ mod test {
async fn test_non_voting_hotshot_node() {
setup_test();

let ver = SequencerVersion::instance();
let ver = StaticVersion::<0, 1>::instance();

let success_height = 5;
// Assign `config` so it isn't dropped early.
Expand Down
12 changes: 6 additions & 6 deletions builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ mod test {
};
use async_lock::RwLock;
use async_std::task;
use es_version::SequencerVersion;
use espresso_types::{FeeAccount, NamespaceId, Transaction};
use hotshot_builder_api::v0_1::{
block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo},
Expand Down Expand Up @@ -257,6 +256,7 @@ mod test {
use sequencer::persistence::no_storage::{self, NoStorage};
use sequencer_utils::test_utils::setup_test;
use surf_disco::Client;
use vbs::version::StaticVersion;

use super::*;
use crate::testing::{
Expand All @@ -270,7 +270,7 @@ mod test {
async fn test_non_permissioned_builder() {
setup_test();

let ver = SequencerVersion::instance();
let ver = StaticVersion::<0, 1>::instance();
// Hotshot Test Config
let hotshot_config = HotShotTestConfig::default();

Expand Down Expand Up @@ -316,10 +316,10 @@ mod test {
let builder_pub_key = builder_config.fee_account;

// Start a builder api client
let builder_client = Client::<
hotshot_builder_api::v0_1::builder::Error,
<SeqTypes as NodeType>::Base,
>::new(hotshot_builder_api_url.clone());
let builder_client =
Client::<hotshot_builder_api::v0_1::builder::Error, StaticVersion<0, 1>>::new(
hotshot_builder_api_url.clone(),
);
assert!(builder_client.connect(Some(Duration::from_secs(60))).await);

let seed = [207_u8; 32];
Expand Down
13 changes: 7 additions & 6 deletions builder/src/permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ mod test {
use async_compatibility_layer::art::{async_sleep, async_spawn};
use async_lock::RwLock;
use async_std::task;
use es_version::SequencerVersion;

use espresso_types::{FeeAccount, NamespaceId, Transaction};
use hotshot_builder_api::v0_1::{
block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo},
Expand Down Expand Up @@ -581,6 +581,7 @@ mod test {
use sequencer::persistence::no_storage::{self, NoStorage};
use sequencer_utils::test_utils::setup_test;
use surf_disco::Client;
use vbs::version::StaticVersion;

use super::*;
use crate::{
Expand All @@ -595,7 +596,7 @@ mod test {
async fn test_permissioned_builder() {
setup_test();

let ver = SequencerVersion::instance();
let ver = StaticVersion::<0, 1>::instance();

// Hotshot Test Config
let hotshot_config = HotShotTestConfig::default();
Expand Down Expand Up @@ -629,10 +630,10 @@ mod test {
let builder_pub_key = builder_config.fee_account;

// Start a builder api client
let builder_client = Client::<
hotshot_builder_api::v0_1::builder::Error,
<SeqTypes as NodeType>::Base,
>::new(hotshot_builder_api_url.clone());
let builder_client =
Client::<hotshot_builder_api::v0_1::builder::Error, StaticVersion<0, 1>>::new(
hotshot_builder_api_url.clone(),
);
assert!(builder_client.connect(Some(Duration::from_secs(60))).await);

let seed = [207_u8; 32];
Expand Down
2 changes: 1 addition & 1 deletion hotshot-state-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ clap = { workspace = true }
cld = { workspace = true }
contract-bindings = { path = "../contract-bindings" }
displaydoc = { version = "0.2.3", default-features = false }
es-version = { workspace = true }
espresso-types = { path = "../types", features = ["testing"] }
ethers = { workspace = true }
futures = { workspace = true }
hotshot-contract-adapter = { workspace = true }
Expand Down
9 changes: 6 additions & 3 deletions hotshot-state-prover/src/bin/state-prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ use std::{str::FromStr as _, time::Duration};

use clap::Parser;
use cld::ClDuration;
use es_version::SEQUENCER_VERSION;
use espresso_types::SeqTypes;
use ethers::{
providers::{Http, Middleware, Provider},
signers::{coins_bip39::English, MnemonicBuilder, Signer},
types::Address,
};
use hotshot_stake_table::config::STAKE_TABLE_CAPACITY;
use hotshot_state_prover::service::{run_prover_once, run_prover_service, StateProverConfig};
use hotshot_types::traits::node_implementation::NodeType;
use sequencer_utils::logging;
use snafu::Snafu;
use url::Url;
use vbs::version::StaticVersionType;

#[derive(Parser)]
struct Args {
Expand Down Expand Up @@ -126,12 +128,13 @@ async fn main() {

if args.daemon {
// Launching the prover service daemon
if let Err(err) = run_prover_service(config, SEQUENCER_VERSION).await {
if let Err(err) = run_prover_service(config, <SeqTypes as NodeType>::Base::instance()).await
{
tracing::error!("Error running prover service: {:?}", err);
};
} else {
// Run light client state update once
if let Err(err) = run_prover_once(config, SEQUENCER_VERSION).await {
if let Err(err) = run_prover_once(config, <SeqTypes as NodeType>::Base::instance()).await {
tracing::error!("Error running prover once: {:?}", err);
};
}
Expand Down
1 change: 0 additions & 1 deletion sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ csv = "1"
derivative = "2.2"
derive_more = { workspace = true }
dotenvy = { workspace = true }
es-version = { workspace = true }
espresso-types = { path = "../types", features = ["testing"] }
ethers = { workspace = true }
futures = { workspace = true }
Expand Down
28 changes: 20 additions & 8 deletions sequencer/src/bin/commitment-task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use std::{io, time::Duration};

use async_std::task::spawn;
use clap::Parser;
use es_version::SEQUENCER_VERSION;
use espresso_types::SeqTypes;
use ethers::prelude::*;
use futures::FutureExt;
use hotshot_types::traits::node_implementation::NodeType;
use sequencer::{
hotshot_commitment::{run_hotshot_commitment_task, CommitmentTaskOptions},
options::parse_duration,
Expand Down Expand Up @@ -68,7 +69,12 @@ async fn main() {
opt.logging.init();

if let Some(port) = opt.port {
start_http_server(port, opt.hotshot_address, SEQUENCER_VERSION).unwrap();
start_http_server(
port,
opt.hotshot_address,
<SeqTypes as NodeType>::Base::instance(),
)
.unwrap();
}

let hotshot_contract_options = CommitmentTaskOptions {
Expand All @@ -82,7 +88,7 @@ async fn main() {
query_service_url: Some(opt.sequencer_url),
};
tracing::info!("Launching HotShot commitment task..");
run_hotshot_commitment_task::<es_version::SequencerVersion>(&hotshot_contract_options).await;
run_hotshot_commitment_task::<<SeqTypes as NodeType>::Base>(&hotshot_contract_options).await;
}

fn start_http_server<Ver: StaticVersionType + 'static>(
Expand Down Expand Up @@ -111,10 +117,12 @@ fn start_http_server<Ver: StaticVersionType + 'static>(

#[cfg(test)]
mod test {
use es_version::{SequencerVersion, SEQUENCER_VERSION};
use espresso_types::SeqTypes;
use hotshot_types::traits::node_implementation::NodeType;
use portpicker::pick_unused_port;
use sequencer_utils::test_utils::setup_test;
use surf_disco::Client;
use vbs::version::StaticVersionType;

use super::{start_http_server, Address, ServerError};

Expand All @@ -126,10 +134,14 @@ mod test {
let expected_addr = "0xED15E1FE0789c524398137a066ceb2EF9884E5D8"
.parse::<Address>()
.unwrap();
start_http_server(port, expected_addr, SEQUENCER_VERSION)
.expect("Failed to start the server");

let client: Client<ServerError, SequencerVersion> =
start_http_server(
port,
expected_addr,
<SeqTypes as NodeType>::Base::instance(),
)
.expect("Failed to start the server");

let client: Client<ServerError, <SeqTypes as NodeType>::Base> =
Client::new(format!("http://localhost:{port}").parse().unwrap());
client.connect(None).await;

Expand Down
Loading

0 comments on commit 99129e3

Please sign in to comment.