Compare commits

...

13 Commits

Author SHA1 Message Date
xermicus 75a83af4da ci: clippy (#227)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-21 16:43:09 +01:00
xermicus 9c330ef8fc llvm-builder: only run expensive tests on linux (#226)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-21 16:38:44 +01:00
Yuri Volkov 687cec31ef Using released LLVM in revive build (#220) 2025-02-21 16:30:26 +01:00
Yuri Volkov 48a019e0ad Fix: add llvm- prefix to llvm version tag (#225)
Needed both for differentiating them from regular releases and for
filtering the tags in automation
2025-02-21 12:05:40 +01:00
xermicus 17a2d2f9f2 update README.md (#223)
Signed-off-by: xermicus <cyrill@parity.io>
2025-02-21 10:51:40 +01:00
Yuri Volkov 6ad7908c5e Using workflow_dispatch for LLVM releases (#222) 2025-02-20 20:00:33 +01:00
Yuri Volkov 840a736fc5 LLVM release workflows (#207)
Co-authored-by: xermicus <cyrill@parity.io>
2025-02-20 12:30:52 +01:00
xermicus 89cdfefab4 remove some dead code leftovers (#218)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-19 10:41:32 +01:00
xermicus 6c2c633651 release resolc v0.1.0-dev.11 (#214)
Signed-off-by: xermicus <cyrill@parity.io>
2025-02-18 08:08:20 +01:00
xermicus a73b0925c6 ci: do not run bun tests (#215) 2025-02-17 17:04:53 +01:00
xermicus ee650cf03a ci: use upstream evm for tests (#213)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-17 11:33:30 +01:00
Evgeny Snitko c2210442b6 Release workflow (#201)
Co-authored-by: xermicus <cyrill@parity.io>
2025-02-17 11:09:10 +01:00
xermicus cb268850a9 llvm-context: remove the linear memory pointer indirection (#211) 2025-02-13 13:21:43 +01:00
23 changed files with 808 additions and 222 deletions
-16
View File
@@ -9,7 +9,6 @@ on:
env:
CARGO_TERM_COLOR: always
REVIVE_WASM_INSTALL_DIR: ${{ github.workspace }}/target/wasm32-unknown-emscripten/release
BUN_VERSION: 1.1.43
jobs:
build-revive-wasm:
@@ -113,21 +112,6 @@ jobs:
with:
node-version: "20"
- name: Install Bun on Windows
if: runner.os == 'Windows'
run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop install bun@${{ env.BUN_VERSION }}
scoop install wget
Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH
- name: Install Bun on macOS and Linux
if: runner.os != 'Windows'
run: |
curl -fsSL https://bun.sh/install | bash -s bun-v${{ env.BUN_VERSION }}
echo "$HOME/.bun/bin" >> $GITHUB_PATH
- name: Install packages
run: npm install
+36
View File
@@ -0,0 +1,36 @@
module.exports = async ({
octokit,
context,
releasePrefix,
artifactSuffix,
}) => {
let page = 1;
while (true) {
const res = await octokit.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
page,
});
if (res.data.length === 0) {
throw new Error(
`No LLVM releases with '${artifactSuffix}' atifacts found! Please release LLVM before running this workflow.`,
);
}
for (let release of res.data) {
if (release.tag_name.startsWith(releasePrefix)) {
for (let asset of release.assets) {
if (asset.name.includes(artifactSuffix)) {
return asset.browser_download_url;
}
}
console.warn(
`LLVM release ${release.tag_name} doesn't have a '${artifactSuffix}' artifact; searching for older releases...`,
);
}
}
page++;
}
};
+167
View File
@@ -0,0 +1,167 @@
name: Release LLVM
on:
workflow_dispatch:
inputs:
llvm_version:
type: string
required: true
description: llvm version in "x.x.x" format, e.g. "18.1.8"
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.resolve-version.outputs.version }}
steps:
- id: resolve-version
run: |
echo "version=llvm-${{ inputs.llvm_version }}-revive.${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: create release
uses: softprops/action-gh-release@v2
with:
name: "LLVM binaries release: ${{ steps.resolve-version.outputs.version }}"
body: "This release includes binaries of LLVM, used to compile revive itself"
make_latest: "false"
tag_name: ${{ steps.resolve-version.outputs.version }}
build-macos:
strategy:
matrix:
os: [macos-14, macos-13]
include:
- os: macos-13
arch: x64
- os: macos-14
arch: arm64
needs: create-release
runs-on: ${{ matrix.os }}
name: "build-macos-${{ matrix.arch }}"
env:
RUST_LOG: trace
permissions:
contents: write # for uploading assets to release
steps:
- uses: actions/checkout@v4
- name: install macos deps
run: |
brew install ninja
- name: versions
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: Build LLVM
run: |
make install-llvm
- name: clean
# check removed files
run: |
cd target-llvm/gnu/target-final/bin/
rm diagtool llvm-libtool-darwin llvm-lipo llvm-pdbutil llvm-dwarfdump llvm-nm llvm-readobj llvm-cfi-verify \
sancov llvm-debuginfo-analyzer llvm-objdump llvm-profgen llvm-extract llvm-jitlink llvm-c-test llvm-gsymutil llvm-dwp \
dsymutil llvm-dwarfutil llvm-exegesis lli clang-rename bugpoint clang-extdef-mapping clang-refactor c-index-test \
llvm-reduce llvm-lto clang-linker-wrapper llc llvm-lto2
- name: package artifacts
run: |
tar -czf "${{ needs.create-release.outputs.version }}-macos-${{ matrix.arch }}.tar.gz" target-llvm/gnu/target-final
- name: upload archive to release
uses: softprops/action-gh-release@v2
with:
make_latest: "false"
tag_name: ${{ needs.create-release.outputs.version }}
files: |
${{ needs.create-release.outputs.version }}-macos-${{ matrix.arch }}.tar.gz
build-linux-all:
needs: create-release
runs-on: parity-large
env:
RUST_LOG: trace
permissions:
contents: write # for uploading assets to release
steps:
- uses: actions/checkout@v4
- name: install linux deps
run: |
sudo apt-get update && sudo apt-get install -y cmake ninja-build curl git libssl-dev pkg-config clang lld musl
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rust-src
target: wasm32-unknown-emscripten
rustflags: ""
- name: versions
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: Build host LLVM
run: |
make install-llvm
- name: Build gnu LLVM
run: |
revive-llvm clone
revive-llvm build --llvm-projects lld --llvm-projects clang
- name: Build musl LLVM
run: |
revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang
- name: Build emscripten LLVM
run: |
revive-llvm --target-env emscripten clone
source emsdk/emsdk_env.sh
revive-llvm --target-env emscripten build --llvm-projects lld
- name: clean
# check removed files
run: |
for target in gnu emscripten musl; do
cd target-llvm/${target}/target-final/bin/
rm -rf diagtool llvm-libtool-darwin llvm-lipo llvm-pdbutil llvm-dwarfdump llvm-nm llvm-readobj llvm-cfi-verify \
sancov llvm-debuginfo-analyzer llvm-objdump llvm-profgen llvm-extract llvm-jitlink llvm-c-test llvm-gsymutil llvm-dwp \
dsymutil llvm-dwarfutil llvm-exegesis lli clang-rename bugpoint clang-extdef-mapping clang-refactor c-index-test \
llvm-reduce llvm-lto clang-linker-wrapper llc llvm-lto2 llvm-otool llvm-readelf
cd -
done
- name: package artifacts
run: |
tar -czf "${{ needs.create-release.outputs.version }}-x86_64-linux-gnu-linux.tar.gz" target-llvm/gnu/target-final
tar -czf "${{ needs.create-release.outputs.version }}-x86_64-linux-musl.tar.gz" target-llvm/musl/target-final
tar -czf "${{ needs.create-release.outputs.version }}-wasm32-unknown-emscripten.tar.gz" target-llvm/emscripten/target-final
- name: upload archive to release
uses: softprops/action-gh-release@v2
with:
make_latest: "false"
tag_name: ${{ needs.create-release.outputs.version }}
files: |
${{ needs.create-release.outputs.version }}-x86_64-linux-gnu-linux.tar.gz
${{ needs.create-release.outputs.version }}-x86_64-linux-musl.tar.gz
${{ needs.create-release.outputs.version }}-wasm32-unknown-emscripten.tar.gz
+366
View File
@@ -0,0 +1,366 @@
name: Release
run-name: Release ${{ github.ref_name }}
on:
push:
branches:
- "main"
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
#rust-musl-cross:x86_64-musl
RUST_MUSL_CROSS_IMAGE: messense/rust-musl-cross@sha256:68b86bc7cb2867259e6b233415a665ff4469c28b57763e78c3bfea1c68091561
RUST_LOG: trace
jobs:
tag:
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
TAG: ${{ steps.versions.outputs.TAG }}
PKG_VER: ${{ steps.versions.outputs.PKG_VER }}
RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: "true"
fetch-depth: 0
- name: Versions
id: versions
run: |
export CURRENT_TAG=$(git describe --tags --abbrev=0 --exclude "llvm-*")
export PKG_VER=v$(cat Cargo.toml | grep -A 5 package] | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d " ")
echo "Current tag $CURRENT_TAG"
echo "Package version $PKG_VER"
#
echo "PKG_VER=$PKG_VER" >> $GITHUB_OUTPUT
if [[ $CURRENT_TAG == $PKG_VER ]];
then
echo "Tag is up to date. Nothing to do.";
export TAG=old;
else
echo "Tag was updated.";
export TAG=new;
fi
echo "TAG=$TAG" >> $GITHUB_OUTPUT
# Generating release notes early, in order to avoid checkout at the last step
export RELEASE_NOTES="$(sed '/^## '${PKG_VER}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
echo "Release notes:"
echo "$RELEASE_NOTES"
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
build-macos:
strategy:
matrix:
os: [macos-14, macos-13]
include:
- os: macos-13
arch: x64
- os: macos-14
arch: arm64
if: ${{ needs.tag.outputs.TAG == 'new' }}
runs-on: ${{ matrix.os }}
name: "build-macos-${{ matrix.arch }}"
needs: [tag]
steps:
- uses: actions/checkout@v4
- name: Get latest macos ${{ matrix.arch }} LLVM release artifact
id: get-llvm-artifact
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js");
return await getReleaseArtifact({
octokit: github,
context,
releasePrefix: "llvm-",
artifactSuffix: "-macos-${{ matrix.arch }}"
});
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rust-src
target: wasm32-unknown-emscripten
rustflags: ""
- name: install macos deps
run: |
brew install ninja
- name: versions
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: download llvm
run: |
curl -L -o llvm.tar.gz "${{ steps.get-llvm-artifact.outputs.result }}"
tar -xvf llvm.tar.gz
- name: build revive
run: |
export LLVM_SYS_181_PREFIX=$PWD/target-llvm/gnu/target-final
make install-bin
cp ./target/release/resolc ./target/release/resolc-${{ matrix.arch }}
- name: check revive
run: |
mkdir solc
curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-macos
chmod +x solc/solc
PATH=$PWD/solc:$PATH
result=$(./target/release/resolc-${{ matrix.arch }} --bin crates/integration/contracts/flipper.sol)
echo $result
if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi
- uses: actions/upload-artifact@v4
with:
name: "revive-macos-${{ matrix.arch }}"
path: |
./target/release/resolc-${{ matrix.arch }}
retention-days: 1
macos-universal-binary:
runs-on: macos-14
needs: [build-macos]
steps:
- uses: actions/download-artifact@v4
with:
pattern: revive-macos-*
path: revive-macos
- name: run lipo
run: |
lipo revive-macos/revive-macos-arm64/resolc-arm64 revive-macos/revive-macos-x64/resolc-x64 -create -output resolc-macos
- name: compress macos artifact
run: |
tar -czf resolc-macos.tar.gz ./resolc-macos
- uses: actions/upload-artifact@v4
with:
name: revive-macos
path: |
resolc-macos.tar.gz
retention-days: 1
build-linux-all:
if: ${{ needs.tag.outputs.TAG == 'new' }}
runs-on: parity-large
needs: [tag]
steps:
- uses: actions/checkout@v4
- name: Get latest linux LLVM release artifact
id: get-llvm-musl-artifact
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js")
return await getReleaseArtifact({
octokit: github,
context,
releasePrefix: "llvm-",
artifactSuffix: "-x86_64-linux-musl"
})
- name: install linux deps
run: |
sudo apt-get update && sudo apt-get install -y cmake ninja-build \
curl git libssl-dev pkg-config clang lld musl
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rust-src
target: wasm32-unknown-emscripten
rustflags: ""
- name: versions
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: download llvm
run: |
curl -L -o llvm.tar.gz "${{ steps.get-llvm-musl-artifact.outputs.result }}"
tar -xvf llvm.tar.gz
# Build revive
- name: build musl
run: |
mkdir resolc-out
docker run -v $PWD:/opt/revive $RUST_MUSL_CROSS_IMAGE /bin/bash -c "
cd /opt/revive
apt update && apt upgrade -y && apt install -y pkg-config
export LLVM_SYS_181_PREFIX=/opt/revive/target-llvm/musl/target-final
make install-bin
cp /root/.cargo/bin/resolc /opt/revive/resolc-out/resolc-static-linux
"
- name: check musl
run: |
mkdir solc
curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-static-linux
chmod +x solc/solc
PATH=$PWD/solc:$PATH
result=$(./resolc-out/resolc-static-linux --bin crates/integration/contracts/flipper.sol)
echo $result
if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi
- name: compress musl artifact
run: |
tar --strip-components 1 -czf resolc-static-linux.tar.gz ./resolc-out/resolc-static-linux
- uses: actions/upload-artifact@v4
with:
name: revive-linux
path: |
./resolc-static-linux.tar.gz
retention-days: 1
- name: Set Up Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Get latest emscripten LLVM release artifact
id: get-llvm-emscripten-artifact
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js")
return await getReleaseArtifact({
octokit: github,
context,
releasePrefix: "llvm-",
artifactSuffix: "-wasm32-unknown-emscripten"
})
- name: download llvm
run: |
curl -L -o llvm.tar.gz "${{ steps.get-llvm-emscripten-artifact.outputs.result }}"
tar -xvf llvm.tar.gz
- name: build wasm
run: |
make install-llvm-builder
revive-llvm --target-env emscripten clone
export LLVM_SYS_181_PREFIX=$PWD/target-llvm/musl/target-final
export REVIVE_LLVM_TARGET_PREFIX=$PWD/target-llvm/emscripten/target-final
source emsdk/emsdk_env.sh
rustup target add wasm32-unknown-emscripten
make install-wasm
- name: check wasm
run: |
curl -sSLo solc/soljson.js https://github.com/ethereum/solidity/releases/download/v0.8.28/soljson.js
node -e "
const soljson = require('solc/soljson');
const createRevive = require('./target/wasm32-unknown-emscripten/release/resolc.js');
const compiler = createRevive();
compiler.soljson = soljson;
const standardJsonInput =
{
language: 'Solidity',
sources: {
'MyContract.sol': {
content: 'pragma solidity ^0.8.0; contract MyContract { function greet() public pure returns (string memory) { return \'Hello\'; } }',
},
},
settings: { optimizer: { enabled: false } }
};
compiler.writeToStdin(JSON.stringify(standardJsonInput));
compiler.callMain(['--standard-json']);
// Collect output
const stdout = compiler.readFromStdout();
const stderr = compiler.readFromStderr();
if (stderr) { console.error(stderr); process.exit(1); }
let out = JSON.parse(stdout);
let bytecode = out.contracts['MyContract.sol']['MyContract'].evm.bytecode.object
console.log(bytecode);
if(!bytecode.startsWith('50564d')) { process.exit(1); }
"
- name: compress wasm artifact
run: |
tar --strip-components 3 -czf resolc-wasm.tar.gz \
./target/wasm32-unknown-emscripten/release/resolc.js \
./target/wasm32-unknown-emscripten/release/resolc.wasm \
./target/wasm32-unknown-emscripten/release/resolc_web.js
- uses: actions/upload-artifact@v4
with:
name: revive-wasm
path: |
resolc-wasm.tar.gz
retention-days: 1
create-release:
needs: [tag, build-linux-all, macos-universal-binary]
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.result }}
steps:
- name: Download revive-wasm
uses: actions/download-artifact@v4
with:
name: revive-wasm
path: resolc-wasm/
- name: Download revive-linux
uses: actions/download-artifact@v4
with:
name: revive-linux
path: resolc-linux/
- name: Download revive-macos
uses: actions/download-artifact@v4
with:
name: revive-macos
path: resolc-macos/
- name: create-release
uses: softprops/action-gh-release@v2
with:
body: ${{ needs.tag.outputs.RELEASE_NOTES }}
tag_name: ${{ needs.tag.outputs.PKG_VER }}
name: ${{ needs.tag.outputs.PKG_VER }}
draft: true
files: |
./resolc-linux/resolc-static-linux.tar.gz
./resolc-macos/resolc-macos.tar.gz
./resolc-wasm/resolc-wasm.tar.gz
+3 -4
View File
@@ -32,10 +32,9 @@ jobs:
- name: Install geth
run: |
git clone https://github.com/xermicus/go-ethereum --branch=cl/fix-runner-state-dump --depth=1
cd go-ethereum
make all
echo "$(pwd)/build/bin/" >> $GITHUB_PATH
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt update
sudo apt install -y ethereum
- name: Machete
uses: bnjbvr/cargo-machete@main
+14
View File
@@ -6,6 +6,20 @@ This is a development pre-release.
Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50`
## v0.1.0-dev.11
This is a development pre-release.
Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50`
### Added
### Changed
### Fixed
- A bug causing incorrect loads from the emulated EVM linear memory.
- A missing integer truncate after switching to 64bit.
## v0.1.0-dev.10
This is a development pre-release.
Generated
+67 -67
View File
@@ -166,9 +166,9 @@ dependencies = [
[[package]]
name = "alloy-eips"
version = "0.11.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7149e011edbd588f6df6564b369c75f6b538d76db14053d95e0b43b2d92e4266"
checksum = "5591581ca2ab0b3e7226a4047f9a1bfcf431da1d0cce3752fda609fea3c27e37"
dependencies = [
"alloy-eip2124",
"alloy-eip2930",
@@ -185,9 +185,9 @@ dependencies = [
[[package]]
name = "alloy-genesis"
version = "0.11.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acaec0cc4c1489d61d6f33d0c3dd522c750025f4b5c8f59cd546221e4df660e5"
checksum = "0cded3a2d4bd7173f696458c5d4c98c18a628dfcc9f194385e80a486e412e2e0"
dependencies = [
"alloy-eips",
"alloy-primitives",
@@ -259,9 +259,9 @@ dependencies = [
[[package]]
name = "alloy-serde"
version = "0.11.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86aa42c36e3c0db5bd9a7314e98aa261a61d5e3d6a0bd7e51fb8b0a3d6438481"
checksum = "8732058f5ca28c1d53d241e8504620b997ef670315d7c8afab856b3e3b80d945"
dependencies = [
"alloy-primitives",
"serde",
@@ -1267,9 +1267,9 @@ dependencies = [
[[package]]
name = "blst"
version = "0.3.13"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874"
checksum = "47c79a94619fade3c0b887670333513a67ac28a6a7e653eb260bf0d4103db38d"
dependencies = [
"cc",
"glob",
@@ -1669,9 +1669,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
version = "1.2.13"
version = "1.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda"
checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9"
dependencies = [
"jobserver",
"libc",
@@ -3050,9 +3050,9 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b"
[[package]]
name = "equivalent"
version = "1.0.1"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "errno"
@@ -4683,7 +4683,7 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
[[package]]
name = "lld-sys"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"cc",
"libc",
@@ -5095,9 +5095,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
[[package]]
name = "openssl"
version = "0.10.70"
version = "0.10.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6"
checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd"
dependencies = [
"bitflags 2.8.0",
"cfg-if",
@@ -5127,9 +5127,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
[[package]]
name = "openssl-sys"
version = "0.9.105"
version = "0.9.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc"
checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd"
dependencies = [
"cc",
"libc",
@@ -7706,15 +7706,15 @@ dependencies = [
[[package]]
name = "polkavm"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0e3ed30e5a50c82ee5747c89cf4a06dbc914871d7ec795622f265428c0fbe40"
checksum = "cfd34e2f74206fff33482ae1718e275f11365ef8c4de7f0e69217f8845303867"
dependencies = [
"libc",
"log",
"polkavm-assembler 0.20.0",
"polkavm-common 0.20.0",
"polkavm-linux-raw 0.20.0",
"polkavm-assembler 0.21.0",
"polkavm-common 0.21.0",
"polkavm-linux-raw 0.21.0",
]
[[package]]
@@ -7737,9 +7737,9 @@ dependencies = [
[[package]]
name = "polkavm-assembler"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90acfc8722902636fd875d48654696ba64208e469e5e9030ef55a509656c02f0"
checksum = "f512bc80cb10439391a7c13a9eb2d37cf66b7305e7df0a06d662eff4f5b07625"
dependencies = [
"log",
]
@@ -7766,12 +7766,12 @@ dependencies = [
[[package]]
name = "polkavm-common"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae5e62a5310d5ee861b4623c0929d03d60b95dff0f1ec0c9e05dd1c522f5cc86"
checksum = "5c16b809cfd398f861261c045a8745e6c78b71ea7e0d3ef6f7cc553eb27bc17e"
dependencies = [
"log",
"polkavm-assembler 0.20.0",
"polkavm-assembler 0.21.0",
]
[[package]]
@@ -7838,15 +7838,15 @@ dependencies = [
[[package]]
name = "polkavm-disassembler"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7e81a448e08c0e0adbe2466ef0f6a866f438117cda0c1602a46f779744a308"
checksum = "6de96c15f2c149d3c0680438e8d25b1c0e0bf25c69f4fa37a890ca2401d158a7"
dependencies = [
"clap",
"iced-x86",
"polkavm 0.20.0",
"polkavm-common 0.20.0",
"polkavm-linker 0.20.0",
"polkavm 0.21.0",
"polkavm-common 0.21.0",
"polkavm-linker 0.21.0",
]
[[package]]
@@ -7883,16 +7883,16 @@ dependencies = [
[[package]]
name = "polkavm-linker"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3f2f97a0c34daa9fb29341b235f4480fa80c1029f120f8387da3189036325f1"
checksum = "23bc764986c4a63f9ab9890c3f4eb9b4c13b6ff80d79685bd48ade147234aab4"
dependencies = [
"dirs",
"gimli 0.31.1",
"hashbrown 0.14.5",
"log",
"object 0.36.7",
"polkavm-common 0.20.0",
"polkavm-common 0.21.0",
"regalloc2 0.9.3",
"rustc-demangle",
]
@@ -7911,9 +7911,9 @@ checksum = "136ae072ab6fa38e584a06d12b1b216cff19f54d5cd202a8f8c5ec2e92e7e4bb"
[[package]]
name = "polkavm-linux-raw"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be71d93774fef36046d3707e84081e9e5dc65e046d7ea34f2d422b149ac0a9c8"
checksum = "be6cd1d48c5e7814d287a3e12a339386a5dfa2f3ac72f932335f4cf56467f1b3"
[[package]]
name = "poly1305"
@@ -8113,9 +8113,9 @@ dependencies = [
[[package]]
name = "psm"
version = "0.1.24"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810"
checksum = "f58e5423e24c18cc840e1c98370b3993c6649cd1678b4d24318bcf0a083cbe88"
dependencies = [
"cc",
]
@@ -8364,7 +8364,7 @@ dependencies = [
[[package]]
name = "revive-benchmarks"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"alloy-primitives",
"criterion",
@@ -8376,18 +8376,18 @@ dependencies = [
[[package]]
name = "revive-build-utils"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
[[package]]
name = "revive-builtins"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"revive-build-utils",
]
[[package]]
name = "revive-common"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"anyhow",
"serde",
@@ -8397,7 +8397,7 @@ dependencies = [
[[package]]
name = "revive-differential"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"alloy-genesis",
"alloy-primitives",
@@ -8410,7 +8410,7 @@ dependencies = [
[[package]]
name = "revive-integration"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"alloy-primitives",
"alloy-sol-types",
@@ -8425,19 +8425,19 @@ dependencies = [
[[package]]
name = "revive-linker"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"anyhow",
"libc",
"lld-sys",
"polkavm-linker 0.20.0",
"polkavm-linker 0.21.0",
"revive-builtins",
"tempfile",
]
[[package]]
name = "revive-llvm-builder"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"anyhow",
"assert_cmd",
@@ -8458,14 +8458,14 @@ dependencies = [
[[package]]
name = "revive-llvm-context"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"anyhow",
"hex",
"inkwell",
"itertools 0.14.0",
"num",
"polkavm-common 0.20.0",
"polkavm-common 0.21.0",
"polkavm-disassembler",
"revive-common",
"revive-linker",
@@ -8478,7 +8478,7 @@ dependencies = [
[[package]]
name = "revive-runner"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"alloy-primitives",
"hex",
@@ -8493,7 +8493,7 @@ dependencies = [
[[package]]
name = "revive-runtime-api"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"anyhow",
"inkwell",
@@ -8503,7 +8503,7 @@ dependencies = [
[[package]]
name = "revive-solidity"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"anyhow",
"clap",
@@ -8529,7 +8529,7 @@ dependencies = [
[[package]]
name = "revive-stdlib"
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
dependencies = [
"inkwell",
"revive-build-utils",
@@ -9431,9 +9431,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.13.2"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
[[package]]
name = "snowbridge-amcl"
@@ -10026,7 +10026,7 @@ dependencies = [
[[package]]
name = "sp-crypto-ec-utils"
version = "0.10.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"ark-bls12-377",
"ark-bls12-377-ext",
@@ -10093,7 +10093,7 @@ dependencies = [
[[package]]
name = "sp-debug-derive"
version = "14.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"proc-macro2",
"quote",
@@ -10113,7 +10113,7 @@ dependencies = [
[[package]]
name = "sp-externalities"
version = "0.25.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"environmental",
"parity-scale-codec",
@@ -10322,7 +10322,7 @@ dependencies = [
[[package]]
name = "sp-runtime-interface"
version = "24.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"bytes",
"impl-trait-for-tuples",
@@ -10354,7 +10354,7 @@ dependencies = [
[[package]]
name = "sp-runtime-interface-proc-macro"
version = "17.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"Inflector",
"expander",
@@ -10443,7 +10443,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk?rev=274a781e8ca1a9432c7
[[package]]
name = "sp-std"
version = "14.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
[[package]]
name = "sp-storage"
@@ -10460,7 +10460,7 @@ dependencies = [
[[package]]
name = "sp-storage"
version = "19.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"impl-serde",
"parity-scale-codec",
@@ -10495,7 +10495,7 @@ dependencies = [
[[package]]
name = "sp-tracing"
version = "16.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"parity-scale-codec",
"tracing",
@@ -10592,7 +10592,7 @@ dependencies = [
[[package]]
name = "sp-wasm-interface"
version = "20.0.0"
source = "git+https://github.com/paritytech/polkadot-sdk#f340e07ffd7cff69e930d19563186ff7f0fed601"
source = "git+https://github.com/paritytech/polkadot-sdk#83db0474f4df9988b01c6125a49cc59aa1b90939"
dependencies = [
"anyhow",
"impl-trait-for-tuples",
@@ -11017,9 +11017,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "tempfile"
version = "3.16.0"
version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91"
checksum = "a40f762a77d2afa88c2d919489e390a12bdd261ed568e60cfa7e48d4e20f0d33"
dependencies = [
"cfg-if",
"fastrand",
+21 -21
View File
@@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/*"]
[workspace.package]
version = "0.1.0-dev.10"
version = "0.1.0-dev.11"
authors = [
"Cyrill Leutwiler <cyrill@parity.io>",
"Parity Technologies <admin@parity.io>",
@@ -14,24 +14,24 @@ repository = "https://github.com/paritytech/revive"
rust-version = "1.81.0"
[workspace.dependencies]
revive-benchmarks = { version = "0.1.0-dev.10", path = "crates/benchmarks" }
revive-builtins = { version = "0.1.0-dev.10", path = "crates/builtins" }
revive-common = { version = "0.1.0-dev.10", path = "crates/common" }
revive-differential = { version = "0.1.0-dev.10", path = "crates/differential" }
revive-integration = { version = "0.1.0-dev.10", path = "crates/integration" }
revive-linker = { version = "0.1.0-dev.10", path = "crates/linker" }
lld-sys = { version = "0.1.0-dev.10", path = "crates/lld-sys" }
revive-llvm-context = { version = "0.1.0-dev.10", path = "crates/llvm-context" }
revive-runtime-api = { version = "0.1.0-dev.10", path = "crates/runtime-api" }
revive-runner = { version = "0.1.0-dev.10", path = "crates/runner" }
revive-solidity = { version = "0.1.0-dev.10", path = "crates/solidity" }
revive-stdlib = { version = "0.1.0-dev.10", path = "crates/stdlib" }
revive-build-utils = { version = "0.1.0-dev.10", path = "crates/build-utils" }
revive-benchmarks = { version = "0.1.0-dev.11", path = "crates/benchmarks" }
revive-builtins = { version = "0.1.0-dev.11", path = "crates/builtins" }
revive-common = { version = "0.1.0-dev.11", path = "crates/common" }
revive-differential = { version = "0.1.0-dev.11", path = "crates/differential" }
revive-integration = { version = "0.1.0-dev.11", path = "crates/integration" }
revive-linker = { version = "0.1.0-dev.11", path = "crates/linker" }
lld-sys = { version = "0.1.0-dev.11", path = "crates/lld-sys" }
revive-llvm-context = { version = "0.1.0-dev.11", path = "crates/llvm-context" }
revive-runtime-api = { version = "0.1.0-dev.11", path = "crates/runtime-api" }
revive-runner = { version = "0.1.0-dev.11", path = "crates/runner" }
revive-solidity = { version = "0.1.0-dev.11", path = "crates/solidity" }
revive-stdlib = { version = "0.1.0-dev.11", path = "crates/stdlib" }
revive-build-utils = { version = "0.1.0-dev.11", path = "crates/build-utils" }
hex = "0.4.3"
cc = "1.2"
libc = "0.2.169"
tempfile = "3.16"
tempfile = "3.17"
anyhow = "1.0"
semver = { version = "1.0", features = ["serde"] }
itertools = "0.14"
@@ -47,14 +47,14 @@ which = "7.0"
path-slash = "0.2"
rayon = "1.8"
clap = { version = "4", default-features = false, features = ["derive"] }
polkavm-common = "0.20.0"
polkavm-linker = "0.20.0"
polkavm-disassembler = "0.20.0"
polkavm = "0.20.0"
polkavm-common = "0.21.0"
polkavm-linker = "0.21.0"
polkavm-disassembler = "0.21.0"
polkavm = "0.21.0"
alloy-primitives = { version = "0.8.21", features = ["serde"] }
alloy-sol-types = "0.8.21"
alloy-genesis = "0.11.0"
alloy-serde = "0.11.0"
alloy-genesis = "0.11.1"
alloy-serde = "0.11.1"
env_logger = { version = "0.11.6", default-features = false }
serde_stacker = "0.1.11"
criterion = { version = "0.5.1", features = ["html_reports"] }
+42 -16
View File
@@ -1,5 +1,5 @@
![CI](https://github.com/paritytech/revive/actions/workflows/rust.yml/badge.svg)
[![Docs](https://img.shields.io/badge/Docs-contracts.polkadot.io-brightgreen.svg)](https://contracts.polkadot.io)
[![Docs](https://img.shields.io/badge/Docs-contracts.polkadot.io-brightgreen.svg)](https://contracts.polkadot.io/revive_compiler/)
# revive
@@ -14,10 +14,7 @@ This is experimental software in active development and not ready just yet for p
Discussion around the development is hosted on the [Polkadot Forum](https://forum.polkadot.network/t/contracts-update-solidity-on-polkavm/6949#a-new-solidity-compiler-1).
## Installation
`resolc` depends on the [solc](https://github.com/ethereum/solidity) binary installed on your system.
Download and install the `resolc` frontend executable for your platform from our [releases](https://github.com/paritytech/revive/releases).
Please consult [the documentation](https://contracts.polkadot.io/revive_compiler/installation) for installation instructions.
## Building from source
@@ -25,22 +22,46 @@ Building revive requires a [stable Rust installation](https://rustup.rs/) and a
### LLVM
`revive` depends on a custom build of LLVM `v18.1.8` with the RISC-V _embedded_ target, including the `compiler-rt` builtins. Use the provided [revive-llvm](crates/llvm-builder/README.md) utility to compile a compatible LLVM build locally and point `$LLVM_SYS_181_PREFIX` to the installation afterwards.
`revive` depends on a custom build of LLVM `v18.1.8` with the RISC-V _embedded_ target, including the `compiler-rt` builtins. You can either download a build from our releases (recommended for older hardware) or build it from source.
<details>
<summary>Download from our LLVM releases</summary>
Download the [latest LLVM build](https://github.com/paritytech/revive/releases?q=LLVM+binaries+release&expanded=true) from our releases.
> **MacOS** users need to clear the `downloaded` attribute from all binaries after extracting the archive:
> ```sh
> xattr -rc </path/to/the/extracted/archive>/target-llvm/gnu/target-final/bin/*
> ```
After extracting the archive, point `$LLVM_SYS_181_PREFIX` to it:
```sh
export LLVM_SYS_181_PREFIX=</path/to/the/extracted/archive>/target-llvm/gnu/target-final
```
</details>
<details>
<summary>Building from source</summary>
Use the provided [revive-llvm](crates/llvm-builder/README.md) utility to compile a compatible LLVM build locally and point `$LLVM_SYS_181_PREFIX` to the installation afterwards.
The `Makefile` provides a shortcut target to obtain a compatible LLVM build:
```bash
```sh
make install-llvm
export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final
```
</details>
### The `resolc` Solidity frontend
To build the `resolc` Solidity frontend executable, make sure you have obtained a compatible LLVM build using [revive-llvm](crates/llvm-builder/README.md) and did export the `LLVM_SYS_181_PREFIX` environment variable pointing to it (see [above](#LLVM)).
To build the `resolc` Solidity frontend executable, make sure you have obtained a compatible LLVM build and did export the `LLVM_SYS_181_PREFIX` environment variable pointing to it (see [above](#LLVM)).
To install the `resolc` Solidity frontend executable:
```bash
```sh
make install-bin
resolc --version
```
@@ -49,7 +70,10 @@ resolc --version
Cross-compile the `resolc.js` frontend executable to Wasm for running it in a Node.js or browser environment. The `REVIVE_LLVM_TARGET_PREFIX` environment variable is used to control the target environment LLVM dependency.
```bash
<details>
<summary>Instructions for cross-compilation to wasm32-unknown-emscripten</summary>
```sh
# Build the host LLVM dependency with PolkaVM target support
make install-llvm
export LLVM_SYS_181_PREFIX=${PWD}/target-llvm/gnu/target-final
@@ -65,21 +89,23 @@ make install-wasm
make test-wasm
```
### Development
</details>
## Development
Please consult the [Makefile](Makefile) targets to learn how to run tests and benchmarks.
Ensure that your branch passes `make test` locally when submitting a pull request.
## Design overview
### Design overview
See the [relevant section in our documentation](https://contracts.polkadot.io/revive_compiler/architecture) to learn more about how the compiler works.
`revive` uses [solc](https://github.com/ethereum/solidity/), the Ethereum Solidity compiler, as the [Solidity frontend](crates/solidity/src/lib.rs) to process smart contracts written in Solidity. The YUL IR code (or legacy EVM assembly as a fallback for older `solc` versions) emitted by `solc` is then translated to LLVM IR, targetting [Polkadots `revive` pallet](https://docs.rs/pallet-revive/latest/pallet_revive/trait.SyscallDoc.html).
[Frontend](https://github.com/matter-labs/era-compiler-solidity) and [code generator](https://github.com/matter-labs/era-compiler-llvm-context) are based of ZKSync `zksolc`.
[Frontend](https://github.com/matter-labs/era-compiler-solidity) and [code generator](https://github.com/matter-labs/era-compiler-llvm-context) are based of ZKSync `zksolc` (the project started as a fork of the era compiler).
## Tests
### Tests
Before running the tests, ensure that Geth (Go Ethereum) is installed on your system. Follow the installation guide here: [Installing Geth](https://geth.ethereum.org/docs/getting-started/installing-geth).
Once Geth is installed, you can run the tests using the following command:
```bash
```sh
make test
```
+11 -5
View File
@@ -4,8 +4,14 @@ Prior to the first stable release we neither have formal release processes nor d
To create a new pre-release:
1. Merge a release PR which updates the `-dev.X` versions in the workspace `Cargo.toml` and updates the `CHANGELOG.md` accordingly
2. Push a release tag to `main`
3. Create a __pre-release__ from the tag and manually upload the `resolc` binary from docker image
4. Manually upload `resolc.js`, `resolc-web.js` and `resolc.wasm` from the `build-revive-wasm` action artifacts.
5. Update the [contract-docs](https://github.com/paritytech/contract-docs/) accordingly
1. Merge a release PR which updates the `-dev.X` versions in the workspace `Cargo.toml` and updates the `CHANGELOG.md` accordingly. The release workflow will attempt to build and publish a new release whenever the latest git tag does not match the cargo package version.
2. Wait for the `Release` workflow to finish. If the workflow fails after the `build-linux-all` step, check if a tag has been created and delete it before restarting or pushing updates. Note: It's more convenient to debug the release workflow in a fork (the fork has to be under the `paritytech` org to access `parity-large` runners).
3. Check draft release on [Releases page](https://github.com/paritytech/revive/releases) and publish (should contain `resolc.js`, `resolc.wasm`, `resolc-web.js`, and `resolc-static-linux` release assets)
4. Update the [contract-docs](https://github.com/paritytech/contract-docs/) accordingly
# LLVM release
To create a new LLVM release, run "Release LLVM" workflow. Use current LLVM version as parameter, e.g. `18.1.8`.
Version suffix will be resolved automatically.
The workflows will create new GitHub release, and upload LLVM binaries.
Next release of resolc will use newly created binaries.
+40
View File
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
/* runner.json
{
"differential": true,
"actions": [
{
"Instantiate": {
"code": {
"Solidity": {
"contract": "MLoad"
}
}
}
},
{
"Call": {
"dest": {
"Instantiated": 0
},
"data": "e2179b8e"
}
}
]
}
*/
contract MLoad {
constructor() payable {
assert(g() == 0);
}
function g() public payable returns (uint m) {
assembly {
m := mload(0)
}
}
}
+1
View File
@@ -55,6 +55,7 @@ test_spec!(create2, "CreateB", "Create2.sol");
test_spec!(transfer, "Transfer", "Transfer.sol");
test_spec!(send, "Send", "Send.sol");
test_spec!(function_pointer, "FunctionPointer", "FunctionPointer.sol");
test_spec!(mload, "MLoad", "MLoad.sol");
fn instantiate(path: &str, contract: &str) -> Vec<SpecsAction> {
vec![Instantiate {
+3 -1
View File
@@ -83,6 +83,7 @@ fn clone_build_and_clean_musl() -> anyhow::Result<()> {
/// This test verifies that the LLVM repository can be successfully cloned and built in debug mode
/// with tests and coverage enabled.
#[test]
#[cfg(target_os = "linux")]
fn debug_build_with_tests_coverage() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?;
@@ -107,6 +108,7 @@ fn debug_build_with_tests_coverage() -> anyhow::Result<()> {
/// This test verifies that the LLVM repository can be successfully built with address sanitizer.
#[test]
#[cfg(target_os = "linux")]
fn build_with_sanitizers() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?;
@@ -129,7 +131,7 @@ fn build_with_sanitizers() -> anyhow::Result<()> {
/// Tests the clone, build, and clean process of the LLVM repository for the emscripten target.
#[test]
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(target_os = "linux")]
fn clone_build_and_clean_emscripten() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?;
let command = Command::cargo_bin(common::REVIVE_LLVM)?;
@@ -6,15 +6,9 @@ pub const LLVM_VERSION: semver::Version = semver::Version::new(18, 1, 4);
/// The pointer width sized type.
pub static XLEN: usize = revive_common::BIT_LENGTH_X32;
/// The heap memory pointer pointer global variable name.
pub static GLOBAL_HEAP_MEMORY_POINTER: &str = "memory_pointer";
/// The calldata size global variable name.
pub static GLOBAL_CALLDATA_SIZE: &str = "calldatasize";
/// The call flags global variable name.
pub static GLOBAL_CALL_FLAGS: &str = "call_flags";
/// The deployer call header size that consists of:
/// - bytecode hash (32 bytes)
pub const DEPLOYER_CALL_HEADER_SIZE: usize = revive_common::BYTE_LENGTH_WORD;
@@ -212,22 +212,6 @@ impl<'ctx> Function<'ctx> {
}
}
/// Sets the exception handler attributes.
pub fn set_exception_handler_attributes(
llvm: &'ctx inkwell::context::Context,
declaration: Declaration<'ctx>,
) {
Self::set_attributes(llvm, declaration, vec![Attribute::NoInline], false);
}
/// Sets the CXA-throw attributes.
pub fn set_cxa_throw_attributes(
llvm: &'ctx inkwell::context::Context,
declaration: Declaration<'ctx>,
) {
Self::set_attributes(llvm, declaration, vec![Attribute::NoProfile], false);
}
/// Sets the pure function attributes.
pub fn set_pure_function_attributes(
llvm: &'ctx inkwell::context::Context,
@@ -24,22 +24,6 @@ impl Entry {
where
D: Dependency + Clone,
{
context.set_global(
crate::polkavm::GLOBAL_HEAP_MEMORY_POINTER,
context.llvm().ptr_type(AddressSpace::Heap.into()),
AddressSpace::Stack,
context.xlen_type().get_undef(),
);
context.build_store(
context
.get_global(crate::polkavm::GLOBAL_HEAP_MEMORY_POINTER)?
.into(),
context.build_sbrk(
context.xlen_type().const_zero(),
context.xlen_type().const_zero(),
)?,
)?;
context.set_global(
crate::polkavm::GLOBAL_CALLDATA_SIZE,
context.xlen_type(),
@@ -47,13 +31,6 @@ impl Entry {
context.xlen_type().get_undef(),
);
context.set_global(
crate::polkavm::GLOBAL_CALL_FLAGS,
context.word_type(),
AddressSpace::Stack,
context.word_const(0),
);
Ok(())
}
@@ -70,6 +47,11 @@ impl Entry {
.build_runtime_call(revive_runtime_api::polkavm_imports::CALL_DATA_SIZE, &[])
.expect("the call_data_size syscall method should return a value")
.into_int_value();
let call_data_size_value = context.builder().build_int_truncate(
call_data_size_value,
context.xlen_type(),
"call_data_size_truncated",
)?;
context
.builder()
.build_store(call_data_size_pointer, call_data_size_value)?;
@@ -90,13 +72,6 @@ impl Entry {
.borrow()
.get_nth_param(Self::ARGUMENT_INDEX_CALL_FLAGS);
context.set_global(
crate::polkavm::GLOBAL_CALL_FLAGS,
is_deploy.get_type(),
AddressSpace::Stack,
is_deploy.into_int_value(),
);
let deploy_code_call_block = context.append_basic_block("deploy_code_call_block");
let runtime_code_call_block = context.append_basic_block("runtime_code_call_block");
+14 -13
View File
@@ -1209,17 +1209,17 @@ where
/// Build a call to PolkaVM `msize` for querying the linear memory size.
pub fn build_msize(&self) -> anyhow::Result<inkwell::values::IntValue<'ctx>> {
Ok(self
.builder()
.build_call(
self.runtime_api_method(revive_runtime_api::polkavm_imports::MEMORY_SIZE),
&[],
"call_msize",
)?
.try_as_basic_value()
.left()
.expect("sbrk returns an int")
.into_int_value())
let memory_size_pointer = self
.module()
.get_global(revive_runtime_api::polkavm_imports::MEMORY_SIZE)
.expect("the memory size symbol should have been declared")
.as_pointer_value();
let memory_size_value = self.builder().build_load(
self.xlen_type(),
memory_size_pointer,
"memory_size_value",
)?;
Ok(memory_size_value.into_int_value())
}
/// Call PolkaVM `sbrk` for extending the heap by `offset` + `size`,
@@ -1265,8 +1265,9 @@ where
self.build_heap_alloc(offset, length)?;
let heap_start = self
.get_global(crate::polkavm::GLOBAL_HEAP_MEMORY_POINTER)?
.value
.module()
.get_global(revive_runtime_api::polkavm_imports::MEMORY)
.expect("the memory symbol should have been declared")
.as_pointer_value();
Ok(self.build_gep(
Pointer::new(self.byte_type(), AddressSpace::Stack, heap_start),
+2 -6
View File
@@ -8,8 +8,8 @@
#define EVM_WORD_SIZE 32
#define ALIGN(size) ((size + EVM_WORD_SIZE - 1) & ~(EVM_WORD_SIZE - 1))
#define MAX_MEMORY_SIZE (64 * 1024)
static char __memory[MAX_MEMORY_SIZE];
static uint32_t __memory_size = 0;
char __memory[MAX_MEMORY_SIZE];
uint32_t __memory_size = 0;
void * __sbrk_internal(uint32_t offset, uint32_t size) {
if (offset >= MAX_MEMORY_SIZE || size > MAX_MEMORY_SIZE) {
@@ -27,10 +27,6 @@ void * __sbrk_internal(uint32_t offset, uint32_t size) {
return (void *)&__memory[__memory_size];
}
uint32_t __msize() {
return __memory_size;
}
void * memset(void *b, int c, size_t len) {
uint8_t *dest = b;
while (len-- > 0) *dest++ = c;
+7 -12
View File
@@ -1,18 +1,14 @@
//! This crate vendors the [PolkaVM][0] C API and provides a LLVM module for interacting
//! with the `pallet-revive` runtime API.
//! At present, the revive pallet requires blobs to export `call` and `deploy`,
//! and offers a bunch of [runtime API methods][1]. The provided [module] implements
//! those exports and imports.
//! [0]: [https://crates.io/crates/polkavm]
//! [1]: [https://docs.rs/pallet-contracts/26.0.0/pallet_contracts/api_doc/index.html]
use inkwell::{context::Context, memory_buffer::MemoryBuffer, module::Module, support::LLVMString};
include!(concat!(env!("OUT_DIR"), "/polkavm_imports.rs"));
pub static SBRK: &str = "__sbrk_internal";
/// The emulated EVM heap memory global symbol.
pub static MEMORY: &str = "__memory";
pub static MEMORY_SIZE: &str = "__msize";
/// The emulated EVM heap memory size global symbol.
pub static MEMORY_SIZE: &str = "__memory_size";
pub static SBRK: &str = "__sbrk_internal";
pub static ADDRESS: &str = "address";
@@ -82,9 +78,8 @@ pub static WEIGHT_TO_FEE: &str = "weight_to_fee";
/// All imported runtime API symbols.
/// Useful for configuring common attributes and linkage.
pub static IMPORTS: [&str; 35] = [
pub static IMPORTS: [&str; 34] = [
SBRK,
MEMORY_SIZE,
ADDRESS,
BALANCE,
BALANCE_OF,
@@ -16,11 +16,11 @@
],
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.11",
"@types/jest": "^29.5.14",
"@types/shelljs": "^0.8.15",
"jest": "^29.7.0",
"shelljs": "^0.8.5",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
"ts-jest": "^29.2.5",
"typescript": "^5.7.3"
}
}
@@ -943,7 +943,7 @@ impl FunctionCall {
Name::BlobHash => {
let _arguments = self.pop_arguments_llvm::<D, 1>(context)?;
anyhow::bail!(
"{} The `BLOBHASH` instruction is not supported until zkVM v1.5.0",
"{} The `BLOBHASH` instruction is not supported in revive",
location
);
}
@@ -958,7 +958,7 @@ impl FunctionCall {
}
Name::BlobBaseFee => {
anyhow::bail!(
"{} The `BLOBBASEFEE` instruction is not supported until zkVM v1.5.0",
"{} The `BLOBBASEFEE` instruction is not supported in revive",
location
);
}
+1 -1
View File
@@ -3,7 +3,7 @@
"private": true,
"scripts": {
"test:cli": "npm run test -w crates/solidity/src/tests/cli-tests",
"test:wasm": "npm run test:all -w js",
"test:wasm": "npm run test:node -w js",
"build:package": "npm run build:package -w js"
},
"workspaces": [