ethereum utility library #6751
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Verify PR Commit | |
concurrency: | |
group: ${{github.workflow}}-${{github.ref}} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- main | |
- "*-development" # Feature Branches should suffix with -development | |
# Set default permissions as restrictive | |
permissions: | |
contents: read | |
packages: read | |
env: | |
BIN_DIR_DEBUG: target/debug | |
PR_LABEL_METADATA_CHANGED: metadata-changed | |
PR_LABEL_METADATA_VERSION_NOT_INCREMENTED: metadata-version-not-incremented | |
NIGHTLY_TOOLCHAIN: nightly-2025-04-03 | |
jobs: | |
changes: | |
name: Determine Changed Files | |
runs-on: ubuntu-24.04 | |
outputs: | |
rust: ${{steps.filter.outputs.rust}} | |
build-binary: ${{steps.filter.outputs.build-binary}} | |
cargo-lock: ${{steps.filter.outputs.cargo-lock}} | |
run-e2e: ${{steps.filter.outputs.run-e2e}} | |
ci-docker-image: ${{steps.filter.outputs.ci-docker-image}} | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Check for Changed Files | |
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 | |
id: filter | |
with: | |
filters: | | |
rust: | |
- '**/*.rs' | |
- '**/*.hbs' | |
- '.rustfmt.toml' | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
build-binary: | |
- '**/*.rs' | |
- '**/*.hbs' | |
- '.rustfmt.toml' | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
- 'js/api-augment/**' | |
- 'e2e/**/*.{ts,json}' | |
cargo-lock: | |
- '**/Cargo.toml' | |
- '**/Cargo.lock' | |
run-e2e: | |
- '**/*.rs' | |
- '**/Cargo.toml' | |
- 'e2e/**/*.{ts,json}' | |
clear-metadata-labels: | |
name: Clear Metadata Labels | |
runs-on: ubuntu-24.04 | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Clear Metadata Changed Label | |
if: contains(github.event.pull_request.labels.*.name, env.PR_LABEL_METADATA_CHANGED) | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
LABELS_TO_REMOVE: ${{env.PR_LABEL_METADATA_CHANGED}} | |
- name: Clear Metadata Version Not Incremented Label | |
if: contains(github.event.pull_request.labels.*.name, env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED) | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
LABELS_TO_REMOVE: ${{env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED}} | |
# Workaround to handle skipped required check inside matrix | |
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks | |
build-binaries-dummy: | |
needs: changes | |
if: needs.changes.outputs.build-binary != 'true' | |
runs-on: ubuntu-24.04 | |
name: Build ${{matrix.network}} Binary for ${{matrix.arch}} on ${{matrix.branch_alias}} Branch | |
strategy: | |
matrix: | |
# Match this to the real build-binaries job except the runners should all be GitHub not Ubicloud | |
include: | |
# amd64 builds for all networks | |
- network: dev | |
build-profile: debug | |
git_branch: ${{github.head_ref}} | |
spec: frequency-no-relay | |
branch_alias: pr | |
arch: amd64 | |
runner: ubuntu-24.04 | |
- network: local | |
build-profile: debug | |
git_branch: ${{github.head_ref}} | |
spec: frequency-local | |
branch_alias: pr | |
arch: amd64 | |
runner: ubuntu-24.04 | |
- network: local | |
build-profile: debug | |
git_branch: main | |
spec: frequency-local | |
branch_alias: main | |
arch: amd64 | |
runner: ubuntu-24.04 | |
- network: testnet | |
build-profile: debug | |
spec: frequency-testnet | |
branch_alias: pr | |
arch: amd64 | |
runner: ubuntu-24.04 | |
- network: mainnet | |
build-profile: debug | |
spec: frequency | |
branch_alias: pr | |
arch: amd64 | |
runner: ubuntu-24.04 | |
# arm64 build only for mainnet | |
- network: mainnet | |
build-profile: debug | |
spec: frequency | |
branch_alias: pr | |
arch: arm64 | |
runner: ubuntu-24.04 | |
steps: | |
- run: echo "Just a dummy matrix to satisfy GitHub required checks that were skipped" | |
build-binaries: | |
needs: changes | |
if: needs.changes.outputs.build-binary == 'true' | |
name: Build ${{matrix.network}} Binary for ${{matrix.arch}} on ${{matrix.branch_alias}} Branch | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
# amd64 builds for all networks | |
- network: dev | |
build-profile: debug | |
git_branch: ${{github.head_ref}} | |
spec: frequency-no-relay | |
branch_alias: pr | |
arch: amd64 | |
runner: ubicloud-standard-8 | |
- network: local | |
build-profile: debug | |
git_branch: ${{github.head_ref}} | |
spec: frequency-local | |
branch_alias: pr | |
arch: amd64 | |
runner: ubicloud-standard-8 | |
- network: local | |
build-profile: debug | |
git_branch: main | |
spec: frequency-local | |
branch_alias: main | |
arch: amd64 | |
runner: ubicloud-standard-8 | |
- network: testnet | |
build-profile: debug | |
spec: frequency-testnet | |
branch_alias: pr | |
arch: amd64 | |
runner: ubicloud-standard-16 | |
- network: mainnet | |
build-profile: debug | |
spec: frequency | |
branch_alias: pr | |
arch: amd64 | |
runner: ubicloud-standard-16 | |
# arm64 build only for mainnet | |
- network: mainnet | |
build-profile: debug | |
spec: frequency | |
branch_alias: pr | |
arch: arm64 | |
runner: ubicloud-standard-30-arm | |
runs-on: ${{matrix.runner}} | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
env: | |
NETWORK: mainnet | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{matrix.git_branch}} | |
- name: Set Env Vars | |
run: | | |
export BUILT_BIN_FILENAME=frequency; echo "BUILT_BIN_FILENAME=$BUILT_BIN_FILENAME" >> $GITHUB_ENV | |
echo "FINAL_BIN_FILENAME=$BUILT_BIN_FILENAME.${{matrix.network}}.${{matrix.arch}}.${{matrix.spec}}.${{matrix.branch_alias}}" >> $GITHUB_ENV | |
# # XXX Keep this step as it lets us skip full binary builds during development/testing | |
# - name: Cache Binary for Testing | |
# id: cache-binary | |
# uses: actions/cache@v3 | |
# with: | |
# path: target/${{matrix.build-profile}}/${{env.FINAL_BIN_FILENAME}} | |
# key: binaries-${{runner.os}}-${{env.NETWORK}}-${{github.head_ref}} | |
- name: Compile Binary for ${{matrix.network}} on ${{matrix.arch}} | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
run: | | |
CARGO_INCREMENTAL=0 RUSTFLAGS="-D warnings" cargo build --locked \ | |
${{ matrix.build-profile == 'release' && '--release' || '' }} \ | |
--features ${{matrix.spec}} | |
- name: Run Sanity Checks | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
working-directory: target/${{matrix.build-profile}} | |
run: | | |
file ${{env.BUILT_BIN_FILENAME}} && \ | |
./${{env.BUILT_BIN_FILENAME}} --version | |
- name: Rename Reference Binary | |
if: steps.cache-binary.outputs.cache-hit != 'true' | |
working-directory: target/${{matrix.build-profile}} | |
run: cp ${{env.BUILT_BIN_FILENAME}} ${{env.FINAL_BIN_FILENAME}} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-binary-${{matrix.network}}-${{matrix.arch}}-${{matrix.branch_alias}}-${{github.run_id}} | |
path: target/${{matrix.build-profile}}/${{env.FINAL_BIN_FILENAME}}* | |
if-no-files-found: error | |
check-for-vulnerable-crates: | |
needs: changes | |
if: needs.changes.outputs.cargo-lock == 'true' | |
name: Check for Vulnerable Crates | |
runs-on: ubuntu-24.04 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set Up Cargo Deny | |
run: | | |
cargo install --force --locked [email protected] | |
cargo generate-lockfile | |
- name: Run Cargo Deny | |
run: cargo deny check --hide-inclusion-graph -c deny.toml | |
verify-rust-code-format: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Rust Code Format | |
runs-on: ubuntu-24.04 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image-nightly:1.5.5 | |
steps: | |
- name: Check Out Repository | |
uses: actions/checkout@v4 | |
- name: Verify Rust Code Formatting | |
run: | | |
rustup +${{env.NIGHTLY_TOOLCHAIN}} show | |
cargo +${{env.NIGHTLY_TOOLCHAIN}} fmt --check | |
lint-rust-code: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Lint Rust Code | |
runs-on: ubicloud-standard-4 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Lint | |
# Fail on warnings | |
run: | | |
SKIP_WASM_BUILD=1 cargo clippy \ | |
--features runtime-benchmarks,frequency-lint-check \ | |
-- -Dwarnings | |
verify-rust-developer-docs: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Rust Developer Docs | |
runs-on: ubicloud-standard-4 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Build Docs | |
run: | | |
RUSTC_BOOTSTRAP=1 RUSTDOCFLAGS="--enable-index-page --check -Zunstable-options" cargo doc --no-deps --workspace --features frequency | |
verify-rust-packages-and-deps: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Rust Packages and Dependencies | |
runs-on: ubicloud-standard-4 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Check | |
run: SKIP_WASM_BUILD= cargo check --features runtime-benchmarks,frequency-lint-check | |
run-rust-tests: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Run Rust Tests | |
runs-on: ubicloud-standard-8 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Init Git | |
run: | | |
git config --global --add safe.directory /__w/frequency/frequency | |
- name: Run Tests | |
run: cargo test --features runtime-benchmarks,frequency-lint-check --workspace | |
calc-code-coverage: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Calculate Code Coverage | |
runs-on: ubicloud-standard-30 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Generate and Upload Code Coverage | |
id: codecov | |
uses: ./.github/workflows/common/codecov | |
with: | |
code-cov-token: ${{ secrets.CODECOV_TOKEN }} | |
# Workaround to handle skipped required check inside matrix | |
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks | |
verify-build-runtimes-dummy: | |
needs: changes | |
if: needs.changes.outputs.rust != 'true' | |
name: Verify Build Runtime for ${{matrix.network}} | |
strategy: | |
matrix: | |
# Should match `verify-build-runtimes` | |
network: [paseo, mainnet] | |
runs-on: ubuntu-24.04 | |
steps: | |
- run: echo "Just a dummy matrix to satisfy GitHub required checks that were skipped" | |
verify-build-runtimes: | |
needs: changes | |
if: needs.changes.outputs.rust == 'true' | |
name: Verify Build Runtime for ${{matrix.network}} | |
strategy: | |
fail-fast: true | |
matrix: | |
# Remember, runtimes are separate for each relay chain | |
# Also should match `verify-build-runtimes-dummy` | |
# Only doing paseo-testnet and mainnet | |
network: [paseo, mainnet] | |
build-profile: [bench-dev] | |
runtime-dir: [runtime/frequency] | |
package: [frequency-runtime] | |
built-wasm-file-name-prefix: [frequency_runtime] | |
include: | |
- network: paseo | |
chain: frequency-paseo | |
features: frequency-testnet | |
wasm-core-version: frequency-testnet | |
- network: mainnet | |
chain: frequency | |
features: frequency | |
wasm-core-version: frequency | |
runs-on: ubicloud-standard-8 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Install Rust Toolchain | |
# Match installation steps to CI base docker image | |
run: | | |
curl https://sh.rustup.rs -sSf | bash -s -- -y | |
echo "PATH=$HOME/.cargo/bin:$PATH" >> $GITHUB_ENV | |
- name: Extract Runtime Spec Version | |
run: | | |
echo "RUNTIME_SPEC_VERSION=$(awk '/spec_version:/ {match($0, /[0-9]+/); print substr($0, RSTART, RLENGTH); exit}' \ | |
${{matrix.runtime-dir}}/src/lib.rs)" >> $GITHUB_ENV | |
- name: Validate Extracted Version | |
shell: bash | |
run: | | |
echo "Runtime Spec Version: ${{env.RUNTIME_SPEC_VERSION}}" | |
[[ $RUNTIME_SPEC_VERSION == ?(-)+([0-9]) ]] || \ | |
(echo "ERROR: \"${{env.RUNTIME_SPEC_VERSION}}\" is not a valid integer" && exit 1) | |
- name: Set Env Vars | |
run: | | |
echo "WASM_DIR=${{matrix.runtime-dir}}/target/srtool/${{matrix.build-profile}}/wbuild/${{matrix.package}}" >> $GITHUB_ENV | |
echo "BUILT_WASM_FILENAME=${{matrix.built-wasm-file-name-prefix}}.compact.compressed.wasm" >> $GITHUB_ENV | |
# # XXX Keep this step as it lets us skip WASM builds during development/testing | |
# - name: Cache WASM for Testing | |
# id: cache-wasm | |
# uses: actions/cache@v3 | |
# with: | |
# path: ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}} | |
# key: runtimes-${{runner.os}}-${{matrix.network}}-${{github.head_ref}} | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.DOCKERHUB_USERNAME}} | |
password: ${{secrets.DOCKERHUB_TOKEN}} | |
- name: Build Deterministic WASM | |
id: srtool_build | |
if: steps.cache-wasm.outputs.cache-hit != 'true' | |
uses: ./.github/workflows/common/srtool | |
env: | |
BUILD_OPTS: "--features on-chain-release-build,no-metadata-docs,${{matrix.features}}" | |
with: | |
profile: ${{matrix.build-profile}} | |
package: ${{matrix.package}} | |
chain: ${{matrix.chain}} | |
runtime_dir: ${{ matrix.runtime-dir }} | |
tag: "1.84.1" | |
- name: Check Deterministic WASM Build Exists | |
if: steps.cache-wasm.outputs.cache-hit != 'true' | |
run: | | |
file ${{ steps.srtool_build.outputs.wasm }} | |
- name: Install Subwasm | |
run: | | |
cargo install --locked --git https://github.com/chevdor/subwasm --tag v0.21.3 --force | |
subwasm --version | |
- name: Test WASM file | |
run: | | |
subwasm info ${{ steps.srtool_build.outputs.wasm }} | |
subwasm info ${{ steps.srtool_build.outputs.wasm }} | grep "Core version:.*${{matrix.wasm-core-version}}-${{env.RUNTIME_SPEC_VERSION}}" || \ | |
(echo "ERROR: WASM Core version didn't match ${{matrix.wasm-core-version}}-${{env.RUNTIME_SPEC_VERSION}}" && exit 1) | |
verify-js-api-augment: | |
needs: build-binaries | |
name: Verify JS API Augment | |
runs-on: ubuntu-24.04 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set Env Vars | |
run: | | |
echo "BIN_FILENAME=frequency.local.amd64.frequency-local.pr" >> $GITHUB_ENV | |
- name: Set up NodeJs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
cache-dependency-path: js/api-augment/package-lock.json | |
- name: Install Latest Versions | |
run: npm install # DO NOT use `npm ci` as we want the latest polkadot/api possible | |
working-directory: js/api-augment | |
- name: Lint | |
run: npm run lint | |
working-directory: js/api-augment | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-local-amd64-pr-${{github.run_id}} | |
path: ${{env.BIN_DIR_DEBUG}} | |
- name: Extract and List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
mv "${download_dir}"/artifacts*/* "${download_dir}" | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
chmod 755 ${{env.BIN_FILENAME}} | |
- name: Output Metadata | |
run: ${{env.BIN_DIR_DEBUG}}/${{env.BIN_FILENAME}} export-metadata --chain=frequency-paseo-local --tmp ./js/api-augment/metadata.json | |
- name: Build | |
run: npm run build | |
working-directory: js/api-augment | |
- name: Test | |
run: npm test | |
working-directory: js/api-augment | |
- name: Build & Publish Dry Run | |
run: npm publish --dry-run | |
working-directory: js/api-augment/dist | |
- name: Generate npm tarball | |
run: npm pack | |
working-directory: js/api-augment/dist | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-api-augment-${{github.run_id}} | |
path: js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz | |
if-no-files-found: error | |
verify-js-ethereum-utils: | |
needs: build-binaries | |
name: Verify Ethereum utils | |
runs-on: ubuntu-24.04 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set up NodeJs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
cache-dependency-path: js/ethereum-utils/package-lock.json | |
- name: Install Latest Versions | |
run: npm install | |
working-directory: js/ethereum-utils | |
- name: Lint | |
run: npm run lint | |
working-directory: js/ethereum-utils | |
- name: Test | |
run: npm test | |
working-directory: js/ethereum-utils | |
- name: Build | |
run: npm run build | |
working-directory: js/ethereum-utils | |
- name: Build & Publish Dry Run | |
run: npm publish --dry-run | |
working-directory: js/ethereum-utils/dist | |
- name: Generate npm tarball | |
run: npm pack | |
working-directory: js/ethereum-utils/dist | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-ethereum-utils-${{github.run_id}} | |
path: js/ethereum-utils/dist/frequency-chain-ethereum-utils-0.0.0.tgz | |
if-no-files-found: error | |
verify-js-schemas: | |
name: Verify JS Schemas | |
runs-on: ubuntu-24.04 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set up NodeJs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
cache-dependency-path: js/schemas/package-lock.json | |
- name: Install Latest Versions | |
run: npm install | |
working-directory: js/schemas | |
- name: Lint | |
run: npm run lint | |
working-directory: js/schemas | |
- name: Test | |
run: npm test | |
working-directory: js/schemas | |
- name: Build | |
run: npm run build | |
working-directory: js/schemas | |
- name: Publish Dry Run | |
run: npm publish --dry-run | |
working-directory: js/schemas/dist | |
- name: Generate npm tarball | |
run: npm pack | |
working-directory: js/schemas/dist | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts-schemas-${{github.run_id}} | |
path: js/schemas/dist/frequency-chain-schemas-0.0.0.tgz | |
if-no-files-found: error | |
verify-node-docker-images: | |
needs: build-binaries | |
name: Verify Node Docker Images | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Download amd64 Binaries | |
id: download-amd64-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts-binary-mainnet-amd64-pr-${{github.run_id}} | |
path: ./binaries-amd64 | |
# For PR verification, just use the mainnet arm64 build | |
- name: Download arm64 Binary | |
id: download-arm64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts-binary-mainnet-arm64-pr-${{github.run_id}} | |
path: ./binaries-arm64 | |
# Prepare directory structure for multi-platform docker build | |
- name: Prepare Docker Build Context | |
run: | | |
mkdir -p ./docker-build/linux/amd64/ | |
mkdir -p ./docker-build/linux/arm64/ | |
mkdir -p ./docker-build/scripts/ | |
# Copy scripts needed for the Docker image | |
cp scripts/healthcheck.sh ./docker-build/scripts/ || (echo "ERROR: healthcheck.sh not found" && false) | |
cp docker/frequency-start.sh ./docker-build/scripts/ || (echo "ERROR: frequency-start.sh not found" && false) | |
cp scripts/init.sh ./docker-build/scripts/ || (echo "ERROR: init.sh not found" && false) | |
cp scripts/run_collator.sh ./docker-build/scripts/ || (echo "ERROR: run_collator.sh not found" && false) | |
# Copy resources if needed | |
mkdir -p ./docker-build/resources/ | |
cp -r resources/* ./docker-build/resources/ || (echo "ERROR: resources directory not found" && false) | |
# Move binaries to the right place | |
ls -la ./binaries-amd64/ | |
mv ./binaries-amd64/frequency.mainnet.amd64.frequency.pr ./docker-build/linux/amd64/frequency | |
ls -la ./binaries-arm64/ | |
mv ./binaries-arm64/frequency.mainnet.arm64.frequency.pr ./docker-build/linux/arm64/frequency | |
chmod +x ./docker-build/linux/amd64/frequency | |
chmod +x ./docker-build/linux/arm64/frequency | |
echo "Binary structure prepared:" | |
ls -la ./docker-build/linux/amd64/ | |
ls -la ./docker-build/linux/arm64/ | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: "arm64,amd64" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Uses the mainnet binary as this is testing the docker setup | |
- name: Build standalone node image | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./docker-build | |
push: false | |
platforms: linux/amd64 # Only amd64 for the pr verify | |
file: ./docker/standalone-node.dockerfile | |
# Uses the mainnet binary as this is testing the docker setup | |
- name: Build collator image for local relay chain | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./docker-build | |
push: false | |
platforms: linux/amd64 # Only amd64 for the pr verify | |
file: ./docker/collator-node-local.dockerfile | |
- name: Build parachain node image | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./docker-build | |
push: false | |
platforms: linux/amd64,linux/arm64 # Testing both arch here | |
file: ./docker/parachain-node.dockerfile | |
execute-binary-checks: | |
needs: build-binaries | |
name: Execute Mainnet Binary Checks for ${{matrix.arch}} | |
strategy: | |
fail-fast: true | |
matrix: | |
arch: [amd64, arm64] | |
bin-dir: [target/debug] | |
include: | |
- arch: amd64 | |
runner: ubuntu-24.04 | |
- arch: arm64 | |
runner: ubuntu-24.04-arm | |
runs-on: ${{matrix.runner}} | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
- name: Set Env Vars | |
run: | | |
echo "TEST_BIN_FILENAME=frequency.mainnet.${{matrix.arch}}.frequency.pr" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-mainnet-${{matrix.arch}}-pr-${{github.run_id}} | |
path: ${{matrix.bin-dir}} | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
mv "${download_dir}"/artifacts*/* "${download_dir}" | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{matrix.bin-dir}} | |
run: | | |
chmod 755 ${{env.TEST_BIN_FILENAME}} | |
- name: Output Binary Version | |
working-directory: ${{matrix.bin-dir}} | |
run: | | |
file ./${{env.TEST_BIN_FILENAME}} && ./${{env.TEST_BIN_FILENAME}} --version | |
check-metadata-and-spec-version: | |
needs: build-binaries | |
name: Check Metadata and Spec Version | |
runs-on: ubuntu-24.04 | |
container: ghcr.io/frequency-chain/frequency/ci-base-image:1.5.5 | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Env Vars | |
run: | | |
echo "TEST_BIN_FILENAME=frequency.local.amd64.frequency-local.pr" >> $GITHUB_ENV | |
echo "REF_BIN_FILENAME=frequency.local.amd64.frequency-local.main" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-local-*-${{github.run_id}} | |
path: ${{env.BIN_DIR_DEBUG}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
chmod 755 $TEST_BIN_FILENAME | |
chmod 755 $REF_BIN_FILENAME | |
- name: Compare Metadata | |
id: compare-metadata | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
set -x | |
./$REF_BIN_FILENAME export-metadata --chain=frequency-paseo-local --tmp metadata-ref.json | |
metadata_ref=$(cat metadata-ref.json | jq -r .result) | |
./$TEST_BIN_FILENAME export-metadata --chain=frequency-paseo-local --tmp metadata.json | |
metadata=$(cat metadata.json | jq -r .result) | |
matches=$([ "$metadata" = "$metadata_ref" ] && echo 'true' || echo 'false') | |
echo "Metadata matches?: $match" | |
echo "metadata_matches=$matches" >> $GITHUB_OUTPUT | |
- name: Assign Metadata Changed Label | |
if: steps.compare-metadata.outputs.metadata_matches != 'true' | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
LABELS_TO_ADD: ${{env.PR_LABEL_METADATA_CHANGED}} | |
- name: Check Spec Version | |
if: steps.compare-metadata.outputs.metadata_matches != 'true' | |
id: check-spec-version | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
set -x | |
spec_version_ref=$(./$REF_BIN_FILENAME export-runtime-version | jq -r .specVersion) | |
spec_version=$(./$TEST_BIN_FILENAME export-runtime-version | jq -r .specVersion) | |
incremented=$([ $spec_version -gt $spec_version_ref ] && echo 'true' || echo 'false') | |
echo "spec_version_ref=$spec_version_ref" >> $GITHUB_OUTPUT | |
echo "spec_version=$spec_version" >> $GITHUB_OUTPUT | |
echo "metadata_version_incremented=$incremented" >> $GITHUB_OUTPUT | |
- name: Assign Metadata Version Not Incremented Label | |
if: | | |
(steps.compare-metadata.outputs.metadata_matches != 'true') && | |
(steps.check-spec-version.outputs.metadata_version_incremented != 'true') | |
uses: RobinJesba/GitHub-Labeler-Action@2f69380bbf2ee60b2f0893ef0f40582c9a34a64d | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
LABELS_TO_ADD: ${{env.PR_LABEL_METADATA_VERSION_NOT_INCREMENTED}} | |
- name: Fail CI | |
if: | | |
(steps.compare-metadata.outputs.metadata_matches != 'true') && | |
(steps.check-spec-version.outputs.metadata_version_incremented != 'true') | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
spec_version=${{steps.check-spec-version.outputs.spec_version}} | |
spec_version_ref=${{steps.check-spec-version.outputs.spec_version_ref}} | |
echo "ERROR: When metadata is updated, the new spec version ($spec_version)\ | |
must be greater than the latest version on main branch ($spec_version_ref)" | |
exit 1 | |
run-e2e: | |
if: needs.changes.outputs.run-e2e == 'true' | |
needs: [build-binaries, verify-js-api-augment, verify-js-ethereum-utils] | |
name: Run E2E Tests | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Env Vars | |
run: | | |
echo "BIN_FILENAME=frequency.dev.amd64.frequency-no-relay.pr" >> $GITHUB_ENV | |
echo "FREQUENCY_PROCESS_NAME=frequency" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-dev-amd64-pr-${{github.run_id}} | |
path: ${{env.BIN_DIR_DEBUG}} | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
mv "${download_dir}"/artifacts*/* "${download_dir}" | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Download api-augment tarball | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts-api-augment-${{github.run_id}} | |
path: js/api-augment/dist | |
- name: Download ethereum-utils tarball | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts-ethereum-utils-${{github.run_id}} | |
path: js/ethereum-utils/dist | |
- name: Set Binaries Permissions | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
chmod 755 $BIN_FILENAME | |
- name: Start Local Node | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
./${{env.BIN_FILENAME}} \ | |
-lruntime=debug \ | |
--dev \ | |
--sealing=instant \ | |
--wasm-execution=compiled \ | |
--no-telemetry \ | |
--no-prometheus \ | |
--port $((30333)) \ | |
--rpc-port $((9944)) \ | |
--rpc-external \ | |
--rpc-cors all \ | |
--rpc-methods=Unsafe \ | |
--tmp \ | |
& | |
- name: Set up NodeJs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "npm" | |
cache-dependency-path: e2e/package-lock.json | |
- name: Install Built api-augment and ethereum-utils | |
run: npm install ../js/api-augment/dist/frequency-chain-api-augment-0.0.0.tgz ../js/ethereum-utils/dist/frequency-chain-ethereum-utils-0.0.0.tgz | |
working-directory: e2e | |
- name: Install NPM Modules | |
run: npm ci | |
working-directory: e2e | |
- name: Lint | |
run: npm run lint | |
working-directory: e2e | |
- name: Run E2E Tests | |
working-directory: e2e | |
env: | |
CHAIN_ENVIRONMENT: dev | |
WS_PROVIDER_URL: ws://127.0.0.1:9944 | |
run: npm test | |
- name: Stop Local Node | |
if: always() | |
run: pkill ${{env.FREQUENCY_PROCESS_NAME}} | |
verify-genesis-state: | |
needs: build-binaries | |
name: Verify Genesis State | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Set Env Vars | |
run: | | |
echo "EXPECTED_GENESIS_STATE_PASEO=0x000000000000000000000000000000000000000000000000000000000000000000805f6ddb6879aa31316a38c149e52ffe4e9f2a193e966ddcf3b6a2cb5846e96903170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV | |
echo "EXPECTED_GENESIS_STATE_MAINNET=0x000000000000000000000000000000000000000000000000000000000000000000393a2a0f7778716d006206c5a4787cbf2ea3b26a67379b7a38ee54519d7fd4be03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV | |
echo "BIN_FILENAME_TESTNET=frequency.testnet.amd64.frequency-testnet.pr" >> $GITHUB_ENV | |
echo "BIN_FILENAME_MAINNET=frequency.mainnet.amd64.frequency.pr" >> $GITHUB_ENV | |
- name: Download Binaries | |
id: download-binaries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: artifacts-binary-*-${{github.run_id}} | |
path: ${{env.BIN_DIR_DEBUG}} | |
merge-multiple: true | |
- name: List Downloaded Binaries | |
run: | | |
download_dir=${{steps.download-binaries.outputs.download-path}} | |
echo "Download dir: $download_dir" | |
echo "Downloaded binaries: $(ls -l $download_dir)" | |
- name: Set Binary Permissions | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
chmod 755 $BIN_FILENAME_TESTNET | |
chmod 755 $BIN_FILENAME_MAINNET | |
- name: Test Frequency Paseo Genesis State | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
expected_genesis_state=${{env.EXPECTED_GENESIS_STATE_PASEO}} | |
echo "Expected genesis state: $expected_genesis_state" | |
actual_genesis_state=$(./${{env.BIN_FILENAME_TESTNET}} export-genesis-state --chain=frequency-paseo) | |
echo "Actual genesis state: $actual_genesis_state" | |
[ $actual_genesis_state = $expected_genesis_state ] || \ | |
(echo "ERROR: The actual genesis state does not match the expected" && exit 1) | |
- name: Test Frequency Mainnet Genesis State | |
working-directory: ${{env.BIN_DIR_DEBUG}} | |
run: | | |
expected_genesis_state=${{env.EXPECTED_GENESIS_STATE_MAINNET}} | |
echo "Expected genesis state: $expected_genesis_state" | |
actual_genesis_state=$(./${{env.BIN_FILENAME_MAINNET}} export-genesis-state) | |
echo "Actual genesis state: $actual_genesis_state" | |
[ $actual_genesis_state = $expected_genesis_state ] || \ | |
(echo "ERROR: The actual genesis state does not match the expected" && exit 1) |