Skip to content

Commit 4f1931b

Browse files
authored
Flashtestations flag (#165)
* Add feature flag for flashtestations * fix fmt command
1 parent 0670aa3 commit 4f1931b

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ test: ## Run the tests for rbuilder and op-rbuilder
5454
.PHONY: lt
5555
lt: lint test ## Run "lint" and "test"
5656

57+
## TODO: use all features when tdx dependency is compatible with macOS
5758
.PHONY: fmt
5859
fmt: ## Format the code
5960
cargo +nightly fmt
60-
cargo +nightly clippy --all-features --fix --allow-staged --allow-dirty
61+
cargo +nightly clippy --features ci-features --fix --allow-staged --allow-dirty
6162
cargo +nightly fix --allow-staged --allow-dirty
6263

6364
.PHONY: bench

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cargo run -p op-rbuilder --bin op-rbuilder -- node \
4747
To run op-rbuilder with flashtestations:
4848

4949
```bash
50-
cargo run -p op-rbuilder --bin op-rbuilder -- node \
50+
cargo run -p op-rbuilder --bin op-rbuilder --features=flashtestations -- node \
5151
--chain /path/to/chain-config.json \
5252
--http \
5353
--authrpc.port 9551 \

crates/op-rbuilder/Cargo.toml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ hex = "0.4"
121121
ureq = "2.10"
122122

123123
rollup-boost = { git = "https://github.com/flashbots/rollup-boost", branch = "main" }
124-
tdx = { git = "https://github.com/automata-network/tdx-attestation-sdk.git"}
125-
dcap-rs = { git = "https://github.com/automata-network/dcap-rs.git" }
124+
tdx = { git = "https://github.com/automata-network/tdx-attestation-sdk.git", optional = true }
125+
dcap-rs = { git = "https://github.com/automata-network/dcap-rs.git", optional = true }
126126

127127
dashmap = { version = "6.1", optional = true }
128128
nanoid = { version = "0.4", optional = true }
@@ -175,7 +175,6 @@ min-info-logs = ["tracing/release_max_level_info"]
175175
min-debug-logs = ["tracing/release_max_level_debug"]
176176
min-trace-logs = ["tracing/release_max_level_trace"]
177177

178-
179178
testing = [
180179
"dashmap",
181180
"nanoid",
@@ -187,13 +186,28 @@ testing = [
187186
"rlimit",
188187
]
189188

190-
191189
interop = []
192190

191+
flashtestations = ["dcap-rs", "tdx"]
192+
193193
telemetry = ["reth-tracing-otlp", "opentelemetry"]
194194

195195
custom-engine-api = []
196196

197+
ci-features = [
198+
"default",
199+
"jemalloc-prof",
200+
"min-error-logs",
201+
"min-warn-logs",
202+
"min-info-logs",
203+
"min-debug-logs",
204+
"min-trace-logs",
205+
"testing",
206+
"interop",
207+
"telemetry",
208+
"custom-engine-api",
209+
]
210+
197211
[[bin]]
198212
name = "op-rbuilder"
199213
path = "src/bin/op-rbuilder/main.rs"

crates/op-rbuilder/src/flashtestations/attestation.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::io::Read;
2+
#[cfg(feature = "flashtestations")]
23
use tdx::{device::DeviceOptions, Tdx};
34
use tracing::info;
45
use ureq;
@@ -20,22 +21,26 @@ pub trait AttestationProvider {
2021
}
2122

2223
/// Real TDX hardware attestation provider
24+
#[cfg(feature = "flashtestations")]
2325
pub struct TdxAttestationProvider {
2426
tdx: Tdx,
2527
}
2628

29+
#[cfg(feature = "flashtestations")]
2730
impl Default for TdxAttestationProvider {
2831
fn default() -> Self {
2932
Self::new()
3033
}
3134
}
3235

36+
#[cfg(feature = "flashtestations")]
3337
impl TdxAttestationProvider {
3438
pub fn new() -> Self {
3539
Self { tdx: Tdx::new() }
3640
}
3741
}
3842

43+
#[cfg(feature = "flashtestations")]
3944
impl AttestationProvider for TdxAttestationProvider {
4045
fn get_attestation(&self, report_data: [u8; 64]) -> eyre::Result<Vec<u8>> {
4146
self.tdx
@@ -85,6 +90,16 @@ pub fn get_attestation_provider(
8590
.unwrap_or(DEBUG_QUOTE_SERVICE_URL.to_string()),
8691
))
8792
} else {
88-
Box::new(TdxAttestationProvider::new())
93+
#[cfg(feature = "flashtestations")]
94+
{
95+
Box::new(TdxAttestationProvider::new())
96+
}
97+
#[cfg(not(feature = "flashtestations"))]
98+
{
99+
info!("Using debug attestation provider as flashtestations feature is disabled");
100+
Box::new(DebugAttestationProvider::new(
101+
DEBUG_QUOTE_SERVICE_URL.to_string(),
102+
))
103+
}
89104
}
90105
}

0 commit comments

Comments
 (0)