diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 458d95c52ad1..426d42d9a611 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,6 +14,13 @@ jobs: name: clippy runs-on: ubuntu-latest timeout-minutes: 30 + strategy: + matrix: + include: + - binary: "reth" + network: "ethereum" + - binary: "op-reth" + network: "optimism" steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@clippy @@ -22,7 +29,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - run: cargo clippy --workspace --all-targets --all-features + - run: cargo clippy --bin "${{ matrix.binary }}" --workspace --features "jemalloc,${{ matrix.network }}" env: RUSTFLAGS: -D warnings diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index e2356af71cee..9ab0b1d07973 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -14,12 +14,15 @@ env: jobs: unused-dependencies: runs-on: ubuntu-latest + strategy: + matrix: + network: ["ethereum", "optimism"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - uses: taiki-e/install-action@cargo-udeps - name: Check for unused dependencies - run: cargo udeps --all-features --all-targets + run: cargo udeps --features "jemalloc,${{ matrix.network }}" - uses: JasonEtco/create-an-issue@v2 if: ${{ failure() }} env: diff --git a/Makefile b/Makefile index 69d34910da2c..fb5502821fe9 100644 --- a/Makefile +++ b/Makefile @@ -47,10 +47,20 @@ install: ## Build and install the reth binary under `~/.cargo/bin`. --profile "$(PROFILE)" \ $(CARGO_INSTALL_EXTRA_FLAGS) +.PHONY: install-op +install-op: ## Build and install the op-reth binary under `~/.cargo/bin`. + cargo install --path bin/reth --bin op-reth --force --locked \ + --features "optimism,$(FEATURES)" \ + --profile "$(PROFILE)" \ + $(CARGO_INSTALL_EXTRA_FLAGS) + # Builds the reth binary natively. build-native-%: cargo build --bin reth --target $* --features "$(FEATURES)" --profile "$(PROFILE)" +op-build-native-%: + cargo build --bin op-reth --target $* --features "optimism,$(FEATURES)" --profile "$(PROFILE)" + # The following commands use `cross` to build a cross-compile. # # These commands require that: @@ -70,6 +80,10 @@ build-%: RUSTFLAGS="-C link-arg=-lgcc -Clink-arg=-static-libgcc" \ cross build --bin reth --target $* --features "$(FEATURES)" --profile "$(PROFILE)" +op-build-%: + RUSTFLAGS="-C link-arg=-lgcc -Clink-arg=-static-libgcc" \ + cross build --bin op-reth --target $* --features "optimism,$(FEATURES)" --profile "$(PROFILE)" + # Unfortunately we can't easily use cross to build for Darwin because of licensing issues. # If we wanted to, we would need to build a custom Docker image with the SDK available. # @@ -105,7 +119,8 @@ build-release-tarballs: ## Create a series of `.tar.gz` files in the BIN_DIR dir ##@ Test -UNIT_TEST_ARGS := --locked --workspace --all-features -E 'kind(lib)' -E 'kind(bin)' -E 'kind(proc-macro)' +UNIT_TEST_ARGS := --locked --workspace --features 'jemalloc-prof' -E 'kind(lib)' -E 'kind(bin)' -E 'kind(proc-macro)' +UNIT_TEST_ARGS_OP := --locked --workspace --features 'jemalloc-prof,optimism' -E 'kind(lib)' -E 'kind(bin)' -E 'kind(proc-macro)' COV_FILE := lcov.info .PHONY: test-unit @@ -113,11 +128,21 @@ test-unit: ## Run unit tests. cargo install cargo-nextest --locked cargo nextest run $(UNIT_TEST_ARGS) +.PHONY: test-unit-op +test-unit-op: ## Run unit tests (with optimism feature flag enabled). + cargo install cargo-nextest --locked + cargo nextest run $(UNIT_TEST_ARGS_OP) + .PHONY: cov-unit cov-unit: ## Run unit tests with coverage. rm -f $(COV_FILE) cargo llvm-cov nextest --lcov --output-path $(COV_FILE) $(UNIT_TEST_ARGS) +.PHONY: cov-unit-op +cov-unit-op: ## Run unit tests with coverage (with optimism feature flag enabled). + rm -f $(COV_FILE) + cargo llvm-cov nextest --lcov --output-path $(COV_FILE) $(UNIT_TEST_ARGS_OP) + .PHONY: cov-report-html cov-report-html: cov-unit ## Generate a HTML coverage report and open it in the browser. cargo llvm-cov report --html diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 74dbeb109af8..b4922b37df3a 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -137,3 +137,12 @@ ethereum = [] [build-dependencies] vergen = { version = "8.0.0", features = ["build", "cargo", "git", "gitcl"] } + +[[bin]] +name = "reth" +path = "src/main.rs" + +[[bin]] +name = "op-reth" +path = "src/optimism.rs" +required-features = ["optimism"] diff --git a/bin/reth/src/main.rs b/bin/reth/src/main.rs index 220b04d9d0e7..d7c841d3827f 100644 --- a/bin/reth/src/main.rs +++ b/bin/reth/src/main.rs @@ -3,6 +3,10 @@ #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; +#[cfg(feature = "optimism")] +compile_error!("Cannot build the `reth` binary with the `optimism` feature flag enabled. Did you mean to build `op-reth`?"); + +#[cfg(not(feature = "optimism"))] fn main() { if let Err(err) = reth::cli::run() { eprintln!("Error: {err:?}"); diff --git a/bin/reth/src/optimism.rs b/bin/reth/src/optimism.rs new file mode 100644 index 000000000000..554b91a3ae28 --- /dev/null +++ b/bin/reth/src/optimism.rs @@ -0,0 +1,15 @@ +// We use jemalloc for performance reasons +#[cfg(all(feature = "jemalloc", unix))] +#[global_allocator] +static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; + +#[cfg(not(feature = "optimism"))] +compile_error!("Cannot build the `op-reth` binary with the `optimism` feature flag disabled. Did you mean to build `reth`?"); + +#[cfg(feature = "optimism")] +fn main() { + if let Err(err) = reth::cli::run() { + eprintln!("Error: {err:?}"); + std::process::exit(1); + } +}