|
1 | | -use crate::{convert::ToRethPrimitive, specs::HostBlockSpec}; |
| 1 | +use crate::{chain::Chain, specs::HostBlockSpec}; |
2 | 2 | use alloy::consensus::BlobTransactionSidecar; |
3 | | -use reth_exex::ExExNotification; |
4 | 3 | use signet_types::primitives::TransactionSigned; |
5 | 4 | use std::{collections::BTreeMap, sync::Arc}; |
6 | 5 |
|
| 6 | +/// A shim for reth_exex::ExExNotification that allows us to use it in tests. |
| 7 | +#[derive(Debug, Clone, PartialEq, Eq)] |
| 8 | +pub enum ExExNotification { |
| 9 | + /// Chain got committed without a reorg, and only the new chain is returned. |
| 10 | + Committed { |
| 11 | + /// The new chain after commit. |
| 12 | + new: Arc<Chain>, |
| 13 | + }, |
| 14 | + /// Chain got reorged, and both the old and the new chains are returned. |
| 15 | + Reorged { |
| 16 | + /// The old chain before reorg. |
| 17 | + old: Arc<Chain>, |
| 18 | + /// The new chain after reorg. |
| 19 | + new: Arc<Chain>, |
| 20 | + }, |
| 21 | + /// Chain got reverted, and only the old chain is returned. |
| 22 | + Reverted { |
| 23 | + /// The old chain before reversion. |
| 24 | + old: Arc<Chain>, |
| 25 | + }, |
| 26 | +} |
| 27 | + |
7 | 28 | /// A notification spec. |
8 | 29 | #[derive(Debug, Default)] |
9 | 30 | pub struct NotificationSpec { |
@@ -86,22 +107,18 @@ impl NotificationSpec { |
86 | 107 |
|
87 | 108 | match (old_chain, new_chain) { |
88 | 109 | (Some(old_chain), Some(new_chain)) => NotificationWithSidecars { |
89 | | - notification: ExExNotification::ChainReorged { |
90 | | - old: Arc::new(old_chain.to_reth()), |
91 | | - new: Arc::new(new_chain.to_reth()), |
| 110 | + notification: ExExNotification::Reorged { |
| 111 | + old: Arc::new(old_chain), |
| 112 | + new: Arc::new(new_chain), |
92 | 113 | }, |
93 | 114 | sidecars, |
94 | 115 | }, |
95 | 116 | (Some(old_chain), None) => NotificationWithSidecars { |
96 | | - notification: ExExNotification::ChainReverted { |
97 | | - old: Arc::new(old_chain.to_reth()), |
98 | | - }, |
| 117 | + notification: ExExNotification::Reverted { old: Arc::new(old_chain) }, |
99 | 118 | sidecars, |
100 | 119 | }, |
101 | 120 | (None, Some(new_chain)) => NotificationWithSidecars { |
102 | | - notification: ExExNotification::ChainCommitted { |
103 | | - new: Arc::new(new_chain.to_reth()), |
104 | | - }, |
| 121 | + notification: ExExNotification::Committed { new: Arc::new(new_chain) }, |
105 | 122 | sidecars, |
106 | 123 | }, |
107 | 124 | (None, None) => panic!("missing old and new chains"), |
|
0 commit comments