1- use alloy_consensus:: TxEip1559 ;
21use alloy_eips:: Encodable2718 ;
32use alloy_evm:: Database ;
43use 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} ;
65use alloy_rpc_types_eth:: TransactionInput ;
76use alloy_sol_types:: { SolCall , SolEvent , SolValue } ;
87use core:: fmt:: Debug ;
9- use op_alloy_consensus:: OpTypedTransaction ;
108use op_alloy_rpc_types:: OpTransactionRequest ;
11- use reth_evm:: { ConfigureEvm , Evm , EvmError , precompiles:: PrecompilesMap } ;
9+ use reth_evm:: { ConfigureEvm , Evm , precompiles:: PrecompilesMap } ;
1210use reth_optimism_primitives:: OpTransactionSigned ;
1311use reth_provider:: StateProvider ;
1412use reth_revm:: { State , database:: StateProviderDatabase } ;
15- use revm:: {
16- DatabaseCommit , DatabaseRef , context:: result:: ResultAndState , inspector:: NoOpInspector ,
17- } ;
13+ use revm:: { DatabaseCommit , DatabaseRef , inspector:: NoOpInspector } ;
1814use std:: sync:: { Arc , atomic:: AtomicBool } ;
1915use tracing:: { debug, info, warn} ;
2016
2117use 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
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
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