From c94cdbfa03e2cfeeb034b228882c5a6aafc1d3f0 Mon Sep 17 00:00:00 2001 From: Jeb Bearer <jeb@espressosys.com> Date: Tue, 23 Apr 2024 14:10:42 -0400 Subject: [PATCH] Remove unused parameters from permissionless builder --- .env | 2 - builder/src/bin/permissionless-builder.rs | 84 ++++------------------- docker-compose.yaml | 2 - 3 files changed, 14 insertions(+), 74 deletions(-) diff --git a/.env b/.env index 7d71dd5b09..737093ea02 100644 --- a/.env +++ b/.env @@ -98,8 +98,6 @@ ESPRESSO_STATE_PROVER_UPDATE_INTERVAL=10m ESPRESSO_BUILDER_L1_PROVIDER=${ESPRESSO_SEQUENCER_L1_PROVIDER} ESPRESSO_BUILDER_ETH_MNEMONIC=${ESPRESSO_SEQUENCER_ETH_MNEMONIC} ESPRESSO_BUILDER_SERVER_PORT=41003 -ESPRESSO_BUILDER_PRIVATE_STAKING_KEY=BLS_SIGNING_KEY~tI9He_sCnEbfEajycUXz9Scfy6ocLr0yL9ceD53s8QPa -ESPRESSO_BUILDER_PRIVATE_STATE_KEY=SCHNORR_SIGNING_KEY~IftHINvgzqcd9agX13HHY3Uhz8vsH46i8soKgV7ZUQV- ESPRESSO_BUILDER_CHANNEL_CAPACITY=1024 ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW=0 ESPRESSO_BUILDER_WEBSERVER_RESPONSE_TIMEOUT_DURATION=1s diff --git a/builder/src/bin/permissionless-builder.rs b/builder/src/bin/permissionless-builder.rs index c1ef722abc..3424fb88c5 100644 --- a/builder/src/bin/permissionless-builder.rs +++ b/builder/src/bin/permissionless-builder.rs @@ -1,22 +1,19 @@ -use anyhow::{bail, Context}; use async_compatibility_layer::logging::{setup_backtrace, setup_logging}; use builder::non_permissioned::{build_instance_state, BuilderConfig}; use clap::Parser; use cld::ClDuration; use es_version::SEQUENCER_VERSION; use hotshot_types::data::ViewNumber; -use hotshot_types::light_client::StateSignKey; -use hotshot_types::signature_key::BLSPrivKey; use hotshot_types::traits::node_implementation::ConsensusTime; use sequencer::eth_signature_key::EthKeyPair; use sequencer::{BuilderParams, L1Params}; use snafu::Snafu; use std::num::NonZeroUsize; -use std::{collections::HashMap, path::PathBuf, str::FromStr, time::Duration}; +use std::{str::FromStr, time::Duration}; use url::Url; #[derive(Parser, Clone, Debug)] -pub struct NonPermissionedBuilderOptions { +struct NonPermissionedBuilderOptions { /// URL of hotshot events API running on Espresso Sequencer DA committee node /// The builder will subscribe to this server to receive hotshot events #[clap( @@ -24,68 +21,38 @@ pub struct NonPermissionedBuilderOptions { env = "ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_URL", default_value = "http://localhost:8081" )] - pub hotshot_event_streaming_url: Url, - - /// Path to file containing private keys. - /// - /// The file should follow the .env format, with two keys: - /// * ESPRESSO_BUILDER_PRIVATE_STAKING_KEY - /// * ESPRESSO_BUILDER_PRIVATE_STATE_KEY - /// - /// Appropriate key files can be generated with the `keygen` utility program. - #[clap(long, name = "KEY_FILE", env = "ESPRESSO_BUILDER_KEY_FILE")] - pub key_file: Option<PathBuf>, - - /// Private staking key. - /// - /// This can be used as an alternative to KEY_FILE. - #[clap( - long, - env = "ESPRESSO_BUILDER_PRIVATE_STAKING_KEY", - conflicts_with = "key_file" - )] - pub private_staking_key: Option<BLSPrivKey>, - - /// Private state signing key. - /// - /// This can be used as an alternative to KEY_FILE. - #[clap( - long, - env = "ESPRESSO_BUILDER_PRIVATE_STATE_KEY", - conflicts_with = "key_file" - )] - pub private_state_key: Option<StateSignKey>, + hotshot_event_streaming_url: Url, /// Mnemonic phrase for builder account. /// /// This is the address fees will be charged to. /// It must be funded with ETH in the Espresso fee ledger #[clap(long, env = "ESPRESSO_BUILDER_ETH_MNEMONIC")] - pub eth_mnemonic: String, + eth_mnemonic: String, /// Index of a funded account derived from eth-mnemonic. #[clap(long, env = "ESPRESSO_BUILDER_ETH_ACCOUNT_INDEX", default_value = "8")] - pub eth_account_index: u32, + eth_account_index: u32, /// Url we will use for RPC communication with L1. #[clap(long, env = "ESPRESSO_BUILDER_L1_PROVIDER")] - pub l1_provider_url: Url, + l1_provider_url: Url, /// Peer nodes use to fetch missing state #[clap(long, env = "ESPRESSO_SEQUENCER_STATE_PEERS", value_delimiter = ',')] - pub state_peers: Vec<Url>, + state_peers: Vec<Url>, /// Port to run the builder server on. #[clap(short, long, env = "ESPRESSO_BUILDER_SERVER_PORT")] - pub port: u16, + port: u16, /// Bootstrapping View number #[clap(short, long, env = "ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW")] - pub view_number: u64, + view_number: u64, /// BUILDER CHANNEL CAPACITY #[clap(short, long, env = "ESPRESSO_BUILDER_CHANNEL_CAPACITY")] - pub channel_capacity: NonZeroUsize, + channel_capacity: NonZeroUsize, /// The amount of time a builder can wait before timing out a request to the API. #[clap( @@ -95,7 +62,7 @@ pub struct NonPermissionedBuilderOptions { default_value = "1s", value_parser = parse_duration )] - pub max_api_timeout_duration: Duration, + max_api_timeout_duration: Duration, /// The number of views to buffer before a builder garbage collects its state #[clap( @@ -104,44 +71,21 @@ pub struct NonPermissionedBuilderOptions { env = "ESPRESSO_BUILDER_BUFFER_VIEW_NUM_COUNT", default_value = "15" )] - pub buffer_view_num_count: usize, + buffer_view_num_count: usize, } #[derive(Clone, Debug, Snafu)] -pub struct ParseDurationError { +struct ParseDurationError { reason: String, } -pub fn parse_duration(s: &str) -> Result<Duration, ParseDurationError> { +fn parse_duration(s: &str) -> Result<Duration, ParseDurationError> { ClDuration::from_str(s) .map(Duration::from) .map_err(|err| ParseDurationError { reason: err.to_string(), }) } -impl NonPermissionedBuilderOptions { - pub fn private_keys(&self) -> anyhow::Result<(BLSPrivKey, StateSignKey)> { - if let Some(path) = &self.key_file { - let vars = dotenvy::from_path_iter(path)?.collect::<Result<HashMap<_, _>, _>>()?; - let staking = vars - .get("ESPRESSO_BUILDER_PRIVATE_STAKING_KEY") - .context("key file missing ESPRESSO_BUILDER_PRIVATE_STAKING_KEY")? - .parse()?; - let state = vars - .get("ESPRESSO_BUILDER_PRIVATE_STATE_KEY") - .context("key file missing ESPRESSO_BUILDER_PRIVATE_STATE_KEY")? - .parse()?; - Ok((staking, state)) - } else if let (Some(staking), Some(state)) = ( - self.private_staking_key.clone(), - self.private_state_key.clone(), - ) { - Ok((staking, state)) - } else { - bail!("neither key file nor full set of private keys was provided") - } - } -} #[async_std::main] async fn main() -> anyhow::Result<()> { diff --git a/docker-compose.yaml b/docker-compose.yaml index 4170c9b659..24263ef2cc 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -419,8 +419,6 @@ services: environment: - ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_URL=http://sequencer0:$ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_PORT - ESPRESSO_SEQUENCER_STATE_PEERS=http://sequencer0:$ESPRESSO_SEQUENCER_API_PORT - - ESPRESSO_BUILDER_PRIVATE_STAKING_KEY - - ESPRESSO_BUILDER_PRIVATE_STATE_KEY - ESPRESSO_BUILDER_ETH_MNEMONIC - ESPRESSO_BUILDER_ETH_ACCOUNT_INDEX - ESPRESSO_BUILDER_L1_PROVIDER