Skip to content

Commit

Permalink
Merge pull request #1372 from EspressoSystems/jb/builder-config
Browse files Browse the repository at this point in the history
Remove unused parameters from permissionless builder
  • Loading branch information
jbearer authored Apr 23, 2024
2 parents c291cca + c94cdbf commit 7caed14
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 74 deletions.
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
84 changes: 14 additions & 70 deletions builder/src/bin/permissionless-builder.rs
Original file line number Diff line number Diff line change
@@ -1,91 +1,58 @@
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(
long,
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(
Expand All @@ -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(
Expand All @@ -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<()> {
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7caed14

Please sign in to comment.