diff --git a/.github/actions/get-emsdk/action.yml b/.github/actions/get-emsdk/action.yml new file mode 100644 index 0000000..8a87ade --- /dev/null +++ b/.github/actions/get-emsdk/action.yml @@ -0,0 +1,20 @@ +name: "get emsdk" +inputs: + version: + description: "" + required: false + default: "3.1.64" + + +runs: + using: "composite" + steps: + + - name: install emsdk + shell: bash + run: | + git clone https://github.com/emscripten-core/emsdk.git ./emsdk/ + cd emsdk + git checkout tags/${{ inputs.version }} + ./emsdk install ${{ inputs.version }} + ./emsdk activate ${{ inputs.version }} \ No newline at end of file diff --git a/.github/actions/get-llvm/action.yml b/.github/actions/get-llvm/action.yml new file mode 100644 index 0000000..08b707b --- /dev/null +++ b/.github/actions/get-llvm/action.yml @@ -0,0 +1,91 @@ +# example: +# +# - name: get llvm +# uses: ./.github/actions/get-llvm +# with: +# releasePrefix: llvm- +# artifactArch: macos-arm64 +# dir: target-llvm/macos + +name: "get llvm" +inputs: + artifactArch: + required: true + releasePrefix: + description: "LLVM release tag prefix to search" + required: false + default: "llvm-" + dir: + description: "Archive extract path (`tar -C`)" + required: false + default: "./" + stripComponents: + description: "Strip UMBER leading components from file names on extraction (`tar --strip-components`)" + required: false + default: 0 + + +runs: + using: "composite" + steps: + - name: find asset + id: find + uses: actions/github-script@v7 + env: + releasePrefix: ${{ inputs.releasePrefix }} + artifactArch: ${{ inputs.artifactArch }} + with: + result-encoding: string + script: | + let page = 1; + let releases = []; + + let releasePrefix = process.env.releasePrefix + let artifactArch = process.env.artifactArch + + do { + const res = await github.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + per_page: 50, + page, + }); + + releases = res.data + releases.sort((a, b) => { + return (a.published_at < b.published_at) ? 1 : ((a.published_at > b.published_at) ? -1 : 0); + }); + + let llvmLatestRelease = releases.find(release => { + return release.tag_name.startsWith(releasePrefix); + }); + if (llvmLatestRelease){ + let asset = llvmLatestRelease.assets.find(asset =>{ + return asset.name.includes(artifactArch); + }); + if (!asset){ + core.setFailed(`Artifact for '${artifactArch}' not found in release ${llvmLatestRelease.tag_name} (${llvmLatestRelease.html_url})`); + process.exit(); + } + return asset.browser_download_url; + } + + page++; + } while(releases.length > 0); + + core.setFailed(`No LLVM releases with '${releasePrefix}' atifacts found! Please release LLVM before running this workflow.`); + process.exit(); + + - name: download + shell: bash + run: | + mkdir -p ${{ inputs.dir }} + curl -sSLo llvm.tar.gz ${{ steps.find.outputs.result }} + ls -al + + - name: unpack + shell: bash + run: | + tar -xf llvm.tar.gz -C ${{ inputs.dir }} --strip-components=${{ inputs.stripComponents }} + rm llvm.tar.gz + ls -al ${{ inputs.dir }} \ No newline at end of file diff --git a/.github/workflows/build-revive-wasm.yml b/.github/workflows/build-revive-wasm.yml index 63f5d92..f379b59 100644 --- a/.github/workflows/build-revive-wasm.yml +++ b/.github/workflows/build-revive-wasm.yml @@ -6,62 +6,48 @@ on: branches: ["main"] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: CARGO_TERM_COLOR: always REVIVE_WASM_INSTALL_DIR: ${{ github.workspace }}/target/wasm32-unknown-emscripten/release jobs: build-revive-wasm: - runs-on: parity-large + runs-on: ubuntu-24.04 defaults: run: shell: bash steps: - uses: actions/checkout@v4 - - name: Cache LLVM build - id: cache-llvm - uses: actions/cache@v3 - with: - path: | - target-llvm/emscripten/target-final - target-llvm/gnu/target-final - # Use a unique key based on LLVM version or configuration files to avoid cache invalidation - key: llvm-build-${{ runner.os }}-${{ hashFiles('LLVM.lock', 'Cargo.toml', 'Cargo.lock', 'crates/llvm-builder/**', '.github/workflows/build-revive-wasm.yml') }} - - - name: Install system dependencies - run: | - sudo apt-get update && sudo apt-get install -y cmake ninja-build curl git libssl-dev pkg-config clang lld - - name: Install Rust stable toolchain - uses: actions-rs/toolchain@v1 + uses: actions-rust-lang/setup-rust-toolchain@v1 with: - profile: minimal toolchain: stable components: rust-src target: wasm32-unknown-emscripten + rustflags: "" - - name: Install LLVM build dependencies - run: | - make install-llvm-builder - revive-llvm --target-env emscripten clone + - name: get llvm gnu + uses: ./.github/actions/get-llvm + with: + artifactArch: x86_64-linux-gnu + - name: get llvm emscripten + uses: ./.github/actions/get-llvm + with: + artifactArch: emscripten + + - name: install emsdk + uses: ./.github/actions/get-emsdk - name: Setup revive environment variables run: | echo "LLVM_SYS_181_PREFIX=$(pwd)/target-llvm/gnu/target-final" >> $GITHUB_ENV echo "REVIVE_LLVM_TARGET_PREFIX=$(pwd)/target-llvm/emscripten/target-final" >> $GITHUB_ENV - - name: Build host LLVM - if: steps.cache-llvm.outputs.cache-hit != 'true' - run: | - revive-llvm build --llvm-projects lld --llvm-projects clang - - - name: Build target LLVM - if: steps.cache-llvm.outputs.cache-hit != 'true' - run: | - source emsdk/emsdk_env.sh - revive-llvm --target-env emscripten build --llvm-projects lld - - run: | rustup show cargo --version @@ -70,11 +56,6 @@ jobs: cmake --version bash --version - - name: Use Cached LLVM - if: steps.cache-llvm.outputs.cache-hit == 'true' - run: | - echo "Using cached LLVM" - - name: Build revive run: | source emsdk/emsdk_env.sh diff --git a/.github/workflows/get-release-artifact.js b/.github/workflows/get-release-artifact.js deleted file mode 100644 index b04921b..0000000 --- a/.github/workflows/get-release-artifact.js +++ /dev/null @@ -1,36 +0,0 @@ -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++; - } -}; diff --git a/.github/workflows/release-llvm.yml b/.github/workflows/release-llvm.yml index 917a065..be5ee11 100644 --- a/.github/workflows/release-llvm.yml +++ b/.github/workflows/release-llvm.yml @@ -8,6 +8,10 @@ on: required: true description: llvm version in "x.x.x" format, e.g. "18.1.8" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f199b00..83084d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,9 +4,11 @@ on: push: branches: - "main" + pull_request: + types: [opened, synchronize, reopened, ready_for_review, labeled] concurrency: - group: ${{ github.ref }}-${{ github.workflow }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: @@ -16,6 +18,7 @@ env: jobs: tag: + if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'release-test') runs-on: ubuntu-24.04 permissions: contents: write @@ -48,13 +51,13 @@ jobs: 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<> $GITHUB_OUTPUT echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT @@ -70,24 +73,17 @@ jobs: arch: arm64 if: ${{ needs.tag.outputs.TAG == 'new' }} runs-on: ${{ matrix.os }} - name: "build-macos-${{ matrix.arch }}" + name: build-macos 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 + - name: get llvm + uses: ./.github/actions/get-llvm 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 }}" - }); + releasePrefix: llvm- + artifactArch: macos-${{ matrix.arch }} + dir: ./ - uses: actions-rust-lang/setup-rust-toolchain@v1 with: @@ -109,11 +105,6 @@ jobs: 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 @@ -168,20 +159,6 @@ jobs: 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 \ @@ -203,10 +180,12 @@ jobs: 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 + - name: get llvm musl + uses: ./.github/actions/get-llvm + with: + releasePrefix: llvm- + artifactArch: x86_64-linux-musl + dir: ./ # Build revive @@ -247,29 +226,16 @@ jobs: with: node-version: "20" - - name: Get latest emscripten LLVM release artifact - id: get-llvm-emscripten-artifact - uses: actions/github-script@v7 + - name: get llvm emscripten + uses: ./.github/actions/get-llvm 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" - }) + artifactArch: emscripten - - name: download llvm - run: | - curl -L -o llvm.tar.gz "${{ steps.get-llvm-emscripten-artifact.outputs.result }}" - tar -xvf llvm.tar.gz + - name: install emsdk + uses: ./.github/actions/get-emsdk - 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 @@ -328,12 +294,11 @@ jobs: retention-days: 1 create-release: + if: github.event_name != 'pull_request' 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 @@ -360,7 +325,9 @@ jobs: tag_name: ${{ needs.tag.outputs.PKG_VER }} name: ${{ needs.tag.outputs.PKG_VER }} draft: true + target_commitish: ${{ github.sha }} files: | ./resolc-linux/resolc-static-linux.tar.gz ./resolc-macos/resolc-macos.tar.gz ./resolc-wasm/resolc-wasm.tar.gz + diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f8341a1..6509dc9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -6,6 +6,10 @@ on: pull_request: branches: ["main"] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: CARGO_TERM_COLOR: always diff --git a/CHANGELOG.md b/CHANGELOG.md index 71611f6..b5eef16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50` ### Added -### Changed +### Changed ### Fixed - A bug causing incorrect loads from the emulated EVM linear memory. @@ -30,7 +30,7 @@ Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50` - Support for the `coinbase` opcode. - The resolc web JS version. -### Changed +### Changed - Missing the `--overwrite` flag emits an error instead of a warning. - The `resolc` executable prints the help by default. - Removed support for legacy EVM assembly (EVMLA) translation. @@ -52,7 +52,7 @@ This is a development pre-release. ### Added -### Changed +### Changed - Syscalls with more than 6 arguments now pack them into registers. ### Fixed @@ -92,9 +92,9 @@ This is a development pre-release. - Calls forward maximum weight limits instead of 0, anticipating a change in polkadot-sdk where weight limits of 0 no longer interprets as uncapped limit. ### Fixed -- A linker bug which was preventing certain contracts from linking with the PVM linker. +- A linker bug which was preventing certain contracts from linking with the PVM linker. - JS: Fix encoding conversion from JS string (UTF-16) to UTF-8. -- The git commit hash slug is always displayed in the version string. +- The git commit hash slug is always displayed in the version string. ## v0.1.0-dev.6