mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 22:41:07 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c2c633651 | |||
| a73b0925c6 | |||
| ee650cf03a | |||
| c2210442b6 | |||
| cb268850a9 | |||
| f3a86588f3 |
@@ -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
|
||||
|
||||
|
||||
@@ -0,0 +1,347 @@
|
||||
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
|
||||
|
||||
jobs:
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
tag:
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
TAG: ${{ steps.versions.outputs.TAG }}
|
||||
PKG_VER: ${{ steps.versions.outputs.PKG_VER }}
|
||||
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
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
build-linux-all:
|
||||
if: ${{ needs.tag.outputs.TAG == 'new' }}
|
||||
runs-on: parity-large
|
||||
needs: [tag]
|
||||
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
|
||||
|
||||
- name: Install Rust stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
components: rust-src
|
||||
target: wasm32-unknown-emscripten
|
||||
|
||||
- name: versions
|
||||
run: |
|
||||
rustup show
|
||||
cargo --version
|
||||
cmake --version
|
||||
echo "bash:" && bash --version
|
||||
echo "ninja:" && ninja --version
|
||||
echo "clang:" && clang --version
|
||||
|
||||
- name: build revive-llvm
|
||||
run: make install-llvm-builder
|
||||
|
||||
# musl LLVM
|
||||
|
||||
- name: llvm-musl-cache restore
|
||||
id: llvm-musl-cache
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: target-llvm/musl/target-final
|
||||
key: llvm-linux-musl-${{ hashFiles('crates/solidity/**') }}
|
||||
|
||||
- name: Build musl LLVM
|
||||
if: steps.llvm-musl-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
revive-llvm --target-env musl clone
|
||||
revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang
|
||||
|
||||
- name: llvm-musl-cache save
|
||||
if: steps.llvm-musl-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: target-llvm/musl/target-final
|
||||
key: llvm-linux-musl-${{ hashFiles('crates/solidity/**') }}
|
||||
|
||||
# emscripten LLVM
|
||||
|
||||
- name: llvm-emscripten-cache restore
|
||||
id: llvm-emscripten-cache
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
target-llvm/emscripten/target-final
|
||||
emsdk
|
||||
key: llvm-linux-emscripten-${{ hashFiles('crates/solidity/**') }}
|
||||
|
||||
- name: Build emscripten LLVM
|
||||
if: steps.llvm-emscripten-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
revive-llvm --target-env emscripten clone
|
||||
source emsdk/emsdk_env.sh
|
||||
revive-llvm --target-env emscripten build --llvm-projects lld
|
||||
|
||||
- name: llvm-emscripten-cache save
|
||||
if: steps.llvm-emscripten-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: |
|
||||
target-llvm/emscripten/target-final
|
||||
emsdk
|
||||
key: llvm-linux-emscripten-${{ hashFiles('crates/solidity/**') }}
|
||||
|
||||
# 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
|
||||
"
|
||||
|
||||
- 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 --bin crates/integration/contracts/flipper.sol)
|
||||
echo $result
|
||||
if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi
|
||||
|
||||
- name: Set Up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "20"
|
||||
|
||||
- name: build wasm
|
||||
run: |
|
||||
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); }
|
||||
"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: revive-wasm
|
||||
path: |
|
||||
./target/wasm32-unknown-emscripten/release/resolc.js
|
||||
./target/wasm32-unknown-emscripten/release/resolc.wasm
|
||||
./target/wasm32-unknown-emscripten/release/resolc_web.js
|
||||
retention-days: 1
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: revive-linux
|
||||
path: |
|
||||
./resolc-out/resolc
|
||||
retention-days: 1
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
create-release:
|
||||
needs: [tag, build-linux-all]
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.result }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Create/update tag
|
||||
id: tag
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
await github.rest.git.createRef({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: 'refs/tags/${{ needs.tag.outputs.PKG_VER }}',
|
||||
sha: context.sha
|
||||
})
|
||||
|
||||
- name: get relese notes
|
||||
id: get-notes
|
||||
run: |
|
||||
{
|
||||
echo 'releaseNotes<<EOF'
|
||||
sed '/^## ${{ needs.tag.outputs.PKG_VER }}/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d'
|
||||
echo EOF
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
- name: Create release
|
||||
id: create_release
|
||||
env:
|
||||
releaseNotes: ${{ steps.get-notes.outputs.releaseNotes }}
|
||||
version: ${{ needs.tag.outputs.PKG_VER }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
let response = await github.rest.repos.createRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
tag_name: process.env.version,
|
||||
name: process.env.version,
|
||||
body: process.env.releaseNotes,
|
||||
draft: true,
|
||||
prerelease: true
|
||||
});
|
||||
console.log(response);
|
||||
return response.data.upload_url;
|
||||
|
||||
- name: Log
|
||||
run: |
|
||||
echo "tag result: ${{ needs.tag.outputs.TAG }}"
|
||||
echo "pkg version: ${{ needs.tag.outputs.PKG_VER }}"
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
upload-assets:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [create-release]
|
||||
steps:
|
||||
|
||||
- name: Download Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: revive-wasm
|
||||
path: resolc/
|
||||
|
||||
- name: Download Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: revive-linux
|
||||
path: resolc/
|
||||
|
||||
- name: upload resolc
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ./resolc/resolc
|
||||
asset_name: resolc-static-linux
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: upload resolc.js
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ./resolc/resolc.js
|
||||
asset_name: resolc.js
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: upload resolc.wasm
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ./resolc/resolc.wasm
|
||||
asset_name: resolc.wasm
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: upload resolc_web.js
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ needs.create-release.outputs.upload_url }}
|
||||
asset_path: ./resolc/resolc_web.js
|
||||
asset_name: resolc_web.js
|
||||
asset_content_type: application/octet-stream
|
||||
@@ -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
|
||||
|
||||
@@ -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
+412
-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.10"
|
||||
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.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.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.11.0"
|
||||
alloy-serde = "0.11.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.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" }
|
||||
|
||||
+4
-5
@@ -4,8 +4,7 @@ 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
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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": [
|
||||
|
||||
Reference in New Issue
Block a user