-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(starknet_l1_provider): get errors ready for infra (#2435)
- don't expose internal module `ProviderState` - add serde - extract scraping error, it will be added to a separate interface. Co-Authored-By: Gilad Chase <[email protected]>
- Loading branch information
1 parent
ef39c7f
commit cbd8129
Showing
5 changed files
with
35 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerError; | ||
use serde::{Deserialize, Serialize}; | ||
use thiserror::Error; | ||
|
||
use crate::ProviderState; | ||
|
||
#[derive(Error, Debug)] | ||
#[derive(Clone, Debug, Error, PartialEq, Eq, Serialize, Deserialize)] | ||
pub enum L1ProviderError { | ||
#[error(transparent)] | ||
BaseLayer(#[from] EthereumBaseLayerError), | ||
#[error( | ||
"`get_txs` called while in `Pending` state, likely due to a crash; restart block proposal" | ||
)] | ||
GetTransactionsInPendingState, | ||
#[error("`get_txs` while in validate state")] | ||
GetTransactionConsensusBug, | ||
#[error("Cannot transition from {from} to {to}")] | ||
UnexpectedProviderStateTransition { from: ProviderState, to: ProviderState }, | ||
UnexpectedProviderStateTransition { from: String, to: String }, | ||
#[error( | ||
"`validate` called while in `Pending` state, likely due to a crash; restart block proposal" | ||
)] | ||
ValidateInPendingState, | ||
#[error("`validate` called while in `Propose`")] | ||
ValidateTransactionConsensusBug, | ||
} | ||
|
||
impl L1ProviderError { | ||
pub fn unexpected_transition(from: impl ToString, to: impl ToString) -> Self { | ||
Self::UnexpectedProviderStateTransition { from: from.to_string(), to: to.to_string() } | ||
} | ||
} | ||
|
||
// TODO(Gilad): move to scraper module once it's created. | ||
#[derive(Error, Debug)] | ||
pub enum L1ScraperError { | ||
#[error(transparent)] | ||
BaseLayer(#[from] EthereumBaseLayerError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters