reth_optimism_txpool/error.rs
1use crate::supervisor::{InteropTxValidatorError, InvalidInboxEntry};
2use reth_transaction_pool::error::PoolTransactionError;
3use std::any::Any;
4
5/// Wrapper for [`InteropTxValidatorError`] to implement [`PoolTransactionError`] for it.
6#[derive(thiserror::Error, Debug)]
7pub enum InvalidCrossTx {
8 /// Errors produced by supervisor validation
9 #[error(transparent)]
10 ValidationError(#[from] InteropTxValidatorError),
11 /// Error cause by cross chain tx during not active interop hardfork
12 #[error("cross chain tx is invalid before interop")]
13 CrossChainTxPreInterop,
14}
15
16impl PoolTransactionError for InvalidCrossTx {
17 fn is_bad_transaction(&self) -> bool {
18 match self {
19 Self::ValidationError(err) => {
20 match err {
21 InteropTxValidatorError::InvalidInboxEntry(err) => match err {
22 // This transaction could have been valid earlier. `SafetyLevel::Invalid`
23 // may be returned if tx has been invalidated as a result of reorg caused
24 // by network congestion (not peer's fault). Any other `SafetyLevel` may
25 // become valid when origin chain progresses, but is not safe enough to
26 // match local minimum safety level (also not peer's fault).
27 InvalidInboxEntry::MinimumSafety { .. } => false,
28 // This tx will not become valid unless supervisor is reconfigured, down
29 // score peer
30 InvalidInboxEntry::UnknownChain(_) => true,
31 },
32 // Rpc error or supervisor haven't responded in time
33 InteropTxValidatorError::RpcClientError(_) |
34 InteropTxValidatorError::ValidationTimeout(_) => false,
35 // Transaction caused unknown (for parsing) error in supervisor
36 InteropTxValidatorError::SupervisorServerError(_) => true,
37 }
38 }
39 Self::CrossChainTxPreInterop => true,
40 }
41 }
42
43 fn as_any(&self) -> &dyn Any {
44 self
45 }
46}