Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 43 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ axum = "0.7.5"
backon = { version = "1.6.0", features = ["tokio-sleep"] }
eyre = "0.6.12"
futures-util = "0.3.31"
git-version = "0.3.9"
itertools = "0.14.0"
openssl = { version = "0.10", features = ["vendored"] }
reqwest = { version = "0.12.22", features = ["blocking", "json"] }
thiserror = "2.0.17"
Expand All @@ -63,7 +65,7 @@ alloy-hardforks = "0.4.0"
alloy-chains = "0.2"

# comment / uncomment for local dev
# [patch.crates-io]
[patch.crates-io]
# signet-constants = { path = "../signet-sdk/crates/constants" }
# signet-types = { path = "../signet-sdk/crates/types" }
# signet-zenith = { path = "../signet-sdk/crates/zenith" }
Expand All @@ -73,4 +75,4 @@ alloy-chains = "0.2"
# signet-journal = { path = "../signet-sdk/crates/journal" }
# signet-tx-cache = { path = "../signet-sdk/crates/tx-cache" }
# signet-bundle = { path = "../signet-sdk/crates/bundle" }
# init4-bin-base = { path = "../bin-base" }
init4-bin-base = { git = "https://github.com/init4tech/bin-base", branch = "fraser/eng-1943/various-updates" }
51 changes: 47 additions & 4 deletions bin/builder.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,66 @@
#![recursion_limit = "256"]

use builder::{
config::{BuilderConfig, env_var_info},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanliness while we're here, we should consider following the lib+main convention as that should remove the need to add anonymous imports for bin-only deps

src/
|- lib.rs
|- main.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll restructure as requested (makes sense to me), but turns out this doesn't affect the clippy warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drat, oh well. let's not restructure then, as that may impact docker setups, etc

service::serve_builder,
tasks::{
block::sim::SimulatorTask, cache::CacheTasks, env::EnvTask, metrics::MetricsTask,
submit::FlashbotsTask,
},
};
use init4_bin_base::deps::tracing::{info, info_span};
use eyre::bail;
use git_version::git_version;
use init4_bin_base::{
deps::tracing::{info, info_span},
utils::from_env::FromEnv,
};
use tokio::select;

const GIT_COMMIT: &str =
git_version!(args = ["--always", "--match=", "--abbrev=7"], fallback = "unknown");
const PKG_VERSION: &str = env!("CARGO_PKG_VERSION");

fn should_print_help() -> bool {
std::env::args().any(|arg| {
let lowercase_arg = arg.to_ascii_lowercase();
lowercase_arg == "-h" || lowercase_arg == "--help"
})
}

fn print_help() {
let version = env!("CARGO_PKG_VERSION");
let env_vars = env_var_info();
println!(
r#"Signet block builder v{version}

Run with no args. Configuration is via the following environment variables:
{env_vars}
"#
)
}

// Note: Must be set to `multi_thread` to support async tasks.
// See: https://docs.rs/tokio/latest/tokio/attr.main.html
#[tokio::main(flavor = "multi_thread")]
async fn main() -> eyre::Result<()> {
let _guard = init4_bin_base::init4();
if should_print_help() {
print_help();
return Ok(());
}

if let Err(e) = BuilderConfig::check_inventory() {
for item in e {
eprintln!("missing environment variable: {}: {}", item.var, item.description);
}
bail!(
"missing at least one required environment variable; run with '--help' to see the list"
);
}

let config = builder::config_from_env();
let init_span_guard = info_span!("builder initialization").entered();

builder::config_from_env();
info!(pkg_version = PKG_VERSION, git_commit = GIT_COMMIT, "starting builder");

// Pre-load the KZG settings in a separate thread.
//
Expand Down Expand Up @@ -45,7 +88,7 @@ async fn main() -> eyre::Result<()> {
let build_jh = simulator_task.spawn_simulator_task(cache_system.sim_cache, submit_channel);

// Start the healthcheck server
let server = serve_builder(([0, 0, 0, 0], builder::config().builder_port));
let server = serve_builder(([0, 0, 0, 0], config.builder_port));

// We have finished initializing the builder, so we can drop the init span
// guard.
Expand Down
Loading