Skip to content

Commit bb35cba

Browse files
committed
Merge branch 'reth-1.2.0' into f-reth-1.2.0-op
2 parents 8be6034 + 6b5c83a commit bb35cba

File tree

3 files changed

+31
-33
lines changed

3 files changed

+31
-33
lines changed

crates/rbuilder/benches/benchmarks/mev_boost.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
use alloy_consensus::{Block, Header};
12
use alloy_eips::eip4844::BlobTransactionSidecar;
2-
use alloy_primitives::{BlockHash, U256};
3+
use alloy_primitives::U256;
34
use criterion::{criterion_group, Criterion};
45
use primitive_types::H384;
56
use rbuilder::mev_boost::{
@@ -8,7 +9,7 @@ use rbuilder::mev_boost::{
89
};
910
use reth::primitives::SealedBlock;
1011
use reth_chainspec::SEPOLIA;
11-
use reth_primitives::{kzg::Blob, SealedHeader};
12+
use reth_primitives::kzg::Blob;
1213
use std::{fs, path::PathBuf, sync::Arc};
1314

1415
fn mev_boost_serialize_submit_block(data: DenebSubmitBlockRequest) {
@@ -98,13 +99,15 @@ fn bench_mevboost_sign(c: &mut Criterion) {
9899

99100
// Create a sealed block that is after the Cancun hard fork in Sepolia
100101
// this is, a timestamp higher than 1706655072
101-
let mut sealed_block_deneb: SealedBlock<alloy_consensus::Header, reth_primitives::BlockBody> =
102-
SealedBlock::default();
103-
let mut header = sealed_block_deneb.header().clone();
104-
header.timestamp = 2706655072;
105-
header.blob_gas_used = Some(64);
106-
header.excess_blob_gas = Some(64);
107-
sealed_block_deneb.header = SealedHeader::new(header.clone(), BlockHash::default());
102+
let sealed_block_deneb = SealedBlock::new_unhashed(Block::new(
103+
Header {
104+
timestamp: 2706655072,
105+
blob_gas_used: Some(64),
106+
excess_blob_gas: Some(64),
107+
..Default::default()
108+
},
109+
Default::default(),
110+
));
108111

109112
group.bench_function("Deneb", |b| {
110113
b.iter(|| {

crates/rbuilder/src/building/mod.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use revm::{
5555
db::states::bundle_state::BundleRetention,
5656
primitives::{BlobExcessGasAndPrice, BlockEnv, SpecId},
5757
};
58-
use revm_primitives::InvalidTransaction;
58+
use revm_primitives::{InvalidTransaction, B256};
5959
use serde::Deserialize;
6060
use std::{
6161
hash::Hash,
@@ -601,13 +601,13 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {
601601
Ok(())
602602
}
603603

604-
/// Mostly based on reth's (v1.1.1) default_ethereum_payload_builder.
605-
#[allow(clippy::too_many_arguments)]
606-
pub fn finalize(
607-
self,
604+
/// returns (requests,withdrawals_root)
605+
pub fn process_requests(
606+
&self,
608607
state: &mut BlockState,
609608
ctx: &BlockBuildingContext,
610-
) -> Result<FinalizeResult, FinalizeError> {
609+
) -> Result<(Option<Requests>, Option<B256>), FinalizeError> {
610+
let mut db = state.new_db_ref();
611611
let requests = if ctx
612612
.chain_spec
613613
.is_prague_active_at_timestamp(ctx.attributes.timestamp())
@@ -616,8 +616,6 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {
616616
EthEvmConfig::new(ctx.chain_spec.clone()),
617617
ctx.chain_spec.clone(),
618618
);
619-
let mut db = state.new_db_ref();
620-
621619
let deposit_requests =
622620
parse_deposits_from_receipts(&ctx.chain_spec, self.receipts.iter())
623621
.map_err(|err| FinalizeError::Other(err.into()))?;
@@ -644,7 +642,6 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {
644642
};
645643

646644
let withdrawals_root = {
647-
let mut db = state.new_db_ref();
648645
let withdrawals_root = commit_withdrawals(
649646
db.as_mut(),
650647
&ctx.chain_spec,
@@ -657,7 +654,17 @@ impl<Tracer: SimulationTracer> PartialBlock<Tracer> {
657654
db.as_mut().merge_transitions(BundleRetention::Reverts);
658655
withdrawals_root
659656
};
657+
Ok((requests, withdrawals_root))
658+
}
660659

660+
/// Mostly based on reth's (v1.2) default_ethereum_payload_builder.
661+
#[allow(clippy::too_many_arguments)]
662+
pub fn finalize(
663+
self,
664+
state: &mut BlockState,
665+
ctx: &BlockBuildingContext,
666+
) -> Result<FinalizeResult, FinalizeError> {
667+
let (requests, withdrawals_root) = self.process_requests(state, ctx)?;
661668
let (cached_reads, bundle) = state.clone_bundle_and_cache();
662669
let block_number = ctx.evm_env.block_env.number.to::<u64>();
663670

crates/rbuilder/src/live_builder/order_input/txpool_fetcher.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
primitives::{MempoolTx, Order, TransactionSignedEcRecoveredWithBlobs},
44
telemetry::{add_txfetcher_time_to_query, mark_command_received},
55
};
6-
use alloy_primitives::{hex, Bytes, FixedBytes};
6+
use alloy_primitives::FixedBytes;
77
use alloy_provider::{IpcConnect, Provider, ProviderBuilder};
88
use futures::StreamExt;
99
use std::{pin::pin, time::Instant};
@@ -95,23 +95,11 @@ async fn get_tx_with_blobs(
9595
tx_hash: FixedBytes<32>,
9696
provider: &impl alloy_provider::Provider,
9797
) -> eyre::Result<Option<TransactionSignedEcRecoveredWithBlobs>> {
98-
// TODO: Use https://github.com/alloy-rs/alloy/pull/1168 when it gets cut
99-
// in a release
100-
let raw_tx: Option<String> = provider
101-
.client()
102-
.request("eth_getRawTransactionByHash", vec![tx_hash])
103-
.await?;
104-
105-
let raw_tx = if let Some(raw_tx) = raw_tx {
106-
raw_tx
107-
} else {
98+
let Some(response) = provider.get_raw_transaction_by_hash(tx_hash).await? else {
10899
return Ok(None);
109100
};
110-
111-
let raw_tx = hex::decode(raw_tx)?;
112-
let raw_tx = Bytes::from(raw_tx);
113101
Ok(Some(
114-
TransactionSignedEcRecoveredWithBlobs::decode_enveloped_with_real_blobs(raw_tx)?,
102+
TransactionSignedEcRecoveredWithBlobs::decode_enveloped_with_real_blobs(response)?,
115103
))
116104
}
117105

0 commit comments

Comments
 (0)