Compare commits

..

3 Commits

Author SHA1 Message Date
Marian Radu a5f0c8713f Add PVM heap-size and stack-size configuration for resolc 2026-01-15 18:03:57 +02:00
Marian Radu 89ccd72d20 Inject polkavm settings into resolc standard JSON input 2026-01-15 17:24:10 +02:00
Marian Radu 4a4ac7ede6 Update revive compiler dependencies 2026-01-15 17:13:01 +02:00
10 changed files with 115 additions and 566 deletions
@@ -41,10 +41,6 @@ inputs:
description: "The id of the parachain to spawn with the polkadot-omni-node. This is only required if the polkadot-omni-node is one of the selected platforms."
type: number
required: false
expectations-file-path:
description: "Path to the expectations file to use to compare against."
type: string
required: false
runs:
using: "composite"
@@ -83,12 +79,6 @@ runs:
run: |
${{ inputs['cargo-command'] }} build --locked --profile release -p pallet-revive-eth-rpc -p revive-dev-node --manifest-path ${{ inputs['polkadot-sdk-path'] }}/Cargo.toml
${{ inputs['cargo-command'] }} build --locked --profile release --bin polkadot-omni-node --manifest-path ${{ inputs['polkadot-sdk-path'] }}/Cargo.toml
- name: Installing retester
shell: bash
run: ${{ inputs['cargo-command'] }} install --path ./revive-differential-tests/crates/core
- name: Installing report-processor
shell: bash
run: ${{ inputs['cargo-command'] }} install --path ./revive-differential-tests/crates/report-processor
- name: Running the Differential Tests
shell: bash
run: |
@@ -106,12 +96,11 @@ runs:
)
fi
retester test \
${{ inputs['cargo-command'] }} run --locked --manifest-path revive-differential-tests/Cargo.toml -- test \
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/simple \
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/complex \
--test ./revive-differential-tests/resolc-compiler-tests/fixtures/solidity/translated_semantic_tests \
--platform ${{ inputs['platform'] }} \
--report.file-name report.json \
--concurrency.number-of-nodes 10 \
--concurrency.number-of-threads 10 \
--concurrency.number-of-concurrent-tasks 100 \
@@ -121,21 +110,22 @@ runs:
--eth-rpc.path ${{ inputs['polkadot-sdk-path'] }}/target/release/eth-rpc \
--polkadot-omni-node.path ${{ inputs['polkadot-sdk-path'] }}/target/release/polkadot-omni-node \
--resolc.path ./resolc \
"${OMNI_ARGS[@]}" || true
- name: Generate the expectation file
"${OMNI_ARGS[@]}"
- name: Creating a markdown report of the test execution
shell: bash
run: report-processor generate-expectations-file --report-path ./workdir/report.json --output-path ./workdir/expectations.json --remove-prefix ./revive-differential-tests/resolc-compiler-tests
if: ${{ always() }}
run: |
mv ./workdir/*.json report.json
python3 revive-differential-tests/scripts/process-differential-tests-report.py report.json ${{ inputs['platform'] }}
- name: Upload the Report to the CI
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
if: ${{ always() }}
with:
name: ${{ inputs['platform'] }}-report.json
path: ./workdir/report.json
- name: Upload the Report to the CI
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
name: report-${{ inputs['platform'] }}.md
path: report.md
- name: Posting the report as a comment on the PR
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405
if: ${{ always() }}
with:
name: ${{ inputs['platform'] }}.json
path: ./workdir/expectations.json
- name: Check Expectations
shell: bash
if: ${{ inputs['expectations-file-path'] != '' }}
run: report-processor compare-expectation-files --base-expectation-path ${{ inputs['expectations-file-path'] }} --other-expectation-path ./workdir/expectations.json
header: diff-tests-report-${{ inputs['platform'] }}
path: report.md
Generated
+67 -78
View File
@@ -127,7 +127,7 @@ dependencies = [
"serde",
"serde_json",
"serde_with",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -164,7 +164,7 @@ dependencies = [
"futures",
"futures-util",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -206,7 +206,7 @@ dependencies = [
"alloy-rlp",
"crc",
"serde",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -232,7 +232,7 @@ dependencies = [
"borsh",
"k256",
"serde",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -255,7 +255,7 @@ dependencies = [
"serde",
"serde_with",
"sha2 0.10.9",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -296,7 +296,7 @@ dependencies = [
"http 1.4.0",
"serde",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tracing",
]
@@ -323,7 +323,7 @@ dependencies = [
"futures-utils-wasm",
"serde",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -407,7 +407,7 @@ dependencies = [
"reqwest",
"serde",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio",
"tracing",
"url",
@@ -571,7 +571,7 @@ dependencies = [
"serde",
"serde_json",
"serde_with",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -585,7 +585,7 @@ dependencies = [
"alloy-serde",
"serde",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -623,7 +623,7 @@ dependencies = [
"either",
"elliptic-curve",
"k256",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -639,7 +639,7 @@ dependencies = [
"async-trait",
"k256",
"rand 0.8.5",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -730,7 +730,7 @@ dependencies = [
"parking_lot",
"serde",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio",
"tower 0.5.3",
"tracing",
@@ -1916,9 +1916,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.2.53"
version = "1.2.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932"
checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3"
dependencies = [
"find-msvc-tools",
"shlex",
@@ -2873,20 +2873,21 @@ dependencies = [
[[package]]
name = "filetime"
version = "0.2.27"
version = "0.2.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98844151eee8917efc50bd9e8318cb963ae8b297431495d3f758616ea5c57db"
checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed"
dependencies = [
"cfg-if",
"libc",
"libredox",
"windows-sys 0.60.2",
]
[[package]]
name = "find-msvc-tools"
version = "0.1.8"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db"
checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41"
[[package]]
name = "fixed-hash"
@@ -2976,7 +2977,7 @@ dependencies = [
"semver 1.0.27",
"serde",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tracing",
"yansi",
]
@@ -3009,7 +3010,7 @@ dependencies = [
"semver 1.0.27",
"serde",
"serde_json",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -3039,7 +3040,7 @@ dependencies = [
"scale-info",
"scale-type-resolver",
"sp-crypto-hashing",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -4353,7 +4354,7 @@ dependencies = [
"quick-protobuf",
"rand 0.8.5",
"sha2 0.10.9",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tracing",
"zeroize",
]
@@ -5410,7 +5411,7 @@ dependencies = [
"rustc-hash",
"rustls 0.23.36",
"socket2 0.6.1",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio",
"tracing",
"web-time",
@@ -5431,7 +5432,7 @@ dependencies = [
"rustls 0.23.36",
"rustls-pki-types",
"slab",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tinyvec",
"tracing",
"web-time",
@@ -5876,18 +5877,6 @@ dependencies = [
"tracing",
]
[[package]]
name = "revive-dt-report-processor"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"revive-dt-common",
"revive-dt-report",
"serde",
"serde_json",
]
[[package]]
name = "revive-dt-solc-binaries"
version = "0.1.0"
@@ -5988,9 +5977,9 @@ checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18"
[[package]]
name = "rustc-demangle"
version = "0.1.27"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d"
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
[[package]]
name = "rustc-hash"
@@ -6060,7 +6049,7 @@ dependencies = [
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki 0.103.9",
"rustls-webpki 0.103.8",
"subtle",
"zeroize",
]
@@ -6100,9 +6089,9 @@ dependencies = [
[[package]]
name = "rustls-pki-types"
version = "1.14.0"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd"
checksum = "21e6f2ab2928ca4291b86736a8bd920a277a399bba1589409d72154ff87c1282"
dependencies = [
"web-time",
"zeroize",
@@ -6122,7 +6111,7 @@ dependencies = [
"rustls 0.23.36",
"rustls-native-certs 0.8.3",
"rustls-platform-verifier-android",
"rustls-webpki 0.103.9",
"rustls-webpki 0.103.8",
"security-framework 3.5.1",
"security-framework-sys",
"webpki-root-certs 0.26.11",
@@ -6147,9 +6136,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
version = "0.103.9"
version = "0.103.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53"
checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52"
dependencies = [
"ring",
"rustls-pki-types",
@@ -6239,7 +6228,7 @@ dependencies = [
"scale-decode-derive",
"scale-type-resolver",
"smallvec",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -6266,7 +6255,7 @@ dependencies = [
"scale-encode-derive",
"scale-type-resolver",
"smallvec",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -6328,7 +6317,7 @@ dependencies = [
"quote",
"scale-info",
"syn 2.0.114",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -6346,7 +6335,7 @@ dependencies = [
"scale-encode",
"scale-type-resolver",
"serde",
"thiserror 2.0.18",
"thiserror 2.0.17",
"yap",
]
@@ -7522,7 +7511,7 @@ dependencies = [
"subxt-macro 0.43.1",
"subxt-metadata 0.43.0",
"subxt-rpcs 0.43.0",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio",
"tokio-util",
"tracing",
@@ -7559,7 +7548,7 @@ dependencies = [
"subxt-macro 0.44.2",
"subxt-metadata 0.44.2",
"subxt-rpcs 0.44.2",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio",
"tokio-util",
"tracing",
@@ -7582,7 +7571,7 @@ dependencies = [
"scale-typegen",
"subxt-metadata 0.43.0",
"syn 2.0.114",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -7599,7 +7588,7 @@ dependencies = [
"scale-typegen",
"subxt-metadata 0.44.2",
"syn 2.0.114",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -7628,7 +7617,7 @@ dependencies = [
"serde_json",
"sp-crypto-hashing",
"subxt-metadata 0.43.0",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tracing",
]
@@ -7658,7 +7647,7 @@ dependencies = [
"serde_json",
"sp-crypto-hashing",
"subxt-metadata 0.44.2",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tracing",
]
@@ -7673,7 +7662,7 @@ dependencies = [
"serde",
"serde_json",
"smoldot-light",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio",
"tokio-stream",
"tracing",
@@ -7690,7 +7679,7 @@ dependencies = [
"serde",
"serde_json",
"smoldot-light",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio",
"tokio-stream",
"tracing",
@@ -7742,7 +7731,7 @@ dependencies = [
"parity-scale-codec",
"scale-info",
"sp-crypto-hashing",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -7757,7 +7746,7 @@ dependencies = [
"parity-scale-codec",
"scale-info",
"sp-crypto-hashing",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -7778,7 +7767,7 @@ dependencies = [
"serde_json",
"subxt-core 0.43.0",
"subxt-lightclient 0.43.0",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio-util",
"tracing",
"url",
@@ -7802,7 +7791,7 @@ dependencies = [
"serde_json",
"subxt-core 0.44.2",
"subxt-lightclient 0.44.2",
"thiserror 2.0.18",
"thiserror 2.0.17",
"tokio-util",
"tracing",
"url",
@@ -7832,7 +7821,7 @@ dependencies = [
"sha2 0.10.9",
"sp-crypto-hashing",
"subxt-core 0.43.0",
"thiserror 2.0.18",
"thiserror 2.0.17",
"zeroize",
]
@@ -7844,7 +7833,7 @@ checksum = "8c4fb8fd6b16ecd3537a29d70699f329a68c1e47f70ed1a46d64f76719146563"
dependencies = [
"hex",
"parity-scale-codec",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -7855,7 +7844,7 @@ checksum = "a26ed947c63b4620429465c9f7e1f346433ddc21780c4bfcfade1e3a4dcdfab8"
dependencies = [
"hex",
"parity-scale-codec",
"thiserror 2.0.18",
"thiserror 2.0.17",
]
[[package]]
@@ -8005,11 +7994,11 @@ dependencies = [
[[package]]
name = "thiserror"
version = "2.0.18"
version = "2.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
dependencies = [
"thiserror-impl 2.0.18",
"thiserror-impl 2.0.17",
]
[[package]]
@@ -8025,9 +8014,9 @@ dependencies = [
[[package]]
name = "thiserror-impl"
version = "2.0.18"
version = "2.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
dependencies = [
"proc-macro2",
"quote",
@@ -8415,7 +8404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "786d480bce6247ab75f005b14ae1624ad978d3029d9113f0a22fa1ac773faeaf"
dependencies = [
"crossbeam-channel",
"thiserror 2.0.18",
"thiserror 2.0.17",
"time",
"tracing-subscriber",
]
@@ -8545,7 +8534,7 @@ dependencies = [
"rustls 0.23.36",
"rustls-pki-types",
"sha1",
"thiserror 2.0.18",
"thiserror 2.0.17",
"utf-8",
]
@@ -8859,9 +8848,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasip2"
version = "1.0.2+wasi-0.2.9"
version = "1.0.1+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
dependencies = [
"wit-bindgen",
]
@@ -9445,9 +9434,9 @@ dependencies = [
[[package]]
name = "wit-bindgen"
version = "0.51.0"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
[[package]]
name = "writeable"
@@ -9468,7 +9457,7 @@ dependencies = [
"pharos",
"rustc_version 0.4.1",
"send_wrapper",
"thiserror 2.0.18",
"thiserror 2.0.17",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -9642,9 +9631,9 @@ dependencies = [
[[package]]
name = "zmij"
version = "1.0.15"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2"
checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea"
[[package]]
name = "zombienet-configuration"
-6
View File
@@ -21,7 +21,6 @@ revive-dt-node-interaction = { version = "0.1.0", path = "crates/node-interactio
revive-dt-node-pool = { version = "0.1.0", path = "crates/node-pool" }
revive-dt-report = { version = "0.1.0", path = "crates/report" }
revive-dt-solc-binaries = { version = "0.1.0", path = "crates/solc-binaries" }
revive-dt-report-processor = { version = "0.1.0", path = "crates/report-processor" }
alloy = { version = "1.4.1", features = ["full", "genesis", "json-rpc"] }
ansi_term = "0.12.1"
@@ -82,12 +81,7 @@ zombienet-sdk = { git = "https://github.com/paritytech/zombienet-sdk.git", rev =
[profile.bench]
inherits = "release"
codegen-units = 1
lto = true
[profile.production]
inherits = "release"
codegen-units = 1
lto = true
[workspace.lints.clippy]
-12
View File
@@ -23,18 +23,6 @@ pub struct Mode {
pub version: Option<semver::VersionReq>,
}
impl Ord for Mode {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.to_string().cmp(&other.to_string())
}
}
impl PartialOrd for Mode {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Display for Mode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.pipeline.fmt(f)?;
@@ -1,15 +1,10 @@
use std::{
fmt::Display,
path::{Path, PathBuf},
str::FromStr,
};
use std::{fmt::Display, path::PathBuf, str::FromStr};
use anyhow::{Context as _, bail};
use serde::{Deserialize, Serialize};
use crate::types::Mode;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum ParsedTestSpecifier {
/// All of the test cases in the file should be ran across all of the specified modes
FileOrDirectory {
@@ -39,22 +34,6 @@ pub enum ParsedTestSpecifier {
},
}
impl ParsedTestSpecifier {
pub fn metadata_path(&self) -> &Path {
match self {
ParsedTestSpecifier::FileOrDirectory {
metadata_or_directory_file_path: metadata_file_path,
}
| ParsedTestSpecifier::Case {
metadata_file_path, ..
}
| ParsedTestSpecifier::CaseWithMode {
metadata_file_path, ..
} => metadata_file_path,
}
}
}
impl Display for ParsedTestSpecifier {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
@@ -152,22 +131,3 @@ impl TryFrom<&str> for ParsedTestSpecifier {
value.parse()
}
}
impl Serialize for ParsedTestSpecifier {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
self.to_string().serialize(serializer)
}
}
impl<'de> Deserialize<'de> for ParsedTestSpecifier {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let string = String::deserialize(deserializer)?;
string.parse().map_err(serde::de::Error::custom)
}
}
+2 -8
View File
@@ -294,16 +294,10 @@ impl SolidityCompiler for Resolc {
let map = compiler_output.contracts.entry(source_path).or_default();
for (contract_name, contract_information) in contracts.into_iter() {
let Some(bytecode) = contract_information
let bytecode = contract_information
.evm
.and_then(|evm| evm.bytecode.clone())
else {
tracing::debug!(
"Skipping abstract or interface contract {} - no bytecode",
contract_name
);
continue;
};
.context("Unexpected - Contract compiled with resolc has no bytecode")?;
let abi = {
let metadata = &contract_information.metadata;
if metadata.is_null() {
-4
View File
@@ -1124,10 +1124,6 @@ pub struct ReportConfiguration {
/// Controls if the compiler output is included in the final report.
#[clap(long = "report.include-compiler-output")]
pub include_compiler_output: bool,
/// The filename to use for the report.
#[clap(long = "report.file-name")]
pub file_name: Option<String>,
}
#[derive(Clone, Debug, Parser, Serialize, Deserialize)]
-25
View File
@@ -1,25 +0,0 @@
[package]
name = "revive-dt-report-processor"
description = "revive differential testing report processor utility"
version.workspace = true
authors.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
rust-version.workspace = true
[[bin]]
name = "report-processor"
path = "src/main.rs"
[dependencies]
revive-dt-report = { workspace = true }
revive-dt-common = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
[lints]
workspace = true
-329
View File
@@ -1,329 +0,0 @@
use std::{
borrow::Cow,
collections::{BTreeMap, BTreeSet},
fmt::Display,
fs::{File, OpenOptions},
ops::{Deref, DerefMut},
path::{Path, PathBuf},
str::FromStr,
};
use anyhow::{Context as _, Error, Result, bail};
use clap::Parser;
use serde::{Deserialize, Serialize, de::DeserializeOwned};
use revive_dt_common::types::{Mode, ParsedTestSpecifier};
use revive_dt_report::{Report, TestCaseStatus};
fn main() -> Result<()> {
let cli = Cli::try_parse().context("Failed to parse the CLI arguments")?;
match cli {
Cli::GenerateExpectationsFile {
report_path,
output_path: output_file,
remove_prefix,
} => {
let remove_prefix = remove_prefix
.into_iter()
.map(|path| path.canonicalize().context("Failed to canonicalize path"))
.collect::<Result<Vec<_>>>()?;
let expectations = report_path
.execution_information
.iter()
.flat_map(|(metadata_file_path, metadata_file_report)| {
metadata_file_report
.case_reports
.iter()
.map(move |(case_idx, case_report)| {
(metadata_file_path, case_idx, case_report)
})
})
.flat_map(|(metadata_file_path, case_idx, case_report)| {
case_report.mode_execution_reports.iter().map(
move |(mode, execution_report)| {
(
metadata_file_path,
case_idx,
mode,
execution_report.status.as_ref(),
)
},
)
})
.filter_map(|(metadata_file_path, case_idx, mode, status)| {
status.map(|status| (metadata_file_path, case_idx, mode, status))
})
.map(|(metadata_file_path, case_idx, mode, status)| {
(
TestSpecifier {
metadata_file_path: Cow::Borrowed(
remove_prefix
.iter()
.filter_map(|prefix| {
metadata_file_path.as_inner().strip_prefix(prefix).ok()
})
.next()
.unwrap_or(metadata_file_path.as_inner()),
),
case_idx: case_idx.into_inner(),
mode: Cow::Borrowed(mode),
},
Status::from(status),
)
})
.filter(|(_, status)| *status == Status::Failed)
.collect::<Expectations>();
let output_file = OpenOptions::new()
.truncate(true)
.create(true)
.write(true)
.open(output_file)
.context("Failed to create the output file")?;
serde_json::to_writer_pretty(output_file, &expectations)
.context("Failed to write the expectations to file")?;
}
Cli::CompareExpectationFiles {
base_expectation_path,
other_expectation_path,
} => {
let keys = base_expectation_path
.keys()
.chain(other_expectation_path.keys())
.collect::<BTreeSet<_>>();
for key in keys {
let base_status = base_expectation_path.get(key).context(format!(
"Entry not found in the base expectations: \"{}\"",
key
))?;
let other_status = other_expectation_path.get(key).context(format!(
"Entry not found in the other expectations: \"{}\"",
key
))?;
if base_status != other_status {
bail!(
"Expectations for entry \"{}\" have changed. They were {:?} and now they are {:?}",
key,
base_status,
other_status
)
}
}
}
};
Ok(())
}
type Expectations<'a> = BTreeMap<TestSpecifier<'a>, Status>;
/// A tool that's used to process the reports generated by the retester binary in various ways.
#[derive(Clone, Debug, Parser)]
#[command(name = "retester", term_width = 100)]
pub enum Cli {
/// Generates an expectation file out of a given report.
GenerateExpectationsFile {
/// The path of the report's JSON file to generate the expectation's file for.
#[clap(long)]
report_path: JsonFile<Report>,
/// The path of the output file to generate.
///
/// Note that we expect that:
/// 1. The provided path points to a JSON file.
/// 1. The ancestor's of the provided path already exist such that no directory creations
/// are required.
#[clap(long)]
output_path: PathBuf,
/// Prefix paths to remove from the paths in the final expectations file.
#[clap(long)]
remove_prefix: Vec<PathBuf>,
},
/// Compares two expectation files to ensure that they match each other.
CompareExpectationFiles {
/// The path of the base expectation file.
#[clap(long)]
base_expectation_path: JsonFile<Expectations<'static>>,
/// The path of the other expectation file.
#[clap(long)]
other_expectation_path: JsonFile<Expectations<'static>>,
},
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum Status {
Succeeded,
Failed,
Ignored,
}
impl From<TestCaseStatus> for Status {
fn from(value: TestCaseStatus) -> Self {
match value {
TestCaseStatus::Succeeded { .. } => Self::Succeeded,
TestCaseStatus::Failed { .. } => Self::Failed,
TestCaseStatus::Ignored { .. } => Self::Ignored,
}
}
}
impl<'a> From<&'a TestCaseStatus> for Status {
fn from(value: &'a TestCaseStatus) -> Self {
match value {
TestCaseStatus::Succeeded { .. } => Self::Succeeded,
TestCaseStatus::Failed { .. } => Self::Failed,
TestCaseStatus::Ignored { .. } => Self::Ignored,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct JsonFile<T> {
path: PathBuf,
content: Box<T>,
}
impl<T> Deref for JsonFile<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.content
}
}
impl<T> DerefMut for JsonFile<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.content
}
}
impl<T> FromStr for JsonFile<T>
where
T: DeserializeOwned,
{
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let path = PathBuf::from(s);
let file = File::open(&path).context("Failed to open the file")?;
serde_json::from_reader(&file)
.map(|content| Self { path, content })
.context(format!(
"Failed to deserialize file's content as {}",
std::any::type_name::<T>()
))
}
}
impl<T> Display for JsonFile<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.path.display(), f)
}
}
impl<T> From<JsonFile<T>> for String {
fn from(value: JsonFile<T>) -> Self {
value.to_string()
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TestSpecifier<'a> {
pub metadata_file_path: Cow<'a, Path>,
pub case_idx: usize,
pub mode: Cow<'a, Mode>,
}
impl<'a> Display for TestSpecifier<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}::{}::{}",
self.metadata_file_path.display(),
self.case_idx,
self.mode
)
}
}
impl<'a> From<TestSpecifier<'a>> for ParsedTestSpecifier {
fn from(
TestSpecifier {
metadata_file_path,
case_idx,
mode,
}: TestSpecifier,
) -> Self {
Self::CaseWithMode {
metadata_file_path: metadata_file_path.to_path_buf(),
case_idx,
mode: mode.into_owned(),
}
}
}
impl TryFrom<ParsedTestSpecifier> for TestSpecifier<'static> {
type Error = Error;
fn try_from(value: ParsedTestSpecifier) -> Result<Self> {
let ParsedTestSpecifier::CaseWithMode {
metadata_file_path,
case_idx,
mode,
} = value
else {
bail!("Expected a full test case specifier")
};
Ok(Self {
metadata_file_path: Cow::Owned(metadata_file_path),
case_idx,
mode: Cow::Owned(mode),
})
}
}
impl<'a> Serialize for TestSpecifier<'a> {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
self.to_string().serialize(serializer)
}
}
impl<'d, 'a> Deserialize<'d> for TestSpecifier<'a> {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'d>,
{
let string = String::deserialize(deserializer)?;
let mut splitted = string.split("::");
let (Some(metadata_file_path), Some(case_idx), Some(mode), None) = (
splitted.next(),
splitted.next(),
splitted.next(),
splitted.next(),
) else {
return Err(serde::de::Error::custom(
"Test specifier doesn't contain the components required",
));
};
let metadata_file_path = PathBuf::from(metadata_file_path);
let case_idx = usize::from_str(case_idx)
.map_err(|_| serde::de::Error::custom("Case idx is not a usize"))?;
let mode = Mode::from_str(mode).map_err(|_| serde::de::Error::custom("Invalid mode"))?;
Ok(Self {
metadata_file_path: Cow::Owned(metadata_file_path),
case_idx,
mode: Cow::Owned(mode),
})
}
}
+29 -37
View File
@@ -36,8 +36,6 @@ pub struct ReportAggregator {
runner_tx: Option<UnboundedSender<RunnerEvent>>,
runner_rx: UnboundedReceiver<RunnerEvent>,
listener_tx: Sender<ReporterEvent>,
/* Context */
file_name: Option<String>,
}
impl ReportAggregator {
@@ -45,11 +43,6 @@ impl ReportAggregator {
let (runner_tx, runner_rx) = unbounded_channel::<RunnerEvent>();
let (listener_tx, _) = channel::<ReporterEvent>(0xFFFF);
Self {
file_name: match context {
Context::Test(ref context) => context.report_configuration.file_name.clone(),
Context::Benchmark(ref context) => context.report_configuration.file_name.clone(),
Context::ExportJsonSchema | Context::ExportGenesis(..) => None,
},
report: Report::new(context),
remaining_cases: Default::default(),
runner_tx: Some(runner_tx),
@@ -128,7 +121,7 @@ impl ReportAggregator {
self.handle_completion(CompletionEvent {});
debug!("Report aggregation completed");
let default_file_name = {
let file_name = {
let current_timestamp = SystemTime::now()
.duration_since(UNIX_EPOCH)
.context("System clock is before UNIX_EPOCH; cannot compute report timestamp")?
@@ -137,7 +130,6 @@ impl ReportAggregator {
file_name.push_str(".json");
file_name
};
let file_name = self.file_name.unwrap_or(default_file_name);
let file_path = self
.report
.context
@@ -570,7 +562,7 @@ pub struct Report {
/// The list of metadata files that were found by the tool.
pub metadata_files: BTreeSet<MetadataFilePath>,
/// Metrics from the execution.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub metrics: Option<Metrics>,
/// Information relating to each test case.
pub execution_information: BTreeMap<MetadataFilePath, MetadataFileReport>,
@@ -590,7 +582,7 @@ impl Report {
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct MetadataFileReport {
/// Metrics from the execution.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub metrics: Option<Metrics>,
/// The report of each case keyed by the case idx.
pub case_reports: BTreeMap<CaseIdx, CaseReport>,
@@ -600,7 +592,7 @@ pub struct MetadataFileReport {
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct CaseReport {
/// Metrics from the execution.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub metrics: Option<Metrics>,
/// The [`ExecutionReport`] for each one of the [`Mode`]s.
#[serde_as(as = "HashMap<DisplayFromStr, _>")]
@@ -610,31 +602,31 @@ pub struct CaseReport {
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct ExecutionReport {
/// Information on the status of the test case and whether it succeeded, failed, or was ignored.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<TestCaseStatus>,
/// Metrics from the execution.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub metrics: Option<Metrics>,
/// Information related to the execution on one of the platforms.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub platform_execution: PlatformKeyedInformation<Option<ExecutionInformation>>,
/// Information on the compiled contracts.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub compiled_contracts: BTreeMap<PathBuf, BTreeMap<String, ContractInformation>>,
/// The addresses of the deployed contracts
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub contract_addresses: BTreeMap<ContractInstance, PlatformKeyedInformation<Vec<Address>>>,
/// Information on the mined blocks as part of this execution.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub mined_block_information: PlatformKeyedInformation<Vec<MinedBlockInformation>>,
/// Information tracked for each step that was executed.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub steps: BTreeMap<StepPath, StepReport>,
}
/// Information related to the status of the test. Could be that the test succeeded, failed, or that
/// it was ignored.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "status")]
pub enum TestCaseStatus {
/// The test case succeeded.
@@ -672,19 +664,19 @@ pub struct TestCaseNodeInformation {
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct ExecutionInformation {
/// Information related to the node assigned to this test case.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub node: Option<TestCaseNodeInformation>,
/// Information on the pre-link compiled contracts.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pre_link_compilation_status: Option<CompilationStatus>,
/// Information on the post-link compiled contracts.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub post_link_compilation_status: Option<CompilationStatus>,
/// Information on the deployed libraries.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployed_libraries: Option<BTreeMap<ContractInstance, Address>>,
/// Information on the deployed contracts.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployed_contracts: Option<BTreeMap<ContractInstance, Address>>,
}
@@ -703,11 +695,11 @@ pub enum CompilationStatus {
/// The input provided to the compiler to compile the contracts. This is only included if
/// the appropriate flag is set in the CLI context and if the contracts were not cached and
/// the compiler was invoked.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
compiler_input: Option<CompilerInput>,
/// The output of the compiler. This is only included if the appropriate flag is set in the
/// CLI contexts.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
compiler_output: Option<CompilerOutput>,
},
/// The compilation failed.
@@ -715,15 +707,15 @@ pub enum CompilationStatus {
/// The failure reason.
reason: String,
/// The version of the compiler used to compile the contracts.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
compiler_version: Option<Version>,
/// The path of the compiler used to compile the contracts.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
compiler_path: Option<PathBuf>,
/// The input provided to the compiler to compile the contracts. This is only included if
/// the appropriate flag is set in the CLI context and if the contracts were not cached and
/// the compiler was invoked.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
compiler_input: Option<CompilerInput>,
},
}
@@ -751,24 +743,24 @@ pub struct Metrics {
pub gas_per_second: Metric<u64>,
/* Block Fullness */
pub gas_block_fullness: Metric<u64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ref_time_block_fullness: Option<Metric<u64>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub proof_size_block_fullness: Option<Metric<u64>>,
}
/// The data that we store for a given metric (e.g., TPS).
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Metric<T> {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum: Option<PlatformKeyedInformation<T>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum: Option<PlatformKeyedInformation<T>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mean: Option<PlatformKeyedInformation<T>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub median: Option<PlatformKeyedInformation<T>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub raw: Option<PlatformKeyedInformation<Vec<T>>>,
}