Skip to content

Commit

Permalink
Merge pull request #1435 from EspressoSystems/jb/fix-demo
Browse files Browse the repository at this point in the history
Make builder aware of maximum block size
  • Loading branch information
jbearer authored May 8, 2024
2 parents 54487da + 2a25106 commit 60344e3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ESPRESSO_SEQUENCER1_API_PORT=44001
ESPRESSO_SEQUENCER2_API_PORT=44002
ESPRESSO_SEQUENCER3_API_PORT=44003
ESPRESSO_SEQUENCER4_API_PORT=44004
ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE=10kb
ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE=1mb
ESPRESSO_SEQUENCER_BASE_FEE=1
ESPRESSO_SEQUENCER_URL=http://sequencer0:${ESPRESSO_SEQUENCER_API_PORT}
ESPRESSO_SEQUENCER_STORAGE_PATH=/store/sequencer
Expand Down
7 changes: 6 additions & 1 deletion builder/src/bin/permissioned-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use hotshot_types::traits::metrics::NoMetrics;
use hotshot_types::traits::node_implementation::ConsensusTime;
use sequencer::eth_signature_key::EthKeyPair;
use sequencer::persistence::no_storage::NoStorage;
use sequencer::{BuilderParams, L1Params, NetworkParams};
use sequencer::{options::parse_size, BuilderParams, L1Params, NetworkParams};
use snafu::Snafu;
use std::net::ToSocketAddrs;
use std::num::NonZeroUsize;
Expand Down Expand Up @@ -129,6 +129,10 @@ pub struct PermissionedBuilderOptions {
#[clap(long, env = "ESPRESSO_SEQUENCER_STATE_PEERS", value_delimiter = ',')]
pub state_peers: Vec<Url>,

/// Maximum size in bytes of a block
#[clap(long, env = "ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE", value_parser = parse_size)]
pub max_block_size: u64,

/// Port to run the builder server on.
#[clap(short, long, env = "ESPRESSO_BUILDER_SERVER_PORT")]
pub port: u16,
Expand Down Expand Up @@ -286,6 +290,7 @@ async fn main() -> anyhow::Result<()> {
opt.is_da,
txn_timeout_duration,
opt.base_fee,
opt.max_block_size,
)
.await?;

Expand Down
15 changes: 12 additions & 3 deletions builder/src/bin/permissionless-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use cld::ClDuration;
use es_version::SEQUENCER_VERSION;
use hotshot_types::data::ViewNumber;
use hotshot_types::traits::node_implementation::ConsensusTime;
use sequencer::eth_signature_key::EthKeyPair;
use sequencer::L1Params;
use sequencer::{eth_signature_key::EthKeyPair, options::parse_size};
use snafu::Snafu;
use std::num::NonZeroUsize;
use std::{str::FromStr, time::Duration};
Expand Down Expand Up @@ -42,6 +42,10 @@ struct NonPermissionedBuilderOptions {
#[clap(long, env = "ESPRESSO_SEQUENCER_STATE_PEERS", value_delimiter = ',')]
state_peers: Vec<Url>,

/// Maximum size in bytes of a block
#[clap(long, env = "ESPRESSO_SEQUENCER_MAX_BLOCK_SIZE", value_parser = parse_size)]
pub max_block_size: u64,

/// Port to run the builder server on.
#[clap(short, long, env = "ESPRESSO_BUILDER_SERVER_PORT")]
port: u16,
Expand Down Expand Up @@ -112,8 +116,13 @@ async fn main() -> anyhow::Result<()> {

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

let instance_state =
build_instance_state(l1_params, opt.state_peers, sequencer_version).unwrap();
let instance_state = build_instance_state(
l1_params,
opt.state_peers,
opt.max_block_size,
sequencer_version,
)
.unwrap();

let api_response_timeout_duration = opt.max_api_timeout_duration;

Expand Down
3 changes: 2 additions & 1 deletion builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ pub struct BuilderConfig {
pub fn build_instance_state<Ver: StaticVersionType + 'static>(
l1_params: L1Params,
state_peers: Vec<Url>,
max_block_size: u64,
_: Ver,
) -> anyhow::Result<NodeState> {
let l1_client = L1Client::new(l1_params.url, Address::default());
let instance_state = NodeState::new(
u64::MAX, // dummy node ID, only used for debugging
ChainConfig::default(),
ChainConfig::new(0, max_block_size, 0),
l1_client,
Arc::new(StatePeers::<Ver>::from_urls(state_peers)),
);
Expand Down
3 changes: 2 additions & 1 deletion builder/src/permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
is_da: bool,
maximize_txns_count_timeout_duration: Duration,
base_fee: u64,
max_block_size: u64,
) -> anyhow::Result<BuilderContext<network::Production, P, Ver>> {
// Orchestrator client
let validator_args = ValidatorArgs {
Expand Down Expand Up @@ -252,7 +253,7 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static

let instance_state = NodeState::new(
node_index,
ChainConfig::default(),
ChainConfig::new(0, max_block_size, 0),
l1_client,
Arc::new(StatePeers::<Ver>::from_urls(network_params.state_peers)),
);
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ 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_SEQUENCER_MAX_BLOCK_SIZE
- ESPRESSO_BUILDER_ETH_MNEMONIC
- ESPRESSO_BUILDER_ETH_ACCOUNT_INDEX
- ESPRESSO_BUILDER_L1_PROVIDER
Expand Down

0 comments on commit 60344e3

Please sign in to comment.