mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 14:31:05 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75a83af4da | |||
| 9c330ef8fc | |||
| 687cec31ef | |||
| 48a019e0ad | |||
| 17a2d2f9f2 | |||
| 6ad7908c5e | |||
| 840a736fc5 | |||
| 89cdfefab4 | |||
| 6c2c633651 | |||
| a73b0925c6 | |||
| ee650cf03a | |||
| c2210442b6 | |||
| cb268850a9 | |||
| f3a86588f3 | |||
| 7233738f45 | |||
| 79ec4dd04b | |||
| 374563bbe5 | |||
| a921e425b4 |
@@ -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:
|
||||
@@ -87,6 +86,7 @@ jobs:
|
||||
path: |
|
||||
${{ env.REVIVE_WASM_INSTALL_DIR }}/resolc.js
|
||||
${{ env.REVIVE_WASM_INSTALL_DIR }}/resolc.wasm
|
||||
${{ env.REVIVE_WASM_INSTALL_DIR }}/resolc_web.js
|
||||
retention-days: 1
|
||||
|
||||
test-revive-wasm:
|
||||
@@ -112,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
|
||||
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
tar Jxf llvm.tar.xz -C llvm18/
|
||||
echo "LLVM_SYS_181_PREFIX=$(pwd)/llvm18" >> $GITHUB_ENV
|
||||
|
||||
- name: Install apt dependencies
|
||||
- name: Install geth
|
||||
run: |
|
||||
sudo add-apt-repository -y ppa:ethereum/ethereum
|
||||
sudo apt update
|
||||
|
||||
@@ -6,8 +6,29 @@ 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.
|
||||
|
||||
Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50`
|
||||
|
||||
### Added
|
||||
- Support for the `coinbase` opcode.
|
||||
- The resolc web JS version.
|
||||
|
||||
### Changed
|
||||
- Missing the `--overwrite` flag emits an error instead of a warning.
|
||||
|
||||
Generated
+443
-287
File diff suppressed because it is too large
Load Diff
+29
-29
@@ -3,7 +3,7 @@ resolver = "2"
|
||||
members = ["crates/*"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0-dev.9"
|
||||
version = "0.1.0-dev.11"
|
||||
authors = [
|
||||
"Cyrill Leutwiler <cyrill@parity.io>",
|
||||
"Parity Technologies <admin@parity.io>",
|
||||
@@ -14,31 +14,31 @@ repository = "https://github.com/paritytech/revive"
|
||||
rust-version = "1.81.0"
|
||||
|
||||
[workspace.dependencies]
|
||||
revive-benchmarks = { version = "0.1.0-dev.9", path = "crates/benchmarks" }
|
||||
revive-builtins = { version = "0.1.0-dev.9", path = "crates/builtins" }
|
||||
revive-common = { version = "0.1.0-dev.9", path = "crates/common" }
|
||||
revive-differential = { version = "0.1.0-dev.9", path = "crates/differential" }
|
||||
revive-integration = { version = "0.1.0-dev.9", path = "crates/integration" }
|
||||
revive-linker = { version = "0.1.0-dev.9", path = "crates/linker" }
|
||||
lld-sys = { version = "0.1.0-dev.9", path = "crates/lld-sys" }
|
||||
revive-llvm-context = { version = "0.1.0-dev.9", path = "crates/llvm-context" }
|
||||
revive-runtime-api = { version = "0.1.0-dev.9", path = "crates/runtime-api" }
|
||||
revive-runner = { version = "0.1.0-dev.9", path = "crates/runner" }
|
||||
revive-solidity = { version = "0.1.0-dev.9", path = "crates/solidity" }
|
||||
revive-stdlib = { version = "0.1.0-dev.9", path = "crates/stdlib" }
|
||||
revive-build-utils = { version = "0.1.0-dev.9", 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.0"
|
||||
cc = "1.2"
|
||||
libc = "0.2.169"
|
||||
tempfile = "3.8"
|
||||
tempfile = "3.17"
|
||||
anyhow = "1.0"
|
||||
semver = { version = "1.0", features = ["serde"] }
|
||||
itertools = "0.14"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
|
||||
regex = "1.10"
|
||||
once_cell = "1.19"
|
||||
once_cell = "1.20"
|
||||
num = "0.4.3"
|
||||
sha1 = "0.10"
|
||||
sha3 = "0.10"
|
||||
@@ -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.19.0"
|
||||
polkavm-linker = "0.19.0"
|
||||
polkavm-disassembler = "0.19.0"
|
||||
polkavm = "0.19.0"
|
||||
alloy-primitives = { version = "0.8.19", features = ["serde"] }
|
||||
alloy-sol-types = "0.8.19"
|
||||
alloy-genesis = "0.9.2"
|
||||
alloy-serde = "0.9.2"
|
||||
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.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"] }
|
||||
@@ -64,10 +64,10 @@ downloader = "0.2.8"
|
||||
flate2 = "1.0.35"
|
||||
fs_extra = "1.3.0"
|
||||
num_cpus = "1"
|
||||
tar = "0.4.43"
|
||||
toml = "0.8.19"
|
||||
assert_cmd = "2.0.16"
|
||||
assert_fs = "1.1.2"
|
||||
tar = "0.4"
|
||||
toml = "0.8"
|
||||
assert_cmd = "2.0"
|
||||
assert_fs = "1.1"
|
||||
|
||||
# polkadot-sdk and friends
|
||||
codec = { version = "3.6.12", default-features = false, package = "parity-scale-codec" }
|
||||
|
||||
@@ -30,6 +30,7 @@ install-npm:
|
||||
|
||||
install-wasm: install-npm
|
||||
cargo build --target wasm32-unknown-emscripten -p revive-solidity --release --no-default-features
|
||||
npm run build:package
|
||||
|
||||
install-llvm-builder:
|
||||
cargo install --path crates/llvm-builder
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||

|
||||
[](https://contracts.polkadot.io)
|
||||
[](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
@@ -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` 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.
|
||||
|
||||
@@ -16,7 +16,14 @@
|
||||
"shanghaiTime": 0,
|
||||
"cancunTime": 0,
|
||||
"terminalTotalDifficulty": 0,
|
||||
"terminalTotalDifficultyPassed": true
|
||||
"terminalTotalDifficultyPassed": true,
|
||||
"blobSchedule": {
|
||||
"cancun": {
|
||||
"target": 3,
|
||||
"max": 6,
|
||||
"baseFeeUpdateFraction": 3338477
|
||||
}
|
||||
}
|
||||
},
|
||||
"coinbase": "0xffffffffffffffffffffffffffffffffffffffff",
|
||||
"difficulty": "0x20000",
|
||||
|
||||
@@ -413,7 +413,7 @@ impl Evm {
|
||||
let stderr = str::from_utf8(output.stderr.as_slice())
|
||||
.unwrap_or_else(|err| panic!("{EXECUTABLE_NAME} stderr failed to parse: {err}"));
|
||||
|
||||
let mut log: EvmLog = stdout.into();
|
||||
let mut log: EvmLog = format!("{stdout}{stderr}").as_str().into();
|
||||
log.stderr = stderr.into();
|
||||
if self.bench {
|
||||
log.parse_gas_used_from_bench();
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8;
|
||||
|
||||
/* runner.json
|
||||
{
|
||||
"differential": true,
|
||||
"actions": [
|
||||
{
|
||||
"Instantiate": {
|
||||
"code": {
|
||||
"Solidity": {
|
||||
"contract": "FunctionPointer"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Call": {
|
||||
"dest": {
|
||||
"Instantiated": 0
|
||||
},
|
||||
"data": "26121ff0"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
contract FunctionPointer {
|
||||
bool public flag = false;
|
||||
|
||||
function f0() public {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
function f() public returns (bool) {
|
||||
function() internal x = f0;
|
||||
x();
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,8 @@ test_spec!(coinbase, "Coinbase", "Coinbase.sol");
|
||||
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 {
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#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) {
|
||||
void * __sbrk_internal(uint32_t offset, uint32_t size) {
|
||||
if (offset >= MAX_MEMORY_SIZE || size > MAX_MEMORY_SIZE) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { minify } = require("terser");
|
||||
|
||||
const SOLJSON_URI =
|
||||
"https://binaries.soliditylang.org/wasm/soljson-v0.8.28+commit.7893614a.js";
|
||||
const RESOLC_WASM_URI = "http://127.0.0.1:8080/resolc.wasm";
|
||||
const RESOLC_WASM_TARGET_DIR = path.join(
|
||||
__dirname,
|
||||
"../target/wasm32-unknown-emscripten/release",
|
||||
);
|
||||
const RESOLC_JS = path.join(RESOLC_WASM_TARGET_DIR, "resolc.js");
|
||||
const RESOLC_WEB_JS = path.join(RESOLC_WASM_TARGET_DIR, "resolc_web.js");
|
||||
|
||||
const resolcJs = fs.readFileSync(RESOLC_JS, "utf-8");
|
||||
|
||||
const packedJsContent = `
|
||||
if (typeof importScripts === "function") {
|
||||
importScripts("${SOLJSON_URI}");
|
||||
|
||||
var moduleArgs = {
|
||||
wasmBinary: (function () {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "${RESOLC_WASM_URI}", false);
|
||||
xhr.responseType = "arraybuffer";
|
||||
xhr.send(null);
|
||||
return new Uint8Array(xhr.response);
|
||||
})(),
|
||||
soljson: Module
|
||||
};
|
||||
} else {
|
||||
console.log("Not a WebWorker, skipping Soljson and WASM loading.");
|
||||
}
|
||||
|
||||
${resolcJs}
|
||||
|
||||
createRevive = createRevive.bind(null, moduleArgs);
|
||||
`;
|
||||
|
||||
minify(packedJsContent)
|
||||
.then((minifiedJs) => {
|
||||
if (minifiedJs.error) {
|
||||
console.error("Error during minification:", minifiedJs.error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
fs.writeFileSync(RESOLC_WEB_JS, minifiedJs.code, "utf-8");
|
||||
console.log(`Combined script written to ${RESOLC_WEB_JS}`);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Minification failed:", err);
|
||||
process.exit(1);
|
||||
});
|
||||
+80
-49
@@ -1,16 +1,23 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { test, expect } = require("@playwright/test");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
function loadFixture(fixture) {
|
||||
const fixturePath = path.resolve(__dirname, `../fixtures/${fixture}`);
|
||||
return JSON.parse(fs.readFileSync(fixturePath, 'utf-8'));
|
||||
return JSON.parse(fs.readFileSync(fixturePath, "utf-8"));
|
||||
}
|
||||
|
||||
async function loadTestPage(page) {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
const outputElement = page.locator("#output");
|
||||
await outputElement.waitFor({ state: "visible" });
|
||||
await page.setContent("");
|
||||
}
|
||||
|
||||
async function runWorker(page, input) {
|
||||
return await page.evaluate((input) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = new Worker('worker.js');
|
||||
const worker = new Worker("worker.js");
|
||||
worker.postMessage(JSON.stringify(input));
|
||||
|
||||
worker.onmessage = (event) => {
|
||||
@@ -26,69 +33,87 @@ async function runWorker(page, input) {
|
||||
}, input);
|
||||
}
|
||||
|
||||
test('should successfully compile valid Solidity code in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('storage.json')
|
||||
test("should successfully compile valid Solidity code in browser", async ({
|
||||
page,
|
||||
}) => {
|
||||
await loadTestPage(page);
|
||||
const standardInput = loadFixture("storage.json");
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
|
||||
expect(typeof result).toBe("string");
|
||||
let output = JSON.parse(result);
|
||||
expect(output).toHaveProperty('contracts');
|
||||
expect(output.contracts['fixtures/storage.sol']).toHaveProperty('Storage');
|
||||
expect(output.contracts['fixtures/storage.sol'].Storage).toHaveProperty('abi');
|
||||
expect(output.contracts['fixtures/storage.sol'].Storage).toHaveProperty('evm');
|
||||
expect(output.contracts['fixtures/storage.sol'].Storage.evm).toHaveProperty('bytecode');
|
||||
expect(output).toHaveProperty("contracts");
|
||||
expect(output.contracts["fixtures/storage.sol"]).toHaveProperty("Storage");
|
||||
expect(output.contracts["fixtures/storage.sol"].Storage).toHaveProperty(
|
||||
"abi",
|
||||
);
|
||||
expect(output.contracts["fixtures/storage.sol"].Storage).toHaveProperty(
|
||||
"evm",
|
||||
);
|
||||
expect(output.contracts["fixtures/storage.sol"].Storage.evm).toHaveProperty(
|
||||
"bytecode",
|
||||
);
|
||||
});
|
||||
|
||||
test('should successfully compile large valid Solidity code in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('token.json')
|
||||
test("should successfully compile large valid Solidity code in browser", async ({
|
||||
page,
|
||||
browserName,
|
||||
}) => {
|
||||
if (browserName === "firefox") {
|
||||
// Skipping tests with large contracts on Firefox due to out-of-memory issues.
|
||||
test.skip();
|
||||
}
|
||||
await loadTestPage(page);
|
||||
const standardInput = loadFixture("token.json");
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
|
||||
expect(typeof result).toBe("string");
|
||||
let output = JSON.parse(result);
|
||||
expect(output).toHaveProperty('contracts');
|
||||
expect(output.contracts['fixtures/token.sol']).toHaveProperty('MyToken');
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken).toHaveProperty('abi');
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken).toHaveProperty('evm');
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken.evm).toHaveProperty('bytecode');
|
||||
expect(output).toHaveProperty("contracts");
|
||||
expect(output.contracts["fixtures/token.sol"]).toHaveProperty("MyToken");
|
||||
expect(output.contracts["fixtures/token.sol"].MyToken).toHaveProperty("abi");
|
||||
expect(output.contracts["fixtures/token.sol"].MyToken).toHaveProperty("evm");
|
||||
expect(output.contracts["fixtures/token.sol"].MyToken.evm).toHaveProperty(
|
||||
"bytecode",
|
||||
);
|
||||
});
|
||||
|
||||
test('should throw an error for invalid Solidity code in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('invalid_contract_content.json')
|
||||
test("should throw an error for invalid Solidity code in browser", async ({
|
||||
page,
|
||||
}) => {
|
||||
await loadTestPage(page);
|
||||
const standardInput = loadFixture("invalid_contract_content.json");
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
expect(typeof result).toBe("string");
|
||||
let output = JSON.parse(result);
|
||||
expect(output).toHaveProperty('errors');
|
||||
expect(output).toHaveProperty("errors");
|
||||
expect(Array.isArray(output.errors)).toBeTruthy(); // Check if it's an array
|
||||
expect(output.errors.length).toBeGreaterThan(0);
|
||||
expect(output.errors[0]).toHaveProperty('type');
|
||||
expect(output.errors[0].type).toContain('ParserError');
|
||||
expect(output.errors[0]).toHaveProperty("type");
|
||||
expect(output.errors[0].type).toContain("ParserError");
|
||||
});
|
||||
|
||||
test('should return not found error for missing imports in the browser', async ({page}) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('missing_import.json')
|
||||
test("should return not found error for missing imports in browser", async ({
|
||||
page,
|
||||
}) => {
|
||||
await loadTestPage(page);
|
||||
const standardInput = loadFixture("missing_import.json");
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
|
||||
expect(typeof result).toBe("string");
|
||||
let output = JSON.parse(result);
|
||||
expect(output).toHaveProperty('errors');
|
||||
expect(output).toHaveProperty("errors");
|
||||
expect(Array.isArray(output.errors)).toBeTruthy(); // Check if it's an array
|
||||
expect(output.errors.length).toBeGreaterThan(0);
|
||||
expect(output.errors[0]).toHaveProperty('message');
|
||||
expect(output.errors[0].message).toContain('Source "nonexistent/console.sol" not found');
|
||||
expect(output.errors[0]).toHaveProperty("message");
|
||||
expect(output.errors[0].message).toContain(
|
||||
'Source "nonexistent/console.sol" not found',
|
||||
);
|
||||
});
|
||||
|
||||
test('should successfully compile a valid Solidity contract that instantiates another contract in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
await loadTestPage(page);
|
||||
const standardInput = loadFixture('instantiate.json')
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
@@ -105,9 +130,15 @@ test('should successfully compile a valid Solidity contract that instantiates an
|
||||
expect(output.contracts['fixtures/instantiate.sol'].MainContract.evm).toHaveProperty('bytecode');
|
||||
});
|
||||
|
||||
test('should successfully compile a valid Solidity contract that instantiates the token contracts in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
test('should successfully compile a valid Solidity contract that instantiates the token contracts in the browser', async ({
|
||||
page,
|
||||
browserName,
|
||||
}) => {
|
||||
if (browserName === "firefox") {
|
||||
// Skipping tests with large contracts on Firefox due to out-of-memory issues.
|
||||
test.skip();
|
||||
}
|
||||
await loadTestPage(page);
|
||||
const standardInput = loadFixture('instantiate_tokens.json')
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
|
||||
+55
-52
@@ -1,54 +1,57 @@
|
||||
var Module = {
|
||||
stdinData: null,
|
||||
stdinDataPosition: 0,
|
||||
stdoutData: [],
|
||||
stderrData: [],
|
||||
Module.stdinData = null;
|
||||
Module.stdinDataPosition = 0;
|
||||
Module.stdoutData = [];
|
||||
Module.stderrData = [];
|
||||
|
||||
// Function to read and return all collected stdout data as a string
|
||||
readFromStdout: function() {
|
||||
if (!this.stdoutData.length) return "";
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
const data = decoder.decode(new Uint8Array(this.stdoutData));
|
||||
this.stdoutData = [];
|
||||
return data;
|
||||
},
|
||||
|
||||
// Function to read and return all collected stderr data as a string
|
||||
readFromStderr: function() {
|
||||
if (!this.stderrData.length) return "";
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
const data = decoder.decode(new Uint8Array(this.stderrData));
|
||||
this.stderrData = [];
|
||||
return data;
|
||||
},
|
||||
|
||||
// Function to set input data for stdin
|
||||
writeToStdin: function(data) {
|
||||
const encoder = new TextEncoder();
|
||||
this.stdinData = encoder.encode(data);
|
||||
this.stdinDataPosition = 0;
|
||||
},
|
||||
|
||||
// `preRun` is called before the program starts running
|
||||
preRun: function() {
|
||||
// Define a custom stdin function
|
||||
function customStdin() {
|
||||
if (!Module.stdinData || Module.stdinDataPosition >= Module.stdinData.length) {
|
||||
return null; // End of input (EOF)
|
||||
}
|
||||
return Module.stdinData[Module.stdinDataPosition++];
|
||||
}
|
||||
|
||||
// Define a custom stdout function
|
||||
function customStdout(char) {
|
||||
Module.stdoutData.push(char);
|
||||
}
|
||||
|
||||
// Define a custom stderr function
|
||||
function customStderr(char) {
|
||||
Module.stderrData.push(char);
|
||||
}
|
||||
|
||||
FS.init(customStdin, customStdout, customStderr);
|
||||
},
|
||||
// Method to read all collected stdout data
|
||||
Module.readFromStdout = function () {
|
||||
if (!Module.stdoutData.length) return "";
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
const data = decoder.decode(new Uint8Array(Module.stdoutData));
|
||||
Module.stdoutData = [];
|
||||
return data;
|
||||
};
|
||||
|
||||
// Method to read all collected stderr data
|
||||
Module.readFromStderr = function () {
|
||||
if (!Module.stderrData.length) return "";
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
const data = decoder.decode(new Uint8Array(Module.stderrData));
|
||||
Module.stderrData = [];
|
||||
return data;
|
||||
};
|
||||
|
||||
// Method to write data to stdin
|
||||
Module.writeToStdin = function (data) {
|
||||
const encoder = new TextEncoder();
|
||||
Module.stdinData = encoder.encode(data);
|
||||
Module.stdinDataPosition = 0;
|
||||
};
|
||||
|
||||
// Override the `preRun` method to customize file system initialization
|
||||
Module.preRun = Module.preRun || [];
|
||||
Module.preRun.push(function () {
|
||||
// Custom stdin function
|
||||
function customStdin() {
|
||||
if (
|
||||
!Module.stdinData ||
|
||||
Module.stdinDataPosition >= Module.stdinData.length
|
||||
) {
|
||||
return null; // End of input (EOF)
|
||||
}
|
||||
return Module.stdinData[Module.stdinDataPosition++];
|
||||
}
|
||||
|
||||
// Custom stdout function
|
||||
function customStdout(char) {
|
||||
Module.stdoutData.push(char);
|
||||
}
|
||||
|
||||
// Custom stderr function
|
||||
function customStderr(char) {
|
||||
Module.stderrData.push(char);
|
||||
}
|
||||
|
||||
// Initialize the FS (File System) with custom handlers
|
||||
FS.init(customStdin, customStdout, customStderr);
|
||||
});
|
||||
|
||||
@@ -1,29 +1,34 @@
|
||||
mergeInto(LibraryManager.library, {
|
||||
soljson_compile: function(inputPtr, inputLen) {
|
||||
const inputJson = UTF8ToString(inputPtr, inputLen);
|
||||
const output = Module.soljson.cwrap('solidity_compile', 'string', ['string'])(inputJson);
|
||||
return stringToNewUTF8(output);
|
||||
},
|
||||
soljson_version: function() {
|
||||
const version = Module.soljson.cwrap("solidity_version", "string", [])();
|
||||
return stringToNewUTF8(version);
|
||||
},
|
||||
resolc_compile: function(inputPtr, inputLen) {
|
||||
const inputJson = UTF8ToString(inputPtr, inputLen);
|
||||
var revive = createRevive();
|
||||
revive.writeToStdin(inputJson);
|
||||
soljson_compile: function (inputPtr, inputLen) {
|
||||
const inputJson = UTF8ToString(inputPtr, inputLen);
|
||||
const output = Module.soljson.cwrap("solidity_compile", "string", [
|
||||
"string",
|
||||
])(inputJson);
|
||||
return stringToNewUTF8(output);
|
||||
},
|
||||
soljson_version: function () {
|
||||
const version = Module.soljson.cwrap("solidity_version", "string", [])();
|
||||
return stringToNewUTF8(version);
|
||||
},
|
||||
resolc_compile: function (inputPtr, inputLen) {
|
||||
const inputJson = UTF8ToString(inputPtr, inputLen);
|
||||
var revive = createRevive();
|
||||
revive.writeToStdin(inputJson);
|
||||
|
||||
// Call main on the new instance
|
||||
const result = revive.callMain(['--recursive-process']);
|
||||
// Call main on the new instance
|
||||
const result = revive.callMain(["--recursive-process"]);
|
||||
|
||||
if (result) {
|
||||
const stderrString = revive.readFromStderr();
|
||||
const error = JSON.stringify({ type: 'error', message: stderrString || "Unknown error" });
|
||||
return stringToNewUTF8(error);
|
||||
} else {
|
||||
const stdoutString = revive.readFromStdout();
|
||||
const json = JSON.stringify({ type: 'success', data: stdoutString });
|
||||
return stringToNewUTF8(json);
|
||||
}
|
||||
},
|
||||
if (result) {
|
||||
const stderrString = revive.readFromStderr();
|
||||
const error = JSON.stringify({
|
||||
type: "error",
|
||||
message: stderrString || "Unknown error",
|
||||
});
|
||||
return stringToNewUTF8(error);
|
||||
} else {
|
||||
const stdoutString = revive.readFromStdout();
|
||||
const json = JSON.stringify({ type: "success", data: stdoutString });
|
||||
return stringToNewUTF8(json);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const soljson = require('solc/soljson');
|
||||
const createRevive = require('./resolc.js');
|
||||
const soljson = require("solc/soljson");
|
||||
const createRevive = require("./resolc.js");
|
||||
|
||||
async function compile(standardJsonInput) {
|
||||
if (!standardJsonInput) {
|
||||
throw new Error('Input JSON for the Solidity compiler is required.');
|
||||
throw new Error("Input JSON for the Solidity compiler is required.");
|
||||
}
|
||||
|
||||
// Initialize the compiler
|
||||
@@ -14,7 +14,7 @@ async function compile(standardJsonInput) {
|
||||
compiler.writeToStdin(JSON.stringify(standardJsonInput));
|
||||
|
||||
// Run the compiler
|
||||
compiler.callMain(['--standard-json']);
|
||||
compiler.callMain(["--standard-json"]);
|
||||
|
||||
// Collect output
|
||||
const stdout = compiler.readFromStdout();
|
||||
@@ -29,4 +29,4 @@ async function compile(standardJsonInput) {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
module.exports = { compile };
|
||||
module.exports = { compile };
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const { compile } = require('./revive.js');
|
||||
const { compile } = require("./revive.js");
|
||||
|
||||
const compilerStandardJsonInput = {
|
||||
language: 'Solidity',
|
||||
sources: {
|
||||
'MyContract.sol': {
|
||||
content: `
|
||||
language: "Solidity",
|
||||
sources: {
|
||||
"MyContract.sol": {
|
||||
content: `
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity ^0.8.0;
|
||||
contract MyContract {
|
||||
@@ -13,26 +13,26 @@ const compilerStandardJsonInput = {
|
||||
}
|
||||
}
|
||||
`,
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 200,
|
||||
},
|
||||
outputSelection: {
|
||||
"*": {
|
||||
"*": ["abi"],
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 200,
|
||||
},
|
||||
outputSelection: {
|
||||
'*': {
|
||||
'*': ['abi'],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
async function runCompiler() {
|
||||
let output = await compile(compilerStandardJsonInput)
|
||||
let output = await compile(compilerStandardJsonInput);
|
||||
console.log("Output: " + output);
|
||||
}
|
||||
|
||||
runCompiler().catch(err => {
|
||||
console.error('Error:', err);
|
||||
runCompiler().catch((err) => {
|
||||
console.error("Error:", err);
|
||||
});
|
||||
|
||||
+49
-47
@@ -1,51 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Web Worker Example</title>
|
||||
<style>
|
||||
/* Ensure the pre tag wraps long lines */
|
||||
pre {
|
||||
white-space: pre-wrap; /* Wrap long lines */
|
||||
word-wrap: break-word; /* Break long words */
|
||||
max-width: 100%; /* Optional: Ensures it doesn't overflow container */
|
||||
overflow-wrap: break-word; /* Another method for wrapping */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Web Worker Example</title>
|
||||
<style>
|
||||
/* Ensure the pre tag wraps long lines */
|
||||
pre {
|
||||
white-space: pre-wrap; /* Wrap long lines */
|
||||
word-wrap: break-word; /* Break long words */
|
||||
max-width: 100%; /* Optional: Ensures it doesn't overflow container */
|
||||
overflow-wrap: break-word; /* Another method for wrapping */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Revive Compilation Output</h1>
|
||||
<pre id="output"></pre>
|
||||
<script>
|
||||
var outputElement = document.getElementById('output');
|
||||
var worker = new Worker('./worker.js');
|
||||
const standardJsonInput = {
|
||||
language: 'Solidity',
|
||||
sources: {
|
||||
contract: {
|
||||
content: 'contract MyContract { function f() public { } }',
|
||||
}
|
||||
},
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 200,
|
||||
},
|
||||
outputSelection: {
|
||||
'*': {
|
||||
'*': ['abi'],
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
worker.addEventListener('message', function (e) {
|
||||
outputElement.textContent = e.data.output;
|
||||
}, false);
|
||||
|
||||
worker.postMessage(JSON.stringify(standardJsonInput));
|
||||
</script>
|
||||
</body>
|
||||
<body>
|
||||
<h1>Revive Compilation Output</h1>
|
||||
<pre id="output"></pre>
|
||||
<script>
|
||||
var outputElement = document.getElementById("output");
|
||||
var worker = new Worker("./worker.js");
|
||||
const standardJsonInput = {
|
||||
language: "Solidity",
|
||||
sources: {
|
||||
contract: {
|
||||
content: "contract MyContract { function f() public { } }",
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 200,
|
||||
},
|
||||
outputSelection: {
|
||||
"*": {
|
||||
"*": ["abi"],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
worker.addEventListener(
|
||||
"message",
|
||||
function (e) {
|
||||
outputElement.textContent = e.data.output;
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
worker.postMessage(JSON.stringify(standardJsonInput));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../target/wasm32-unknown-emscripten/release/resolc.js
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../target/wasm32-unknown-emscripten/release/resolc_web.js
|
||||
@@ -1,18 +1,14 @@
|
||||
|
||||
importScripts('./soljson.js');
|
||||
importScripts('./resolc.js');
|
||||
importScripts("./resolc_web.js");
|
||||
|
||||
// Handle messages from the main thread
|
||||
onmessage = async function (e) {
|
||||
const m = createRevive();
|
||||
const m = createRevive();
|
||||
|
||||
m.soljson = Module;
|
||||
// Set input data for stdin
|
||||
m.writeToStdin(e.data);
|
||||
|
||||
// Set input data for stdin
|
||||
m.writeToStdin(e.data);
|
||||
// Compile the Solidity source code
|
||||
m.callMain(["--standard-json"]);
|
||||
|
||||
// Compile the Solidity source code
|
||||
m.callMain(['--standard-json']);
|
||||
|
||||
postMessage({output: m.readFromStdout() || m.readFromStderr()});
|
||||
postMessage({ output: m.readFromStdout() || m.readFromStderr() });
|
||||
};
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"fixtures/storage.sol": {
|
||||
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\nimport \"nonexistent/console.sol\";\ncontract MyContract { function greet() public pure returns (string memory) { return \"Hello\" // Missing semicolon }}"
|
||||
}
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"fixtures/storage.sol": {
|
||||
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\nimport \"nonexistent/console.sol\";\ncontract MyContract { function greet() public pure returns (string memory) { return \"Hello\" // Missing semicolon }}"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi"
|
||||
]
|
||||
}
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": ["abi"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"fixtures/storage.sol": {
|
||||
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\nimport \"nonexistent/console.sol\";\ncontract MyContract { function f() public { } }"
|
||||
}
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"fixtures/storage.sol": {
|
||||
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\nimport \"nonexistent/console.sol\";\ncontract MyContract { function f() public { } }"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi"
|
||||
]
|
||||
}
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": ["abi"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-17
@@ -1,22 +1,19 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"fixtures/storage.sol": {
|
||||
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.2 <0.9.0;\ncontract Storage {\n uint256 number;\n function store(uint256 num) public { number = num; }\n function retrieve() public view returns (uint256){ return number; }\n}"
|
||||
}
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"fixtures/storage.sol": {
|
||||
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.2 <0.9.0;\ncontract Storage {\n uint256 number;\n function store(uint256 num) public { number = num; }\n function retrieve() public view returns (uint256){ return number; }\n}"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi"
|
||||
]
|
||||
}
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": ["abi"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+74
-77
File diff suppressed because one or more lines are too long
+8
-5
@@ -5,17 +5,20 @@
|
||||
"solc": "^0.8.28"
|
||||
},
|
||||
"scripts": {
|
||||
"fetch:soljson": "wget https://binaries.soliditylang.org/wasm/soljson-v0.8.28+commit.7893614a.js -O ./examples/web/soljson.js",
|
||||
"example:web": "npm run fetch:soljson && http-server ./examples/web/",
|
||||
"example:web": "http-server ./examples/web/",
|
||||
"example:node": "node ./examples/node/run_revive.js",
|
||||
"test:node": "mocha --timeout 60000 ./tests",
|
||||
"test:bun": "bun test --timeout 60000 node.test",
|
||||
"test:all": "npm run test:node && npm run test:bun"
|
||||
"test:all": "npm run test:node && npm run test:bun",
|
||||
"format": "prettier --write .",
|
||||
"build:package": "node ./build.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.49.1",
|
||||
"chai": "^5.1.2",
|
||||
"http-server": "^14.1.1",
|
||||
"mocha": "^11.0.1"
|
||||
"mocha": "^11.0.1",
|
||||
"prettier": "^3.4.2",
|
||||
"terser": "^5.37.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-15
@@ -1,10 +1,10 @@
|
||||
const { defineConfig, devices } = require('@playwright/test');
|
||||
const { defineConfig, devices } = require("@playwright/test");
|
||||
|
||||
/**
|
||||
* @see https://playwright.dev/docs/test-configuration
|
||||
*/
|
||||
module.exports = defineConfig({
|
||||
testDir: './e2e',
|
||||
testDir: "./e2e",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
@@ -14,39 +14,38 @@ module.exports = defineConfig({
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: 'list',
|
||||
reporter: "list",
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: 'http://127.0.0.1:8080',
|
||||
baseURL: "http://127.0.0.1:8080",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
trace: "on-first-retry",
|
||||
},
|
||||
timeout: 480000,
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
|
||||
{
|
||||
name: 'firefox',
|
||||
use: { ...devices['Desktop Firefox'] },
|
||||
name: "firefox",
|
||||
use: { ...devices["Desktop Firefox"] },
|
||||
},
|
||||
|
||||
{
|
||||
name: 'webkit',
|
||||
use: { ...devices['Desktop Safari'] },
|
||||
}
|
||||
name: "webkit",
|
||||
use: { ...devices["Desktop Safari"] },
|
||||
},
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: {
|
||||
command: 'npm run example:web',
|
||||
url: 'http://127.0.0.1:8080',
|
||||
command: "npm run example:web",
|
||||
url: "http://127.0.0.1:8080",
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
+53
-35
@@ -1,45 +1,61 @@
|
||||
import { expect } from 'chai';
|
||||
import { compile } from '../examples/node/revive.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { expect } from "chai";
|
||||
import { compile } from "../examples/node/revive.js";
|
||||
import { fileURLToPath } from "url";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
function loadFixture(fixture) {
|
||||
const fixturePath = path.resolve(__dirname, `../fixtures/${fixture}`);
|
||||
return JSON.parse(fs.readFileSync(fixturePath, 'utf-8'));
|
||||
return JSON.parse(fs.readFileSync(fixturePath, "utf-8"));
|
||||
}
|
||||
|
||||
describe('Compile Function Tests', function () {
|
||||
it('should successfully compile valid Solidity code', async function () {
|
||||
const standardInput = loadFixture('storage.json')
|
||||
describe("Compile Function Tests", function () {
|
||||
it("should successfully compile valid Solidity code", async function () {
|
||||
const standardInput = loadFixture("storage.json");
|
||||
|
||||
const result = await compile(standardInput);
|
||||
expect(result).to.be.a('string');
|
||||
expect(result).to.be.a("string");
|
||||
const output = JSON.parse(result);
|
||||
expect(output).to.have.property('contracts');
|
||||
expect(output.contracts['fixtures/storage.sol']).to.have.property('Storage');
|
||||
expect(output.contracts['fixtures/storage.sol'].Storage).to.have.property('abi');
|
||||
expect(output.contracts['fixtures/storage.sol'].Storage).to.have.property('evm');
|
||||
expect(output.contracts['fixtures/storage.sol'].Storage.evm).to.have.property('bytecode');
|
||||
expect(output).to.have.property("contracts");
|
||||
expect(output.contracts["fixtures/storage.sol"]).to.have.property(
|
||||
"Storage",
|
||||
);
|
||||
expect(output.contracts["fixtures/storage.sol"].Storage).to.have.property(
|
||||
"abi",
|
||||
);
|
||||
expect(output.contracts["fixtures/storage.sol"].Storage).to.have.property(
|
||||
"evm",
|
||||
);
|
||||
expect(
|
||||
output.contracts["fixtures/storage.sol"].Storage.evm,
|
||||
).to.have.property("bytecode");
|
||||
});
|
||||
|
||||
if (typeof globalThis.Bun == 'undefined') {
|
||||
if (typeof globalThis.Bun == "undefined") {
|
||||
// Running this test with Bun on a Linux host causes:
|
||||
// RuntimeError: Out of bounds memory access (evaluating 'getWasmTableEntry(index)(a1, a2, a3, a4, a5)')
|
||||
// Once this issue is resolved, the test will be re-enabled.
|
||||
it('should successfully compile large Solidity code', async function () {
|
||||
const standardInput = loadFixture('token.json')
|
||||
it("should successfully compile large Solidity code", async function () {
|
||||
const standardInput = loadFixture("token.json");
|
||||
|
||||
const result = await compile(standardInput);
|
||||
expect(result).to.be.a('string');
|
||||
expect(result).to.be.a("string");
|
||||
const output = JSON.parse(result);
|
||||
expect(output).to.have.property('contracts');
|
||||
expect(output.contracts['fixtures/token.sol']).to.have.property('MyToken');
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken).to.have.property('abi');
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken).to.have.property('evm');
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken.evm).to.have.property('bytecode');
|
||||
expect(output).to.have.property("contracts");
|
||||
expect(output.contracts["fixtures/token.sol"]).to.have.property(
|
||||
"MyToken",
|
||||
);
|
||||
expect(output.contracts["fixtures/token.sol"].MyToken).to.have.property(
|
||||
"abi",
|
||||
);
|
||||
expect(output.contracts["fixtures/token.sol"].MyToken).to.have.property(
|
||||
"evm",
|
||||
);
|
||||
expect(
|
||||
output.contracts["fixtures/token.sol"].MyToken.evm,
|
||||
).to.have.property("bytecode");
|
||||
});
|
||||
|
||||
it("should successfully compile a valid Solidity contract that instantiates the token contracts", async function () {
|
||||
@@ -64,29 +80,31 @@ describe('Compile Function Tests', function () {
|
||||
});
|
||||
}
|
||||
|
||||
it('should throw an error for invalid Solidity code', async function () {
|
||||
const standardInput = loadFixture('invalid_contract_content.json')
|
||||
it("should throw an error for invalid Solidity code", async function () {
|
||||
const standardInput = loadFixture("invalid_contract_content.json");
|
||||
|
||||
const result = await compile(standardInput);
|
||||
expect(result).to.be.a('string');
|
||||
expect(result).to.be.a("string");
|
||||
const output = JSON.parse(result);
|
||||
expect(output).to.have.property('errors');
|
||||
expect(output.errors).to.be.an('array');
|
||||
expect(output).to.have.property("errors");
|
||||
expect(output.errors).to.be.an("array");
|
||||
expect(output.errors.length).to.be.greaterThan(0);
|
||||
expect(output.errors[0].type).to.exist;
|
||||
expect(output.errors[0].type).to.contain("ParserError");
|
||||
});
|
||||
|
||||
it('should return not found error for missing imports', async function () {
|
||||
const standardInput = loadFixture('missing_import.json')
|
||||
it("should return not found error for missing imports", async function () {
|
||||
const standardInput = loadFixture("missing_import.json");
|
||||
|
||||
const result = await compile(standardInput);
|
||||
const result = await compile(standardInput);
|
||||
const output = JSON.parse(result);
|
||||
expect(output).to.have.property('errors');
|
||||
expect(output.errors).to.be.an('array');
|
||||
expect(output).to.have.property("errors");
|
||||
expect(output.errors).to.be.an("array");
|
||||
expect(output.errors.length).to.be.greaterThan(0);
|
||||
expect(output.errors[0].message).to.exist;
|
||||
expect(output.errors[0].message).to.include('Source "nonexistent/console.sol" not found');
|
||||
expect(output.errors[0].message).to.include(
|
||||
'Source "nonexistent/console.sol" not found',
|
||||
);
|
||||
});
|
||||
|
||||
it("should successfully compile a valid Solidity contract that instantiates another contract", async function () {
|
||||
|
||||
+3
-2
@@ -3,10 +3,11 @@
|
||||
"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": [
|
||||
"crates/solidity/src/tests/cli-tests",
|
||||
"js"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user