Commit Graph
23 Commits
Author SHA1 Message Date
ed95ffbdfe Code coverage (#529)
Adds `make coverage` (cargo-llvm-cov over the full workspace including
revive-llvm-builder), a new "Code coverage" book chapter that briefly
explains how to run it, and a PR workflow that runs coverage and
comments on the PR (it updates the same comment if it already exists)
when the `measure code coverage` label is applied (see e.g. [this
comment](https://github.com/paritytech/revive/pull/529#issuecomment-4966136441)).

Building instrumented LLVM and generating an LLVM C++ coverage report is
also possible, see accompanying [PR description
#575](https://github.com/paritytech/revive/pull/575) for more details.

---------

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: xermicus <bigcyrill@hotmail.com>
Co-authored-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Co-authored-by: xermicus <cyrill@parity.io>
Co-authored-by: elle-j <linnea@parity.io>
Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
2026-07-16 14:48:44 +02:00
98d818f958 The new Yul optimizer toolkit (#519)
This PR introduces powerful code size optimizations. This is achieved
with an additional IR layer in between Yul and LLVM IR. It works quite
well (see below for a comparison) because it captures optimization gains
that neither solc nor LLVM can realize.

The feature is gated behind `--newyork` or a corresponding standard JSON
input setting and **off by default**.

### How it works

We implemented an SSA IR modelled after or inspired by the [MLIR SCF
dialect](https://mlir.llvm.org/docs/Dialects/SCFDialect/). Yul is
translated into this IR and the IR implements mainly the following
optimizations:

- **Type narrowing**: narrows 256-bit values to I1..I160 where provable
(bidirectional + interprocedural), so LLVM emits native 32/64-bit ops
instead
    of software 256-bit arithmetic.
- **FMP range proof**: exposes the `mload(0x40) < heap_size` bound to
LLVM
IPSCCP, eliminating trailing overflow checks on FMP-derived offsets.
Single
    largest code-size contributor.
- **Heap analysis**: skips big-endian byte-swaps where native
little-endian
    layout is safe.
  - **mem_opt / keccak fusion+folding**, **compound outlining** (mapping
sload/sstore), **guard narrowing**, **inlining** tuned for PolkaVM, and
    **exact + fuzzy function dedup**.

### Results
The optimizations implemented with the newyork IR bring substantial code
size improvements.
  - Integration contracts: approximately **-20% to -50%** code size.
  - OpenZeppelin Wizard corpus: around **-47%** code size.

This table shows the code size improvements on various OpenZeppelin ERC
implementations, taken from their [contracts
wizard](https://wizard.openzeppelin.com/), with almost all features
enabled.

| Contract | Default: (bytes) | With `--newyork`: (bytes) | Reduction |
|---|---:|---:|---:|
| erc1155 | 59,206 | 30,649 | -48.2% |
| erc20 | 81,697 | 42,893 | -47.5% |
| erc721 | 92,052 | 49,423 | -46.3% |
| oz_gov | 141,861 | 81,159 | -42.8% |
| oz_rwa | 77,274 | 37,975 | -50.9% |
| oz_simple_erc20 | 29,950 | 16,554 | -44.7% |
| oz_stable | 82,117 | 39,032 | -52.5% |
| **Total** | **564,157** | **297,685** | **-47.2%** |

We believe this to be a reasonably representative dataset and conclude
that the newyork IR achieves drastic code size reductions on real world
dApp implementations.

### Methodology, security and runtime performance

Since the main contributors to these improvements are the FMP range
proofs and the type narrowing, we don't expect big runtime performance
regressions (it may even benefit runtime performance in some cases).

The PR also includes docs
(`book/src/developer_guide/newyork_{optimizer,ir}.md`) and many new
integration tests, including regression tests for known FMP soundness
traps.

The PR was authored collaboratively and reviewed extensively by the
`revive` maintainers, as well as Claude Opus, Claude Fable, Qwen,
Minimax and Deepseek LLMs, over a span of many months.

The `newyork` compiler pipeline introduces no new regressions over our
integration and differential test suites (containing over 30000 test
cases). This was achieved by careful manual reviews and many LLM bughunt
loops. Additionally, a final security review by Anthropic's Fable 5 LLM
found no remaining soundness issues. Nonetheless, like any brand new
software, please consider this an experimental feature upon release.

---------

Signed-off-by: xermicus <bigcyrill@hotmail.com>
Signed-off-by: xermicus <cyrill@parity.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: neo <me@90f9.org>
Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
2026-06-17 12:35:16 +02:00
e7e40a0ded The revive compiler documentation (#424)
This PR adds comprehensive project documentation in the form of an
mdBook.

---------

Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
Co-authored-by: PG Herveou <pgherveou@gmail.com>
2025-12-01 14:58:02 +01:00
LJ ad61b6e3c9 Implement resolc end-to-end compilation benchmarks (#406)
# Description

Closes [#403](https://github.com/paritytech/revive/issues/403)

Adds compilation time benchmarks for resolc end-to-end.

The benchmarks can be run from the root via:

```sh
make bench-resolc
```

HTML reports will be generated under `target/criterion`, and a summary
of the results at
[crates/resolc/BENCHMARKS_M4PRO.md](https://github.com/paritytech/revive/blob/lj/compilation-benchmarks/crates/resolc/BENCHMARKS_M4PRO.md)
(currently from running on a Mac M4 Pro).
2025-11-19 12:16:07 +01:00
kvpanch e78f3cc419 add LLVM 18.x as a git submodule (#399)
This changeset is based on https://github.com/paritytech/revive/pull/346
2025-11-18 16:10:15 -05:00
PG Herveou a560b2d919 Fix npm-release job (#297)
follow up from #295
2025-04-30 21:48:11 +02:00
PG Herveou e07d0f0cb7 Move @parity/resolc from js-revive (#296)
- Move npm package from paritytech/js-revive 
- Rename package to `@parity/resolc`
2025-04-30 17:24:52 +02:00
Sebastian Miasojed 939138d0cd Add the revive tests in the browsers (#158) 2025-01-14 22:29:02 +01:00
Cyrill Leutwiler 7f81f37e0c revive llvm builder utility (#154)
Pre-eliminary support for LLVM releases and resolc binary releases by streamlining the build process for all supported hosts platforms.

- Introduce the revive-llvm-builder crate with the revive-llvm builder utilty.
- Do not rely on the LLVM dependency in $PATH to decouple the system LLVM installation from the LLVM host dependency.
- Fix the emscripten build by decoupling the host and native LLVM dependencies. Thus allowing a single LLVM emscripten release that can be used on any host platform.
- An example Dockerfile building an alpine container with a fully statically linked resolc ELF binary.
- Remove the Debian builder utilities and workflow.
2025-01-13 15:58:27 +01:00
Sebastian Miasojed afe44ad21b JS: Fix encoding conversion from utf16 to utf8 (#131) 2024-12-11 09:23:02 +01:00
Sebastian Miasojed 6a4fd1e991 Add web worker compatibility 2024-11-27 15:17:26 +01:00
Sebastian Miasojed 4e024655a1 Add support for esm and cjs modules 2024-11-25 10:26:22 +01:00
Sebastian Miasojed a772ff1354 Fix build path 2024-11-21 10:29:21 +01:00
Sebastian Miasojed cece20deb1 Cleanup 2024-11-18 10:18:21 +01:00
Sebastian Miasojed ce8bf3d9ef Apply suggestions from previous review 2024-11-14 11:20:33 +01:00
wpt967 bd89ebc45a Put llvm and compiler-rt build directories in one place. (#30)
Adjust the llvm build script to put the llvm and compiler-rt build
directories outside the llvm-project source directory. A new build
directory 'build' at the toplevel of the revive directory is used
instead. LLVM is built into 'build/llvm' and compiler-rt into
'build/compiler-rt'.

Adjust .gitignore to ignore the contents of the build directory.

This is intended to keep the build artifacts separate from the upstream
sources and any changes made as part of the revive work.
2024-08-12 16:35:19 +02:00
xermicus 0d39b289cb init mdbook
Signed-off-by: xermicus <cyrill@parity.io>
2024-06-08 16:41:40 +02:00
Chris 09b905415b feat: added npm workspaces support (#4)
Description
===========
  - Introduced npm workspaces to manage
    CLI tests from the root directory.
  - Enabled simplified npm dependency
    installation from the root.
  - Updated .gitignore to align with
    the new workspace structure.

Usage
=====

From the root directory

To install repo npm packages, run:
```
npm install && npm fund
```

To run related tests, run:
```
npm run test:cli
```
2024-04-17 12:49:10 +02:00
xermicus 3f9a90fe79 provide build script for LLVM
Signed-off-by: xermicus <cyrill@parity.io>
2024-04-12 15:07:52 +02:00
xermicus 2b9e40225d implement calldatacopy
Signed-off-by: xermicus <cyrill@parity.io>
2024-03-19 10:49:47 +01:00
Cyrill Leutwiler cffa14a4d2 Emerge Yul recompiler (#1)
Provide a modified (and incomplete) version of ZKSync zksolc that can compile the most basic contracts
2024-03-12 12:06:02 +01:00
Cyrill Leutwiler d238d8f39e custom ir
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2024-02-02 09:10:03 +01:00
Cyrill Leutwiler 426ab4b095 initial commit
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2023-12-07 20:37:23 +01:00