Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
config::FlashBlocksConfigExt,
timing::FlashblockScheduler,
},
generator::{BlockCell, BuildArguments, PayloadBuilder},
generator::{BuildArguments, PayloadBuilder},
},
gas_limiter::AddressGasLimiter,
metrics::OpRBuilderMetrics,
Expand Down Expand Up @@ -52,7 +52,7 @@ use reth_transaction_pool::TransactionPool;
use reth_trie::{HashedPostState, updates::TrieUpdates};
use revm::Database;
use std::{collections::BTreeMap, sync::Arc, time::Instant};
use tokio::sync::mpsc;
use tokio::sync::{mpsc, watch};
use tokio_util::sync::CancellationToken;
use tracing::{debug, error, info, metadata::Level, span, warn};

Expand Down Expand Up @@ -401,7 +401,7 @@ where
async fn build_payload(
&self,
args: BuildArguments<OpPayloadBuilderAttributes<OpTransactionSigned>, OpBuiltPayload>,
best_payload: BlockCell<OpBuiltPayload>,
best_payload_tx: watch::Sender<Option<OpBuiltPayload>>,
) -> Result<(), PayloadBuilderError> {
let block_build_start_time = Instant::now();
let BuildArguments {
Expand Down Expand Up @@ -499,7 +499,7 @@ where
"Failed to send updated payload"
);
}
best_payload.set(payload);
best_payload_tx.send_replace(Some(payload));

info!(
target: "payload_builder",
Expand Down Expand Up @@ -672,7 +672,6 @@ where
&state_provider,
&mut best_txs,
&block_cancel,
&best_payload,
);

let cache = std::mem::take(&mut state.cache);
Expand All @@ -684,7 +683,10 @@ where
transition = new_transition;

let next_flashblock_state = match build_result {
Ok(Some(next_flashblock_state)) => next_flashblock_state,
Ok(Some((next_flashblock_state, new_payload))) => {
best_payload_tx.send_replace(Some(new_payload));
next_flashblock_state
}
Ok(None) => {
self.record_flashblocks_metrics(
&ctx,
Expand Down Expand Up @@ -726,8 +728,7 @@ where
state_provider: impl reth::providers::StateProvider + Clone,
best_txs: &mut NextFlashblockPoolTxCursor<'a, Pool>,
block_cancel: &CancellationToken,
best_payload: &BlockCell<OpBuiltPayload>,
) -> eyre::Result<Option<FlashblocksState>> {
) -> eyre::Result<Option<(FlashblocksState, OpBuiltPayload)>> {
let flashblock_index = fb_state.flashblock_index();
let mut target_gas_for_batch = fb_state.target_gas_for_batch();
let mut target_da_for_batch = fb_state.target_da_for_batch();
Expand Down Expand Up @@ -893,8 +894,6 @@ where
"Failed to send updated payload"
);
}
best_payload.set(new_payload);

// Record flashblock build duration
ctx.metrics
.flashblock_build_duration
Expand Down Expand Up @@ -944,7 +943,7 @@ where
"Flashblock built"
);

Ok(Some(next_flashblock_state))
Ok(Some((next_flashblock_state, new_payload)))
}
}
}
Expand Down Expand Up @@ -998,9 +997,9 @@ where
async fn try_build(
&self,
args: BuildArguments<Self::Attributes, Self::BuiltPayload>,
best_payload: BlockCell<Self::BuiltPayload>,
best_payload_tx: watch::Sender<Option<Self::BuiltPayload>>,
) -> Result<(), PayloadBuilderError> {
self.build_payload(args, best_payload).await
self.build_payload(args, best_payload_tx).await
}
}

Expand Down
Loading
Loading