-
Notifications
You must be signed in to change notification settings - Fork 26
Improve log for event processor #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unstable
Are you sure you want to change the base?
Changes from all commits
c54c14f
af94fc8
9adeafa
ba5cff3
1b590f6
791ecb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,121 @@ | ||
| use std::fmt::Display; | ||
| use thiserror::Error; | ||
|
|
||
| use crate::util::ShareParseError; | ||
|
|
||
| // Custom execution integration layer errors | ||
| #[derive(Debug)] | ||
| #[derive(Debug, Error)] | ||
| pub enum ExecutionError { | ||
| #[error("Sync error: {0}")] | ||
| SyncError(String), | ||
| InvalidEvent(String), | ||
|
|
||
| #[error("Invalid event for operator {operator_id:?} (owner: {owner:?}): {message}")] | ||
| InvalidOperatorEvent { | ||
| operator_id: ssv_types::OperatorId, | ||
| owner: alloy::primitives::Address, | ||
| message: String, | ||
| #[source] | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
|
Comment on lines
+16
to
+17
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is kind of emulating
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think anyhow's context is a message describing what we were trying to do when the function called failed. The |
||
| }, | ||
|
|
||
| #[error( | ||
| "Invalid event for validator {validator_pubkey:?} (cluster: {cluster_id:?}): {message}" | ||
| )] | ||
| InvalidValidatorEvent { | ||
| validator_pubkey: Option<String>, | ||
| cluster_id: Option<ssv_types::ClusterId>, | ||
| message: String, | ||
| #[source] | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
| }, | ||
|
|
||
| #[error("Invalid event for cluster {cluster_id:?} (owner: {owner:?}): {message}")] | ||
| InvalidClusterEvent { | ||
| cluster_id: Option<ssv_types::ClusterId>, | ||
| owner: Option<alloy::primitives::Address>, | ||
| message: String, | ||
| #[source] | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
| }, | ||
|
|
||
| #[error("Invalid event: {message}")] | ||
| InvalidEvent { | ||
| message: String, | ||
| #[source] | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
| }, | ||
|
Comment on lines
+40
to
+45
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a variant per event type, maybe embed the event into this variant? |
||
|
|
||
| #[error("RPC error: {0}")] | ||
| RpcError(String), | ||
|
|
||
| #[error("WebSocket error: {0}")] | ||
| WsError(String), | ||
|
|
||
| #[error("Decode error: {0}")] | ||
| DecodeError(String), | ||
|
|
||
| #[error("Miscellaneous error: {0}")] | ||
| Misc(String), | ||
|
|
||
| #[error("Duplicate error: {0}")] | ||
| Duplicate(String), | ||
|
|
||
| #[error("Database error: {0}")] | ||
| Database(String), | ||
|
|
||
| #[error("Share parse error: {0}")] | ||
| ShareParseError(#[from] ShareParseError), | ||
| } | ||
|
|
||
| impl Display for ExecutionError { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| write!(f, "{self:?}") | ||
| impl ExecutionError { | ||
| pub fn invalid_operator_event( | ||
| operator_id: ssv_types::OperatorId, | ||
| owner: alloy::primitives::Address, | ||
| message: impl Into<String>, | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
| ) -> Self { | ||
| Self::InvalidOperatorEvent { | ||
| operator_id, | ||
| owner, | ||
| message: message.into(), | ||
| source, | ||
| } | ||
| } | ||
|
|
||
| pub fn invalid_validator_event( | ||
| validator_pubkey: Option<String>, | ||
| cluster_id: Option<ssv_types::ClusterId>, | ||
| message: impl Into<String>, | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
| ) -> Self { | ||
| Self::InvalidValidatorEvent { | ||
| validator_pubkey, | ||
| cluster_id, | ||
| message: message.into(), | ||
| source, | ||
| } | ||
| } | ||
|
|
||
| pub fn invalid_cluster_event( | ||
| cluster_id: Option<ssv_types::ClusterId>, | ||
| owner: Option<alloy::primitives::Address>, | ||
| message: impl Into<String>, | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
| ) -> Self { | ||
| Self::InvalidClusterEvent { | ||
| cluster_id, | ||
| owner, | ||
| message: message.into(), | ||
| source, | ||
| } | ||
| } | ||
|
|
||
| pub fn invalid_event( | ||
| message: impl Into<String>, | ||
| source: Option<Box<dyn std::error::Error + Send + Sync>>, | ||
| ) -> Self { | ||
| Self::InvalidEvent { | ||
| message: message.into(), | ||
| source, | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a
message: Stringfield in here feels like an anti pattern. I'd rather have a nonOptional sub error for context