Skip to content

Commit 35b51a6

Browse files
committed
fix log validation
1 parent 8b9f17b commit 35b51a6

File tree

8 files changed

+34
-46
lines changed

8 files changed

+34
-46
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cargo run -p op-rbuilder --bin op-rbuilder --features=flashtestations -- node \
6868
- `--flashtestations.enable-block-proofs`: Enable end-of-block transaction proofs that verify the block was built within a TEE
6969
- `--flashtestations.debug`: Enable debug mode with a deterministic TEE key and debug attestation server for testing and development
7070
- `--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
71+
- `--flashtestations.rpc-url <URL>`: Use a remote rpc provider to submit attestations to
7272

7373
## Observability
7474

crates/op-rbuilder/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ alloy-primitives.workspace = true
5959
alloy-consensus.workspace = true
6060
alloy-contract.workspace = true
6161
alloy-eips.workspace = true
62+
alloy-evm.workspace = true
6263
alloy-rpc-types-beacon.workspace = true
6364
alloy-rpc-types-engine.workspace = true
6465
alloy-transport-http.workspace = true

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use alloy_consensus::TxEip1559;
22
use alloy_eips::{eip7623::TOTAL_COST_FLOOR_PER_TOKEN, Encodable2718};
3+
use alloy_evm::Database;
34
use alloy_primitives::{
45
map::foldhash::{HashSet, HashSetExt},
56
Address, TxKind,
@@ -15,7 +16,7 @@ use reth_provider::{ProviderError, StateProvider};
1516
use reth_revm::State;
1617
use revm::{
1718
context::result::{EVMError, ResultAndState},
18-
Database, DatabaseCommit,
19+
DatabaseCommit,
1920
};
2021
use tracing::{debug, warn};
2122

@@ -75,15 +76,15 @@ pub trait BuilderTransactions: Debug {
7576
state_provider: impl StateProvider,
7677
info: &mut ExecutionInfo<Extra>,
7778
ctx: &OpPayloadBuilderCtx,
78-
db: &mut State<impl Database<Error = ProviderError>>,
79+
db: &mut State<impl Database>,
7980
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError>;
8081

8182
fn add_builder_txs<Extra: Debug + Default>(
8283
&self,
8384
state_provider: impl StateProvider,
8485
info: &mut ExecutionInfo<Extra>,
8586
builder_ctx: &OpPayloadBuilderCtx,
86-
db: &mut State<impl Database<Error = ProviderError>>,
87+
db: &mut State<impl Database>,
8788
) -> Result<(), BuilderTransactionError> {
8889
{
8990
let mut evm = builder_ctx
@@ -156,7 +157,7 @@ impl StandardBuilderTx {
156157
pub fn simulate_builder_tx(
157158
&self,
158159
ctx: &OpPayloadBuilderCtx,
159-
db: &mut State<impl Database<Error = ProviderError>>,
160+
db: &mut State<impl Database>,
160161
) -> Result<Option<BuilderTransactionCtx>, BuilderTransactionError> {
161162
match self.signer {
162163
Some(signer) => {
@@ -197,17 +198,14 @@ impl StandardBuilderTx {
197198
std::cmp::max(zero_cost + nonzero_cost + 21_000, floor_gas)
198199
}
199200

200-
fn signed_builder_tx<DB>(
201+
fn signed_builder_tx(
201202
&self,
202203
ctx: &OpPayloadBuilderCtx,
203-
db: &mut State<DB>,
204+
db: &mut State<impl Database>,
204205
signer: Signer,
205206
gas_used: u64,
206207
message: Vec<u8>,
207-
) -> Result<Recovered<OpTransactionSigned>, BuilderTransactionError>
208-
where
209-
DB: Database<Error = ProviderError>,
210-
{
208+
) -> Result<Recovered<OpTransactionSigned>, BuilderTransactionError> {
211209
let nonce = db
212210
.load_cache_account(signer.address)
213211
.map(|acc| acc.account_info().unwrap_or_default().nonce)
@@ -240,7 +238,7 @@ impl BuilderTransactions for StandardBuilderTx {
240238
_state_provider: impl StateProvider,
241239
_info: &mut ExecutionInfo<Extra>,
242240
ctx: &OpPayloadBuilderCtx,
243-
db: &mut State<impl Database<Error = ProviderError>>,
241+
db: &mut State<impl Database>,
244242
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError> {
245243
let builder_tx = self.simulate_builder_tx(ctx, db)?;
246244
Ok(builder_tx.into_iter().collect())

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

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use alloy_consensus::{conditional::BlockConditionalAttributes, Eip658Value, Transaction};
22
use alloy_eips::Typed2718;
3+
use alloy_evm::Database;
34
use alloy_op_evm::block::receipt_builder::OpReceiptBuilder;
45
use alloy_primitives::{BlockHash, Bytes, U256};
56
use alloy_rpc_types_eth::Withdrawals;
@@ -27,12 +28,9 @@ use reth_optimism_txpool::{
2728
use reth_payload_builder::PayloadId;
2829
use reth_primitives::SealedHeader;
2930
use reth_primitives_traits::{InMemorySize, SignedTransaction};
30-
use reth_provider::ProviderError;
3131
use reth_revm::{context::Block, State};
3232
use reth_transaction_pool::{BestTransactionsAttributes, PoolTransaction};
33-
use revm::{
34-
context::result::ResultAndState, interpreter::as_u64_saturated, Database, DatabaseCommit,
35-
};
33+
use revm::{context::result::ResultAndState, interpreter::as_u64_saturated, DatabaseCommit};
3634
use std::{sync::Arc, time::Instant};
3735
use tokio_util::sync::CancellationToken;
3836
use tracing::{debug, info, trace};
@@ -237,13 +235,10 @@ impl OpPayloadBuilderCtx {
237235
}
238236

239237
/// Executes all sequencer transactions that are included in the payload attributes.
240-
pub fn execute_sequencer_transactions<DB, E: Debug + Default>(
238+
pub fn execute_sequencer_transactions<E: Debug + Default>(
241239
&self,
242-
db: &mut State<DB>,
243-
) -> Result<ExecutionInfo<E>, PayloadBuilderError>
244-
where
245-
DB: Database<Error = ProviderError> + std::fmt::Debug,
246-
{
240+
db: &mut State<impl Database>,
241+
) -> Result<ExecutionInfo<E>, PayloadBuilderError> {
247242
let mut info = ExecutionInfo::with_capacity(self.attributes().transactions.len());
248243

249244
let mut evm = self.evm_config.evm_with_env(&mut *db, self.evm_env.clone());
@@ -324,17 +319,14 @@ impl OpPayloadBuilderCtx {
324319
/// Executes the given best transactions and updates the execution info.
325320
///
326321
/// Returns `Ok(Some(())` if the job was cancelled.
327-
pub fn execute_best_transactions<DB, E: Debug + Default>(
322+
pub fn execute_best_transactions<E: Debug + Default>(
328323
&self,
329324
info: &mut ExecutionInfo<E>,
330-
db: &mut State<DB>,
325+
db: &mut State<impl Database>,
331326
mut best_txs: impl PayloadTxsBounds,
332327
block_gas_limit: u64,
333328
block_da_limit: Option<u64>,
334-
) -> Result<Option<()>, PayloadBuilderError>
335-
where
336-
DB: Database<Error = ProviderError> + std::fmt::Debug,
337-
{
329+
) -> Result<Option<()>, PayloadBuilderError> {
338330
let execute_txs_start_time = Instant::now();
339331
let mut num_txs_considered = 0;
340332
let mut num_txs_simulated = 0;
@@ -343,11 +335,7 @@ impl OpPayloadBuilderCtx {
343335
let mut num_bundles_reverted = 0;
344336
let base_fee = self.base_fee();
345337
let tx_da_limit = self.da_config.max_da_tx_size();
346-
let mut evm: alloy_op_evm::OpEvm<
347-
&mut State<DB>,
348-
revm::inspector::NoOpInspector,
349-
reth_evm::precompiles::PrecompilesMap,
350-
> = self.evm_config.evm_with_env(&mut *db, self.evm_env.clone());
338+
let mut evm = self.evm_config.evm_with_env(&mut *db, self.evm_env.clone());
351339

352340
info!(
353341
target: "payload_builder",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ where
367367
flashblock_count = flashblock_count,
368368
target_gas = total_gas_per_batch,
369369
gas_used = info.cumulative_gas_used,
370-
target_da = total_da_per_batch.unwrap_or(0),
370+
target_da = total_da_per_batch,
371371
da_used = info.cumulative_da_bytes_used,
372372
"Building flashblock",
373373
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use alloy_consensus::{
99
constants::EMPTY_WITHDRAWALS, proofs, BlockBody, Header, EMPTY_OMMER_ROOT_HASH,
1010
};
1111
use alloy_eips::{eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE};
12+
use alloy_evm::Database;
1213
use alloy_primitives::U256;
1314
use reth::payload::PayloadBuilderAttributes;
1415
use reth_basic_payload_builder::{BuildOutcome, BuildOutcomeKind, MissingPayloadBehaviour};
@@ -22,14 +23,13 @@ use reth_optimism_node::{OpBuiltPayload, OpPayloadBuilderAttributes};
2223
use reth_optimism_primitives::{OpPrimitives, OpTransactionSigned};
2324
use reth_payload_util::{BestPayloadTransactions, NoopPayloadTransactions, PayloadTransactions};
2425
use reth_primitives::RecoveredBlock;
25-
use reth_provider::{ExecutionOutcome, ProviderError, StateProvider};
26+
use reth_provider::{ExecutionOutcome, StateProvider};
2627
use reth_revm::{
2728
database::StateProviderDatabase, db::states::bundle_state::BundleRetention, State,
2829
};
2930
use reth_transaction_pool::{
3031
BestTransactions, BestTransactionsAttributes, PoolTransaction, TransactionPool,
3132
};
32-
use revm::Database;
3333
use std::{sync::Arc, time::Instant};
3434
use tokio_util::sync::CancellationToken;
3535
use tracing::{error, info, warn};
@@ -300,7 +300,7 @@ impl<Txs: PayloadTxsBounds> OpBuilder<'_, Txs> {
300300
pub fn execute<BuilderTx>(
301301
self,
302302
state_provider: impl StateProvider,
303-
db: &mut State<impl Database<Error = ProviderError>>,
303+
db: &mut State<impl Database>,
304304
ctx: &OpPayloadBuilderCtx,
305305
builder_tx: BuilderTx,
306306
) -> Result<BuildOutcomeKind<ExecutedPayload>, PayloadBuilderError>
@@ -392,7 +392,7 @@ impl<Txs: PayloadTxsBounds> OpBuilder<'_, Txs> {
392392
/// Builds the payload on top of the state.
393393
pub fn build<BuilderTx>(
394394
self,
395-
state: impl Database<Error = ProviderError>,
395+
state: impl Database,
396396
state_provider: impl StateProvider,
397397
ctx: OpPayloadBuilderCtx,
398398
builder_tx: BuilderTx,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
use alloy::sol_types::{SolCall, SolEvent, SolValue};
22
use alloy_consensus::TxEip1559;
33
use alloy_eips::Encodable2718;
4+
use alloy_evm::Database;
45
use alloy_op_evm::OpEvm;
56
use alloy_primitives::{keccak256, map::foldhash::HashMap, Address, Bytes, TxKind, B256, U256};
67
use core::fmt::Debug;
78
use op_alloy_consensus::OpTypedTransaction;
89
use reth_evm::{precompiles::PrecompilesMap, ConfigureEvm, Evm, EvmError};
910
use reth_optimism_primitives::OpTransactionSigned;
1011
use reth_primitives::{Log, Recovered};
11-
use reth_provider::{ProviderError, StateProvider};
12+
use reth_provider::StateProvider;
1213
use reth_revm::{database::StateProviderDatabase, State};
1314
use revm::{
1415
context::result::{ExecutionResult, ResultAndState},
1516
inspector::NoOpInspector,
1617
state::Account,
17-
Database, DatabaseCommit,
18+
DatabaseCommit,
1819
};
1920
use std::sync::{
2021
atomic::{AtomicBool, Ordering},
@@ -177,6 +178,7 @@ impl FlashtestationsBuilderTx {
177178

178179
/// Computes the block content hash according to the formula:
179180
/// keccak256(abi.encode(parentHash, blockNumber, timestamp, transactionHashes))
181+
/// https://github.com/flashbots/rollup-boost/blob/main/specs/flashtestations.md#block-building-process
180182
fn compute_block_content_hash(
181183
transactions: Vec<OpTransactionSigned>,
182184
parent_hash: B256,
@@ -269,9 +271,9 @@ impl FlashtestationsBuilderTx {
269271

270272
fn check_tee_address_registered_log(&self, logs: Vec<Log>, address: Address) -> bool {
271273
for log in logs {
272-
if log.topics().len() > 1 && log.topics()[0] == TEEServiceRegistered::SIGNATURE_HASH {
274+
if log.topics().first() == Some(&TEEServiceRegistered::SIGNATURE_HASH) {
273275
if let Ok(decoded) = TEEServiceRegistered::decode_log(&log) {
274-
if decoded.address == address {
276+
if decoded.teeAddress == address {
275277
return true;
276278
}
277279
};
@@ -343,9 +345,7 @@ impl FlashtestationsBuilderTx {
343345

344346
fn check_verify_block_proof_log(&self, logs: Vec<Log>) -> bool {
345347
for log in logs {
346-
if log.topics().len() > 1
347-
&& log.topics()[0] == BlockBuilderProofVerified::SIGNATURE_HASH
348-
{
348+
if log.topics().first() == Some(&BlockBuilderProofVerified::SIGNATURE_HASH) {
349349
return true;
350350
}
351351
}
@@ -515,7 +515,7 @@ impl BuilderTransactions for FlashtestationsBuilderTx {
515515
state_provider: impl StateProvider,
516516
info: &mut ExecutionInfo<Extra>,
517517
ctx: &OpPayloadBuilderCtx,
518-
db: &mut State<impl Database<Error = ProviderError>>,
518+
db: &mut State<impl Database>,
519519
) -> Result<Vec<BuilderTransactionCtx>, BuilderTransactionError> {
520520
let state = StateProviderDatabase::new(state_provider);
521521
let mut simulation_state = State::builder()

0 commit comments

Comments
 (0)