Skip to content

Commit

Permalink
Adding configuration changes for builder-core update
Browse files Browse the repository at this point in the history
  • Loading branch information
nyospe committed Jun 21, 2024
1 parent 4d4965e commit 7862a1d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
3 changes: 2 additions & 1 deletion builder/src/bin/permissioned-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ async fn main() -> anyhow::Result<()> {
builder_server_url.clone(),
builder_key_pair,
bootstrapped_view,
opt.channel_capacity,
opt.tx_channel_capacity,
opt.event_channel_capacity,
sequencer_version,
NoStorage,
max_api_response_timeout_duration,
Expand Down
10 changes: 7 additions & 3 deletions builder/src/bin/permissionless-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ struct NonPermissionedBuilderOptions {
#[clap(short, long, env = "ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW")]
view_number: u64,

/// BUILDER CHANNEL CAPACITY
#[clap(short, long, env = "ESPRESSO_BUILDER_CHANNEL_CAPACITY")]
channel_capacity: NonZeroUsize,
/// BUILDER TRANSACTIONS CHANNEL CAPACITY
#[clap(long, env = "ESPRESSO_BUILDER_TX_CHANNEL_CAPACITY")]
pub tx_channel_capacity: NonZeroUsize,

/// BUILDER HS EVENTS CHANNEL CAPACITY
#[clap(long, env = "ESPRESSO_BUILDER_EVENT_CHANNEL_CAPACITY")]
pub event_channel_capacity: NonZeroUsize,

/// NETWORK INITIAL NODE COUNT
#[clap(short, long, env = "ESPRESSO_BUILDER_INIT_NODE_COUNT")]
Expand Down
6 changes: 4 additions & 2 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ pub mod testing {
let (fee_account, key_pair) = FeeAccount::generated_from_seed_indexed(seed, 2011_u64);

// channel capacity for the builder states
let channel_capacity = NonZeroUsize::new(100).unwrap();
let tx_channel_capacity = NonZeroUsize::new(20).unwrap();
let event_channel_capacity = NonZeroUsize::new(500).unwrap();
// bootstrapping view number
// A new builder can use this view number to start building blocks from this view number
let bootstrapped_view = ViewNumber::new(0);
Expand All @@ -618,7 +619,8 @@ pub mod testing {
node_id,
key_pair,
bootstrapped_view,
channel_capacity,
tx_channel_capacity,
event_channel_capacity,
node_state,
ValidatedState::default(),
hotshot_builder_api_url,
Expand Down
5 changes: 3 additions & 2 deletions builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ impl BuilderConfig {
tracing::info!(
address = %builder_key_pair.fee_account(),
?bootstrapped_view,
%channel_capacity,
%tx_channel_capacity,
%event_channel_capacity,
?max_api_timeout_duration,
buffered_view_num_count,
?maximize_txns_count_timeout_duration,
"initializing builder",
);

// tx channel
let (tx_sender, tx_receiver) =
let (mut tx_sender, tx_receiver) =
broadcast::<Arc<ReceivedTransaction<SeqTypes>>>(tx_channel_capacity.get());
tx_sender.set_overflow(true);

Expand Down
25 changes: 16 additions & 9 deletions builder/src/permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
hotshot_builder_api_url: Url,
eth_key_pair: EthKeyPair,
bootstrapped_view: ViewNumber,
channel_capacity: NonZeroUsize,
tx_channel_capacity: NonZeroUsize,
event_channel_capacity: NonZeroUsize,
bind_version: Ver,
persistence: P,
max_api_timeout_duration: Duration,
Expand Down Expand Up @@ -310,7 +311,8 @@ pub async fn init_node<P: SequencerPersistence, Ver: StaticVersionType + 'static
node_index,
eth_key_pair,
bootstrapped_view,
channel_capacity,
tx_channel_capacity,
event_channel_capacity,
instance_state,
genesis_state,
hotshot_builder_api_url,
Expand Down Expand Up @@ -408,7 +410,8 @@ impl<N: network::Type, P: SequencerPersistence, Ver: StaticVersionType + 'static
node_index: u64,
eth_key_pair: EthKeyPair,
bootstrapped_view: ViewNumber,
channel_capacity: NonZeroUsize,
tx_channel_capacity: NonZeroUsize,
event_channel_capacity: NonZeroUsize,
instance_state: NodeState,
validated_state: ValidatedState,
hotshot_builder_api_url: Url,
Expand All @@ -417,21 +420,25 @@ impl<N: network::Type, P: SequencerPersistence, Ver: StaticVersionType + 'static
maximize_txns_count_timeout_duration: Duration,
) -> anyhow::Result<Self> {
// tx channel
let (tx_sender, tx_receiver) =
broadcast::<Arc<ReceivedTransaction<SeqTypes>>>(channel_capacity.get());
let (mut tx_sender, tx_receiver) =
broadcast::<Arc<ReceivedTransaction<SeqTypes>>>(tx_channel_capacity.get());
tx_sender.set_overflow(true);

// da channel
let (da_sender, da_receiver) = broadcast::<MessageType<SeqTypes>>(channel_capacity.get());
let (da_sender, da_receiver) =
broadcast::<MessageType<SeqTypes>>(event_channel_capacity.get());

// qc channel
let (qc_sender, qc_receiver) = broadcast::<MessageType<SeqTypes>>(channel_capacity.get());
let (qc_sender, qc_receiver) =
broadcast::<MessageType<SeqTypes>>(event_channel_capacity.get());

// decide channel
let (decide_sender, decide_receiver) =
broadcast::<MessageType<SeqTypes>>(channel_capacity.get());
broadcast::<MessageType<SeqTypes>>(event_channel_capacity.get());

// builder api request channel
let (req_sender, req_receiver) = broadcast::<MessageType<SeqTypes>>(channel_capacity.get());
let (req_sender, req_receiver) =
broadcast::<MessageType<SeqTypes>>(event_channel_capacity.get());

let (genesis_payload, genesis_ns_table) =
Payload::from_transactions([], &validated_state, &instance_state)
Expand Down

0 comments on commit 7862a1d

Please sign in to comment.