diff --git a/Cargo.lock b/Cargo.lock index 70a373a..e71f722 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4468,10 +4468,12 @@ name = "revive-dt-common" version = "0.1.0" dependencies = [ "anyhow", + "clap", "moka", "once_cell", "semver 1.0.26", "serde", + "strum", "tokio", ] diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index 20cf865..0922ec2 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -10,10 +10,12 @@ rust-version.workspace = true [dependencies] anyhow = { workspace = true } +clap = { workspace = true } moka = { workspace = true, features = ["sync"] } once_cell = { workspace = true } semver = { workspace = true } serde = { workspace = true } +strum = { workspace = true } tokio = { workspace = true, default-features = false, features = ["time"] } [lints] diff --git a/crates/common/src/types/identifiers.rs b/crates/common/src/types/identifiers.rs new file mode 100644 index 0000000..f52a6f1 --- /dev/null +++ b/crates/common/src/types/identifiers.rs @@ -0,0 +1,119 @@ +use clap::ValueEnum; +use serde::{Deserialize, Serialize}; +use strum::{AsRefStr, Display, EnumString, IntoStaticStr}; + +/// An enum of the platform identifiers of all of the platforms supported by this framework. +#[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + Serialize, + Deserialize, + ValueEnum, + EnumString, + Display, + AsRefStr, + IntoStaticStr, +)] +#[serde(rename = "kebab-case")] +#[strum(serialize_all = "kebab-case")] +pub enum PlatformIdentifier { + /// The Go-ethereum reference full node EVM implementation. + GethEvm, + /// The kitchensink node with the PolkaVM backend. + KitchensinkPolkaVM, + /// The kitchensink node with the REVM backend. + KitchensinkREVM, + /// The revive dev node with the PolkaVM backend. + ReviveDevNodePolkaVM, + /// The revive dev node with the REVM backend. + ReviveDevNodeREVM, +} + +/// An enum of the platform identifiers of all of the platforms supported by this framework. +#[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + Serialize, + Deserialize, + ValueEnum, + EnumString, + Display, + AsRefStr, + IntoStaticStr, +)] +#[serde(rename = "kebab-case")] +#[strum(serialize_all = "kebab-case")] +pub enum CompilerIdentifier { + /// The solc compiler. + Solc, + /// The resolc compiler. + Resolc, +} + +/// An enum representing the identifiers of the supported nodes. +#[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + Serialize, + Deserialize, + ValueEnum, + EnumString, + Display, + AsRefStr, + IntoStaticStr, +)] +#[serde(rename = "kebab-case")] +#[strum(serialize_all = "kebab-case")] +pub enum NodeIdentifier { + /// The go-ethereum node implementation. + Geth, + /// The Kitchensink node implementation. + Kitchensink, + /// The revive dev node implementation. + ReviveDevNode, +} + +/// An enum representing the identifiers of the supported VMs. +#[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + Serialize, + Deserialize, + ValueEnum, + EnumString, + Display, + AsRefStr, + IntoStaticStr, +)] +#[serde(rename = "kebab-case")] +#[strum(serialize_all = "kebab-case")] +pub enum VmIdentifier { + /// The ethereum virtual machine. + Evm, + /// Polkadot's PolaVM Risc-v based virtual machine. + PolkaVm, +} diff --git a/crates/common/src/types/mod.rs b/crates/common/src/types/mod.rs index 0e1c34f..c44de1b 100644 --- a/crates/common/src/types/mod.rs +++ b/crates/common/src/types/mod.rs @@ -1,5 +1,7 @@ +mod identifiers; mod mode; mod version_or_requirement; +pub use identifiers::*; pub use mode::*; pub use version_or_requirement::*; diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 21bb27e..8141dfa 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -564,34 +564,3 @@ pub enum TestingPlatform { /// The kitchensink runtime provides the PolkaVM (PVM) based node implementation. Kitchensink, } - -/// An enum of the platform identifiers of all of the platforms supported by this framework. -#[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - Serialize, - ValueEnum, - EnumString, - Display, - AsRefStr, - IntoStaticStr, -)] -#[strum(serialize_all = "kebab-case")] -pub enum PlatformIdentifier { - /// The Go-ethereum reference full node EVM implementation. - GethEvm, - /// The kitchensink node with the PolkaVM backend. - KitchensinkPolkaVM, - /// The kitchensink node with the REVM backend. - KitchensinkREVM, - /// The revive dev node with the PolkaVM backend. - ReviveDevNodePolkaVM, - /// The revive dev node with the REVM backend. - ReviveDevNodeREVM, -} diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index f8ab7e6..e303867 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -3,7 +3,7 @@ //! This crate defines the testing configuration and //! provides a helper utility to execute tests. -use revive_dt_common::types::VersionOrRequirement; +use revive_dt_common::types::*; use revive_dt_compiler::{DynSolidityCompiler, SolidityCompiler, revive_resolc, solc}; use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; @@ -49,9 +49,28 @@ impl Platform for Kitchensink { /// A trait that describes the interface for the platforms that are supported by the tool. pub trait DynPlatform { - /// Returns the identifier of this platform. + /// Returns the identifier of this platform. This is a combination of the node and the compiler + /// used. fn platform_identifier(&self) -> PlatformIdentifier; + /// Returns a full identifier for the platform. + fn full_identifier(&self) -> (NodeIdentifier, VmIdentifier, CompilerIdentifier) { + ( + self.node_identifier(), + self.vm_identifier(), + self.compiler_identifier(), + ) + } + + /// Returns the identifier of the node used. + fn node_identifier(&self) -> NodeIdentifier; + + /// Returns the identifier of the vm used. + fn vm_identifier(&self) -> VmIdentifier; + + /// Returns the identifier of the compiler used. + fn compiler_identifier(&self) -> CompilerIdentifier; + /// Creates a new node for the platform by spawning a new thread, creating the node object, /// initializing it, spawning it, and waiting for it to start up. fn new_node(