From 35c83c12c687c6573c2e57174a38a334ba0e7379 Mon Sep 17 00:00:00 2001 From: avalonche Date: Wed, 18 Jun 2025 04:00:58 +1000 Subject: [PATCH 1/2] Add feature flag for flashtestations --- README.md | 2 +- crates/op-rbuilder/Cargo.toml | 7 ++++--- .../src/flashtestations/attestation.rs | 17 ++++++++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7b361d6..dab84c1 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ cargo run -p op-rbuilder --bin op-rbuilder -- node \ To run op-rbuilder with flashtestations: ```bash -cargo run -p op-rbuilder --bin op-rbuilder -- node \ +cargo run -p op-rbuilder --bin op-rbuilder --features=flashtestations -- node \ --chain /path/to/chain-config.json \ --http \ --authrpc.port 9551 \ diff --git a/crates/op-rbuilder/Cargo.toml b/crates/op-rbuilder/Cargo.toml index 8464c0e..c2f31ca 100644 --- a/crates/op-rbuilder/Cargo.toml +++ b/crates/op-rbuilder/Cargo.toml @@ -121,8 +121,8 @@ hex = "0.4" ureq = "2.10" rollup-boost = { git = "http://github.com/flashbots/rollup-boost", branch = "main" } -tdx = { git = "https://github.com/automata-network/tdx-attestation-sdk.git"} -dcap-rs = { git = "https://github.com/automata-network/dcap-rs.git" } +tdx = { git = "https://github.com/automata-network/tdx-attestation-sdk.git", optional = true } +dcap-rs = { git = "https://github.com/automata-network/dcap-rs.git", optional = true } dashmap = { version = "6.1", optional = true } nanoid = { version = "0.4", optional = true } @@ -187,9 +187,10 @@ testing = [ "rlimit", ] - interop = [] +flashtestations = ["dcap-rs", "tdx"] + telemetry = ["reth-tracing-otlp", "opentelemetry"] custom-engine-api = [] diff --git a/crates/op-rbuilder/src/flashtestations/attestation.rs b/crates/op-rbuilder/src/flashtestations/attestation.rs index 4119f44..9e3a83c 100644 --- a/crates/op-rbuilder/src/flashtestations/attestation.rs +++ b/crates/op-rbuilder/src/flashtestations/attestation.rs @@ -1,4 +1,5 @@ use std::io::Read; +#[cfg(feature = "flashtestations")] use tdx::{device::DeviceOptions, Tdx}; use tracing::info; use ureq; @@ -20,22 +21,26 @@ pub trait AttestationProvider { } /// Real TDX hardware attestation provider +#[cfg(feature = "flashtestations")] pub struct TdxAttestationProvider { tdx: Tdx, } +#[cfg(feature = "flashtestations")] impl Default for TdxAttestationProvider { fn default() -> Self { Self::new() } } +#[cfg(feature = "flashtestations")] impl TdxAttestationProvider { pub fn new() -> Self { Self { tdx: Tdx::new() } } } +#[cfg(feature = "flashtestations")] impl AttestationProvider for TdxAttestationProvider { fn get_attestation(&self, report_data: [u8; 64]) -> eyre::Result> { self.tdx @@ -85,6 +90,16 @@ pub fn get_attestation_provider( .unwrap_or(DEBUG_QUOTE_SERVICE_URL.to_string()), )) } else { - Box::new(TdxAttestationProvider::new()) + #[cfg(feature = "flashtestations")] + { + Box::new(TdxAttestationProvider::new()) + } + #[cfg(not(feature = "flashtestations"))] + { + info!("Using debug attestation provider as flashtestations feature is disabled"); + Box::new(DebugAttestationProvider::new( + DEBUG_QUOTE_SERVICE_URL.to_string(), + )) + } } } From 669ab9f0380afc6cac8e559020e91d8490ffe496 Mon Sep 17 00:00:00 2001 From: avalonche Date: Wed, 18 Jun 2025 04:19:17 +1000 Subject: [PATCH 2/2] fix fmt command --- Makefile | 3 ++- crates/op-rbuilder/Cargo.toml | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bcaad47..2a8a0bf 100644 --- a/Makefile +++ b/Makefile @@ -54,10 +54,11 @@ test: ## Run the tests for rbuilder and op-rbuilder .PHONY: lt lt: lint test ## Run "lint" and "test" +## TODO: use all features when tdx dependency is compatible with macOS .PHONY: fmt fmt: ## Format the code cargo +nightly fmt - cargo +nightly clippy --all-features --fix --allow-staged --allow-dirty + cargo +nightly clippy --features ci-features --fix --allow-staged --allow-dirty cargo +nightly fix --allow-staged --allow-dirty .PHONY: bench diff --git a/crates/op-rbuilder/Cargo.toml b/crates/op-rbuilder/Cargo.toml index c2f31ca..1076478 100644 --- a/crates/op-rbuilder/Cargo.toml +++ b/crates/op-rbuilder/Cargo.toml @@ -175,7 +175,6 @@ min-info-logs = ["tracing/release_max_level_info"] min-debug-logs = ["tracing/release_max_level_debug"] min-trace-logs = ["tracing/release_max_level_trace"] - testing = [ "dashmap", "nanoid", @@ -195,6 +194,20 @@ telemetry = ["reth-tracing-otlp", "opentelemetry"] custom-engine-api = [] +ci-features = [ + "default", + "jemalloc-prof", + "min-error-logs", + "min-warn-logs", + "min-info-logs", + "min-debug-logs", + "min-trace-logs", + "testing", + "interop", + "telemetry", + "custom-engine-api", +] + [[bin]] name = "op-rbuilder" path = "src/bin/op-rbuilder/main.rs"