Skip to content

Commit 255d50b

Browse files
authored
Add cli flag for funding key (#168)
* Add cli flag for funding key * add docs
1 parent a62d35e commit 255d50b

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ cargo run -p op-rbuilder --bin op-rbuilder --features=flashtestations -- node \
5555
--flashtestations.enabled \
5656
--flashtestations.rpc-url your-rpc-url \ # rpc to submit the attestation transaction to
5757
--flashtestations.funding-amount 0.01 \ # amount in ETH to fund the TEE generated key
58-
--flashtestations.registry-address 0xFlashtestationsRegistryAddress
58+
--flashtestations.funding-key secret-key \ # funding key for the TEE key
59+
--flashtestations.registry-address 0xFlashtestationsRegistryAddress \
60+
flashtestations.builder-policy-address 0xBuilderPolicyAddress
5961
```
6062

6163
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.

crates/op-rbuilder/src/builders/flashblocks/service.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ where
7373
tracing::debug!("Spawning flashblocks payload builder service");
7474
let signer = self.0.builder_signer;
7575
if self.0.flashtestations_config.flashtestations_enabled {
76-
let funding_signer = signer.expect("Key to fund TEE generated address not set");
7776
let flashtestations_service = match spawn_flashtestations_service(
7877
self.0.flashtestations_config.clone(),
79-
funding_signer,
8078
ctx,
8179
)
8280
.await

crates/op-rbuilder/src/builders/standard/payload.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,8 @@ where
5353
pool: Pool,
5454
_evm_config: OpEvmConfig,
5555
) -> eyre::Result<Self::PayloadBuilder> {
56-
let signer = self.0.builder_signer;
57-
5856
if self.0.flashtestations_config.flashtestations_enabled {
59-
let funding_signer = signer.expect("Key to fund TEE generated address not set");
60-
match spawn_flashtestations_service(
61-
self.0.flashtestations_config.clone(),
62-
funding_signer,
63-
ctx,
64-
)
65-
.await
66-
{
57+
match spawn_flashtestations_service(self.0.flashtestations_config.clone(), ctx).await {
6758
Ok(service) => service,
6859
Err(e) => {
6960
tracing::warn!(error = %e, "Failed to spawn flashtestations service, falling back to standard builder tx");

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use alloy_primitives::{utils::parse_ether, Address, U256};
22

3+
use crate::tx_signer::Signer;
4+
35
/// Parameters for Flashtestations configuration
46
/// The names in the struct are prefixed with `flashtestations`
57
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::Args)]
@@ -33,6 +35,14 @@ pub struct FlashtestationsArgs {
3335
)]
3436
pub rpc_url: String,
3537

38+
/// Funding key for the TEE key
39+
#[arg(
40+
long = "flashtestations.funding-key",
41+
env = "FLASHTESTATIONS_FUNDING_KEY",
42+
required_if_eq("flashtestations_enabled", "true")
43+
)]
44+
pub funding_key: Option<Signer>,
45+
3646
/// Funding amount for the generated signer
3747
#[arg(
3848
long = "flashtestations.funding-amount",

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct FlashtestationsService {
3232

3333
// TODO: FlashtestationsService error types
3434
impl FlashtestationsService {
35-
pub fn new(args: FlashtestationsArgs, funding_signer: Signer) -> Self {
35+
pub fn new(args: FlashtestationsArgs) -> Self {
3636
let (private_key, public_key, address) = generate_ethereum_keypair();
3737
let tee_service_signer = Signer {
3838
address,
@@ -47,7 +47,8 @@ impl FlashtestationsService {
4747

4848
let tx_manager = TxManager::new(
4949
tee_service_signer,
50-
funding_signer,
50+
args.funding_key
51+
.expect("funding key required when flashtestations enabled"),
5152
args.rpc_url,
5253
args.registry_address
5354
.expect("registry address required when flashtestations enabled"),
@@ -101,15 +102,14 @@ impl BuilderTx for FlashtestationsService {
101102

102103
pub async fn spawn_flashtestations_service<Node>(
103104
args: FlashtestationsArgs,
104-
funding_signer: Signer,
105105
ctx: &BuilderContext<Node>,
106106
) -> eyre::Result<FlashtestationsService>
107107
where
108108
Node: NodeBounds,
109109
{
110110
info!("Flashtestations enabled");
111111

112-
let flashtestations_service = FlashtestationsService::new(args.clone(), funding_signer);
112+
let flashtestations_service = FlashtestationsService::new(args.clone());
113113
// Generates new key and registers the attestation onchain
114114
flashtestations_service.bootstrap().await?;
115115

0 commit comments

Comments
 (0)