Skip to content

Commit ca90c3c

Browse files
committed
fix registration retries
1 parent 35b51a6 commit ca90c3c

File tree

7 files changed

+51
-21
lines changed

7 files changed

+51
-21
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/op-rbuilder/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ http = "1.0"
122122
sha3 = "0.10"
123123
hex = "0.4"
124124
ureq = "2.10"
125+
k256 = "0.13.4"
125126

126127
rollup-boost = { git = "http://github.com/flashbots/rollup-boost", branch = "main" }
127128

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ impl From<BuilderTransactionError> for PayloadBuilderError {
7373
pub trait BuilderTransactions: Debug {
7474
fn simulate_builder_txs<Extra: Debug + Default>(
7575
&self,
76-
state_provider: impl StateProvider,
76+
state_provider: impl StateProvider + Clone,
7777
info: &mut ExecutionInfo<Extra>,
7878
ctx: &OpPayloadBuilderCtx,
7979
db: &mut State<impl Database>,
8080
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError>;
8181

8282
fn add_builder_txs<Extra: Debug + Default>(
8383
&self,
84-
state_provider: impl StateProvider,
84+
state_provider: impl StateProvider + Clone,
8585
info: &mut ExecutionInfo<Extra>,
8686
builder_ctx: &OpPayloadBuilderCtx,
8787
db: &mut State<impl Database>,
@@ -235,7 +235,7 @@ impl StandardBuilderTx {
235235
impl BuilderTransactions for StandardBuilderTx {
236236
fn simulate_builder_txs<Extra: Debug + Default>(
237237
&self,
238-
_state_provider: impl StateProvider,
238+
_state_provider: impl StateProvider + Clone,
239239
_info: &mut ExecutionInfo<Extra>,
240240
ctx: &OpPayloadBuilderCtx,
241241
db: &mut State<impl Database>,

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

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use alloy::sol_types::{SolCall, SolEvent, SolValue};
21
use alloy_consensus::TxEip1559;
32
use alloy_eips::Encodable2718;
43
use alloy_evm::Database;
54
use alloy_op_evm::OpEvm;
65
use alloy_primitives::{keccak256, map::foldhash::HashMap, Address, Bytes, TxKind, B256, U256};
6+
use alloy_sol_types::{SolCall, SolEvent, SolValue};
77
use core::fmt::Debug;
88
use op_alloy_consensus::OpTypedTransaction;
99
use reth_evm::{precompiles::PrecompilesMap, ConfigureEvm, Evm, EvmError};
@@ -385,7 +385,7 @@ impl FlashtestationsBuilderTx {
385385
}
386386
}
387387
};
388-
info!(target: "flashtestations", "adding funding tx to builder txs");
388+
info!(target: "flashtestations", block_number = ctx.block_number(), tx_hash = ?funding_tx.tx_hash(), "adding funding tx to builder txs");
389389
evm.db_mut().commit(state);
390390
Ok(Some(BuilderTransactionCtx {
391391
gas_used: 21000,
@@ -431,7 +431,7 @@ impl FlashtestationsBuilderTx {
431431
let da_size = op_alloy_flz::tx_estimated_size_fjord_bytes(
432432
register_tx.encoded_2718().as_slice(),
433433
);
434-
info!(target: "flashtestations", "adding register tee tx to builder txs");
434+
info!(target: "flashtestations", block_number = ctx.block_number(), tx_hash = ?register_tx.tx_hash(), "adding register tee tx to builder txs");
435435
evm.db_mut().commit(state_changes);
436436
Ok((
437437
Some(BuilderTransactionCtx {
@@ -494,7 +494,7 @@ impl FlashtestationsBuilderTx {
494494
let da_size = op_alloy_flz::tx_estimated_size_fjord_bytes(
495495
verify_block_proof_tx.encoded_2718().as_slice(),
496496
);
497-
debug!(target: "flashtestations", "adding verify block proof tx to builder txs");
497+
debug!(target: "flashtestations", block_number = ctx.block_number(), tx_hash = ?verify_block_proof_tx.tx_hash(), "adding verify block proof tx to builder txs");
498498
Ok(Some(BuilderTransactionCtx {
499499
gas_used,
500500
da_size,
@@ -507,21 +507,47 @@ impl FlashtestationsBuilderTx {
507507
.simulate_builder_tx(ctx, evm.db_mut())
508508
}
509509
}
510+
511+
fn set_registered(
512+
&self,
513+
state_provider: impl StateProvider + Clone,
514+
ctx: &OpPayloadBuilderCtx,
515+
) {
516+
let state = StateProviderDatabase::new(state_provider.clone());
517+
let mut simulation_state = State::builder()
518+
.with_database(state)
519+
.with_bundle_update()
520+
.build();
521+
let mut evm = ctx
522+
.evm_config
523+
.evm_with_env(&mut simulation_state, ctx.evm_env.clone());
524+
evm.modify_cfg(|cfg| {
525+
cfg.disable_balance_check = true;
526+
});
527+
match self.register_tee_service_tx(ctx, &mut evm) {
528+
Ok((_, registered)) => {
529+
self.registered.store(registered, Ordering::Relaxed);
530+
}
531+
Err(e) => {
532+
debug!(target: "flashtestations", error = ?e, "simulation error when checking if registered");
533+
}
534+
}
535+
}
510536
}
511537

512538
impl BuilderTransactions for FlashtestationsBuilderTx {
513539
fn simulate_builder_txs<Extra: Debug + Default>(
514540
&self,
515-
state_provider: impl StateProvider,
541+
state_provider: impl StateProvider + Clone,
516542
info: &mut ExecutionInfo<Extra>,
517543
ctx: &OpPayloadBuilderCtx,
518544
db: &mut State<impl Database>,
519545
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError> {
520-
let state = StateProviderDatabase::new(state_provider);
546+
let state = StateProviderDatabase::new(state_provider.clone());
521547
let mut simulation_state = State::builder()
522548
.with_database(state)
523-
.with_bundle_prestate(db.bundle_state.clone())
524549
.with_cached_prestate(db.cache.clone())
550+
.with_bundle_prestate(db.bundle_state.clone())
525551
.with_bundle_update()
526552
.build();
527553

@@ -535,11 +561,10 @@ impl BuilderTransactions for FlashtestationsBuilderTx {
535561
let mut builder_txs = Vec::<BuilderTransactionCtx>::new();
536562

537563
if !self.registered.load(Ordering::Relaxed) {
564+
info!(target: "flashtestations", "tee service not registered yet, attempting to add registration tx");
565+
self.set_registered(state_provider, ctx);
538566
builder_txs.extend(self.fund_tee_service_tx(ctx, &mut evm)?);
539-
let (register_tx, registered) = self.register_tee_service_tx(ctx, &mut evm)?;
540-
if registered {
541-
self.registered.store(true, Ordering::Relaxed);
542-
}
567+
let (register_tx, _) = self.register_tee_service_tx(ctx, &mut evm)?;
543568
builder_txs.extend(register_tx);
544569
}
545570

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use alloy::{sol, sol_types::SolError};
21
use alloy_primitives::{Address, Bytes, FixedBytes, B256, U256};
2+
use alloy_sol_types::{sol, SolError};
33

44
sol!(
55
#[sol(rpc, abi)]

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
use alloy_json_rpc::RpcError;
22
use alloy_network::ReceiptResponse;
3-
use alloy_primitives::{keccak256, Address, Bytes, TxHash, TxKind, B256, U256};
3+
use alloy_primitives::{Address, Bytes, TxHash, TxKind, U256};
44
use alloy_rpc_types_eth::TransactionRequest;
5-
use alloy_transport::TransportResult;
5+
use alloy_sol_types::SolCall;
6+
use alloy_transport::{TransportError, TransportErrorKind, TransportResult};
7+
use k256::ecdsa;
68
use std::time::Duration;
79

8-
use alloy_provider::{PendingTransactionBuilder, Provider, ProviderBuilder};
10+
use alloy_provider::{
11+
PendingTransactionBuilder, PendingTransactionError, Provider, ProviderBuilder,
12+
};
913
use alloy_signer_local::PrivateKeySigner;
10-
use alloy_sol_types::{sol, SolCall, SolValue};
1114
use op_alloy_network::Optimism;
1215
use tracing::{debug, error, info, warn};
1316

crates/op-rbuilder/src/tx_signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::str::FromStr;
22

3-
use alloy::signers::k256::sha2::Sha256;
43
use alloy_consensus::SignableTransaction;
54
use alloy_primitives::{Address, Signature, B256, U256};
5+
use k256::sha2::Sha256;
66
use op_alloy_consensus::OpTypedTransaction;
77
use reth_optimism_primitives::OpTransactionSigned;
88
use reth_primitives::Recovered;

0 commit comments

Comments
 (0)