Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ report-processor generate-expectations-file \
--include-status failed
```

## Supported Platforms
### Supported Platforms
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned on element, I think it's best for us to remove the CLAUDE.md file as it doesn't improve the LLMs performance unless it contains insights which are hard for it to find.


| Platform CLI Name | Description |
|-------------------|-------------|
Expand All @@ -99,6 +99,64 @@ report-processor generate-expectations-file \
| `polkadot-omni-node-polkavm-resolc` | Polkadot Omni Node + Resolc |
| `polkadot-omni-node-revm-solc` | Polkadot Omni Node + Solc |

## Running Compilations and Comparing Bytecode Hashes

You can compile contracts using different resolc builds (e.g. for Linux, macOS, and Windows) without executing differential tests. The compilation modes to compile each contract with (e.g. `Y M3 S+`) are passed via `--mode` arguments.

The bytecode hashes generated are included in the compilation report and can be exported and then compared in order to verify that the bytecode produced by each build is identical for the specified mode.

### Compiling Contracts

How to compile (for each platform/build):

```bash
retester compile \
--compile ./resolc-compiler-tests/fixtures/solidity/simple \
--compile ./resolc-compiler-tests/fixtures/solidity/complex \
--compile ./resolc-compiler-tests/fixtures/solidity/translated_semantic_tests \
--mode "Y M0 S+" \
--mode "Y M3 S+" \
--mode "Y Mz S+" \
--resolc.path /path/to/resolc \
--resolc.heap-size 500000 \
--solc.version "0.8.33" \
--report.file-name report-compile.json \
--report.include-compiler-input \
--report.include-compiler-output \
--working-directory ./workdir \
--concurrency.number-of-threads 10 \
--concurrency.number-of-concurrent-tasks 100 \
> logs-compile.log \
2> output-compile.log
```

### Exporting Bytecode Hashes

How to export bytecode hashes (for each platform/build):

```bash
report-processor export-hashes \
--report-path ./workdir/report-compile.json \
--output-path ./exported-hashes/hashes-macos.json \
--remove-prefix ./resolc-compiler-tests \
--platform-label macos
```

### Comparing Bytecode Hashes

How to compare bytecode hashes:

```bash
report-processor compare-hashes \
--hash-path ./exported-hashes/hashes-macos.json \
--hash-path ./exported-hashes/hashes-linux.json \
--hash-path ./exported-hashes/hashes-windows.json \
--mode "Y M0 S+" \
--mode "Y M3 S+" \
--mode "Y Mz S+" \
--output-path ./hash-comparison.json
```

## Architecture

The project is a Rust workspace (edition 2024, MSRV 1.87.0) with crates in `/crates/`:
Expand Down Expand Up @@ -151,7 +209,7 @@ For tests that fail gas estimation (e.g., due to `consume_all_gas` behavior in r
## External Dependencies

**Always required:**
- Solc (Solidity compiler) - auto-downloaded but resolc needs it in PATH
- Solc (Solidity compiler) - auto-downloaded
Comment on lines -154 to +212
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolc doesn't need solc in PATH when solc is passed explicitly which it is here.


**Platform-specific:**
| Platform | Required Tools |
Expand Down
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ This section describes the required dependencies that this framework requires to
- Geth - When doing differential testing against the PVM we submit transactions to a Geth node and to Revive Dev Node to compare them.
- Revive Dev Node - When doing differential testing against the PVM we submit transactions to a Geth node and to Revive Dev Node to compare them.
- ETH-RPC - All communication with Revive Dev Node is done through the ETH RPC.
- Solc - This is actually a transitive dependency, while this tool doesn't require solc as it downloads the versions that it requires, resolc requires that Solc is installed and available in the path.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- Resolc - This is required to compile the contracts to PolkaVM bytecode.
- Kurtosis - The Kurtosis CLI tool is required for the production Ethereum mainnet-like node configuration with Geth as the execution layer and lighthouse as the consensus layer. Kurtosis also requires docker to be installed since it runs everything inside of docker containers.

All of the above need to be installed and available in the path in order for the tool to work.

## Running The Tool
## Running Differential Tests

This tool is being updated quite frequently. Therefore, it's recommended that you don't install the tool and then run it, but rather that you run it from the root of the directory using `cargo run --release --bin retester`. The help command of the tool gives you all of the information you need to know about each of the options and flags that the tool offers.

Expand Down Expand Up @@ -118,3 +117,61 @@ RUST_LOG="info" retester test \
```

</details>

## Running Compilations and Comparing Bytecode Hashes
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same content here as in CLAUDE.md.


You can compile contracts using different resolc builds (e.g. for Linux, macOS, and Windows) without executing differential tests. The compilation modes to compile each contract with (e.g. `Y M3 S+`) are passed via `--mode` arguments.

The bytecode hashes generated are included in the compilation report and can be exported and then compared in order to verify that the bytecode produced by each build is identical for the specified mode.

### Compiling Contracts

How to compile (for each platform/build):

```bash
retester compile \
--compile ./resolc-compiler-tests/fixtures/solidity/simple \
--compile ./resolc-compiler-tests/fixtures/solidity/complex \
--compile ./resolc-compiler-tests/fixtures/solidity/translated_semantic_tests \
--mode "Y M0 S+" \
--mode "Y M3 S+" \
--mode "Y Mz S+" \
--resolc.path /path/to/resolc \
--resolc.heap-size 500000 \
--solc.version "0.8.33" \
--report.file-name report-compile.json \
--report.include-compiler-input \
--report.include-compiler-output \
--working-directory ./workdir \
--concurrency.number-of-threads 10 \
--concurrency.number-of-concurrent-tasks 100 \
> logs-compile.log \
2> output-compile.log
```

### Exporting Bytecode Hashes

How to export bytecode hashes (for each platform/build):

```bash
report-processor export-hashes \
--report-path ./workdir/report-compile.json \
--output-path ./exported-hashes/hashes-macos.json \
--remove-prefix ./resolc-compiler-tests \
--platform-label macos
```

### Comparing Bytecode Hashes

How to compare bytecode hashes:

```bash
report-processor compare-hashes \
--hash-path ./exported-hashes/hashes-macos.json \
--hash-path ./exported-hashes/hashes-linux.json \
--hash-path ./exported-hashes/hashes-windows.json \
--mode "Y M0 S+" \
--mode "Y M3 S+" \
--mode "Y Mz S+" \
--output-path ./hash-comparison.json
```
6 changes: 3 additions & 3 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod context {
pub corpus: CorpusExecutionConfiguration,
}

/// Compiles contracts for pre-link compilations only without executing any tests.
/// Compiles contracts without executing any tests.
#[subcommand]
pub struct Compile {
pub log: LogConfiguration,
Expand Down Expand Up @@ -227,11 +227,11 @@ mod context {
pub test_specifiers: Vec<ParsedTestSpecifier>,
}

/// A set of configuration parameters for the corpus files to use for the pre-link-only compilation.
/// A set of configuration parameters for the corpus files to use for the post-link-only compilation.
#[serde_with::serde_as]
#[configuration(key = "corpus")]
pub struct CorpusCompilationConfiguration {
/// A list of compilation specifiers for the pre-link-only compilations that the tool should run.
/// A list of compilation specifiers for the post-link-only compilations that the tool should run.
///
/// Compile specifiers follow the following format:
///
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/compilations/entry_point.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The main entry point into compiling in pre-link-only mode without any test execution.
//! The main entry point into compiling in post-link-only mode without any test execution.

use crate::internal_prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/compilations/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module contains all of the code responsible for performing compilations,
//! including the driver implementation and the core logic that allows for contracts
//! to be compiled in pre-link-only mode without any test execution.
//! to be compiled in post-link-only mode without any test execution.

mod driver;
mod entry_point;
Expand Down
2 changes: 1 addition & 1 deletion crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sp-core = { workspace = true }
sp-runtime = { workspace = true }
subxt = { workspace = true }
# Zombienet uses `std::os::unix` which prevents compiling retester on Windows.
# For running pre-link-only contract compilations on Windows, Zombienet is gated.
# For running only contract compilations on Windows, Zombienet is gated.
[target.'cfg(unix)'.dependencies]
zombienet-sdk = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion crates/report-processor/src/export_hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl HashData {
}
}

/// Extracts all bytecode hashes from pre-link compilations from a [`Report`].
/// Extracts all bytecode hashes from post-link compilations from a [`Report`].
pub fn extract_hashes(
report: &Report,
contracts_base_dir: &Path,
Expand Down
2 changes: 1 addition & 1 deletion crates/report-processor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ pub enum Cli {
output_path: PathBuf,
},

/// Extracts and exports the bytecode hashes from pre-link compilations from a [`Report`].
/// Extracts and exports the bytecode hashes from post-link compilations from a [`Report`].
ExportHashes {
/// The path to the report's JSON file.
#[clap(long = "report-path")]
Expand Down
2 changes: 1 addition & 1 deletion crates/report/src/reporter_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum ReporterEvent {
},

/// An event sent by the reporter once an entire metadata file and mode combination has
/// finished pre-link-only compilation.
/// finished post-link-only compilation.
MetadataFileModeCombinationCompilationCompleted {
metadata_file_path: MetadataFilePath,
compilation_status: BTreeMap<Mode, CompilationStatus>,
Expand Down
Loading