Skip to content

Commit 0fe01d5

Browse files
authored
Remove non permit flashtestation calls (#302)
1 parent 8107f87 commit 0fe01d5

File tree

7 files changed

+93
-426
lines changed

7 files changed

+93
-426
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292
let flashtestations_builder_tx = if let Some(builder_key) = signer
9393
&& self.0.flashtestations_config.flashtestations_enabled
9494
{
95-
match bootstrap_flashtestations(self.0.flashtestations_config.clone(), builder_key, ctx)
95+
match bootstrap_flashtestations(self.0.flashtestations_config.clone(), builder_key)
9696
.await
9797
{
9898
Ok(builder_tx) => Some(builder_tx),

crates/builder/op-rbuilder/src/builders/standard/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ where
7575
let flashtestations_builder_tx = if let Some(builder_key) = signer
7676
&& self.0.flashtestations_config.flashtestations_enabled
7777
{
78-
match bootstrap_flashtestations(self.0.flashtestations_config.clone(), builder_key, ctx)
78+
match bootstrap_flashtestations(self.0.flashtestations_config.clone(), builder_key)
7979
.await
8080
{
8181
Ok(builder_tx) => Some(builder_tx),

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use alloy_primitives::{Address, U256, utils::parse_ether};
1+
use alloy_primitives::Address;
22
use clap::Parser;
33
use reth_optimism_cli::commands::Commands;
44

5-
use crate::{args::Cli, tx_signer::Signer};
5+
use crate::args::Cli;
66

77
/// Parameters for Flashtestations configuration
88
/// The names in the struct are prefixed with `flashtestations`
@@ -52,23 +52,6 @@ pub struct FlashtestationsArgs {
5252
#[arg(long = "flashtestations.rpc-url", env = "FLASHTESTATIONS_RPC_URL")]
5353
pub rpc_url: Option<String>,
5454

55-
/// Funding key for the TEE key
56-
#[arg(
57-
long = "flashtestations.funding-key",
58-
env = "FLASHTESTATIONS_FUNDING_KEY",
59-
required_if_eq("flashtestations_enabled", "true")
60-
)]
61-
pub funding_key: Option<Signer>,
62-
63-
/// Funding amount for the generated signer
64-
#[arg(
65-
long = "flashtestations.funding-amount",
66-
env = "FLASHTESTATIONS_FUNDING_AMOUNT",
67-
default_value = "1",
68-
value_parser = parse_ether
69-
)]
70-
pub funding_amount: U256,
71-
7255
/// Enable end of block TEE proof
7356
#[arg(
7457
long = "flashtestations.enable-block-proofs",
@@ -100,14 +83,6 @@ pub struct FlashtestationsArgs {
10083
default_value = "1"
10184
)]
10285
pub builder_proof_version: u8,
103-
104-
/// Use permit for the flashtestation builder tx
105-
#[arg(
106-
long = "flashtestations.use-permit",
107-
env = "FLASHTESTATIONS_USE_PERMIT",
108-
default_value = "false"
109-
)]
110-
pub flashtestations_use_permit: bool,
11186
}
11287

11388
impl Default for FlashtestationsArgs {

crates/builder/op-rbuilder/src/flashtestations/builder_tx.rs

Lines changed: 10 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
use alloy_consensus::TxEip1559;
21
use alloy_eips::Encodable2718;
32
use alloy_evm::Database;
43
use alloy_op_evm::OpEvm;
5-
use alloy_primitives::{Address, B256, Bytes, Signature, TxKind, U256, keccak256};
4+
use alloy_primitives::{Address, B256, Bytes, Signature, U256, keccak256};
65
use alloy_rpc_types_eth::TransactionInput;
76
use alloy_sol_types::{SolCall, SolEvent, SolValue};
87
use core::fmt::Debug;
9-
use op_alloy_consensus::OpTypedTransaction;
108
use op_alloy_rpc_types::OpTransactionRequest;
11-
use reth_evm::{ConfigureEvm, Evm, EvmError, precompiles::PrecompilesMap};
9+
use reth_evm::{ConfigureEvm, Evm, precompiles::PrecompilesMap};
1210
use reth_optimism_primitives::OpTransactionSigned;
1311
use reth_provider::StateProvider;
1412
use reth_revm::{State, database::StateProviderDatabase};
15-
use revm::{
16-
DatabaseCommit, DatabaseRef, context::result::ResultAndState, inspector::NoOpInspector,
17-
};
13+
use revm::{DatabaseCommit, DatabaseRef, inspector::NoOpInspector};
1814
use std::sync::{Arc, atomic::AtomicBool};
1915
use tracing::{debug, info, warn};
2016

2117
use crate::{
2218
builders::{
2319
BuilderTransactionCtx, BuilderTransactionError, BuilderTransactions, OpPayloadBuilderCtx,
24-
SimulationSuccessResult, get_balance, get_nonce,
20+
SimulationSuccessResult, get_nonce,
2521
},
2622
flashtestations::{
2723
BlockData,
@@ -37,14 +33,11 @@ pub struct FlashtestationsBuilderTxArgs {
3733
pub attestation: Vec<u8>,
3834
pub extra_registration_data: Bytes,
3935
pub tee_service_signer: Signer,
40-
pub funding_key: Signer,
41-
pub funding_amount: U256,
4236
pub registry_address: Address,
4337
pub builder_policy_address: Address,
4438
pub builder_proof_version: u8,
4539
pub enable_block_proofs: bool,
4640
pub registered: bool,
47-
pub use_permit: bool,
4841
pub builder_key: Signer,
4942
}
5043

@@ -60,10 +53,6 @@ where
6053
extra_registration_data: Bytes,
6154
// TEE service generated key
6255
tee_service_signer: Signer,
63-
// Funding key for the TEE signer
64-
funding_key: Signer,
65-
// Funding amount for the TEE signer
66-
funding_amount: U256,
6756
// Registry address for the attestation
6857
registry_address: Address,
6958
// Builder policy address for the block builder proof
@@ -74,8 +63,6 @@ where
7463
registered: Arc<AtomicBool>,
7564
// Whether block proofs are enabled
7665
enable_block_proofs: bool,
77-
// Whether to use permit for the flashtestation builder tx
78-
use_permit: bool,
7966
// Builder key for the flashtestation permit tx
8067
builder_signer: Signer,
8168
// Extra context and data
@@ -92,14 +79,11 @@ where
9279
attestation: args.attestation,
9380
extra_registration_data: args.extra_registration_data,
9481
tee_service_signer: args.tee_service_signer,
95-
funding_key: args.funding_key,
96-
funding_amount: args.funding_amount,
9782
registry_address: args.registry_address,
9883
builder_policy_address: args.builder_policy_address,
9984
builder_proof_version: args.builder_proof_version,
10085
registered: Arc::new(AtomicBool::new(args.registered)),
10186
enable_block_proofs: args.enable_block_proofs,
102-
use_permit: args.use_permit,
10387
builder_signer: args.builder_key,
10488
_marker: std::marker::PhantomData,
10589
}
@@ -137,136 +121,6 @@ where
137121
keccak256(&encoded)
138122
}
139123

140-
// TODO: deprecate in favour of permit calls
141-
fn fund_tee_service_tx(
142-
&self,
143-
ctx: &OpPayloadBuilderCtx<ExtraCtx>,
144-
evm: &mut OpEvm<&mut State<impl Database + DatabaseRef>, NoOpInspector, PrecompilesMap>,
145-
) -> Result<Option<BuilderTransactionCtx>, BuilderTransactionError> {
146-
let balance = get_balance(evm.db(), self.tee_service_signer.address)?;
147-
if balance.is_zero() {
148-
let funding_nonce = get_nonce(evm.db(), self.funding_key.address)?;
149-
let tx = OpTypedTransaction::Eip1559(TxEip1559 {
150-
chain_id: ctx.chain_id(),
151-
nonce: funding_nonce,
152-
gas_limit: 21000,
153-
max_fee_per_gas: ctx.base_fee().into(),
154-
to: TxKind::Call(self.tee_service_signer.address),
155-
value: self.funding_amount,
156-
..Default::default()
157-
});
158-
let funding_tx = self.funding_key.sign_tx(tx)?;
159-
let da_size =
160-
op_alloy_flz::tx_estimated_size_fjord_bytes(funding_tx.encoded_2718().as_slice());
161-
let ResultAndState { state, .. } = match evm.transact(&funding_tx) {
162-
Ok(res) => res,
163-
Err(err) => {
164-
if err.is_invalid_tx_err() {
165-
return Err(BuilderTransactionError::InvalidTransactionError(Box::new(
166-
err,
167-
)));
168-
} else {
169-
return Err(BuilderTransactionError::EvmExecutionError(Box::new(err)));
170-
}
171-
}
172-
};
173-
info!(target: "flashtestations", block_number = ctx.block_number(), tx_hash = ?funding_tx.tx_hash(), "adding funding tx to builder txs");
174-
evm.db_mut().commit(state);
175-
Ok(Some(BuilderTransactionCtx {
176-
gas_used: 21000,
177-
da_size,
178-
signed_tx: funding_tx,
179-
is_top_of_block: false,
180-
}))
181-
} else {
182-
Ok(None)
183-
}
184-
}
185-
186-
// TODO: deprecate in favour of permit calls
187-
fn register_tee_service_tx(
188-
&self,
189-
ctx: &OpPayloadBuilderCtx<ExtraCtx>,
190-
evm: &mut OpEvm<&mut State<impl Database + DatabaseRef>, NoOpInspector, PrecompilesMap>,
191-
) -> Result<BuilderTransactionCtx, BuilderTransactionError> {
192-
let calldata = IFlashtestationRegistry::registerTEEServiceCall {
193-
rawQuote: self.attestation.clone().into(),
194-
extendedRegistrationData: self.extra_registration_data.clone(),
195-
};
196-
let SimulationSuccessResult {
197-
gas_used,
198-
state_changes,
199-
..
200-
} = self.flashtestation_call(
201-
self.registry_address,
202-
calldata.clone(),
203-
vec![TEEServiceRegistered::SIGNATURE_HASH],
204-
ctx,
205-
evm,
206-
)?;
207-
let signed_tx = self.sign_tx(
208-
self.registry_address,
209-
self.tee_service_signer,
210-
gas_used,
211-
calldata.abi_encode().into(),
212-
ctx,
213-
evm.db(),
214-
)?;
215-
let da_size =
216-
op_alloy_flz::tx_estimated_size_fjord_bytes(signed_tx.encoded_2718().as_slice());
217-
// commit the register transaction state so the block proof transaction can succeed
218-
evm.db_mut().commit(state_changes);
219-
Ok(BuilderTransactionCtx {
220-
gas_used,
221-
da_size,
222-
signed_tx,
223-
is_top_of_block: false,
224-
})
225-
}
226-
227-
// TODO: remove in favour of permit calls
228-
fn verify_block_proof_tx(
229-
&self,
230-
transactions: Vec<OpTransactionSigned>,
231-
ctx: &OpPayloadBuilderCtx<ExtraCtx>,
232-
evm: &mut OpEvm<impl Database + DatabaseRef, NoOpInspector, PrecompilesMap>,
233-
) -> Result<BuilderTransactionCtx, BuilderTransactionError> {
234-
let block_content_hash = Self::compute_block_content_hash(
235-
&transactions,
236-
ctx.parent_hash(),
237-
ctx.block_number(),
238-
ctx.timestamp(),
239-
);
240-
241-
let calldata = IBlockBuilderPolicy::verifyBlockBuilderProofCall {
242-
blockContentHash: block_content_hash,
243-
version: self.builder_proof_version,
244-
};
245-
let SimulationSuccessResult { gas_used, .. } = self.flashtestation_call(
246-
self.builder_policy_address,
247-
calldata.clone(),
248-
vec![BlockBuilderProofVerified::SIGNATURE_HASH],
249-
ctx,
250-
evm,
251-
)?;
252-
let signed_tx = self.sign_tx(
253-
self.builder_policy_address,
254-
self.tee_service_signer,
255-
gas_used,
256-
calldata.abi_encode().into(),
257-
ctx,
258-
evm.db(),
259-
)?;
260-
let da_size =
261-
op_alloy_flz::tx_estimated_size_fjord_bytes(signed_tx.encoded_2718().as_slice());
262-
Ok(BuilderTransactionCtx {
263-
gas_used,
264-
da_size,
265-
signed_tx,
266-
is_top_of_block: false,
267-
})
268-
}
269-
270124
fn set_registered(
271125
&self,
272126
state_provider: impl StateProvider + Clone,
@@ -534,35 +388,18 @@ where
534388

535389
if !self.registered.load(std::sync::atomic::Ordering::SeqCst) {
536390
info!(target: "flashtestations", "tee service not registered yet, attempting to register");
537-
let register_tx = if self.use_permit {
538-
self.signed_registration_permit_tx(ctx, &mut evm)?
539-
} else {
540-
builder_txs.extend(self.fund_tee_service_tx(ctx, &mut evm)?);
541-
self.register_tee_service_tx(ctx, &mut evm)?
542-
};
391+
let register_tx = self.signed_registration_permit_tx(ctx, &mut evm)?;
543392
builder_txs.push(register_tx);
544393
}
545394

546395
// don't return on error for block proof as previous txs in builder_txs will not be returned
547396
if self.enable_block_proofs {
548-
if self.use_permit {
549-
debug!(target: "flashtestations", "adding permit verify block proof tx");
550-
match self.signed_block_proof_permit_tx(&info.executed_transactions, ctx, &mut evm)
551-
{
552-
Ok(block_proof_tx) => builder_txs.push(block_proof_tx),
553-
Err(e) => {
554-
warn!(target: "flashtestations", error = ?e, "failed to add permit block proof transaction")
555-
}
397+
debug!(target: "flashtestations", "adding permit verify block proof tx");
398+
match self.signed_block_proof_permit_tx(&info.executed_transactions, ctx, &mut evm) {
399+
Ok(block_proof_tx) => builder_txs.push(block_proof_tx),
400+
Err(e) => {
401+
warn!(target: "flashtestations", error = ?e, "failed to add permit block proof transaction")
556402
}
557-
} else {
558-
// add verify block proof tx
559-
match self.verify_block_proof_tx(info.executed_transactions.clone(), ctx, &mut evm)
560-
{
561-
Ok(block_proof_tx) => builder_txs.push(block_proof_tx),
562-
Err(e) => {
563-
warn!(target: "flashtestations", error = ?e, "failed to add block proof transaction")
564-
}
565-
};
566403
}
567404
}
568405
Ok(builder_txs)

0 commit comments

Comments
 (0)