diff --git a/Cargo.lock b/Cargo.lock index 68d37b7e47..37aa6516bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -140,16 +140,16 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206e825321d0ed5b6e3907e6ddf70c2139cfdc6274e83a1ca2f4784bd0abc0c9" +checksum = "45625825df98039a6dced71fedca82e69a8a0177453e21faeed47b9a6f16a178" dependencies = [ "alloy-rlp", "arbitrary", "num_enum 0.7.2", "proptest", "serde", - "strum", + "strum 0.26.1", ] [[package]] @@ -1494,8 +1494,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ "crossterm", - "strum", - "strum_macros", + "strum 0.25.0", + "strum_macros 0.25.3", "unicode-width", ] @@ -2619,7 +2619,7 @@ dependencies = [ "rlp", "serde", "serde_json", - "strum", + "strum 0.25.0", "syn 2.0.48", "tempfile", "thiserror", @@ -5563,7 +5563,7 @@ dependencies = [ "lru 0.12.2", "paste", "stability", - "strum", + "strum 0.25.0", "unicode-segmentation", "unicode-width", ] @@ -6589,7 +6589,7 @@ dependencies = [ "serde_json", "sha2", "smallvec", - "strum", + "strum 0.26.1", "sucds 0.6.0", "tempfile", "test-fuzz 4.0.5", @@ -6623,7 +6623,7 @@ dependencies = [ "reth-primitives", "reth-trie", "revm", - "strum", + "strum 0.26.1", "tempfile", "tokio", "tokio-stream", @@ -6782,7 +6782,7 @@ dependencies = [ "reth-transaction-pool", "serde", "serde_json", - "strum", + "strum 0.26.1", "thiserror", "tokio", "tower", @@ -7994,7 +7994,16 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" dependencies = [ - "strum_macros", + "strum_macros 0.25.3", +] + +[[package]] +name = "strum" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" +dependencies = [ + "strum_macros 0.26.1", ] [[package]] @@ -8010,6 +8019,19 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "strum_macros" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.48", +] + [[package]] name = "substrate-bn" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 53e0f0112e..8821804852 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -214,7 +214,7 @@ serde_json = "1.0.94" serde = { version = "1.0", default-features = false } rand = "0.8.5" schnellru = "0.2" -strum = "0.25" +strum = "0.26" rayon = "1.7" itertools = "0.12" parking_lot = "0.12" diff --git a/crates/node-core/src/args/rpc_server_args.rs b/crates/node-core/src/args/rpc_server_args.rs index c70fe3a0e8..e36d6d7f31 100644 --- a/crates/node-core/src/args/rpc_server_args.rs +++ b/crates/node-core/src/args/rpc_server_args.rs @@ -607,7 +607,7 @@ impl TypedValueParser for RpcModuleSelectionValueParser { value.to_str().ok_or_else(|| clap::Error::new(clap::error::ErrorKind::InvalidUtf8))?; val.parse::().map_err(|err| { let arg = arg.map(|a| a.to_string()).unwrap_or_else(|| "...".to_owned()); - let possible_values = RethRpcModule::all_variants().to_vec().join(","); + let possible_values = RethRpcModule::all_variant_names().to_vec().join(","); let msg = format!( "Invalid value '{val}' for {arg}: {err}.\n [possible values: {possible_values}]" ); @@ -616,7 +616,7 @@ impl TypedValueParser for RpcModuleSelectionValueParser { } fn possible_values(&self) -> Option + '_>> { - let values = RethRpcModule::all_variants().iter().map(PossibleValue::new); + let values = RethRpcModule::all_variant_names().iter().map(PossibleValue::new); Some(Box::new(values)) } } diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index a9473cc258..a6ddc8912b 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -169,7 +169,7 @@ use jsonrpsee::{ }; use reth_node_api::{EngineTypes, EvmEnvConfig}; use serde::{Deserialize, Serialize, Serializer}; -use strum::{AsRefStr, EnumIter, EnumVariantNames, IntoStaticStr, ParseError, VariantNames}; +use strum::{AsRefStr, EnumIter, IntoStaticStr, ParseError, VariantArray, VariantNames}; use tower::layer::util::{Identity, Stack}; use tower_http::cors::CorsLayer; use tracing::{instrument, trace}; @@ -628,9 +628,9 @@ impl RpcModuleSelection { pub const STANDARD_MODULES: [RethRpcModule; 3] = [RethRpcModule::Eth, RethRpcModule::Net, RethRpcModule::Web3]; - /// Returns a selection of [RethRpcModule] with all [RethRpcModule::VARIANTS]. + /// Returns a selection of [RethRpcModule] with all [RethRpcModule::all_variants]. pub fn all_modules() -> Vec { - RpcModuleSelection::try_from_selection(RethRpcModule::VARIANTS.iter().copied()) + RpcModuleSelection::try_from_selection(RethRpcModule::all_variants().iter().copied()) .expect("valid selection") .into_selection() } @@ -823,7 +823,8 @@ impl fmt::Display for RpcModuleSelection { Hash, AsRefStr, IntoStaticStr, - EnumVariantNames, + VariantNames, + VariantArray, EnumIter, Deserialize, )] @@ -860,9 +861,14 @@ pub enum RethRpcModule { // === impl RethRpcModule === impl RethRpcModule { + /// Returns all variant names of the enum + pub const fn all_variant_names() -> &'static [&'static str] { + ::VARIANTS + } + /// Returns all variants of the enum - pub const fn all_variants() -> &'static [&'static str] { - Self::VARIANTS + pub const fn all_variants() -> &'static [Self] { + ::VARIANTS } /// Returns all variants of the enum