From cc6bd8afa48fc2f6101a8fbfaefae24d616dea24 Mon Sep 17 00:00:00 2001 From: tbro <48967308+tbro@users.noreply.github.com> Date: Wed, 12 Feb 2025 18:29:01 -0300 Subject: [PATCH] Conditionally compile versions (#2559) This facilitates selecting versions compiled into the binary. If you are only working with a single version, you easily choose to compile a single version by supplying it as a feature. For example: `cargo build --features fee`. For some tasks you want two versions. You can also set via ENV as demonstrated by the following simple test: RUSTFLAGS="--cfg feature=\"fee\"" cargo +nightly -Z unstable-options rustc --print cfg Currently most of our testing infrastructure requires two versions. But we *could* (with additional effort) organize tests to take more advantage of conditional compilation. --------- Co-authored-by: tbro --- .github/workflows/cargo-features.yml | 2 +- .github/workflows/test.yml | 1 + sequencer/Cargo.toml | 4 ++++ sequencer/src/run.rs | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cargo-features.yml b/.github/workflows/cargo-features.yml index de382698ab..95157a2fdd 100644 --- a/.github/workflows/cargo-features.yml +++ b/.github/workflows/cargo-features.yml @@ -19,7 +19,7 @@ concurrency: jobs: cargo-features: - runs-on: ubuntu-latest + runs-on: buildjet-8vcpu-ubuntu-2204 steps: - uses: taiki-e/install-action@cargo-hack diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2007b8a988..5d4c588733 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ concurrency: env: RUST_LOG: info,libp2p=off,node=error + RUSTFLAGS: "--cfg feature=\"fee\" --cfg feature=\"marketplace\"" CARGO_TERM_COLOR: always # Save the process compose logs PC_LOGS: /tmp/pc.log diff --git a/sequencer/Cargo.toml b/sequencer/Cargo.toml index 69564f90d5..d1fd78f25b 100644 --- a/sequencer/Cargo.toml +++ b/sequencer/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] +default = ["fee"] testing = [ "hotshot-testing", "marketplace-builder-core", @@ -15,6 +16,9 @@ testing = [ ] benchmarking = [] embedded-db = ["hotshot-query-service/embedded-db"] +fee = [] +pos = [] +marketplace = [] [[bin]] name = "espresso-dev-node" diff --git a/sequencer/src/run.rs b/sequencer/src/run.rs index 9eb4acc021..182be004e2 100644 --- a/sequencer/src/run.rs +++ b/sequencer/src/run.rs @@ -8,6 +8,7 @@ use super::{ persistence, Genesis, L1Params, NetworkParams, }; use clap::Parser; +#[allow(unused_imports)] use espresso_types::{ traits::NullEventConsumer, FeeVersion, MarketplaceVersion, SequencerVersions, SolverAuctionResultsProvider, V0_0, @@ -38,6 +39,7 @@ pub async fn main() -> anyhow::Result<()> { let upgrade = genesis.upgrade_version; match (base, upgrade) { + #[cfg(all(feature = "fee", feature = "marketplace"))] (FeeVersion::VERSION, MarketplaceVersion::VERSION) => { run( genesis, @@ -47,6 +49,7 @@ pub async fn main() -> anyhow::Result<()> { ) .await } + #[cfg(feature = "fee")] (FeeVersion::VERSION, _) => { run( genesis, @@ -56,6 +59,7 @@ pub async fn main() -> anyhow::Result<()> { ) .await } + #[cfg(feature = "marketplace")] (MarketplaceVersion::VERSION, _) => { run( genesis,