From f181e748893169d456c95a93f765cc1388173c84 Mon Sep 17 00:00:00 2001 From: Guy Nir Date: Sun, 26 Oct 2025 17:43:04 +0200 Subject: [PATCH] apollo_l1_provider: remove panic on unknown L1 event type; add support for cancellations --- crates/apollo_l1_provider/src/l1_provider.rs | 8 +++++++- crates/apollo_l1_provider/src/l1_scraper.rs | 7 ------- crates/apollo_l1_provider_types/src/errors.rs | 8 -------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/crates/apollo_l1_provider/src/l1_provider.rs b/crates/apollo_l1_provider/src/l1_provider.rs index d8dc0013851..a24e89d11ea 100644 --- a/crates/apollo_l1_provider/src/l1_provider.rs +++ b/crates/apollo_l1_provider/src/l1_provider.rs @@ -231,6 +231,13 @@ impl L1Provider { ); }); } + Event::TransactionCanceled(event_data) => { + // TODO(guyn): delete the transaction from the provider. + info!( + "Cancellation finalized with data: {event_data:?}. THIS DOES NOT DELETE \ + THE TRANSACTION FROM THE PROVIDER YET." + ); + } Event::TransactionConsumed { tx_hash, timestamp: consumed_at } => { if let Err(previously_consumed_at) = self.tx_manager.consume_tx(tx_hash, consumed_at, self.clock.unix_now()) @@ -241,7 +248,6 @@ impl L1Provider { ); } } - _ => return Err(L1ProviderError::unsupported_l1_event(event)), } } Ok(()) diff --git a/crates/apollo_l1_provider/src/l1_scraper.rs b/crates/apollo_l1_provider/src/l1_scraper.rs index fa9cc3181be..c49fef414c6 100644 --- a/crates/apollo_l1_provider/src/l1_scraper.rs +++ b/crates/apollo_l1_provider/src/l1_scraper.rs @@ -424,13 +424,6 @@ fn handle_client_error( L1ProviderClientError::L1ProviderError(L1ProviderError::Uninitialized) => { Err(L1ScraperError::NeedsRestart) } - L1ProviderClientError::L1ProviderError(L1ProviderError::UnsupportedL1Event(event)) => { - panic!( - "Scraper-->Provider consistency error: the event {event} is not supported by the \ - provider, but has been scraped and sent to it nonetheless. Check the list of \ - tracked events in the scraper and compare to the provider's." - ) - } error => panic!("Unexpected error: {error}"), } } diff --git a/crates/apollo_l1_provider_types/src/errors.rs b/crates/apollo_l1_provider_types/src/errors.rs index 2523e6d2308..9de7017d861 100644 --- a/crates/apollo_l1_provider_types/src/errors.rs +++ b/crates/apollo_l1_provider_types/src/errors.rs @@ -5,8 +5,6 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use thiserror::Error; -use crate::Event; - #[derive(Clone, Debug, Error, PartialEq, Eq, Serialize, Deserialize)] pub enum L1ProviderError { #[error("`get_txs` while in `Validate` state")] @@ -26,8 +24,6 @@ pub enum L1ProviderError { UnexpectedHeight { expected_height: BlockNumber, got: BlockNumber }, #[error("Cannot transition from {from} to {to}")] UnexpectedProviderStateTransition { from: String, to: String }, - #[error("L1 event not supported: {0}")] - UnsupportedL1Event(String), #[error("`validate` called while in `Propose` state")] ValidateTransactionConsensusBug, } @@ -36,10 +32,6 @@ impl L1ProviderError { pub fn unexpected_transition(from: impl ToString, to: impl ToString) -> Self { Self::UnexpectedProviderStateTransition { from: from.to_string(), to: to.to_string() } } - - pub fn unsupported_l1_event(event: Event) -> Self { - Self::UnsupportedL1Event(event.to_string()) - } } #[derive(Clone, Debug, Error)]