Skip to content

Commit 53d54e6

Browse files
apollo_l1_provider: remove panic on unknown L1 event type; add support for cancellations (#9776) (#9800)
Co-authored-by: guy-starkware <guy.n@starkware.co>
1 parent d165c66 commit 53d54e6

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

crates/apollo_l1_provider/src/l1_provider.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ impl L1Provider {
116116
);
117117
});
118118
}
119+
Event::TransactionCanceled(event_data) => {
120+
// TODO(guyn): delete the transaction from the provider.
121+
info!(
122+
"Cancellation finalized with data: {event_data:?}. THIS DOES NOT DELETE \
123+
THE TRANSACTION FROM THE PROVIDER YET."
124+
);
125+
}
119126
Event::TransactionConsumed { tx_hash, timestamp: consumed_at } => {
120127
if let Err(previously_consumed_at) =
121128
self.tx_manager.consume_tx(tx_hash, consumed_at, self.clock.unix_now())
@@ -126,7 +133,6 @@ impl L1Provider {
126133
);
127134
}
128135
}
129-
_ => return Err(L1ProviderError::unsupported_l1_event(event)),
130136
}
131137
}
132138
Ok(())

crates/apollo_l1_provider/src/l1_scraper.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,6 @@ fn handle_client_error<B: BaseLayerContract + Send + Sync>(
378378
L1ProviderClientError::L1ProviderError(L1ProviderError::Uninitialized) => {
379379
Err(L1ScraperError::NeedsRestart)
380380
}
381-
L1ProviderClientError::L1ProviderError(L1ProviderError::UnsupportedL1Event(event)) => {
382-
panic!(
383-
"Scraper-->Provider consistency error: the event {event} is not supported by the \
384-
provider, but has been scraped and sent to it nonetheless. Check the list of \
385-
tracked events in the scraper and compare to the provider's."
386-
)
387-
}
388381
error => panic!("Unexpected error: {error}"),
389382
}
390383
}

crates/apollo_l1_provider_types/src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use serde::{Deserialize, Serialize};
55
use starknet_api::block::BlockNumber;
66
use thiserror::Error;
77

8-
use crate::Event;
9-
108
#[derive(Clone, Debug, Error, PartialEq, Eq, Serialize, Deserialize)]
119
pub enum L1ProviderError {
1210
#[error("`get_txs` while in `Validate` state")]
@@ -26,8 +24,6 @@ pub enum L1ProviderError {
2624
UnexpectedHeight { expected_height: BlockNumber, got: BlockNumber },
2725
#[error("Cannot transition from {from} to {to}")]
2826
UnexpectedProviderStateTransition { from: String, to: String },
29-
#[error("L1 event not supported: {0}")]
30-
UnsupportedL1Event(String),
3127
#[error("`validate` called while in `Propose` state")]
3228
ValidateTransactionConsensusBug,
3329
}
@@ -36,10 +32,6 @@ impl L1ProviderError {
3632
pub fn unexpected_transition(from: impl ToString, to: impl ToString) -> Self {
3733
Self::UnexpectedProviderStateTransition { from: from.to_string(), to: to.to_string() }
3834
}
39-
40-
pub fn unsupported_l1_event(event: Event) -> Self {
41-
Self::UnsupportedL1Event(event.to_string())
42-
}
4335
}
4436

4537
#[derive(Clone, Debug, Error)]

0 commit comments

Comments
 (0)