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..4d9be1e494 100644 --- a/crates/astria-auctioneer/src/block/mod.rs +++ b/crates/astria-auctioneer/src/block/mod.rs @@ -21,7 +21,10 @@ use astria_eyre::eyre::{ OptionExt, }; use bytes::Bytes; -use prost::Message as _; +use prost::{ + DecodeError, + Message as _, +}; pub(crate) mod block_commitment_stream; pub(crate) mod executed_stream; @@ -62,7 +65,7 @@ impl Optimistic { pub(crate) fn try_into_base_block( self, rollup_id: RollupId, - ) -> eyre::Result { + ) -> Result { let FilteredSequencerBlockParts { block_hash, header, @@ -72,9 +75,7 @@ impl Optimistic { let serialized_transactions = rollup_transactions .swap_remove(&rollup_id) - .ok_or_eyre( - "FilteredSequencerBlock does not contain transactions for the given rollup", - )? + .ok_or_else(|| BaseBlockError::rollup_id_not_found(rollup_id))? .into_parts(); let transactions = serialized_transactions @@ -82,7 +83,7 @@ impl Optimistic { .into_iter() .map(raw_sequencer_block::RollupData::decode) .collect::>() - .wrap_err("failed to decode RollupData")?; + .map_err(BaseBlockError::decode_rollup_data)?; let timestamp = Some(convert_tendermint_time_to_protobuf_timestamp(header.time())); @@ -102,6 +103,28 @@ impl Optimistic { } } +#[derive(Debug, thiserror::Error)] +#[error(transparent)] +pub(crate) struct BaseBlockError(BaseBlockErrorKind); + +#[derive(Debug, thiserror::Error)] +enum BaseBlockErrorKind { + #[error("RollupId not found: {0}")] + RollupIdNotFound(RollupId), + #[error("failed to decode RollupData")] + DecodeRollupData(DecodeError), +} + +impl BaseBlockError { + pub(crate) fn rollup_id_not_found(rollup_id: RollupId) -> Self { + Self(BaseBlockErrorKind::RollupIdNotFound(rollup_id)) + } + + fn decode_rollup_data(error: DecodeError) -> Self { + Self(BaseBlockErrorKind::DecodeRollupData(error)) + } +} + #[derive(Debug, Clone)] pub(crate) struct Executed { block: execution::v1::Block,