Redo how we parse and use modes (#125)

* WIP redo how we parse and use modes

* test expanding, too

* WIP integrate new Mode/ParsedMode into rest of code

* First pass integrated new mode bits

* fmt

* clippy

* Remove mode we no longer support from test metadata

* Address nits

* Add ability for compiler to opt out if it can't work with some Mode/version

* Elide viaIR input if compiler does not support it

* Improve test output a little; string modes and list ignored tests

* Move Mode to common crate

* constants.mod, and Display for CaseIdx to use it

* fmt

* Rename ModePipeline::E/Y

* Re-arrange Mode things; ParsedMode in format and Mode etc in common

* Move compile check to prepare_tests

* Remove now-unused deps

* clippy nits

* Update fallback tx weights to avoid out of gas errors

* Update kitchensink weights too and fmt

* Bump default geth timeout to 10s

* 30s timeout

* Improve geth stdout logging on failure

* fix line logging

* remove --networkid and arg, back to 5s timeout for geth
This commit is contained in:
James Wilson
2025-08-16 12:38:17 +01:00
committed by GitHub
parent a59e287fa1
commit 09d56f5177
20 changed files with 627 additions and 210 deletions
+20 -8
View File
@@ -3,6 +3,8 @@
//! - Polkadot revive resolc compiler
//! - Polkadot revive Wasm compiler
mod constants;
use std::{
collections::HashMap,
hash::Hash,
@@ -19,6 +21,9 @@ use revive_dt_common::cached_fs::read_to_string;
use revive_dt_common::types::VersionOrRequirement;
use revive_dt_config::Arguments;
// Re-export this as it's a part of the compiler interface.
pub use revive_dt_common::types::{Mode, ModeOptimizerSetting, ModePipeline};
pub mod revive_js;
pub mod revive_resolc;
pub mod solc;
@@ -43,13 +48,20 @@ pub trait SolidityCompiler {
) -> impl Future<Output = anyhow::Result<PathBuf>>;
fn version(&self) -> anyhow::Result<Version>;
/// Does the compiler support the provided mode and version settings?
fn supports_mode(
compiler_version: &Version,
optimize_setting: ModeOptimizerSetting,
pipeline: ModePipeline,
) -> bool;
}
/// The generic compilation input configuration.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompilerInput {
pub enable_optimization: Option<bool>,
pub via_ir: Option<bool>,
pub pipeline: Option<ModePipeline>,
pub optimization: Option<ModeOptimizerSetting>,
pub evm_version: Option<EVMVersion>,
pub allow_paths: Vec<PathBuf>,
pub base_path: Option<PathBuf>,
@@ -85,8 +97,8 @@ where
pub fn new() -> Self {
Self {
input: CompilerInput {
enable_optimization: Default::default(),
via_ir: Default::default(),
pipeline: Default::default(),
optimization: Default::default(),
evm_version: Default::default(),
allow_paths: Default::default(),
base_path: Default::default(),
@@ -98,13 +110,13 @@ where
}
}
pub fn with_optimization(mut self, value: impl Into<Option<bool>>) -> Self {
self.input.enable_optimization = value.into();
pub fn with_optimization(mut self, value: impl Into<Option<ModeOptimizerSetting>>) -> Self {
self.input.optimization = value.into();
self
}
pub fn with_via_ir(mut self, value: impl Into<Option<bool>>) -> Self {
self.input.via_ir = value.into();
pub fn with_pipeline(mut self, value: impl Into<Option<ModePipeline>>) -> Self {
self.input.pipeline = value.into();
self
}