From edc08c77de8de1c11d9fb3688520cb906d220b18 Mon Sep 17 00:00:00 2001 From: itamar Date: Tue, 5 Nov 2024 16:13:41 -0500 Subject: [PATCH] dont skip empty blocks --- crates/astria-auctioneer/src/auction/mod.rs | 2 +- .../src/block/executed_stream.rs | 8 +----- crates/astria-auctioneer/src/block/mod.rs | 27 ++++++++++--------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/crates/astria-auctioneer/src/auction/mod.rs b/crates/astria-auctioneer/src/auction/mod.rs index 01a51a0d0b..d6ff31c193 100644 --- a/crates/astria-auctioneer/src/auction/mod.rs +++ b/crates/astria-auctioneer/src/auction/mod.rs @@ -234,7 +234,7 @@ impl Auction { let submission_result = select! { biased; - // TODO: should this be Ok(())? + // TODO: should this be Ok(())? or Ok("received shutdown signal")? () = self.shutdown_token.cancelled() => Err(eyre!("received shutdown signal")), // submit the transaction to the sequencer diff --git a/crates/astria-auctioneer/src/block/executed_stream.rs b/crates/astria-auctioneer/src/block/executed_stream.rs index 9bcee7cddb..297f3a4a6d 100644 --- a/crates/astria-auctioneer/src/block/executed_stream.rs +++ b/crates/astria-auctioneer/src/block/executed_stream.rs @@ -95,14 +95,8 @@ pub(crate) fn make_execution_requests_stream( let (blocks_to_execute_tx, blocks_to_execute_rx) = mpsc::channel(16); let blocks_to_execute_stream_rx = ReceiverStream::new(blocks_to_execute_rx); - // TODO: dont skip empty blocks let requests = blocks_to_execute_stream_rx.filter_map(move |block: Optimistic| async move { - let base_block = block - .try_into_base_block(rollup_id) - .wrap_err("failed to create BaseBlock from FilteredSequencerBlock"); - - // skip blocks which fail to produce a BaseBlock for the given rollup_id - match base_block { + match block.try_into_base_block(rollup_id) { Ok(base_block) => Some(ExecuteOptimisticBlockStreamRequest { base_block: Some(base_block), }), diff --git a/crates/astria-auctioneer/src/block/mod.rs b/crates/astria-auctioneer/src/block/mod.rs index 8b9b50cd88..9fe12cf848 100644 --- a/crates/astria-auctioneer/src/block/mod.rs +++ b/crates/astria-auctioneer/src/block/mod.rs @@ -59,6 +59,9 @@ impl Optimistic { self.filtered_sequencer_block.into_raw() } + /// Converts this [`Optimistic`] into a [`BaseBlock`] for the given `rollup_id`. + /// If there are no transactions for the given `rollup_id`, this will return a `BaseBlock`. + // TODO: add typed errors here? pub(crate) fn try_into_base_block( self, rollup_id: RollupId, @@ -70,19 +73,19 @@ impl Optimistic { .. } = self.filtered_sequencer_block.into_parts(); - let serialized_transactions = rollup_transactions + let maybe_serialized_transactions = rollup_transactions .swap_remove(&rollup_id) - .ok_or_eyre( - "FilteredSequencerBlock does not contain transactions for the given rollup", - )? - .into_parts(); - - let transactions = serialized_transactions - .transactions - .into_iter() - .map(raw_sequencer_block::RollupData::decode) - .collect::>() - .wrap_err("failed to decode RollupData")?; + .map(|transactions| transactions.into_parts()); + + let transactions = + maybe_serialized_transactions.map_or(Ok(vec![]), |serialized_transactions| { + serialized_transactions + .transactions + .into_iter() + .map(raw_sequencer_block::RollupData::decode) + .collect::>() + .wrap_err("failed to decode RollupData") + })?; let timestamp = Some(convert_tendermint_time_to_protobuf_timestamp(header.time()));