Skip to content

Commit 079db2f

Browse files
committed
better logging and README
1 parent 107c3cd commit 079db2f

File tree

9 files changed

+336
-183
lines changed

9 files changed

+336
-183
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ revm = { version = "24.0.1", features = [
107107
"optional_balance_check",
108108
], default-features = false }
109109
revm-inspectors = { version = "0.22.0", default-features = false }
110-
op-revm = { version = "5.0.1", default-features = false }
110+
op-revm = { version = "5.0.1", features = ["serde"], default-features = false }
111111

112112
ethereum_ssz_derive = "0.9.0"
113113
ethereum_ssz = "0.9.0"

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ cargo run -p op-rbuilder --bin op-rbuilder -- node \
4444

4545
### Flashtestations
4646

47+
Flashtestations is a feature that enables Trusted Execution Environment (TEE) attestation for block building. It provides cryptographic proof that blocks were built within a secure enclave, ensuring the integrity and confidentiality of the block building process.
48+
49+
#### Usage
50+
4751
To run op-rbuilder with flashtestations:
4852

4953
```bash
@@ -53,14 +57,18 @@ cargo run -p op-rbuilder --bin op-rbuilder --features=flashtestations -- node \
5357
--authrpc.port 9551 \
5458
--authrpc.jwtsecret /path/to/jwt.hex \
5559
--flashtestations.enabled \
56-
--flashtestations.rpc-url your-rpc-url \ # rpc to submit the attestation transaction to
5760
--flashtestations.funding-amount 0.01 \ # amount in ETH to fund the TEE generated key
5861
--flashtestations.funding-key secret-key \ # funding key for the TEE key
5962
--flashtestations.registry-address 0xFlashtestationsRegistryAddress \
60-
flashtestations.builder-policy-address 0xBuilderPolicyAddress
63+
--flashtestations.builder-policy-address 0xBuilderPolicyAddress
6164
```
6265

63-
Note that `--rollup.builder-secret-key` must be set and funded in order for the flashtestations key to be funded and submit the attestation on-chain.
66+
#### Additional CLI Config
67+
68+
- `--flashtestations.enable-block-proofs`: Enable end-of-block transaction proofs that verify the block was built within a TEE
69+
- `--flashtestations.debug`: Enable debug mode with a deterministic TEE key and debug attestation server for testing and development
70+
- `--flashtestations.quote-provider <URL>`: Specify a remote URL to provide an attestation instead of generating a quote in process
71+
- `--flashtestations.rpc-url <URL>`: Use a remote provider to submit attestations to
6472

6573
## Observability
6674

@@ -189,4 +197,4 @@ More instructions on installing and configuring `act` can be found on [their web
189197
### Known issues
190198

191199
- Running actions locally require a Github Token. You can generate one by following instructions on [Github Docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). After generating a token you will need to pass it to `act` either through the command line using `-s GITHUB_TOKEN=<your token>` or by adding it to the `~/.config/act/actrc` file.
192-
- You might get an error about missing or incompatible `warp-ubuntu-latest-x64-32x` platform. This can be mitigated by adding `-P warp-ubuntu-latest-x64-32x=ghcr.io/catthehacker/ubuntu:act-latest` on the command line when calling `act` or appending this flag to `~/.config/act/actrc`
200+
- You might get an error about missing or incompatible `warp-ubuntu-latest-x64-32x` platform. This can be mitigated by adding `-P warp-ubuntu-latest-x64-32x=ghcr.io/catthehacker/ubuntu:act-latest` on the command line when calling `act` or appending this flag to `~/.config/act/actrc`

crates/op-rbuilder/src/builders/builder_tx.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ impl StandardBuilderTx {
153153
Self { signer }
154154
}
155155

156-
pub fn simulate_builder_txs(
156+
pub fn simulate_builder_tx(
157157
&self,
158158
ctx: &OpPayloadBuilderCtx,
159159
db: &mut State<impl Database<Error = ProviderError>>,
160-
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError> {
160+
) -> Result<Option<BuilderTransactionCtx>, BuilderTransactionError> {
161161
match self.signer {
162162
Some(signer) => {
163163
let message: Vec<u8> = format!("Block Number: {}", ctx.block_number()).into_bytes();
@@ -166,13 +166,13 @@ impl StandardBuilderTx {
166166
let da_size = op_alloy_flz::tx_estimated_size_fjord_bytes(
167167
signed_tx.encoded_2718().as_slice(),
168168
);
169-
Ok(vec![BuilderTransactionCtx {
169+
Ok(Some(BuilderTransactionCtx {
170170
gas_used,
171171
da_size,
172172
signed_tx,
173-
}])
173+
}))
174174
}
175-
None => Ok(vec![]),
175+
None => Ok(None),
176176
}
177177
}
178178

@@ -242,6 +242,7 @@ impl BuilderTransactions for StandardBuilderTx {
242242
ctx: &OpPayloadBuilderCtx,
243243
db: &mut State<impl Database<Error = ProviderError>>,
244244
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError> {
245-
self.simulate_builder_txs(ctx, db)
245+
let builder_tx = self.simulate_builder_tx(ctx, db)?;
246+
Ok(builder_tx.into_iter().collect())
246247
}
247248
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ pub struct FlashtestationsArgs {
2424
pub debug: bool,
2525

2626
// Debug url for attestations
27-
#[arg(long = "flashtestations.debug-url", env = "FLASHTESTATIONS_DEBUG_URL")]
28-
pub debug_url: Option<String>,
27+
#[arg(
28+
long = "flashtestations.debug-tee-key-seed",
29+
env = "FLASHTESTATIONS_DEBUG_TEE_KEY_SEED",
30+
default_value = "debug"
31+
)]
32+
pub debug_tee_key_seed: String,
33+
34+
// Remote url for attestations
35+
#[arg(
36+
long = "flashtestations.quote-provider",
37+
env = "FLASHTESTATIONS_QUOTE_PROVIDER"
38+
)]
39+
pub quote_provider: Option<String>,
2940

3041
/// The rpc url to post the onchain attestation requests to
3142
#[arg(long = "flashtestations.rpc-url", env = "FLASHTESTATIONS_RPC_URL")]

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const DEBUG_QUOTE_SERVICE_URL: &str = "http://ns31695324.ip-141-94-163.eu:10080/
1111
pub struct AttestationConfig {
1212
/// If true, uses the debug HTTP service instead of real TDX hardware
1313
pub debug: bool,
14-
/// The URL of the debug HTTP service
15-
pub debug_url: Option<String>,
14+
/// The URL of the quote provider
15+
pub quote_provider: Option<String>,
1616
}
1717

1818
/// Trait for attestation providers
@@ -51,18 +51,18 @@ impl AttestationProvider for TdxAttestationProvider {
5151
}
5252
}
5353

54-
/// Debug HTTP service attestation provider
55-
pub struct DebugAttestationProvider {
54+
/// Remote HTTP service attestation provider
55+
pub struct RemoteAttestationProvider {
5656
service_url: String,
5757
}
5858

59-
impl DebugAttestationProvider {
59+
impl RemoteAttestationProvider {
6060
pub fn new(service_url: String) -> Self {
6161
Self { service_url }
6262
}
6363
}
6464

65-
impl AttestationProvider for DebugAttestationProvider {
65+
impl AttestationProvider for RemoteAttestationProvider {
6666
fn get_attestation(&self, report_data: [u8; 64]) -> eyre::Result<Vec<u8>> {
6767
let report_data_hex = hex::encode(report_data);
6868
let url = format!("{}/{}", self.service_url, report_data_hex);
@@ -83,10 +83,12 @@ impl AttestationProvider for DebugAttestationProvider {
8383
pub fn get_attestation_provider(
8484
config: AttestationConfig,
8585
) -> Box<dyn AttestationProvider + Send + Sync> {
86-
if config.debug {
87-
Box::new(DebugAttestationProvider::new(
86+
if let Some(quote_provider) = config.quote_provider {
87+
Box::new(RemoteAttestationProvider::new(quote_provider))
88+
} else if config.debug {
89+
Box::new(RemoteAttestationProvider::new(
8890
config
89-
.debug_url
91+
.quote_provider
9092
.unwrap_or(DEBUG_QUOTE_SERVICE_URL.to_string()),
9193
))
9294
} else {
@@ -97,7 +99,7 @@ pub fn get_attestation_provider(
9799
#[cfg(not(feature = "flashtestations"))]
98100
{
99101
info!("Using debug attestation provider as flashtestations feature is disabled");
100-
Box::new(DebugAttestationProvider::new(
102+
Box::new(RemoteAttestationProvider::new(
101103
DEBUG_QUOTE_SERVICE_URL.to_string(),
102104
))
103105
}

0 commit comments

Comments
 (0)