diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 97acbf9f6..2875643e9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -254,7 +254,7 @@ jobs: # Docker buildx is required by docker/build-push-action # see https://github.com/docker/setup-buildx-action - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 # https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts - name: Download component.gwos and omni_lock @@ -309,7 +309,7 @@ jobs: # GitHub automatically creates a unique GITHUB_TOKEN secret to use in this workflow. - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} @@ -318,7 +318,7 @@ jobs: # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image to ${{ env.REGISTRY }}${{ github.repository_owner }}/${{ env.IMAGE_NAME }} - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . file: docker/Dockerfile diff --git a/.github/workflows/godwoken-tests.yml b/.github/workflows/godwoken-tests.yml index f3b4af268..62a4f1787 100644 --- a/.github/workflows/godwoken-tests.yml +++ b/.github/workflows/godwoken-tests.yml @@ -26,9 +26,6 @@ jobs: MANUAL_BUILD_WEB3_INDEXER=true WEB3_GIT_URL="https://github.com/${{ github.repository }}" WEB3_GIT_CHECKOUT=${{ github.ref }} - MANUAL_BUILD_POLYJUICE=true - POLYJUICE_GIT_URL=https://github.com/${{ github.repository }} - POLYJUICE_GIT_CHECKOUT=${{ github.ref }} GODWOKEN_KICKER_REPO=godwokenrises/godwoken-kicker GODWOKEN_KICKER_REF=develop DOCKER_MANUAL_BUILD_IMAGE=retricsu/godwoken-manual-build:node18 diff --git a/.github/workflows/gwos-evm-fuzz.yml b/.github/workflows/gwos-evm-fuzz.yml index 79ca2062c..f0a3c5a7f 100644 --- a/.github/workflows/gwos-evm-fuzz.yml +++ b/.github/workflows/gwos-evm-fuzz.yml @@ -93,7 +93,7 @@ jobs: mv corpus-new corpus-cache - name: Archive inputs that triggered crashes or sanitizer failures - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: fuzzing-inputs @@ -103,7 +103,7 @@ jobs: polyjuice-tests/fuzz/timeout-* polyjuice-tests/fuzz/oom-* - name: Archive corpus - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: corpus path: | diff --git a/.github/workflows/gwos-scripts.yml b/.github/workflows/gwos-scripts.yml new file mode 100644 index 000000000..4b4759b50 --- /dev/null +++ b/.github/workflows/gwos-scripts.yml @@ -0,0 +1,93 @@ +name: Scripts test + +on: + merge_group: + types: [checks_requested] + push: + # TODO: remove this comment + # paths: + # - 'gwos/**' + # - 'crates/tests/src/script_tests/**' + pull_request: + paths: + - 'gwos/**' + - 'crates/tests/src/script_tests/**' + +jobs: + check-c-format: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + # Note: cargo fmt is done in .github/workflows/rust.yml + - name: Check format of gwos/c + working-directory: gwos/c + run: make fmt + + build-gwos-and-test-scripts: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Cache of Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ runner.arch }}-cargo-gwos-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-cargo-gwos + + - name: Install moleculec + run: | + test "$(moleculec --version)" = "Moleculec 0.7.2" \ + || cargo install moleculec --version 0.7.2 --force + - name: Install capsule + env: + CAPSULE_VERSION: v0.7.0 + run: | + (which capsule && test "$(capsule --version)" = "Capsule 0.7.0") \ + || curl -OL https://github.com/nervosnetwork/capsule/releases/download/${CAPSULE_VERSION}/capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ + && tar xf capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ + && mv capsule_${CAPSULE_VERSION}_x86_64-linux/capsule ~/.cargo/bin/ \ + && rm capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \ + && rm -rf capsule_${CAPSULE_VERSION}_x86_64-linux/ + capsule --version + + - name: Compile C contracts of gwos + working-directory: gwos/c + run: make + + - uses: actions/cache@v3 + id: fetch-capsule-cache + with: + path: | + gwos/.tmp/capsule-cache.tar + key: ${{ runner.os }}-capsule-cache-${{ hashFiles('contracts/Cargo.lock') }} + + - name: Restore capsule cache + if: steps.fetch-capsule-cache.outputs.cache-hit == 'true' + working-directory: gwos + run: tools/restore-capsule-cache.sh + + - name: Build Rust contracts + working-directory: gwos + run: capsule build + + - name: Backup capsule cache + if: steps.fetch-capsule-cache.outputs.cache-hit != 'true' + working-directory: gwos + run: tools/backup-capsule-cache.sh + + - name: Test C Uint256 + run: cargo test -p c-uint256-tests + - name: Script tests + run: cargo test --features scripts --features gw-config/no-builtin script_tests diff --git a/.github/workflows/prepare-builtin-binaries.yml b/.github/workflows/prepare-builtin-binaries.yml index 02877cbf5..e7acceb85 100644 --- a/.github/workflows/prepare-builtin-binaries.yml +++ b/.github/workflows/prepare-builtin-binaries.yml @@ -87,7 +87,7 @@ jobs: # commit to submodule repo - name: Push to godwoken-builtin-binaries repo - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: repository: crates/builtin-binaries/builtin branch: master diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 44b1a8d91..65c76963c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,59 +3,85 @@ name: Build and Test on: [push, pull_request] jobs: - rust-clippy-and-test: - runs-on: ubuntu-latest + rustfmt-and-clippy: + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install Rust components - run: rustup component add rustfmt && rustup component add clippy - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-${{ runner.arch }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-${{ runner.arch }}-cargo-test - ${{ runner.os }}-${{ runner.arch }}-cargo - - name: Install moleculec v0.7.2 - run: CARGO_TARGET_DIR=target/ cargo install moleculec --version 0.7.2 - - name: Check format - run: cargo fmt -- --check - - name: Cargo clippy check - env: - RUSTFLAGS: -D warnings - run: cargo clippy --tests --all-features --all-targets + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Cache of Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ runner.arch }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-cargo-clippy + + - name: Install Rust components + run: | + cargo fmt --version || rustup component add rustfmt + cargo clippy --version || rustup component add clippy + - name: Check format + run: cargo fmt --all -- --check --verbose + - name: Cargo clippy check + env: + RUSTFLAGS: -D warnings + run: cargo clippy --tests --all-features --all-targets + + + rust-test: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Cache of Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ runner.arch }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-cargo-test + + - name: Cache of component.gwos-evm + id: godwoken-polyjuice-cache + uses: actions/cache@v3 + with: + path: | + gwos-evm/build/*generator* + gwos-evm/build/*validator* + key: component.gwos-evm-${{ hashFiles('gwos-evm/**') }} + - name: Build godwoken-polyjuice + if: steps.godwoken-polyjuice-cache.outputs.cache-hit != 'true' + working-directory: gwos-evm + run: | + test "$(moleculec --version)" = "Moleculec 0.7.2" \ + || cargo install moleculec --version 0.7.2 --force + git submodule update --init --recursive --depth=1 + make all-via-docker - - name: Cache of component.gwos-evm - id: godwoken-polyjuice-cache - uses: actions/cache@v3 - with: - path: | - gwos-evm/build/*generator* - gwos-evm/build/*validator* - key: component.gwos-evm-${{ hashFiles('gwos-evm/**') }} - - name: Build godwoken-polyjuice - if: steps.godwoken-polyjuice-cache.outputs.cache-hit != 'true' - working-directory: gwos-evm - run: | - git submodule update --init --recursive --depth=1 - make all-via-docker + - name: Test all targets + run: RUST_BACKTRACE=1 cargo test --all-targets - - name: Tests all targets - run: RUST_BACKTRACE=1 cargo test --all-targets test-generate-example-config: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Cache of Cargo - id: cargo-test-cache uses: actions/cache@v3 with: path: | @@ -67,6 +93,5 @@ jobs: key: ${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-${{ runner.arch }}-cargo-build - ${{ runner.os }}-${{ runner.arch }}-cargo - name: Test TOML serialization run: cargo run --bin godwoken -- generate-example-config -o test.toml diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml deleted file mode 100644 index aaef03518..000000000 --- a/.github/workflows/scripts.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Scripts test - -on: - merge_group: - types: [checks_requested] - push: - paths: - - 'gwos/**' - - 'crates/tests/src/script_tests/**' - pull_request: - paths: - - 'gwos/**' - - 'crates/tests/src/script_tests/**' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Install Rust components - run: rustup component add rustfmt && rustup component add clippy - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - - name: Install moleculec - working-directory: gwos - run: CARGO_TARGET_DIR=target/ cargo install moleculec --version 0.7.2 - - name: Install capsule - env: - CAPSULE_VERSION: v0.7.0 - run: curl -OL https://github.com/nervosnetwork/capsule/releases/download/${CAPSULE_VERSION}/capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz && tar xf capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz && echo `pwd`/capsule_${CAPSULE_VERSION}_x86_64-linux >> $GITHUB_PATH - - name: Check Tests format - run: cargo fmt --all -- --check - # - name: Check Rust format - # working-directory: gwos/contracts - # run: cargo fmt -- --check - - name: Check C format - working-directory: gwos/c - run: make fmt - - name: Init submodules - run: git submodule init && git submodule update -r - - name: Compile C contracts - working-directory: gwos/c - run: make - #- name: Cargo clippy check - # env: - # RUSTFLAGS: -D warnings - # run: cd contracts && cargo clippy - - uses: actions/cache@v3 - id: fetch-capsule-cache - with: - path: | - gwos/.tmp/capsule-cache.tar - key: ${{ runner.os }}-capsule-cache-${{ hashFiles('contracts/Cargo.lock') }} - - name: Restore capsule cache - if: steps.fetch-capsule-cache.outputs.cache-hit == 'true' - working-directory: gwos - run: tools/restore-capsule-cache.sh - - name: Build Rust contracts - working-directory: gwos - run: capsule build - - name: Backup capsule cache - if: steps.fetch-capsule-cache.outputs.cache-hit != 'true' - working-directory: gwos - run: tools/backup-capsule-cache.sh - # TODO: remove this - - name: Copy contracts from prebuild docker images - run: devtools/fetch-binaries.sh - - name: Test C Uint256 - run: cargo test -p c-uint256-tests - - name: Script tests - run: cargo test --features scripts --features gw-config/no-builtin script_tests diff --git a/.github/workflows/web3-docker-publish.yml b/.github/workflows/web3-docker-publish.yml index 1504aaac5..6cda14279 100644 --- a/.github/workflows/web3-docker-publish.yml +++ b/.github/workflows/web3-docker-publish.yml @@ -46,7 +46,7 @@ jobs: # https://github.com/docker/login-action # GitHub automatically creates a unique GITHUB_TOKEN secret to use in this workflow. - name: Log into registry ${{ env.REGISTRY }} - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} @@ -67,7 +67,7 @@ jobs: # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: New Commit Build => Build and push commit image to ${{ env.REGISTRY }} - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: file: ./web3/Dockerfile push: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/web3-indexer-docker-publish.yml b/.github/workflows/web3-indexer-docker-publish.yml index 0af61d5c5..4d12b4c03 100644 --- a/.github/workflows/web3-indexer-docker-publish.yml +++ b/.github/workflows/web3-indexer-docker-publish.yml @@ -46,7 +46,7 @@ jobs: # https://github.com/docker/login-action # GitHub automatically creates a unique GITHUB_TOKEN secret to use in this workflow. - name: Log into registry ${{ env.REGISTRY }} - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} @@ -67,7 +67,7 @@ jobs: # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: New Commit Build => Build and push commit image to ${{ env.REGISTRY }} - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: file: web3/docker/indexer/Dockerfile push: ${{ github.event_name != 'pull_request' }} diff --git a/.github/workflows/web3-rust.yml b/.github/workflows/web3-rust.yml index 3d26f76ea..dfb66a766 100644 --- a/.github/workflows/web3-rust.yml +++ b/.github/workflows/web3-rust.yml @@ -27,10 +27,14 @@ jobs: - uses: actions/cache@v3 with: path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-web3-indexer-${{ hashFiles('Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-web3-indexer - name: Build run: cargo build --verbose - name: Check format diff --git a/gwos-evm/Makefile b/gwos-evm/Makefile index 8b62eb1bd..5eafdb703 100644 --- a/gwos-evm/Makefile +++ b/gwos-evm/Makefile @@ -234,7 +234,7 @@ contract/sudt-erc20-proxy: # fetch godwoken-scripts from godwoken-prebuilds image, # including meta-contract and sudt-contract -PREBUILDS := ghcr.io/zeroqn/godwoken-prebuilds:v1.1-feat-change-ckb-decimal-to-18 +PREBUILDS := ghcr.io/godwokenrises/godwoken:v1.14.0 fetch-gw-scripts: mkdir -p build docker run --rm -v `pwd`/build:/build-dir \ diff --git a/gwos-evm/polyjuice-tests/fuzz/Makefile b/gwos-evm/polyjuice-tests/fuzz/Makefile index cd4c0abe1..bc33557a2 100644 --- a/gwos-evm/polyjuice-tests/fuzz/Makefile +++ b/gwos-evm/polyjuice-tests/fuzz/Makefile @@ -39,7 +39,6 @@ LDFLAGS := -Wl,--gc-sections,-rpath,./gw-syscall-simulator/target/debug SANITIZER_FLAGS := -g -O1 -fsanitize=fuzzer,address,undefined,leak -Wno-incompatible-pointer-types LIMIT_ERROR := -ferror-limit=10 -# TODO: read PROTOCOL_VERSION from deps/godwoken-scripts/c/Makefile MOLC := moleculec MOLC_VERSION := $(shell cat $(GW_SCRIPTS)/Makefile | egrep "MOLC_VERSION :=" | awk '{print $$3}')