diff --git a/crates/compiler/src/lib.rs b/crates/compiler/src/lib.rs index 165545e..21af0bc 100644 --- a/crates/compiler/src/lib.rs +++ b/crates/compiler/src/lib.rs @@ -7,6 +7,7 @@ use std::{ collections::HashMap, hash::Hash, path::{Path, PathBuf}, + pin::Pin, }; use alloy::json_abi::JsonAbi; @@ -27,13 +28,33 @@ pub mod revive_js; pub mod revive_resolc; pub mod solc; +/// A common interface for all supported Solidity compilers. +pub trait DynSolidityCompiler { + /// Returns the version of the compiler. + fn version(&self) -> &Version; + + /// Returns the path of the compiler executable. + fn path(&self) -> &Path; + + /// The low-level compiler interface. + fn build(&self, input: CompilerInput) -> Pin>>>; + + /// Does the compiler support the provided mode and version settings. + fn supports_mode( + &self, + optimizer_setting: ModeOptimizerSetting, + pipeline: ModePipeline, + ) -> bool; +} + +// TODO: Remove /// A common interface for all supported Solidity compilers. pub trait SolidityCompiler: Sized { /// Instantiates a new compiler object. /// - /// Based on the given [`Context`] and [`VersionOrRequirement`] this function instantiates a - /// new compiler object. Certain implementations of this trait might choose to cache cache the - /// compiler objects and return the same ones over and over again. + /// Based on the given context and [`VersionOrRequirement`] this function instantiates a + /// new compiler object. Certain implementations of this trait might choose to cache the + /// compiler objects and return the same compiler objects if given the same set of arguments. fn new( context: impl AsRef + AsRef @@ -74,7 +95,7 @@ pub struct CompilerInput { /// The generic compilation output configuration. #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct CompilerOutput { - /// The compiled contracts. The bytecode of the contract is kept as a string incase linking is + /// The compiled contracts. The bytecode of the contract is kept as a string in case linking is /// required and the compiled source has placeholders. pub contracts: HashMap>, } diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index c6e450b..f8ab7e6 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -3,8 +3,9 @@ //! This crate defines the testing configuration and //! provides a helper utility to execute tests. -use revive_dt_compiler::{SolidityCompiler, revive_resolc, solc}; -use revive_dt_config::{PlatformIdentifier, TestingPlatform}; +use revive_dt_common::types::VersionOrRequirement; +use revive_dt_compiler::{DynSolidityCompiler, SolidityCompiler, revive_resolc, solc}; +use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; use revive_dt_node::{Node, geth, kitchensink::KitchensinkNode}; use revive_dt_node_interaction::EthereumNode; @@ -53,5 +54,28 @@ pub trait DynPlatform { /// 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(&self) -> Box; + fn new_node( + &self, + context: impl AsRef + + AsRef + + AsRef + + AsRef + + AsRef + + AsRef + + AsRef + + AsRef + + Send + + Sync + + Clone + + 'static, + ) -> Box; + + /// Creates a new compiler for the provided platform + fn new_compiler( + &self, + context: impl AsRef + + AsRef + + AsRef, + version: impl Into>, + ) -> Box; } diff --git a/crates/node/src/pool.rs b/crates/node/src/pool.rs index 9221d92..f6d9dcb 100644 --- a/crates/node/src/pool.rs +++ b/crates/node/src/pool.rs @@ -17,7 +17,7 @@ use tracing::info; use crate::Node; /// The node pool starts one or more [Node] which then can be accessed -/// in a round robbin fasion. +/// in a round robbin fashion. pub struct NodePool { next: AtomicUsize, nodes: Vec,