Skip to content

Commit

Permalink
Added configuration setting for builder: initial node_count (#1434)
Browse files Browse the repository at this point in the history
* Forced commit so this can be merged to whatever branch does other updates

* setting env for builder init

* Fixing total_nodes() call

* Unrelated: builder could not reconnect to events service

* Putting back --testing feature on sequencer, until BlockPayload::genesis() gets removed
  • Loading branch information
nyospe authored May 7, 2024
1 parent 09806ad commit 54487da
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 30 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ ESPRESSO_BUILDER_L1_PROVIDER=${ESPRESSO_SEQUENCER_L1_PROVIDER}
ESPRESSO_BUILDER_ETH_MNEMONIC=${ESPRESSO_SEQUENCER_ETH_MNEMONIC}
ESPRESSO_BUILDER_SERVER_PORT=41003
ESPRESSO_BUILDER_CHANNEL_CAPACITY=1024
ESPRESSO_BUILDER_INIT_NODE_COUNT=$ESPRESSO_ORCHESTRATOR_NUM_NODES
ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW=0
ESPRESSO_BUILDER_WEBSERVER_RESPONSE_TIMEOUT_DURATION=1500ms
ESPRESSO_BUILDER_BUFFER_VIEW_NUM_COUNT=50
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ ethers = { version = "2.0", features = ["solc"] }
futures = "0.3"

hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.50" }

# Hotshot imports
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.50" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.18" }
Expand Down
3 changes: 3 additions & 0 deletions builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ tide-disco = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
vbs = { workspace = true }

[dev-dependencies]
sequencer = { path = "../sequencer", features = ["testing"] }
5 changes: 5 additions & 0 deletions builder/src/bin/permissionless-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ struct NonPermissionedBuilderOptions {
#[clap(short, long, env = "ESPRESSO_BUILDER_CHANNEL_CAPACITY")]
channel_capacity: NonZeroUsize,

/// NETWORK INITIAL NODE COUNT
#[clap(short, long, env = "ESPRESSO_BUILDER_INIT_NODE_COUNT")]
node_count: NonZeroUsize,

/// The amount of time a builder can wait before timing out a request to the API.
#[clap(
short,
Expand Down Expand Up @@ -122,6 +126,7 @@ async fn main() -> anyhow::Result<()> {
builder_key_pair,
bootstrapped_view,
opt.channel_capacity,
opt.node_count,
instance_state,
opt.hotshot_event_streaming_url,
builder_server_url,
Expand Down
3 changes: 3 additions & 0 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,13 @@ pub mod testing {
// A new builder can use this view number to start building blocks from this view number
let bootstrapped_view = ViewNumber::new(0);

let node_count = NonZeroUsize::new(HotShotTestConfig::total_nodes()).unwrap();

let builder_config = BuilderConfig::init(
key_pair,
bootstrapped_view,
channel_capacity,
node_count,
node_state,
hotshot_events_streaming_api_url,
hotshot_builder_api_url,
Expand Down
16 changes: 13 additions & 3 deletions builder/src/non_permissioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl BuilderConfig {
builder_key_pair: EthKeyPair,
bootstrapped_view: ViewNumber,
channel_capacity: NonZeroUsize,
node_count: NonZeroUsize,
instance_state: NodeState,
hotshot_events_api_url: Url,
hotshot_builder_apis_url: Url,
Expand Down Expand Up @@ -141,7 +142,7 @@ impl BuilderConfig {
qc_receiver,
req_receiver,
global_state_clone,
NonZeroUsize::new(1).unwrap(),
node_count,
bootstrapped_view,
buffered_view_num_count as u64,
maximize_txns_count_timeout_duration,
Expand All @@ -164,11 +165,17 @@ impl BuilderConfig {
// start the hotshot api service
run_builder_api_service(hotshot_builder_apis_url.clone(), proxy_global_state);

// spawn the builder service
let events_url = hotshot_events_api_url
.clone()
.join("hotshot-events/events")
.unwrap();

tracing::info!(
"Running permissionless builder against hotshot events API at {}",
events_url.to_string()
);

// spawn the builder service
async_spawn(async move {
let res = run_non_permissioned_standalone_builder_service(
tx_sender,
Expand All @@ -178,7 +185,10 @@ impl BuilderConfig {
events_url,
)
.await;
tracing::error!(?res, "builder service exited")
tracing::error!(?res, "builder service exited");
if res.is_err() {
panic!("Builder should restart.");
}
});

tracing::info!("Builder init finished");
Expand Down
53 changes: 27 additions & 26 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
# different parts of the CDN
keydb:
image: docker.io/eqalpha/keydb:latest
command: ["--requirepass", "changemeplease!!"]
command: [ "--requirepass", "changemeplease!!" ]
healthcheck:
# Attempt to PING the database
test: keydb-cli --pass changemeplease!! --raw incr PING
Expand All @@ -67,7 +67,7 @@ services:
- cdn-marshal
- -d
- redis://:changemeplease!!@keydb:6379
- -b
- -b
- $ESPRESSO_CDN_SERVER_PORT
- -m
- 0.0.0.0:$ESPRESSO_CDN_SERVER_METRICS_PORT
Expand All @@ -81,16 +81,16 @@ services:
- RUST_LOG
- ESPRESSO_CDN_SERVER_METRICS_PORT
image: ghcr.io/espressosystems/espresso-sequencer/cdn-broker:main
command:
- cdn-broker
- -d
- redis://:changemeplease!!@keydb:6379
- --public-advertise-endpoint
- broker-0:1738
- --private-advertise-endpoint
- broker-0:1739
- -m
- 0.0.0.0:$ESPRESSO_CDN_SERVER_METRICS_PORT
command:
- cdn-broker
- -d
- redis://:changemeplease!!@keydb:6379
- --public-advertise-endpoint
- broker-0:1738
- --private-advertise-endpoint
- broker-0:1739
- -m
- 0.0.0.0:$ESPRESSO_CDN_SERVER_METRICS_PORT
depends_on:
keydb:
condition: service_healthy
Expand All @@ -101,16 +101,16 @@ services:
- RUST_LOG
- ESPRESSO_CDN_SERVER_METRICS_PORT
image: ghcr.io/espressosystems/espresso-sequencer/cdn-broker:main
command:
- cdn-broker
- -d
- redis://:changemeplease!!@keydb:6379
- --public-advertise-endpoint
- broker-1:1738
- --private-advertise-endpoint
- broker-1:1739
- -m
- 0.0.0.0:$ESPRESSO_CDN_SERVER_METRICS_PORT
command:
- cdn-broker
- -d
- redis://:changemeplease!!@keydb:6379
- --public-advertise-endpoint
- broker-1:1738
- --private-advertise-endpoint
- broker-1:1739
- -m
- 0.0.0.0:$ESPRESSO_CDN_SERVER_METRICS_PORT
depends_on:
keydb:
condition: service_healthy
Expand All @@ -122,10 +122,10 @@ services:
- RUST_LOG
- ESPRESSO_SEQUENCER_ORCHESTRATOR_URL
image: ghcr.io/espressosystems/espresso-sequencer/cdn-whitelist:main
command:
- cdn-whitelist
- -d
- redis://:changemeplease!!@keydb:6379
command:
- cdn-whitelist
- -d
- redis://:changemeplease!!@keydb:6379
depends_on:
keydb:
condition: service_healthy
Expand Down Expand Up @@ -437,6 +437,7 @@ services:
- ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW
- ESPRESSO_BUILDER_WEBSERVER_RESPONSE_TIMEOUT_DURATION
- ESPRESSO_BUILDER_BUFFER_VIEW_NUM_COUNT
- ESPRESSO_BUILDER_INIT_NODE_COUNT
- RUST_LOG
- RUST_LOG_FORMAT
- ASYNC_STD_THREAD_COUNT
Expand Down

0 comments on commit 54487da

Please sign in to comment.