diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml deleted file mode 100644 index e24d48ae5..000000000 --- a/.github/workflows/dependencies.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Runs `cargo update` periodically. - -name: Update Dependencies - -on: - schedule: - # Run at the first of every month - - cron: "0 0 1 * *" - workflow_dispatch: - # Needed so we can run it manually - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: cargo-update - TITLE: "chore(deps): monthly `cargo update`" - BODY: | - Automation to keep dependencies in `Cargo.lock` current. - -
cargo update log -

- - ```log - $cargo_update_log - ``` - -

-
- -jobs: - update: - name: Update - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: nightly-2024-07-27 - - - name: cargo update - # Remove first line that always just says "Updating crates.io index" - run: cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log - - - name: craft commit message and PR body - id: msg - run: | - export cargo_update_log="$(cat cargo_update.log)" - - echo "commit_message<> $GITHUB_OUTPUT - printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - echo "body<> $GITHUB_OUTPUT - echo "$BODY" | envsubst >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v7 - with: - add-paths: ./Cargo.lock - commit-message: ${{ steps.msg.outputs.commit_message }} - title: ${{ env.TITLE }} - body: ${{ steps.msg.outputs.body }} - branch: ${{ env.BRANCH }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 31c4bbda7..000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Docs - -on: - pull_request: - merge_group: - push: - branches: [main] - -env: - CARGO_TERM_COLOR: always - -jobs: - docs: - name: Generate docs - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: nightly-2024-07-27 - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Check docs leaving the dependencies out - env: - RUSTDOCFLAGS: --show-type-layout --enable-index-page -Zunstable-options -A rustdoc::private-doc-tests -D warnings - run: cargo doc --workspace --no-deps diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml deleted file mode 100644 index 4655f02fe..000000000 --- a/.github/workflows/functional.yml +++ /dev/null @@ -1,139 +0,0 @@ -name: Run functional tests - -on: - pull_request: - merge_group: - push: - branches: [main] - -env: - CARGO_TERM_COLOR: always -jobs: - lint: - name: Lint test files - runs-on: ubuntu-latest - timeout-minutes: 60 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - id: setup-python - with: - python-version: "^3.10" # Keep in sync with `pyproject.toml` - - - name: Install poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v4 - with: - path: functional-tests/.venv - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - - - name: Install dependencies - working-directory: functional-tests - #if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' # this was giving issues in cache - run: poetry install --no-root --no-interaction - - - name: Check formatting - working-directory: functional-tests - run: poetry run ruff format --check - - - name: Lint - working-directory: functional-tests - run: poetry run ruff check - - run: - name: Run functional tests - runs-on: ubuntu-latest - timeout-minutes: 60 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Cleanup Space - uses: ./.github/actions/cleanup - - - name: Install bitcoind - env: - BITCOIND_VERSION: "28.0" - BITCOIND_ARCH: "x86_64-linux-gnu" - SHASUM: "7fe294b02b25b51acb8e8e0a0eb5af6bbafa7cd0c5b0e5fcbb61263104a82fbc" - run: | - curl -fsSLO --proto "=https" --tlsv1.2 "https://bitcoincore.org/bin/bitcoin-core-${{ env.BITCOIND_VERSION }}/bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" - sha256sum -c <<< "$SHASUM bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" - tar xzf "bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" - sudo install -m 0755 -t /usr/local/bin bitcoin-${{ env.BITCOIND_VERSION }}/bin/* - bitcoind --version - rm -rf "bitcoin-${{ env.BITCOIND_VERSION }}" "bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" - - - name: Set up Python - uses: actions/setup-python@v5 - id: setup-python - with: - python-version: "^3.10" # Keep in sync with `pyproject.toml` - - - name: Install poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v4 - with: - path: functional-tests/.venv - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - - - name: Install dependencies - working-directory: functional-tests - #if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' # this was giving issues in cache - run: poetry install --no-root --no-interaction - - - name: Set up Rust - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: nightly-2024-07-27 - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Build Cargo project - run: cargo build --locked - - - name: Run functional tests (1) - id: funcTestsRun1 - continue-on-error: true - run: | - export PATH=$(realpath target/debug/):$PATH - which strata-client - cd functional-tests && \ - poetry run python entry.py - - # Run again just to be sure as some tests are flaky - - name: Run functional tests (2) - if: steps.funcTestsRun1.outcome == 'failure' - run: | - export PATH=$(realpath target/debug/):$PATH - which strata-client - cd functional-tests && \ - poetry run python entry.py - - functional-tests-success: - name: Check that all checks pass - runs-on: ubuntu-latest - if: always() - needs: [lint, run] - timeout-minutes: 60 - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 - with: - jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml deleted file mode 100644 index e223fbf7d..000000000 --- a/.github/workflows/integration.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Runs integration tests. - -name: Integration Tests - -on: - pull_request: - merge_group: - push: - branches: [main] - -env: - CARGO_TERM_COLOR: always - RUST_LOG: debug - RUST_BACKTRACE: full - -jobs: - test: - name: Run integration tests and generate report - runs-on: ubuntu-latest - timeout-minutes: 60 # better fail-safe than the default 360 in github actions - steps: - - uses: actions/checkout@v4 - - - name: Cleanup space - uses: ./.github/actions/cleanup - - - uses: dtolnay/rust-toolchain@nightly - - name: Install latest nextest release - uses: taiki-e/install-action@v2 - with: - tool: nextest - - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Run tests - run: | - cargo nextest run -p integration-tests --locked --profile ci --no-capture - - name: Test Summary - uses: test-summary/action@v2 - if: always() - with: - paths: "target/nextest/ci/junit.xml" diff --git a/.github/workflows/lint-actions.yml b/.github/workflows/lint-actions.yml deleted file mode 100644 index bad2e7698..000000000 --- a/.github/workflows/lint-actions.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Lint GitHub Actions workflows -on: - pull_request: - paths: - - ".github/**" - merge_group: - push: - paths: - - ".github/**" - -jobs: - actionlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Download actionlint - id: get_actionlint - run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) - shell: bash - - name: Check workflow files - run: SHELLCHECK_OPTS="-S error" ${{ steps.get_actionlint.outputs.executable }} -color - shell: bash diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index f551338b6..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Lint - -on: - pull_request: - merge_group: - push: - branches: [main] - -env: - CARGO_TERM_COLOR: always - -jobs: - clippy: - name: Run clippy on crates - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@clippy - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - run: cargo clippy --workspace --lib --examples --tests --benches --all-features --all-targets --locked - env: - RUSTFLAGS: -D warnings - - crate-checks: - name: Check that crates compile on their own - runs-on: ubuntu-latest - timeout-minutes: 90 # cold run takes a lot of time as each crate is compiled separately - steps: - - uses: actions/checkout@v4 - - - name: Cleanup space - uses: ./.github/actions/cleanup - - - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: nightly-2024-07-27 - - uses: taiki-e/install-action@cargo-hack - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Configure sccache - run: | - echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.6 - with: - version: "v0.8.1" # sccache version - - - run: cargo hack check --locked - - fmt: - name: Check code formatting - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - with: - components: rustfmt - toolchain: nightly-2024-07-27 - - run: cargo fmt --all --check - - codespell: - name: Check code spellings - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: codespell-project/actions-codespell@v2 - - taplo: - name: Lint and check formatting of TOML files - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - name: Install taplo - run: | - curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz \ - | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo - - name: Run taplo lint - run: | - taplo lint - - name: Run taplo format check - run: | - taplo fmt --check - - lint-success: - name: Check that lints passed - runs-on: ubuntu-latest - if: always() - needs: - - clippy - - crate-checks - - fmt - - codespell - - taplo - timeout-minutes: 30 - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 - with: - jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml deleted file mode 100644 index 1c84f2c2e..000000000 --- a/.github/workflows/mutants.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Runs mutants tests. - -name: Mutants Tests - -on: - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - DEFAULT_BRANCH: main - -concurrency: - group: ${{ github.workflow }}-${{ github.run_id }} - cancel-in-progress: true - -jobs: - mutants-test: - name: Generate mutants on diff against default branch and test - runs-on: ubuntu-latest - continue-on-error: true # FIXME: remove this if all mutants are covered - strategy: - fail-fast: false # Collect all mutants even if some are missed - matrix: - shard: [0, 1, 2, 3, 4, 5, 6, 7] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Relative diff - run: | - git branch -av - git diff origin/$DEFAULT_BRANCH | tee git.diff - - uses: Swatinem/rust-cache@v2 - - uses: taiki-e/install-action@v2 - name: Install `cargo-mutants` - with: - tool: cargo-mutants - - name: Run `cargo-mutants` - run: | - cargo mutants --no-shuffle -vV --in-diff git.diff --shard ${{ matrix.shard }}/8 --timeout 300 - - name: Archive mutants.out - uses: actions/upload-artifact@v4 - if: always() - with: - name: mutants-incremental.out - path: mutants-shard${{ matrix.shard }}.out - overwrite: true diff --git a/.github/workflows/prover.yml b/.github/workflows/prover.yml new file mode 100644 index 000000000..b5a8654b7 --- /dev/null +++ b/.github/workflows/prover.yml @@ -0,0 +1,41 @@ +name: Run prover guest code checks + +on: + pull_request: + merge_group: + push: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Set up Rust + uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2024-07-27 + + # Installs mold (modern ld), a drop-in replacement for lld. + # Under the hood, the following actions symlinks mold binary onto lld, + # so everything is linked faster (hopefully). + - name: Install mold linker + uses: rui314/setup-mold@v1 + + - name: Set up Clang + uses: egor-tensin/setup-clang@v1 + with: + version: latest + platform: x64 + + - name: Install SP1 Toolchain + run: | + curl -L https://sp1.succinct.xyz | bash && ~/.sp1/bin/sp1up + export PATH=~/.sp1/bin:$PATH + cargo prove --version + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build guest code + run: cd provers/sp1/ && RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo build --profile prover-ci -F "prover" diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml deleted file mode 100644 index 7abcc216d..000000000 --- a/.github/workflows/security.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Security - -on: - pull_request: - merge_group: - push: - branches: [main] - -env: - CARGO_TERM_COLOR: always - -jobs: - supply-chain: - name: Run `cargo-audit` - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@clippy - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - # HACK: v0.21.0 fails during dependency resolution. Remove when this is resolved - # https://github.com/rustsec/rustsec/issues/1249#issuecomment-2423257490 - - name: Install cargo-audit v0.20.0 - run: cargo install cargo-audit --version 0.20.0 --force - - # HACK: not denying warnings as we depend on `yaml-rust` via `format-serde-error` which is unmaintained - - name: Check for audit warnings - run: cargo audit -D warnings - continue-on-error: true - - # HACK: re-run without denying warnings so that we don't miss any vulnerabilities - - name: Check for vulnerabilities - run: cargo audit diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml deleted file mode 100644 index f3b2e6cbf..000000000 --- a/.github/workflows/unit.yml +++ /dev/null @@ -1,92 +0,0 @@ -# Runs unit tests. - -name: Unit Tests - -on: - pull_request: - merge_group: - push: - branches: [main] - -env: - CARGO_TERM_COLOR: always - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - test: - name: Run unit tests and generate report - runs-on: ubuntu-latest - timeout-minutes: 60 # better fail-safe than the default 360 in github actions - steps: - - uses: actions/checkout@v4 - - - name: Cleanup space - uses: ./.github/actions/cleanup - - - uses: dtolnay/rust-toolchain@nightly - with: - components: llvm-tools-preview - toolchain: nightly-2024-07-27 - - name: Install latest nextest release - uses: taiki-e/install-action@v2 - with: - tool: nextest - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@v2 - with: - tool: cargo-llvm-cov - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Run tests with coverage - run: | - cargo llvm-cov --workspace --locked nextest --profile ci --lcov --output-path lcov.info - - - name: Test Summary - uses: test-summary/action@v2 - if: always() - with: - paths: "target/nextest/ci/junit.xml" - - name: Publish Test Coverage - uses: codecov/codecov-action@v5.0.7 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - files: lcov.info - - doc: - name: Run doc tests - runs-on: ubuntu-latest - env: - RUST_BACKTRACE: 1 - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - - name: Cleanup space - uses: ./.github/actions/cleanup - - - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: nightly-2024-07-27 - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - - name: Run doctests - run: cargo test --doc --workspace - - unit-success: - name: Check that unit tests pass - runs-on: ubuntu-latest - if: always() - needs: [test, doc] - timeout-minutes: 60 - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 - with: - jobs: ${{ toJSON(needs) }} diff --git a/Cargo.toml b/Cargo.toml index bfa8ef844..405e4d9f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -242,3 +242,10 @@ uuid = { version = "1.0", features = ["v4", "serde"] } # This is needed for custom build of SP1 [profile.release.build-override] opt-level = 3 + +# This shall be used only in the CI for the prover to optimize the build time. +[profile.prover-ci] +inherits = "release" +opt-level = 0 +lto = "off" +strip = true diff --git a/provers/sp1/build.rs b/provers/sp1/build.rs index 84d50f7b7..84bc200bf 100644 --- a/provers/sp1/build.rs +++ b/provers/sp1/build.rs @@ -234,10 +234,32 @@ fn generate_elf_contents_and_vk_hash(program: &str) -> ([u32; 8], String) { } }; + let rustflags = { + #[cfg(feature = "prover")] + { + //vec![] + vec![ + //"-C".to_string(), + //"linker=clang".to_string(), + //"-C".to_string(), + //"link-arg=-fuse-ld=/usr/bin/ldd".to_string(), + "-C".to_string(), + "link-arg=--dynamic-linker=/usr/local/bin/mold".to_string() + //"-C".to_string(), + //"link-arg=--target2=riscv32".to_string(), + ] + } + #[cfg(not(feature = "prover"))] + { + vec![] + } + }; + let build_args = BuildArgs { elf_name: format!("{}.elf", program), output_directory: "cache".to_owned(), features, + rustflags, ..Default::default() };