Skip to content

Commit

Permalink
dont skip empty blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
itamarreif committed Nov 5, 2024
1 parent 58ac5fd commit edc08c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/astria-auctioneer/src/auction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions crates/astria-auctioneer/src/block/executed_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}),
Expand Down
27 changes: 15 additions & 12 deletions crates/astria-auctioneer/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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::<Result<_, _>>()
.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::<Result<_, _>>()
.wrap_err("failed to decode RollupData")
})?;

let timestamp = Some(convert_tendermint_time_to_protobuf_timestamp(header.time()));

Expand Down

0 comments on commit edc08c7

Please sign in to comment.