From bc4a16737bf7124109b314771c8fa887887f7710 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Wed, 17 Jul 2024 17:39:19 +0100 Subject: [PATCH] chore(exex): move notification to types crate (#9586) --- Cargo.lock | 3 +- crates/exex/exex/Cargo.toml | 3 +- crates/exex/exex/src/lib.rs | 3 -- crates/exex/types/Cargo.toml | 11 ++++++++ crates/exex/types/src/finished_height.rs | 25 +++++++++++++++++ crates/exex/types/src/lib.rs | 28 +++---------------- .../exex/{exex => types}/src/notification.rs | 0 7 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 crates/exex/types/src/finished_height.rs rename crates/exex/{exex => types}/src/notification.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index c2b7186346..2633e56df6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7293,7 +7293,6 @@ dependencies = [ "reth-testing-utils", "reth-tracing", "secp256k1", - "serde", "tokio", "tokio-util", ] @@ -7333,6 +7332,8 @@ name = "reth-exex-types" version = "1.0.2" dependencies = [ "alloy-primitives", + "reth-provider", + "serde", ] [[package]] diff --git a/crates/exex/exex/Cargo.toml b/crates/exex/exex/Cargo.toml index ec86deb6f4..58a2695b89 100644 --- a/crates/exex/exex/Cargo.toml +++ b/crates/exex/exex/Cargo.toml @@ -37,7 +37,6 @@ tokio-util.workspace = true ## misc eyre.workspace = true metrics.workspace = true -serde = { workspace = true, optional = true } [dev-dependencies] reth-chainspec.workspace = true @@ -53,4 +52,4 @@ secp256k1.workspace = true [features] default = [] -serde = ["dep:serde", "reth-provider/serde"] +serde = ["reth-provider/serde", "reth-exex-types/serde"] diff --git a/crates/exex/exex/src/lib.rs b/crates/exex/exex/src/lib.rs index 5f859accca..434036bccb 100644 --- a/crates/exex/exex/src/lib.rs +++ b/crates/exex/exex/src/lib.rs @@ -46,9 +46,6 @@ pub use event::*; mod manager; pub use manager::*; -mod notification; -pub use notification::*; - // Re-export exex types #[doc(inline)] pub use reth_exex_types::*; diff --git a/crates/exex/types/Cargo.toml b/crates/exex/types/Cargo.toml index e03b63342f..a70bcc1dd4 100644 --- a/crates/exex/types/Cargo.toml +++ b/crates/exex/types/Cargo.toml @@ -12,4 +12,15 @@ description = "Commonly used types for exex usage in reth." workspace = true [dependencies] +# reth +reth-provider.workspace = true + +# reth alloy-primitives.workspace = true + +# misc +serde = { workspace = true, optional = true } + +[features] +default = [] +serde = ["dep:serde", "reth-provider/serde"] diff --git a/crates/exex/types/src/finished_height.rs b/crates/exex/types/src/finished_height.rs new file mode 100644 index 0000000000..c33f7c9cd5 --- /dev/null +++ b/crates/exex/types/src/finished_height.rs @@ -0,0 +1,25 @@ +use alloy_primitives::BlockNumber; + +/// The finished height of all `ExEx`'s. +#[derive(Debug, Clone, Copy)] +pub enum FinishedExExHeight { + /// No `ExEx`'s are installed, so there is no finished height. + NoExExs, + /// Not all `ExExs` have emitted a `FinishedHeight` event yet. + NotReady, + /// The finished height of all `ExEx`'s. + /// + /// This is the lowest common denominator between all `ExEx`'s. + /// + /// This block is used to (amongst other things) determine what blocks are safe to prune. + /// + /// The number is inclusive, i.e. all blocks `<= finished_height` are safe to prune. + Height(BlockNumber), +} + +impl FinishedExExHeight { + /// Returns `true` if not all `ExExs` have emitted a `FinishedHeight` event yet. + pub const fn is_not_ready(&self) -> bool { + matches!(self, Self::NotReady) + } +} diff --git a/crates/exex/types/src/lib.rs b/crates/exex/types/src/lib.rs index b76530df09..3c0ca731f2 100644 --- a/crates/exex/types/src/lib.rs +++ b/crates/exex/types/src/lib.rs @@ -8,28 +8,8 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -use alloy_primitives::BlockNumber; +mod finished_height; +mod notification; -/// The finished height of all `ExEx`'s. -#[derive(Debug, Clone, Copy)] -pub enum FinishedExExHeight { - /// No `ExEx`'s are installed, so there is no finished height. - NoExExs, - /// Not all `ExExs` have emitted a `FinishedHeight` event yet. - NotReady, - /// The finished height of all `ExEx`'s. - /// - /// This is the lowest common denominator between all `ExEx`'s. - /// - /// This block is used to (amongst other things) determine what blocks are safe to prune. - /// - /// The number is inclusive, i.e. all blocks `<= finished_height` are safe to prune. - Height(BlockNumber), -} - -impl FinishedExExHeight { - /// Returns `true` if not all `ExExs` have emitted a `FinishedHeight` event yet. - pub const fn is_not_ready(&self) -> bool { - matches!(self, Self::NotReady) - } -} +pub use finished_height::FinishedExExHeight; +pub use notification::ExExNotification; diff --git a/crates/exex/exex/src/notification.rs b/crates/exex/types/src/notification.rs similarity index 100% rename from crates/exex/exex/src/notification.rs rename to crates/exex/types/src/notification.rs