From 62f98dbbe4e903a42a4aa5fe9e897294d33313b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:16:37 +0300 Subject: [PATCH 01/12] Test ci --- .github/scripts/check_genesis.sh | 52 +++ .github/workflows/checks.yml | 703 ++++++++++++++++--------------- 2 files changed, 423 insertions(+), 332 deletions(-) create mode 100755 .github/scripts/check_genesis.sh diff --git a/.github/scripts/check_genesis.sh b/.github/scripts/check_genesis.sh new file mode 100755 index 000000000..0e5a0cfe6 --- /dev/null +++ b/.github/scripts/check_genesis.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Paths +paths=( "./resources/genesis/bitcoin-regtest/evm.json" + "./resources/genesis/mock/evm.json" + "./resources/genesis/mock-dockerized/evm.json" + "./resources/test-data/demo-tests/bitcoin-regtest/evm.json" + "./resources/test-data/demo-tests/mock/evm.json" + "./resources/test-data/integration-tests/evm.json" + "./resources/test-data/integration-tests-low-block-gas-limit/evm.json" + "./resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json") + +# Function to clean up copied directories +cleanup() { + for path in "${paths[@]}"; + do + rm -rf "${path}_tmp" + done +} +cleanup + +sleep 1 + +# Copy directories +for path in "${paths[@]}"; +do + cp -r "$path" "${path}_tmp" +done + +sleep 5 + +# Run make command +make genesis + +# Compare directories +for path in "${paths[@]}"; +do + diff -r "$path" "${path}_tmp" + if [ $? -ne 0 ]; then + echo "Error: Differences found between $path and ${path}_tmp" + cleanup + exit 1 + fi +done + +echo "All directories are identical." +sleep 1 + +# Clean up copied directories +cleanup + +exit 0 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 2299103dd..325b93cd0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -61,344 +61,374 @@ concurrency: cancel-in-progress: ${{ (github.ref != 'refs/heads/nightly') && (github.ref != 'refs/heads/main') }} jobs: - check: - name: check - runs-on: ubicloud-standard-16 - timeout-minutes: 60 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v4 - - uses: rui314/setup-mold@v1 - - name: Install Protoc - uses: arduino/setup-protoc@v2 - with: - version: "23.2" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Toolchain - uses: dtolnay/rust-toolchain@nightly - with: - override: true - components: rustfmt, clippy - - name: Rust Cache - uses: Swatinem/rust-cache@v2 - - name: Install cargo-risczero - uses: taiki-e/install-action@v2 - with: - tool: cargo-risczero@1.0.1 - - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - run: cargo risczero install --version r0.1.78.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check TOML - uses: dprint/check@v2.2 - - name: Run lint - run: | - if ! SKIP_GUEST_BUILD=1 make lint ; then - echo "Linting or formatting errors detected, please run 'make lint-fix' to fix it"; - exit 1 - fi + # check: + # name: check + # runs-on: ubicloud-standard-16 + # timeout-minutes: 60 + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # - uses: rui314/setup-mold@v1 + # - name: Install Protoc + # uses: arduino/setup-protoc@v2 + # with: + # version: "23.2" + # repo-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Toolchain + # uses: dtolnay/rust-toolchain@nightly + # with: + # override: true + # components: rustfmt, clippy + # - name: Rust Cache + # uses: Swatinem/rust-cache@v2 + # - name: Install cargo-risczero + # uses: taiki-e/install-action@v2 + # with: + # tool: cargo-risczero@1.0.1 + # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + # run: cargo risczero install --version r0.1.78.0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Check TOML + # uses: dprint/check@v2.2 + # - name: Run lint + # run: | + # if ! SKIP_GUEST_BUILD=1 make lint ; then + # echo "Linting or formatting errors detected, please run 'make lint-fix' to fix it"; + # exit 1 + # fi - udeps: - name: udeps - runs-on: ubicloud-standard-8 - timeout-minutes: 60 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v4 - - uses: rui314/setup-mold@v1 - - name: Install Protoc - uses: arduino/setup-protoc@v2 - with: - version: "23.2" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - - name: Rust Cache - uses: Swatinem/rust-cache@v2 - - name: Install cargo-risczero - uses: taiki-e/install-action@v2 - with: - tool: cargo-risczero@1.0.1 - - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - run: cargo risczero install --version r0.1.78.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Run cargo-udeps - env: - RUSTFLAGS: -A warnings - uses: aig787/cargo-udeps-action@v1 - with: - version: 'latest' - args: '--workspace --all-features --all-targets' + # udeps: + # name: udeps + # runs-on: ubicloud-standard-8 + # timeout-minutes: 60 + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # - uses: rui314/setup-mold@v1 + # - name: Install Protoc + # uses: arduino/setup-protoc@v2 + # with: + # version: "23.2" + # repo-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Toolchain + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: nightly + # override: true + # - name: Rust Cache + # uses: Swatinem/rust-cache@v2 + # - name: Install cargo-risczero + # uses: taiki-e/install-action@v2 + # with: + # tool: cargo-risczero@1.0.1 + # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + # run: cargo risczero install --version r0.1.78.0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Run cargo-udeps + # env: + # RUSTFLAGS: -A warnings + # uses: aig787/cargo-udeps-action@v1 + # with: + # version: 'latest' + # args: '--workspace --all-features --all-targets' - deny: - runs-on: ubuntu-latest - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v4 - - name: Run cargo-deny - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check + # deny: + # runs-on: ubuntu-latest + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # - name: Run cargo-deny + # uses: EmbarkStudios/cargo-deny-action@v1 + # with: + # command: check - coverage: - runs-on: ubicloud-standard-16 - if: github.event.pull_request.draft == false - services: - postgres: - image: postgres:latest - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres - ports: - - 5432:5432 - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.78.0 - with: - components: llvm-tools-preview - - name: Rust Cache - uses: Swatinem/rust-cache@v2 - - uses: taiki-e/install-action@nextest - - uses: taiki-e/install-action@cargo-llvm-cov - - name: Install cargo-risczero - uses: taiki-e/install-action@v2 - with: - tool: cargo-risczero@1.0.1 - - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - run: cargo risczero install --version r0.1.78.0 - - name: Cache ethereum-tests - uses: actions/cache@v3 - with: - key: "eth-tests-1c23e3c" - path: crates/evm/ethereum-tests - - name: Run coverage - run: make coverage - env: - RUST_BACKTRACE: 1 - - name: Upload coverage - uses: codecov/codecov-action@v4 - with: - fail_ci_if_error: true # optional (default = false) - files: ./lcov.info - token: ${{ secrets.CODECOV_TOKEN }} + # coverage: + # runs-on: ubicloud-standard-16 + # if: github.event.pull_request.draft == false + # services: + # postgres: + # image: postgres:latest + # env: + # POSTGRES_USER: postgres + # POSTGRES_PASSWORD: postgres + # POSTGRES_DB: postgres + # ports: + # - 5432:5432 + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # steps: + # - uses: actions/checkout@v4 + # - uses: dtolnay/rust-toolchain@1.78.0 + # with: + # components: llvm-tools-preview + # - name: Rust Cache + # uses: Swatinem/rust-cache@v2 + # - uses: taiki-e/install-action@nextest + # - uses: taiki-e/install-action@cargo-llvm-cov + # - name: Install cargo-risczero + # uses: taiki-e/install-action@v2 + # with: + # tool: cargo-risczero@1.0.1 + # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + # run: cargo risczero install --version r0.1.78.0 + # - name: Cache ethereum-tests + # uses: actions/cache@v3 + # with: + # key: "eth-tests-1c23e3c" + # path: crates/evm/ethereum-tests + # - name: Run coverage + # run: make coverage + # env: + # RUST_BACKTRACE: 1 + # - name: Upload coverage + # uses: codecov/codecov-action@v4 + # with: + # fail_ci_if_error: true # optional (default = false) + # files: ./lcov.info + # token: ${{ secrets.CODECOV_TOKEN }} - uniswap: - runs-on: ubicloud-standard-16 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.78.0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Rust Cache - uses: Swatinem/rust-cache@v2 - - uses: dcarbone/install-jq-action@v2 - - name: Install cargo-risczero - uses: taiki-e/install-action@v2 - with: - tool: cargo-risczero@1.0.1 - - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - run: cargo risczero install --version r0.1.78.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build citrea - run: make build - - name: Install node dependencies - working-directory: ./bin/citrea/tests/evm/uniswap - run: npm install - - name: Run uniswap tests - run: | - RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & - sleep 2 - RUST_LOG=off ./target/debug/citrea --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & - sleep 2 - ./resources/configs/mock-dockerized/publish_da_block.sh & - cd ./bin/citrea/tests/evm/uniswap - npx hardhat run --network citrea scripts/01_deploy.js - npx hardhat run --network citrea scripts/02_swap.js - seqnHeight=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get sequencer block"; exit 1) - nodeHeight=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get full node block"; exit 1) - echo seqnHeight: $seqnHeight - echo nodeHeight: $nodeHeight - sleep 10 - seqnRoot=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get sequencer state root"; exit 1) - nodeRoot=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get full node state root"; exit 1) - echo seqnRoot: $seqnRoot - echo nodeRoot: $nodeRoot - if [ "$seqnRoot" != "$nodeRoot" ]; then - echo "State root mismatch"; - exit 1 - fi + # uniswap: + # runs-on: ubicloud-standard-16 + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # - uses: dtolnay/rust-toolchain@1.78.0 + # - uses: actions/setup-node@v4 + # with: + # node-version: 18 + # - name: Rust Cache + # uses: Swatinem/rust-cache@v2 + # - uses: dcarbone/install-jq-action@v2 + # - name: Install cargo-risczero + # uses: taiki-e/install-action@v2 + # with: + # tool: cargo-risczero@1.0.1 + # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + # run: cargo risczero install --version r0.1.78.0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Build citrea + # run: make build + # - name: Install node dependencies + # working-directory: ./bin/citrea/tests/evm/uniswap + # run: npm install + # - name: Run uniswap tests + # run: | + # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & + # sleep 2 + # RUST_LOG=off ./target/debug/citrea --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & + # sleep 2 + # ./resources/configs/mock-dockerized/publish_da_block.sh & + # cd ./bin/citrea/tests/evm/uniswap + # npx hardhat run --network citrea scripts/01_deploy.js + # npx hardhat run --network citrea scripts/02_swap.js + # seqnHeight=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get sequencer block"; exit 1) + # nodeHeight=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get full node block"; exit 1) + # echo seqnHeight: $seqnHeight + # echo nodeHeight: $nodeHeight + # sleep 10 + # seqnRoot=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get sequencer state root"; exit 1) + # nodeRoot=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get full node state root"; exit 1) + # echo seqnRoot: $seqnRoot + # echo nodeRoot: $nodeRoot + # if [ "$seqnRoot" != "$nodeRoot" ]; then + # echo "State root mismatch"; + # exit 1 + # fi - web3_py: - runs-on: ubicloud-standard-16 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - - uses: dtolnay/rust-toolchain@1.78.0 - - uses: dcarbone/install-jq-action@v2 - - name: Install cargo-risczero - uses: taiki-e/install-action@v2 - with: - tool: cargo-risczero@1.0.1 - - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - run: cargo risczero install --version r0.1.78.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-${{ github.job }}-${{ github.head_ref }} - path: ./target - - name: Build citrea - run: make build - - name: Install dependencies - working-directory: ./bin/citrea/tests/evm/web3_py - run: pip install -r requirements.txt - - name: Run web3.py tests - run: | - RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & - sleep 2 - RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & - sleep 2 - # ./resources/configs/mock-dockerized/publish_da_block.sh & - cd ./bin/citrea/tests/evm/web3_py - python test.py + # web3_py: + # runs-on: ubicloud-standard-16 + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v4 + # - uses: dtolnay/rust-toolchain@1.78.0 + # - uses: dcarbone/install-jq-action@v2 + # - name: Install cargo-risczero + # uses: taiki-e/install-action@v2 + # with: + # tool: cargo-risczero@1.0.1 + # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + # run: cargo risczero install --version r0.1.78.0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - uses: actions/cache@v3 + # with: + # key: ${{ runner.os }}-${{ github.job }}-${{ github.head_ref }} + # path: ./target + # - name: Build citrea + # run: make build + # - name: Install dependencies + # working-directory: ./bin/citrea/tests/evm/web3_py + # run: pip install -r requirements.txt + # - name: Run web3.py tests + # run: | + # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & + # sleep 2 + # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & + # sleep 2 + # # ./resources/configs/mock-dockerized/publish_da_block.sh & + # cd ./bin/citrea/tests/evm/web3_py + # python test.py - ethers_js: - runs-on: ubicloud-standard-16 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@1.78.0 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - name: Rust Cache - uses: Swatinem/rust-cache@v2 - - uses: dcarbone/install-jq-action@v2 - - name: Install cargo-risczero - uses: taiki-e/install-action@v2 - with: - tool: cargo-risczero@1.0.1 - - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - run: cargo risczero install --version r0.1.78.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build citrea - run: make build - - name: Install node dependencies - working-directory: ./bin/citrea/tests/evm/ethers_js - run: npm install - - name: Run ethers_js tests - run: | - RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & - sleep 2 - RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & - sleep 2 - ./resources/configs/mock-dockerized/publish_da_block.sh & - cd ./bin/citrea/tests/evm/ethers_js - npx mocha test.js + # ethers_js: + # runs-on: ubicloud-standard-16 + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # - uses: dtolnay/rust-toolchain@1.78.0 + # - uses: actions/setup-node@v4 + # with: + # node-version: 18 + # - name: Rust Cache + # uses: Swatinem/rust-cache@v2 + # - uses: dcarbone/install-jq-action@v2 + # - name: Install cargo-risczero + # uses: taiki-e/install-action@v2 + # with: + # tool: cargo-risczero@1.0.1 + # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + # run: cargo risczero install --version r0.1.78.0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Build citrea + # run: make build + # - name: Install node dependencies + # working-directory: ./bin/citrea/tests/evm/ethers_js + # run: npm install + # - name: Run ethers_js tests + # run: | + # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & + # sleep 2 + # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & + # sleep 2 + # ./resources/configs/mock-dockerized/publish_da_block.sh & + # cd ./bin/citrea/tests/evm/ethers_js + # npx mocha test.js - check_no_std: - runs-on: ubicloud-standard-4 - if: github.event.pull_request.draft == false - steps: - - uses: actions/checkout@v4 - - name: Install Rust Bare Metal - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.78.0 - target: thumbv6m-none-eabi - override: true - - name: Install Rust WASM - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.78.0 - target: wasm32-unknown-unknown - override: true - - name: cargo install cargo-hack - uses: taiki-e/install-action@cargo-hack - - uses: Swatinem/rust-cache@v2 - with: - save-if: ${{ github.ref == 'refs/heads/nightly' }} - - name: Run check - run: make check-no-std + # check_no_std: + # runs-on: ubicloud-standard-4 + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # - name: Install Rust Bare Metal + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: 1.78.0 + # target: thumbv6m-none-eabi + # override: true + # - name: Install Rust WASM + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: 1.78.0 + # target: wasm32-unknown-unknown + # override: true + # - name: cargo install cargo-hack + # uses: taiki-e/install-action@cargo-hack + # - uses: Swatinem/rust-cache@v2 + # with: + # save-if: ${{ github.ref == 'refs/heads/nightly' }} + # - name: Run check + # run: make check-no-std - nextest: - name: nextest - runs-on: ubicloud-standard-16 - timeout-minutes: 60 - if: github.event.pull_request.draft == false - services: - postgres: - image: postgres:latest - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres - ports: - - 5432:5432 - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - steps: - - uses: actions/checkout@v4 - - uses: rui314/setup-mold@v1 - - name: Install Protoc - uses: arduino/setup-protoc@v2 - with: - version: "23.2" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Toolchain - uses: dtolnay/rust-toolchain@1.78.0 - with: - override: true - components: rustfmt, clippy - - name: Rust Cache - uses: Swatinem/rust-cache@v2 - - name: Install cargo-risczero - uses: taiki-e/install-action@v2 - with: - tool: cargo-risczero@1.0.1 - - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - run: cargo risczero install --version r0.1.78.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # `cargo-nextest` is much faster than standard `cargo test`. - - uses: taiki-e/install-action@nextest - - name: Cache ethereum-tests - uses: actions/cache@v3 - with: - key: "eth-tests-1c23e3c" - path: crates/evm/ethereum-tests - - name: Run nextest - run: make test - env: - RUST_BACKTRACE: 1 - REPR_GUEST_BUILD: 1 - BONSAI_API_URL: ${{ secrets.BONSAI_API_URL }} # TODO: remove this once we don't use the client on tests - BONSAI_API_KEY: ${{ secrets.BONSAI_API_KEY }} # TODO: remove this once we don't use the client on tests + # nextest: + # name: nextest + # runs-on: ubicloud-standard-16 + # timeout-minutes: 60 + # if: github.event.pull_request.draft == false + # services: + # postgres: + # image: postgres:latest + # env: + # POSTGRES_USER: postgres + # POSTGRES_PASSWORD: postgres + # POSTGRES_DB: postgres + # ports: + # - 5432:5432 + # options: >- + # --health-cmd pg_isready + # --health-interval 10s + # --health-timeout 5s + # --health-retries 5 + # steps: + # - uses: actions/checkout@v4 + # - uses: rui314/setup-mold@v1 + # - name: Install Protoc + # uses: arduino/setup-protoc@v2 + # with: + # version: "23.2" + # repo-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Toolchain + # uses: dtolnay/rust-toolchain@1.78.0 + # with: + # override: true + # components: rustfmt, clippy + # - name: Rust Cache + # uses: Swatinem/rust-cache@v2 + # - name: Install cargo-risczero + # uses: taiki-e/install-action@v2 + # with: + # tool: cargo-risczero@1.0.1 + # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + # run: cargo risczero install --version r0.1.78.0 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # # `cargo-nextest` is much faster than standard `cargo test`. + # - uses: taiki-e/install-action@nextest + # - name: Cache ethereum-tests + # uses: actions/cache@v3 + # with: + # key: "eth-tests-1c23e3c" + # path: crates/evm/ethereum-tests + # - name: Run nextest + # run: make test + # env: + # RUST_BACKTRACE: 1 + # REPR_GUEST_BUILD: 1 + # BONSAI_API_URL: ${{ secrets.BONSAI_API_URL }} # TODO: remove this once we don't use the client on tests + # BONSAI_API_KEY: ${{ secrets.BONSAI_API_KEY }} # TODO: remove this once we don't use the client on tests - system-contracts: + # system-contracts: + # strategy: + # fail-fast: true + + # name: Foundry project + # runs-on: ubicloud-standard-2 + # if: github.event.pull_request.draft == false + # steps: + # - uses: actions/checkout@v4 + # with: + # submodules: recursive + + # - name: Install Foundry + # uses: foundry-rs/foundry-toolchain@v1 + # with: + # version: nightly + + # - name: Run Forge build + # run: | + # cd crates/evm/src/evm/system_contracts + # forge --version + # forge build --sizes + # id: build + + # - name: Run Forge tests + # run: | + # cd crates/evm/src/evm/system_contracts + # forge test -vvv + # id: test + + check_genesis_files: strategy: fail-fast: true - name: Foundry project + name: Check Genesis Files runs-on: ubicloud-standard-2 if: github.event.pull_request.draft == false steps: @@ -411,15 +441,24 @@ jobs: with: version: nightly - - name: Run Forge build + - name: Run Forge install run: | cd crates/evm/src/evm/system_contracts forge --version - forge build --sizes - id: build - - - name: Run Forge tests + forge install + id: forgeInstall + + - name: Foundryup run: | cd crates/evm/src/evm/system_contracts - forge test -vvv - id: test + foundryup + id: foundryup + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Run check_genesis.sh + run: ./.github/scripts/check_genesis.sh + From e46bd4c904d09f90d54b60c36c0dc787d08e202c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:35:44 +0300 Subject: [PATCH 02/12] Test ci 2 --- .github/workflows/checks.yml | 18 +-- .../script/GenesisToEvmJson.py | 146 ++++++++++++------ 2 files changed, 104 insertions(+), 60 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 325b93cd0..5c963d4da 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -423,7 +423,6 @@ jobs: # cd crates/evm/src/evm/system_contracts # forge test -vvv # id: test - check_genesis_files: strategy: fail-fast: true @@ -441,18 +440,14 @@ jobs: with: version: nightly - - name: Run Forge install + - name: Run Foundry Setup run: | - cd crates/evm/src/evm/system_contracts - forge --version - forge install - id: forgeInstall - - - name: Foundryup - run: | - cd crates/evm/src/evm/system_contracts + export FOUNDRY_HOME="$HOME/.foundry" + curl -L https://foundry.paradigm.xyz | bash + source $HOME/.bashrc foundryup - id: foundryup + foundry --version + shell: bash - name: Set up Python uses: actions/setup-python@v4 @@ -461,4 +456,5 @@ jobs: - name: Run check_genesis.sh run: ./.github/scripts/check_genesis.sh + shell: bash diff --git a/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py b/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py index 70e7d9f91..567fee374 100644 --- a/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py +++ b/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py @@ -1,57 +1,105 @@ import json import sys +import time +import asyncio +i = 0 +async def main(): + global i + print(1) + with open(sys.argv[1], "r") as file: + data = json.load(file) + print(2) + i+=1 + # Sort the data by key + data = {k: data[k] for k in sorted(data)} + print(3) + i+=1 + new_data = [] + print(4) + i+=1 + for key in data: + new_data.append({ + "address": key, + "balance": data[key]["balance"], + "code": data[key]["code"] + }) + if data[key]["storage"] != {}: + new_data[-1]["storage"] = data[key]["storage"] + print(5) + i+=1 + evm_json = {} + evm_json["data"] = new_data + evm_json["chain_id"] = 5655 + evm_json["limit_contract_code_size"] = None + evm_json["spec"] = {"0": "SHANGHAI"} + evm_json["coinbase"] = "0x3100000000000000000000000000000000000005" + evm_json["starting_base_fee"] = 1000000000 + evm_json["block_gas_limit"] = 30000000 + evm_json["base_fee_params"] = {"max_change_denominator": 8, "elasticity_multiplier" : 2} + evm_json["difficulty"] = 0 + evm_json["extra_data"] = "0x" + evm_json["timestamp"] = 0 + evm_json["nonce"] = 0 + print(6) + i+=1 + with open(sys.argv[2], "w") as file: + json.dump(evm_json, file, indent=2) + print(7) + i+=1 + # Copy evm.json to following paths + paths = [ + "../../../../../resources/genesis/bitcoin-regtest/evm.json", + "../../../../../resources/genesis/mock/evm.json", + "../../../../../resources/genesis/mock-dockerized/evm.json", + "../../../../../resources/test-data/demo-tests/bitcoin-regtest/evm.json", + "../../../../../resources/test-data/demo-tests/mock/evm.json", + "../../../../../resources/test-data/integration-tests/evm.json", + "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json", + "../../../../../resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json" + ] + print(8) + i+=1 -with open(sys.argv[1], "r") as file: - data = json.load(file) + # check if the files are equal -# Sort the data by key -data = {k: data[k] for k in sorted(data)} + for path in paths: + with open(path, "r") as file: + data = json.load(file) -new_data = [] + if path == "../../../../../resources/genesis/bitcoin-regtest/evm.json": + print("111111\n\n\n\n\n") + # print(data) + print("222222\n\n\n\n\n") + # print(evm_json) + print("3333333\n\n\n\n\n") + if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json": + new_evm_json = evm_json.copy() + new_evm_json["block_gas_limit"] = 1500000 + if json.dumps(new_evm_json, indent=None, separators=(',', ':')) != json.dumps(data, indent=None, separators=(',', ':')): + print("Not Eq", path) + continue + if json.dumps(evm_json, indent=None, separators=(',', ':')) != json.dumps(data, indent=None, separators=(',', ':')): + print("Not Eq", path) -for key in data: - new_data.append({ - "address": key, - "balance": data[key]["balance"], - "code": data[key]["code"] - }) - if data[key]["storage"] != {}: - new_data[-1]["storage"] = data[key]["storage"] + print(9) + i+=1 + print(i) + await asyncio.sleep(5) + print(10) + for path in paths: + print("W1") + with open(path, "w+") as file: + print("W2") + if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json": + new_evm_json = evm_json.copy() + new_evm_json["block_gas_limit"] = 1500000 + json.dump(new_evm_json, file, indent=2) + print("W3") + continue + json.dump(evm_json, file, indent=2) + print("W3") + print(11) -evm_json = {} -evm_json["data"] = new_data -evm_json["chain_id"] = 5655 -evm_json["limit_contract_code_size"] = None -evm_json["spec"] = {"0": "SHANGHAI"} -evm_json["coinbase"] = "0x3100000000000000000000000000000000000005" -evm_json["starting_base_fee"] = 1000000000 -evm_json["block_gas_limit"] = 30000000 -evm_json["base_fee_params"] = {"max_change_denominator": 8, "elasticity_multiplier" : 2} -evm_json["difficulty"] = 0 -evm_json["extra_data"] = "0x" -evm_json["timestamp"] = 0 -evm_json["nonce"] = 0 +if __name__ == '__main__': -with open(sys.argv[2], "w") as file: - json.dump(evm_json, file, indent=2) - -# Copy evm.json to following paths -paths = [ - "../../../../../resources/genesis/bitcoin-regtest/evm.json", - "../../../../../resources/genesis/mock/evm.json", - "../../../../../resources/genesis/mock-dockerized/evm.json", - "../../../../../resources/test-data/demo-tests/bitcoin-regtest/evm.json", - "../../../../../resources/test-data/demo-tests/mock/evm.json", - "../../../../../resources/test-data/integration-tests/evm.json", - "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json", - "../../../../../resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json" -] - -for path in paths: - with open(path, "w") as file: - if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json": - new_evm_json = evm_json.copy() - new_evm_json["block_gas_limit"] = 1500000 - json.dump(new_evm_json, file, indent=2) - continue - json.dump(evm_json, file, indent=2) \ No newline at end of file + asyncio.run(main()) \ No newline at end of file From 13d5d913e9b7292c0f9481deb37bf343aff5463c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:38:18 +0300 Subject: [PATCH 03/12] Test ci 3 --- .github/workflows/checks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5c963d4da..c411cd7cd 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -443,7 +443,6 @@ jobs: - name: Run Foundry Setup run: | export FOUNDRY_HOME="$HOME/.foundry" - curl -L https://foundry.paradigm.xyz | bash source $HOME/.bashrc foundryup foundry --version From d38b1a2128c062d2880a46c569da5e918bfa7fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:46:35 +0300 Subject: [PATCH 04/12] Test ci 4 --- .github/workflows/checks.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c411cd7cd..f966190d2 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -440,14 +440,6 @@ jobs: with: version: nightly - - name: Run Foundry Setup - run: | - export FOUNDRY_HOME="$HOME/.foundry" - source $HOME/.bashrc - foundryup - foundry --version - shell: bash - - name: Set up Python uses: actions/setup-python@v4 with: From 3a558b976261d1678d8373b1136304975ae6ae0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:50:39 +0300 Subject: [PATCH 05/12] Gitkeep state dir for temp genesis files --- crates/evm/src/evm/system_contracts/.gitignore | 3 ++- crates/evm/src/evm/system_contracts/state/.gitkeep | 0 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 crates/evm/src/evm/system_contracts/state/.gitkeep diff --git a/crates/evm/src/evm/system_contracts/.gitignore b/crates/evm/src/evm/system_contracts/.gitignore index f4ee93e35..edd2de820 100644 --- a/crates/evm/src/evm/system_contracts/.gitignore +++ b/crates/evm/src/evm/system_contracts/.gitignore @@ -1,7 +1,8 @@ # Compiler files cache/ out/ -state/ +state/*.json + # Ignores development broadcast logs !/broadcast diff --git a/crates/evm/src/evm/system_contracts/state/.gitkeep b/crates/evm/src/evm/system_contracts/state/.gitkeep new file mode 100644 index 000000000..e69de29bb From fb426383edeae8c204876dbd5ba70c983e75f146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:53:25 +0300 Subject: [PATCH 06/12] Test if ci works & revert python script --- .../script/GenesisToEvmJson.py | 146 ++++++------------ resources/genesis/bitcoin-regtest/evm.json | 2 +- 2 files changed, 50 insertions(+), 98 deletions(-) diff --git a/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py b/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py index 567fee374..70e7d9f91 100644 --- a/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py +++ b/crates/evm/src/evm/system_contracts/script/GenesisToEvmJson.py @@ -1,105 +1,57 @@ import json import sys -import time -import asyncio -i = 0 -async def main(): - global i - print(1) - with open(sys.argv[1], "r") as file: - data = json.load(file) - print(2) - i+=1 - # Sort the data by key - data = {k: data[k] for k in sorted(data)} - print(3) - i+=1 - new_data = [] - print(4) - i+=1 - for key in data: - new_data.append({ - "address": key, - "balance": data[key]["balance"], - "code": data[key]["code"] - }) - if data[key]["storage"] != {}: - new_data[-1]["storage"] = data[key]["storage"] - print(5) - i+=1 - evm_json = {} - evm_json["data"] = new_data - evm_json["chain_id"] = 5655 - evm_json["limit_contract_code_size"] = None - evm_json["spec"] = {"0": "SHANGHAI"} - evm_json["coinbase"] = "0x3100000000000000000000000000000000000005" - evm_json["starting_base_fee"] = 1000000000 - evm_json["block_gas_limit"] = 30000000 - evm_json["base_fee_params"] = {"max_change_denominator": 8, "elasticity_multiplier" : 2} - evm_json["difficulty"] = 0 - evm_json["extra_data"] = "0x" - evm_json["timestamp"] = 0 - evm_json["nonce"] = 0 - print(6) - i+=1 - with open(sys.argv[2], "w") as file: - json.dump(evm_json, file, indent=2) - print(7) - i+=1 - # Copy evm.json to following paths - paths = [ - "../../../../../resources/genesis/bitcoin-regtest/evm.json", - "../../../../../resources/genesis/mock/evm.json", - "../../../../../resources/genesis/mock-dockerized/evm.json", - "../../../../../resources/test-data/demo-tests/bitcoin-regtest/evm.json", - "../../../../../resources/test-data/demo-tests/mock/evm.json", - "../../../../../resources/test-data/integration-tests/evm.json", - "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json", - "../../../../../resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json" - ] - print(8) - i+=1 - # check if the files are equal +with open(sys.argv[1], "r") as file: + data = json.load(file) - for path in paths: - with open(path, "r") as file: - data = json.load(file) +# Sort the data by key +data = {k: data[k] for k in sorted(data)} - if path == "../../../../../resources/genesis/bitcoin-regtest/evm.json": - print("111111\n\n\n\n\n") - # print(data) - print("222222\n\n\n\n\n") - # print(evm_json) - print("3333333\n\n\n\n\n") - if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json": - new_evm_json = evm_json.copy() - new_evm_json["block_gas_limit"] = 1500000 - if json.dumps(new_evm_json, indent=None, separators=(',', ':')) != json.dumps(data, indent=None, separators=(',', ':')): - print("Not Eq", path) - continue - if json.dumps(evm_json, indent=None, separators=(',', ':')) != json.dumps(data, indent=None, separators=(',', ':')): - print("Not Eq", path) +new_data = [] - print(9) - i+=1 - print(i) - await asyncio.sleep(5) - print(10) - for path in paths: - print("W1") - with open(path, "w+") as file: - print("W2") - if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json": - new_evm_json = evm_json.copy() - new_evm_json["block_gas_limit"] = 1500000 - json.dump(new_evm_json, file, indent=2) - print("W3") - continue - json.dump(evm_json, file, indent=2) - print("W3") - print(11) +for key in data: + new_data.append({ + "address": key, + "balance": data[key]["balance"], + "code": data[key]["code"] + }) + if data[key]["storage"] != {}: + new_data[-1]["storage"] = data[key]["storage"] -if __name__ == '__main__': +evm_json = {} +evm_json["data"] = new_data +evm_json["chain_id"] = 5655 +evm_json["limit_contract_code_size"] = None +evm_json["spec"] = {"0": "SHANGHAI"} +evm_json["coinbase"] = "0x3100000000000000000000000000000000000005" +evm_json["starting_base_fee"] = 1000000000 +evm_json["block_gas_limit"] = 30000000 +evm_json["base_fee_params"] = {"max_change_denominator": 8, "elasticity_multiplier" : 2} +evm_json["difficulty"] = 0 +evm_json["extra_data"] = "0x" +evm_json["timestamp"] = 0 +evm_json["nonce"] = 0 - asyncio.run(main()) \ No newline at end of file +with open(sys.argv[2], "w") as file: + json.dump(evm_json, file, indent=2) + +# Copy evm.json to following paths +paths = [ + "../../../../../resources/genesis/bitcoin-regtest/evm.json", + "../../../../../resources/genesis/mock/evm.json", + "../../../../../resources/genesis/mock-dockerized/evm.json", + "../../../../../resources/test-data/demo-tests/bitcoin-regtest/evm.json", + "../../../../../resources/test-data/demo-tests/mock/evm.json", + "../../../../../resources/test-data/integration-tests/evm.json", + "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json", + "../../../../../resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json" +] + +for path in paths: + with open(path, "w") as file: + if path == "../../../../../resources/test-data/integration-tests-low-block-gas-limit/evm.json": + new_evm_json = evm_json.copy() + new_evm_json["block_gas_limit"] = 1500000 + json.dump(new_evm_json, file, indent=2) + continue + json.dump(evm_json, file, indent=2) \ No newline at end of file diff --git a/resources/genesis/bitcoin-regtest/evm.json b/resources/genesis/bitcoin-regtest/evm.json index 9912585bd..276379a61 100644 --- a/resources/genesis/bitcoin-regtest/evm.json +++ b/resources/genesis/bitcoin-regtest/evm.json @@ -3,7 +3,7 @@ { "address": "0x0f820f428ae436c1000b27577bf5bbf09bfec8f2", "balance": "0xffffffffffffffffffffffffffffff", - "code": "0x" + "code": "0x00" }, { "address": "0x3100000000000000000000000000000000000001", From 78cc531feaf75ab1ebf099edcdedab861ba2a871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:57:15 +0300 Subject: [PATCH 07/12] Remove comments of cis --- .github/workflows/checks.yml | 696 ++++++++++----------- resources/genesis/bitcoin-regtest/evm.json | 2 +- 2 files changed, 349 insertions(+), 349 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f966190d2..926e190f1 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -61,368 +61,368 @@ concurrency: cancel-in-progress: ${{ (github.ref != 'refs/heads/nightly') && (github.ref != 'refs/heads/main') }} jobs: - # check: - # name: check - # runs-on: ubicloud-standard-16 - # timeout-minutes: 60 - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # - uses: rui314/setup-mold@v1 - # - name: Install Protoc - # uses: arduino/setup-protoc@v2 - # with: - # version: "23.2" - # repo-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Toolchain - # uses: dtolnay/rust-toolchain@nightly - # with: - # override: true - # components: rustfmt, clippy - # - name: Rust Cache - # uses: Swatinem/rust-cache@v2 - # - name: Install cargo-risczero - # uses: taiki-e/install-action@v2 - # with: - # tool: cargo-risczero@1.0.1 - # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - # run: cargo risczero install --version r0.1.78.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # - name: Check TOML - # uses: dprint/check@v2.2 - # - name: Run lint - # run: | - # if ! SKIP_GUEST_BUILD=1 make lint ; then - # echo "Linting or formatting errors detected, please run 'make lint-fix' to fix it"; - # exit 1 - # fi + check: + name: check + runs-on: ubicloud-standard-16 + timeout-minutes: 60 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + - uses: rui314/setup-mold@v1 + - name: Install Protoc + uses: arduino/setup-protoc@v2 + with: + version: "23.2" + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Toolchain + uses: dtolnay/rust-toolchain@nightly + with: + override: true + components: rustfmt, clippy + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Install cargo-risczero + uses: taiki-e/install-action@v2 + with: + tool: cargo-risczero@1.0.1 + - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + run: cargo risczero install --version r0.1.78.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check TOML + uses: dprint/check@v2.2 + - name: Run lint + run: | + if ! SKIP_GUEST_BUILD=1 make lint ; then + echo "Linting or formatting errors detected, please run 'make lint-fix' to fix it"; + exit 1 + fi - # udeps: - # name: udeps - # runs-on: ubicloud-standard-8 - # timeout-minutes: 60 - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # - uses: rui314/setup-mold@v1 - # - name: Install Protoc - # uses: arduino/setup-protoc@v2 - # with: - # version: "23.2" - # repo-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Toolchain - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: nightly - # override: true - # - name: Rust Cache - # uses: Swatinem/rust-cache@v2 - # - name: Install cargo-risczero - # uses: taiki-e/install-action@v2 - # with: - # tool: cargo-risczero@1.0.1 - # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - # run: cargo risczero install --version r0.1.78.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # - name: Run cargo-udeps - # env: - # RUSTFLAGS: -A warnings - # uses: aig787/cargo-udeps-action@v1 - # with: - # version: 'latest' - # args: '--workspace --all-features --all-targets' + udeps: + name: udeps + runs-on: ubicloud-standard-8 + timeout-minutes: 60 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + - uses: rui314/setup-mold@v1 + - name: Install Protoc + uses: arduino/setup-protoc@v2 + with: + version: "23.2" + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Install cargo-risczero + uses: taiki-e/install-action@v2 + with: + tool: cargo-risczero@1.0.1 + - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + run: cargo risczero install --version r0.1.78.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Run cargo-udeps + env: + RUSTFLAGS: -A warnings + uses: aig787/cargo-udeps-action@v1 + with: + version: 'latest' + args: '--workspace --all-features --all-targets' - # deny: - # runs-on: ubuntu-latest - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # - name: Run cargo-deny - # uses: EmbarkStudios/cargo-deny-action@v1 - # with: - # command: check + deny: + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + - name: Run cargo-deny + uses: EmbarkStudios/cargo-deny-action@v1 + with: + command: check - # coverage: - # runs-on: ubicloud-standard-16 - # if: github.event.pull_request.draft == false - # services: - # postgres: - # image: postgres:latest - # env: - # POSTGRES_USER: postgres - # POSTGRES_PASSWORD: postgres - # POSTGRES_DB: postgres - # ports: - # - 5432:5432 - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # steps: - # - uses: actions/checkout@v4 - # - uses: dtolnay/rust-toolchain@1.78.0 - # with: - # components: llvm-tools-preview - # - name: Rust Cache - # uses: Swatinem/rust-cache@v2 - # - uses: taiki-e/install-action@nextest - # - uses: taiki-e/install-action@cargo-llvm-cov - # - name: Install cargo-risczero - # uses: taiki-e/install-action@v2 - # with: - # tool: cargo-risczero@1.0.1 - # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - # run: cargo risczero install --version r0.1.78.0 - # - name: Cache ethereum-tests - # uses: actions/cache@v3 - # with: - # key: "eth-tests-1c23e3c" - # path: crates/evm/ethereum-tests - # - name: Run coverage - # run: make coverage - # env: - # RUST_BACKTRACE: 1 - # - name: Upload coverage - # uses: codecov/codecov-action@v4 - # with: - # fail_ci_if_error: true # optional (default = false) - # files: ./lcov.info - # token: ${{ secrets.CODECOV_TOKEN }} + coverage: + runs-on: ubicloud-standard-16 + if: github.event.pull_request.draft == false + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.78.0 + with: + components: llvm-tools-preview + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@nextest + - uses: taiki-e/install-action@cargo-llvm-cov + - name: Install cargo-risczero + uses: taiki-e/install-action@v2 + with: + tool: cargo-risczero@1.0.1 + - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + run: cargo risczero install --version r0.1.78.0 + - name: Cache ethereum-tests + uses: actions/cache@v3 + with: + key: "eth-tests-1c23e3c" + path: crates/evm/ethereum-tests + - name: Run coverage + run: make coverage + env: + RUST_BACKTRACE: 1 + - name: Upload coverage + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true # optional (default = false) + files: ./lcov.info + token: ${{ secrets.CODECOV_TOKEN }} - # uniswap: - # runs-on: ubicloud-standard-16 - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # - uses: dtolnay/rust-toolchain@1.78.0 - # - uses: actions/setup-node@v4 - # with: - # node-version: 18 - # - name: Rust Cache - # uses: Swatinem/rust-cache@v2 - # - uses: dcarbone/install-jq-action@v2 - # - name: Install cargo-risczero - # uses: taiki-e/install-action@v2 - # with: - # tool: cargo-risczero@1.0.1 - # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - # run: cargo risczero install --version r0.1.78.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # - name: Build citrea - # run: make build - # - name: Install node dependencies - # working-directory: ./bin/citrea/tests/evm/uniswap - # run: npm install - # - name: Run uniswap tests - # run: | - # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & - # sleep 2 - # RUST_LOG=off ./target/debug/citrea --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & - # sleep 2 - # ./resources/configs/mock-dockerized/publish_da_block.sh & - # cd ./bin/citrea/tests/evm/uniswap - # npx hardhat run --network citrea scripts/01_deploy.js - # npx hardhat run --network citrea scripts/02_swap.js - # seqnHeight=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get sequencer block"; exit 1) - # nodeHeight=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get full node block"; exit 1) - # echo seqnHeight: $seqnHeight - # echo nodeHeight: $nodeHeight - # sleep 10 - # seqnRoot=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get sequencer state root"; exit 1) - # nodeRoot=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get full node state root"; exit 1) - # echo seqnRoot: $seqnRoot - # echo nodeRoot: $nodeRoot - # if [ "$seqnRoot" != "$nodeRoot" ]; then - # echo "State root mismatch"; - # exit 1 - # fi + uniswap: + runs-on: ubicloud-standard-16 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.78.0 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - uses: dcarbone/install-jq-action@v2 + - name: Install cargo-risczero + uses: taiki-e/install-action@v2 + with: + tool: cargo-risczero@1.0.1 + - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + run: cargo risczero install --version r0.1.78.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build citrea + run: make build + - name: Install node dependencies + working-directory: ./bin/citrea/tests/evm/uniswap + run: npm install + - name: Run uniswap tests + run: | + RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & + sleep 2 + RUST_LOG=off ./target/debug/citrea --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & + sleep 2 + ./resources/configs/mock-dockerized/publish_da_block.sh & + cd ./bin/citrea/tests/evm/uniswap + npx hardhat run --network citrea scripts/01_deploy.js + npx hardhat run --network citrea scripts/02_swap.js + seqnHeight=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get sequencer block"; exit 1) + nodeHeight=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":["latest"],"id":1,"jsonrpc":"2.0"}' | jq -e .result.number) || (echo "Couldn't get full node block"; exit 1) + echo seqnHeight: $seqnHeight + echo nodeHeight: $nodeHeight + sleep 10 + seqnRoot=$(curl -s 0.0.0.0:12345/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get sequencer state root"; exit 1) + nodeRoot=$(curl -s 0.0.0.0:12346/ -H "Content-Type: application/json" --data '{"method":"eth_getBlockByNumber","params":['${seqnHeight}'],"id":1,"jsonrpc":"2.0"}' | jq -e .result.stateRoot) || (echo "Couldn't get full node state root"; exit 1) + echo seqnRoot: $seqnRoot + echo nodeRoot: $nodeRoot + if [ "$seqnRoot" != "$nodeRoot" ]; then + echo "State root mismatch"; + exit 1 + fi - # web3_py: - # runs-on: ubicloud-standard-16 - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # - uses: actions/setup-python@v4 - # - uses: dtolnay/rust-toolchain@1.78.0 - # - uses: dcarbone/install-jq-action@v2 - # - name: Install cargo-risczero - # uses: taiki-e/install-action@v2 - # with: - # tool: cargo-risczero@1.0.1 - # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - # run: cargo risczero install --version r0.1.78.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # - uses: actions/cache@v3 - # with: - # key: ${{ runner.os }}-${{ github.job }}-${{ github.head_ref }} - # path: ./target - # - name: Build citrea - # run: make build - # - name: Install dependencies - # working-directory: ./bin/citrea/tests/evm/web3_py - # run: pip install -r requirements.txt - # - name: Run web3.py tests - # run: | - # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & - # sleep 2 - # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & - # sleep 2 - # # ./resources/configs/mock-dockerized/publish_da_block.sh & - # cd ./bin/citrea/tests/evm/web3_py - # python test.py + web3_py: + runs-on: ubicloud-standard-16 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - uses: dtolnay/rust-toolchain@1.78.0 + - uses: dcarbone/install-jq-action@v2 + - name: Install cargo-risczero + uses: taiki-e/install-action@v2 + with: + tool: cargo-risczero@1.0.1 + - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + run: cargo risczero install --version r0.1.78.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/cache@v3 + with: + key: ${{ runner.os }}-${{ github.job }}-${{ github.head_ref }} + path: ./target + - name: Build citrea + run: make build + - name: Install dependencies + working-directory: ./bin/citrea/tests/evm/web3_py + run: pip install -r requirements.txt + - name: Run web3.py tests + run: | + RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & + sleep 2 + RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & + sleep 2 + # ./resources/configs/mock-dockerized/publish_da_block.sh & + cd ./bin/citrea/tests/evm/web3_py + python test.py - # ethers_js: - # runs-on: ubicloud-standard-16 - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # - uses: dtolnay/rust-toolchain@1.78.0 - # - uses: actions/setup-node@v4 - # with: - # node-version: 18 - # - name: Rust Cache - # uses: Swatinem/rust-cache@v2 - # - uses: dcarbone/install-jq-action@v2 - # - name: Install cargo-risczero - # uses: taiki-e/install-action@v2 - # with: - # tool: cargo-risczero@1.0.1 - # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - # run: cargo risczero install --version r0.1.78.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # - name: Build citrea - # run: make build - # - name: Install node dependencies - # working-directory: ./bin/citrea/tests/evm/ethers_js - # run: npm install - # - name: Run ethers_js tests - # run: | - # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & - # sleep 2 - # RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & - # sleep 2 - # ./resources/configs/mock-dockerized/publish_da_block.sh & - # cd ./bin/citrea/tests/evm/ethers_js - # npx mocha test.js + ethers_js: + runs-on: ubicloud-standard-16 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.78.0 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - uses: dcarbone/install-jq-action@v2 + - name: Install cargo-risczero + uses: taiki-e/install-action@v2 + with: + tool: cargo-risczero@1.0.1 + - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + run: cargo risczero install --version r0.1.78.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build citrea + run: make build + - name: Install node dependencies + working-directory: ./bin/citrea/tests/evm/ethers_js + run: npm install + - name: Run ethers_js tests + run: | + RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/sequencer_rollup_config.toml --sequencer-config-path resources/configs/mock/sequencer_config.toml --genesis-paths resources/genesis/mock/ & + sleep 2 + RUST_LOG=off ./target/debug/citrea --da-layer mock --rollup-config-path resources/configs/mock/rollup_config.toml --genesis-paths resources/genesis/mock/ & + sleep 2 + ./resources/configs/mock-dockerized/publish_da_block.sh & + cd ./bin/citrea/tests/evm/ethers_js + npx mocha test.js - # check_no_std: - # runs-on: ubicloud-standard-4 - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # - name: Install Rust Bare Metal - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: 1.78.0 - # target: thumbv6m-none-eabi - # override: true - # - name: Install Rust WASM - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: 1.78.0 - # target: wasm32-unknown-unknown - # override: true - # - name: cargo install cargo-hack - # uses: taiki-e/install-action@cargo-hack - # - uses: Swatinem/rust-cache@v2 - # with: - # save-if: ${{ github.ref == 'refs/heads/nightly' }} - # - name: Run check - # run: make check-no-std + check_no_std: + runs-on: ubicloud-standard-4 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + - name: Install Rust Bare Metal + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.78.0 + target: thumbv6m-none-eabi + override: true + - name: Install Rust WASM + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.78.0 + target: wasm32-unknown-unknown + override: true + - name: cargo install cargo-hack + uses: taiki-e/install-action@cargo-hack + - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/nightly' }} + - name: Run check + run: make check-no-std - # nextest: - # name: nextest - # runs-on: ubicloud-standard-16 - # timeout-minutes: 60 - # if: github.event.pull_request.draft == false - # services: - # postgres: - # image: postgres:latest - # env: - # POSTGRES_USER: postgres - # POSTGRES_PASSWORD: postgres - # POSTGRES_DB: postgres - # ports: - # - 5432:5432 - # options: >- - # --health-cmd pg_isready - # --health-interval 10s - # --health-timeout 5s - # --health-retries 5 - # steps: - # - uses: actions/checkout@v4 - # - uses: rui314/setup-mold@v1 - # - name: Install Protoc - # uses: arduino/setup-protoc@v2 - # with: - # version: "23.2" - # repo-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Toolchain - # uses: dtolnay/rust-toolchain@1.78.0 - # with: - # override: true - # components: rustfmt, clippy - # - name: Rust Cache - # uses: Swatinem/rust-cache@v2 - # - name: Install cargo-risczero - # uses: taiki-e/install-action@v2 - # with: - # tool: cargo-risczero@1.0.1 - # - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain - # run: cargo risczero install --version r0.1.78.0 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # # `cargo-nextest` is much faster than standard `cargo test`. - # - uses: taiki-e/install-action@nextest - # - name: Cache ethereum-tests - # uses: actions/cache@v3 - # with: - # key: "eth-tests-1c23e3c" - # path: crates/evm/ethereum-tests - # - name: Run nextest - # run: make test - # env: - # RUST_BACKTRACE: 1 - # REPR_GUEST_BUILD: 1 - # BONSAI_API_URL: ${{ secrets.BONSAI_API_URL }} # TODO: remove this once we don't use the client on tests - # BONSAI_API_KEY: ${{ secrets.BONSAI_API_KEY }} # TODO: remove this once we don't use the client on tests + nextest: + name: nextest + runs-on: ubicloud-standard-16 + timeout-minutes: 60 + if: github.event.pull_request.draft == false + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v4 + - uses: rui314/setup-mold@v1 + - name: Install Protoc + uses: arduino/setup-protoc@v2 + with: + version: "23.2" + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Toolchain + uses: dtolnay/rust-toolchain@1.78.0 + with: + override: true + components: rustfmt, clippy + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Install cargo-risczero + uses: taiki-e/install-action@v2 + with: + tool: cargo-risczero@1.0.1 + - name: Install risc0-zkvm toolchain # Use the risc0 cargo extension to install the risc0 std library for the current toolchain + run: cargo risczero install --version r0.1.78.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # `cargo-nextest` is much faster than standard `cargo test`. + - uses: taiki-e/install-action@nextest + - name: Cache ethereum-tests + uses: actions/cache@v3 + with: + key: "eth-tests-1c23e3c" + path: crates/evm/ethereum-tests + - name: Run nextest + run: make test + env: + RUST_BACKTRACE: 1 + REPR_GUEST_BUILD: 1 + BONSAI_API_URL: ${{ secrets.BONSAI_API_URL }} # TODO: remove this once we don't use the client on tests + BONSAI_API_KEY: ${{ secrets.BONSAI_API_KEY }} # TODO: remove this once we don't use the client on tests - # system-contracts: - # strategy: - # fail-fast: true + system-contracts: + strategy: + fail-fast: true - # name: Foundry project - # runs-on: ubicloud-standard-2 - # if: github.event.pull_request.draft == false - # steps: - # - uses: actions/checkout@v4 - # with: - # submodules: recursive + name: Foundry project + runs-on: ubicloud-standard-2 + if: github.event.pull_request.draft == false + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive - # - name: Install Foundry - # uses: foundry-rs/foundry-toolchain@v1 - # with: - # version: nightly + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly - # - name: Run Forge build - # run: | - # cd crates/evm/src/evm/system_contracts - # forge --version - # forge build --sizes - # id: build + - name: Run Forge build + run: | + cd crates/evm/src/evm/system_contracts + forge --version + forge build --sizes + id: build - # - name: Run Forge tests - # run: | - # cd crates/evm/src/evm/system_contracts - # forge test -vvv - # id: test + - name: Run Forge tests + run: | + cd crates/evm/src/evm/system_contracts + forge test -vvv + id: test check_genesis_files: strategy: fail-fast: true diff --git a/resources/genesis/bitcoin-regtest/evm.json b/resources/genesis/bitcoin-regtest/evm.json index 276379a61..9912585bd 100644 --- a/resources/genesis/bitcoin-regtest/evm.json +++ b/resources/genesis/bitcoin-regtest/evm.json @@ -3,7 +3,7 @@ { "address": "0x0f820f428ae436c1000b27577bf5bbf09bfec8f2", "balance": "0xffffffffffffffffffffffffffffff", - "code": "0x00" + "code": "0x" }, { "address": "0x3100000000000000000000000000000000000001", From 76fb4242a41e2cf16016c908df43953701e3a8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 10:58:38 +0300 Subject: [PATCH 08/12] Reduces unnecessary sleep --- .github/scripts/check_genesis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/check_genesis.sh b/.github/scripts/check_genesis.sh index 0e5a0cfe6..81b7e85a4 100755 --- a/.github/scripts/check_genesis.sh +++ b/.github/scripts/check_genesis.sh @@ -27,7 +27,7 @@ do cp -r "$path" "${path}_tmp" done -sleep 5 +sleep 1 # Run make command make genesis From d0164ed7a606eb4bb4ec7f97f2343332e6dc6269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 12:36:00 +0300 Subject: [PATCH 09/12] New script using git diff --- .github/scripts/check_genesis.sh | 47 +++----------------------------- .github/workflows/checks.yml | 4 +++ 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/.github/scripts/check_genesis.sh b/.github/scripts/check_genesis.sh index 81b7e85a4..65671097f 100755 --- a/.github/scripts/check_genesis.sh +++ b/.github/scripts/check_genesis.sh @@ -1,52 +1,13 @@ #!/bin/bash -# Paths -paths=( "./resources/genesis/bitcoin-regtest/evm.json" - "./resources/genesis/mock/evm.json" - "./resources/genesis/mock-dockerized/evm.json" - "./resources/test-data/demo-tests/bitcoin-regtest/evm.json" - "./resources/test-data/demo-tests/mock/evm.json" - "./resources/test-data/integration-tests/evm.json" - "./resources/test-data/integration-tests-low-block-gas-limit/evm.json" - "./resources/test-data/integration-tests-low-max-l2-blocks-per-l1/evm.json") - -# Function to clean up copied directories -cleanup() { - for path in "${paths[@]}"; - do - rm -rf "${path}_tmp" - done -} -cleanup - -sleep 1 - -# Copy directories -for path in "${paths[@]}"; -do - cp -r "$path" "${path}_tmp" -done - -sleep 1 - # Run make command make genesis -# Compare directories -for path in "${paths[@]}"; -do - diff -r "$path" "${path}_tmp" - if [ $? -ne 0 ]; then - echo "Error: Differences found between $path and ${path}_tmp" - cleanup - exit 1 - fi -done - -echo "All directories are identical." sleep 1 -# Clean up copied directories -cleanup +# Check if script generates different genesis +git diff --exit-code + +echo "All directories are identical." exit 0 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 926e190f1..3a65ce3cd 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -444,6 +444,10 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.x' + + - name: Install Git + run: sudo apt-get update && sudo apt-get install -y git + shell: bash - name: Run check_genesis.sh run: ./.github/scripts/check_genesis.sh From 223e748fea009237e791b85ea802aa4413f5db2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 12:40:38 +0300 Subject: [PATCH 10/12] Test ci works --- .github/scripts/check_genesis.sh | 2 +- resources/genesis/bitcoin-regtest/evm.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/check_genesis.sh b/.github/scripts/check_genesis.sh index 65671097f..ecd55bb6d 100755 --- a/.github/scripts/check_genesis.sh +++ b/.github/scripts/check_genesis.sh @@ -6,7 +6,7 @@ make genesis sleep 1 # Check if script generates different genesis -git diff --exit-code +git diff --exit-code ./resources/ echo "All directories are identical." diff --git a/resources/genesis/bitcoin-regtest/evm.json b/resources/genesis/bitcoin-regtest/evm.json index 9912585bd..276379a61 100644 --- a/resources/genesis/bitcoin-regtest/evm.json +++ b/resources/genesis/bitcoin-regtest/evm.json @@ -3,7 +3,7 @@ { "address": "0x0f820f428ae436c1000b27577bf5bbf09bfec8f2", "balance": "0xffffffffffffffffffffffffffffff", - "code": "0x" + "code": "0x00" }, { "address": "0x3100000000000000000000000000000000000001", From 1c3e224cb918dad7bb5c228a51e3c87f5424f6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 12:45:47 +0300 Subject: [PATCH 11/12] Test ci --- .github/scripts/check_genesis.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/scripts/check_genesis.sh b/.github/scripts/check_genesis.sh index ecd55bb6d..5b2dbf352 100755 --- a/.github/scripts/check_genesis.sh +++ b/.github/scripts/check_genesis.sh @@ -8,6 +8,11 @@ sleep 1 # Check if script generates different genesis git diff --exit-code ./resources/ +if [ $? -ne 0 ]; then + echo "Differences found in genesis files." + exit 1 +fi + echo "All directories are identical." exit 0 From c94d79b6603d5208d7114adf0ac7e15f1751c30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 19 Jul 2024 12:49:23 +0300 Subject: [PATCH 12/12] CI should work --- .github/workflows/checks.yml | 4 ---- resources/genesis/bitcoin-regtest/evm.json | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3a65ce3cd..926e190f1 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -444,10 +444,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.x' - - - name: Install Git - run: sudo apt-get update && sudo apt-get install -y git - shell: bash - name: Run check_genesis.sh run: ./.github/scripts/check_genesis.sh diff --git a/resources/genesis/bitcoin-regtest/evm.json b/resources/genesis/bitcoin-regtest/evm.json index 276379a61..9912585bd 100644 --- a/resources/genesis/bitcoin-regtest/evm.json +++ b/resources/genesis/bitcoin-regtest/evm.json @@ -3,7 +3,7 @@ { "address": "0x0f820f428ae436c1000b27577bf5bbf09bfec8f2", "balance": "0xffffffffffffffffffffffffffffff", - "code": "0x00" + "code": "0x" }, { "address": "0x3100000000000000000000000000000000000001",