diff --git a/.github/workflows/audit-check.yml b/.github/workflows/audit-check.yml deleted file mode 100644 index 332799198..000000000 --- a/.github/workflows/audit-check.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Security audit -on: - pull_request: - branches: - - "**" - -jobs: - security_audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: cargo audit - run: cargo audit --ignore RUSTSEC-2023-0071 diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index cf1ad22fd..000000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,136 +0,0 @@ -name: Tests - -on: - push: - branches: - - main - tags: - - "**" - pull_request: - branches: - - "**" - -jobs: - tests: - name: Unit Tests - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - uses: chia-network/actions/setup-python@main - name: Install Python ${{ matrix.python-version }} - with: - python-version: ${{ matrix.python-version }} - - - name: Update pip - run: | - python -m pip install --upgrade pip - - - name: Set up rust - uses: dtolnay/rust-toolchain@stable - - - name: setup venv - run: | - python -m venv venv - - - uses: chia-network/actions/activate-venv@main - - - name: Install dependencies - run: | - python -m pip install maturin - rustup target add x86_64-unknown-linux-musl - python -m pip install pytest pytest-xdist - python -m pip install mypy - python -m pip install black - - - name: Build - run: | - python -m pip install clvm_tools colorama blspy chia-blockchain==2.1.2 clvm==0.9.8 - maturin develop --release -m wheel/Cargo.toml - - - name: python mypy - run: | - mypy --ignore-missing-imports tests - - - name: python black - run: | - black --check tests - black --check wheel/generate_type_stubs.py - - - name: python tests - run: | - pytest tests - - generator-benchmarks: - name: Generator performance - runs-on: benchmark - strategy: - fail-fast: false - matrix: - python-version: ["3.10", "3.11"] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - uses: chia-network/actions/setup-python@main - name: Install Python ${{ matrix.python-version }} - with: - python-version: ${{ matrix.python-version }} - - - name: Set up rust - uses: dtolnay/rust-toolchain@stable - - - name: setup venv - run: | - python -m venv venv - - - uses: chia-network/actions/activate-venv@main - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install maturin colorama clvm_tools - rustup target add x86_64-unknown-linux-musl - - - name: Build - run: | - maturin develop --release -m wheel/Cargo.toml - - - name: test generators - run: | - cd tests - ./test-generators.py - - - name: Run cost checks - run: | - cd tests - ./generate-programs.py - ./run-programs.py - - benchmarks: - name: rust benchmarks - runs-on: benchmark - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Set up rust - uses: dtolnay/rust-toolchain@stable - - - name: cargo bench - run: | - cargo bench --workspace --exclude chia_rs diff --git a/.github/workflows/build-crate-and-npm.yml b/.github/workflows/build-crate-and-npm.yml deleted file mode 100644 index 3b9d79d2f..000000000 --- a/.github/workflows/build-crate-and-npm.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build crate and npm package - -on: - push: - branches: - - main - tags: - - "**" - pull_request: - branches: - - "**" - -jobs: - build_crate: - name: Crate & NPM - runs-on: ubuntu-latest - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up rusts - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy - - - name: fmt - run: cargo fmt -- --files-with-diff --check - - name: clippy - run: cargo clippy - - name: tests - run: cargo test && cargo test --release - - name: build - run: cargo build --release - - - name: Upload crate artifacts - uses: actions/upload-artifact@v4 - with: - name: crate - path: ./target/package/*-*.crate - - - name: install wasm-pack - run: cargo install wasm-pack --locked - - - name: wasm-pack build and pack - run: cd wasm && wasm-pack build && wasm-pack pack - - - name: Upload npm pkg artifacts - uses: actions/upload-artifact@v4 - with: - name: npm-pkg - path: ./wasm/pkg/*-*.tgz - - - name: publish to crates.io if tagged - if: startsWith(github.event.ref, 'refs/tags') - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }} - run: | - cargo install cargo-workspaces --locked - cargo ws publish --publish-as-is - - # this has not been tested, so probably needs to be debugged next time a tag is created - - name: publish to npmjs.com if tagged - if: startsWith(github.event.ref, 'refs/tags') - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.node_auth_token }} - package: wasm/pkg/package.json diff --git a/.github/workflows/build-riscv64.yml b/.github/workflows/build-riscv64.yml index 4099724be..c9dcbfb73 100644 --- a/.github/workflows/build-riscv64.yml +++ b/.github/workflows/build-riscv64.yml @@ -1,4 +1,4 @@ -name: QEMU Build and test riscv64 crate +name: Python wheel (QEMU RISCV-64) on: push: @@ -15,18 +15,15 @@ permissions: contents: read jobs: - build_crate: - name: Build riscv64 crate and run tests + test-riscv64: + name: Test runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest] steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: actions/checkout@v4 - name: Set up QEMU on x86_64 id: qemu @@ -43,8 +40,8 @@ jobs: cargo test --release -p chia-consensus ' - build_wheels: - name: ${{ matrix.os }} 📦 Build Wheel ${{ matrix.python.major-dot-minor }} + build-wheels: + name: Wheel (${{ matrix.os }} ${{ matrix.python.major-dot-minor }}) runs-on: ${{ matrix.os }} strategy: matrix: @@ -60,10 +57,7 @@ jobs: matrix: "3.11" steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: actions/checkout@v4 - name: Set up QEMU on x86_64 id: qemu @@ -91,18 +85,16 @@ jobs: name: packages-${{ matrix.os }}-${{ matrix.python.major-dot-minor }} path: ./target/wheels if-no-files-found: error + upload: name: Upload to Chia PyPI runs-on: ubuntu-latest needs: - - build_wheels + - build-wheels steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - - name: Set Env + - name: Set env uses: Chia-Network/actions/setjobenv@main env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 29387b657..d568759e4 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -14,8 +14,6 @@ jobs: prettier: name: Prettier runs-on: ubuntu-latest - strategy: - fail-fast: false steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/build-test.yml b/.github/workflows/python.yml similarity index 65% rename from .github/workflows/build-test.yml rename to .github/workflows/python.yml index 006c20dfb..dc6d38dc5 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/python.yml @@ -1,4 +1,4 @@ -name: build - check - upload +name: Python on: push: @@ -20,8 +20,8 @@ permissions: contents: read jobs: - build-wheels: - name: Wheel - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + build-wheel: + name: Wheel (${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }}) runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} strategy: fail-fast: false @@ -126,27 +126,19 @@ jobs: - name: Clean workspace uses: Chia-Network/actions/clean-workspace@main - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - uses: Chia-Network/actions/setup-python@main with: python-version: ${{ matrix.python.major-dot-minor }} - - name: Update pip - run: | - python -m pip install --upgrade pip - - - name: Set up rust + - name: Set up Rust uses: dtolnay/rust-toolchain@stable - name: Install dependencies - run: | - python -m pip install maturin + run: pip install maturin - - name: Build MacOs with maturin on Python ${{ matrix.python }} + - name: MacOS wheel (Python ${{ matrix.python }}) if: matrix.os.matrix == 'macos' env: MACOSX_DEPLOYMENT_TARGET: "11.0" @@ -155,7 +147,7 @@ jobs: . venv/bin/activate maturin build -i python --release -m wheel/Cargo.toml - - name: Build Linux with maturin on Python ${{ matrix.python }} + - name: Linux wheel (Python ${{ matrix.python }}) if: matrix.os.matrix == 'ubuntu' run: | docker run --rm --pull always \ @@ -172,7 +164,7 @@ jobs: CC=gcc maturin build --release --manylinux ${{ matrix.python.by-arch[matrix.arch.matrix].manylinux-version }} -m wheel/Cargo.toml \ ' - - name: Build Windows with maturin on Python ${{ matrix.python }} + - name: Windows wheel (Python ${{ matrix.python }}) if: matrix.os.matrix == 'windows' env: CC: "clang" @@ -189,7 +181,7 @@ jobs: with: directories: ${{ steps.create-venv.outputs.activate-venv-directories }} - - name: Install chia_rs wheel + - name: Install wheel run: | pip install --no-index --find-links target/wheels/ chia_rs @@ -202,12 +194,8 @@ jobs: check-typestubs: name: Check chia_rs.pyi runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - uses: Chia-Network/actions/setup-python@main @@ -216,25 +204,8 @@ jobs: python wheel/generate_type_stubs.py git diff --exit-code - build-tools: - name: build chia-tools - runs-on: ubuntu-latest - steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: cargo build - run: | - cd crates/chia-tools - cargo build - build-sdist: - name: sdist - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + name: Build sdist (${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }}) runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} strategy: fail-fast: false @@ -256,10 +227,7 @@ jobs: - name: Clean workspace uses: Chia-Network/actions/clean-workspace@main - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - uses: Chia-Network/actions/setup-python@main with: @@ -276,135 +244,105 @@ jobs: name: packages-sdist-${{ matrix.os.name }}-${{ matrix.python.major-dot-minor }}-${{ matrix.arch.name }} path: ./target/wheels/ - fmt: + lint: + name: Lint runs-on: ubuntu-latest - name: cargo fmt steps: - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Install rust - uses: dtolnay/rust-toolchain@stable + - uses: chia-network/actions/setup-python@main + name: Install Python 3.12 with: - components: rustfmt, clippy + python-version: 3.12 - - name: fmt - run: | - cargo fmt --all -- --files-with-diff --check - cd wheel - cargo fmt -- --files-with-diff --check - - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy + - name: Install dependencies + run: pip install mypy black - - name: workspace - run: | - cargo clippy --workspace --all-features --all-targets + - name: python mypy + run: mypy --ignore-missing-imports tests - fuzz_targets: - runs-on: ubuntu-latest - env: - CARGO_PROFILE_RELEASE_LTO: false - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@nightly - - name: cargo-fuzz - run: cargo +nightly install cargo-fuzz - - name: cargo fuzz (chia-consensus) - run: | - cd crates/chia-consensus - cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" - - name: cargo fuzz (chia-bls) - env: - # we disable leak reports here because blspy appears to be allocating - # memory that's not freed. It might be a false positive since python is - # not unloaded before exiting - LSAN_OPTIONS: detect_leaks=0 + - name: python black run: | - cd crates/chia-bls - python -m pip install blspy - cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=10 || exit 255" - - name: cargo fuzz (clvm-utils) - run: | - cd crates/clvm-utils - cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" - - name: cargo fuzz (chia-protocol) - run: | - cd crates/chia-protocol - cargo +nightly fuzz build - cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" - - name: cargo fuzz (chia-puzzles) - run: | - cd crates/chia-puzzles - cargo +nightly fuzz build - cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" + black --check tests + black --check wheel/generate_type_stubs.py - unit_tests: + unit-tests: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] - name: Unit tests + python-version: ["3.8", "3.9", "3.10", "3.11"] + name: Tests (${{ matrix.os }} ${{ matrix.python-version }}) steps: - # the test files are read verbatim, making it problematic if git is - # allowed to insert \r when checking out files - - name: disable git autocrlf - run: | - git config --global core.autocrlf false + # The test files are read verbatim, making it problematic if git is + # allowed to insert \r when checking out files. + - name: Disable git autocrlf + run: git config --global core.autocrlf false - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - uses: dtolnay/rust-toolchain@stable - - name: Prepare for coverage - if: matrix.os == 'ubuntu-latest' - run: | - cargo install grcov --locked - echo "RUSTFLAGS=-Cinstrument-coverage" >> "$GITHUB_ENV" - echo "LLVM_PROFILE_FILE=$(pwd)/target/chia_rs-%p-%m.profraw" >> "$GITHUB_ENV" - echo "CARGO_TARGET_DIR=$(pwd)/target" >> "$GITHUB_ENV" - - name: cargo test - run: cargo test --workspace --all-features - - name: cargo test (release) - run: cargo test --workspace --all-features --release - - name: Continue with coverage + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + + - name: Pytest if: matrix.os == 'ubuntu-latest' run: | - sudo apt-get update - sudo apt-get install lcov -y - rustup component add llvm-tools-preview python -m venv venv source venv/bin/activate - git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch - pip install ./clvm_tools - pip install colorama maturin pytest pytest-xdist chia-blockchain==2.1.2 clvm==0.9.8 + pip install clvm-tools colorama maturin pytest pytest-xdist chia-blockchain==2.1.2 clvm==0.9.8 maturin develop --release -m wheel/Cargo.toml pytest tests - grcov . --binary-path target -s . --branch --ignore-not-existing --ignore='*/.cargo/*' --ignore='tests/*' --ignore='venv/*' -o rust_cov.info - python -c 'with open("rust_cov.info") as f: lines = [l for l in f if not (l.startswith("DA:") and int(l.split(",")[1].strip()) >= 2**63)]; open("lcov.info", "w").writelines(lines)' - - name: Upload to Coveralls - uses: coverallsapp/github-action@v2 - if: matrix.os == 'ubuntu-latest' - env: - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + + generator-benchmarks: + name: Benchmark generators + runs-on: benchmark + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + + - uses: chia-network/actions/setup-python@main + name: Install Python ${{ matrix.python-version }} with: - path-to-lcov: "./lcov.info" + python-version: ${{ matrix.python-version }} + + - name: Set up rust + uses: dtolnay/rust-toolchain@stable + + - name: setup venv + run: python -m venv venv + + - uses: chia-network/actions/activate-venv@main + + - name: Install dependencies + run: pip install maturin colorama clvm_tools + + - name: Build + run: maturin develop --release -m wheel/Cargo.toml + + - name: test generators + run: | + cd tests + ./test-generators.py + + - name: Run cost checks + run: | + cd tests + ./generate-programs.py + ./run-programs.py upload: name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} needs: - - build-wheels + - build-wheel - build-sdist - - fmt - - clippy - - unit_tests + - unit-tests + - check-typestubs strategy: fail-fast: false matrix: @@ -425,10 +363,7 @@ jobs: - name: Clean workspace uses: Chia-Network/actions/clean-workspace@main - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - uses: Chia-Network/actions/setup-python@main with: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 000000000..4728e0ab0 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,236 @@ +name: Rust + +on: + push: + branches: + - main + tags: + - "**" + pull_request: + branches: + - "**" + +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} + cancel-in-progress: true + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - uses: cargo-bins/cargo-binstall@main + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.5 + + - name: Rustfmt + run: cargo fmt --all -- --files-with-diff --check + + - name: Clippy + run: cargo clippy --workspace --all-targets --all-features + + - name: Audit + run: cargo audit --ignore RUSTSEC-2023-0071 + + - name: Install cargo-machete + run: cargo binstall cargo-machete -y + + - name: Unused dependencies + run: cargo machete + + - name: Display sccache stats + run: sccache --show-stats + + test: + name: Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + steps: + # The test files are read verbatim, making it problematic if git is + # allowed to insert \r when checking out files. + - name: Disable git autocrlf + run: git config --global core.autocrlf false + + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + + - uses: cargo-bins/cargo-binstall@main + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.5 + + - name: Prepare for coverage + if: matrix.os == 'ubuntu-latest' + run: | + cargo binstall grcov -y + echo "RUSTFLAGS=-Cinstrument-coverage" >> "$GITHUB_ENV" + echo "LLVM_PROFILE_FILE=$(pwd)/target/chia_rs-%p-%m.profraw" >> "$GITHUB_ENV" + echo "CARGO_TARGET_DIR=$(pwd)/target" >> "$GITHUB_ENV" + + - name: Run tests + run: cargo test --workspace --all-features --release + + - name: Continue with coverage + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get install lcov -y + rustup component add llvm-tools-preview + grcov . --binary-path target -s . --branch --ignore-not-existing --ignore='*/.cargo/*' --ignore='tests/*' --ignore='venv/*' -o rust_cov.info + python -c 'with open("rust_cov.info") as f: lines = [l for l in f if not (l.startswith("DA:") and int(l.split(",")[1].strip()) >= 2**63)]; open("lcov.info", "w").writelines(lines)' + + - name: Upload to Coveralls + uses: coverallsapp/github-action@v2 + if: matrix.os == 'ubuntu-latest' + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + with: + path-to-lcov: "./lcov.info" + + - name: Display sccache stats + run: sccache --show-stats + + publish: + name: Publish + needs: [lint, test] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + + - uses: cargo-bins/cargo-binstall@main + + - name: Build + run: cargo build --release + + - name: Upload crate artifacts + uses: actions/upload-artifact@v4 + with: + name: crate + path: ./target/package/*-*.crate + + - name: Install wasm-pack + run: cargo binstall wasm-pack -y + + - name: Build and pack wasm + run: | + cd wasm + wasm-pack build + wasm-pack pack + + - name: Upload NPM artifacts + uses: actions/upload-artifact@v4 + with: + name: npm-pkg + path: ./wasm/pkg/*-*.tgz + + - name: Install cargo-workspaces + run: cargo binstall cargo-workspaces -y + + - name: Publish to crates.io if tagged + if: startsWith(github.event.ref, 'refs/tags') + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }} + run: cargo ws publish --publish-as-is + + - name: Publish to npmjs.com if tagged + if: startsWith(github.event.ref, 'refs/tags') + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.node_auth_token }} + package: wasm/pkg/package.json + + benchmark: + name: Benchmark + runs-on: benchmark + env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.5 + + - name: Run benchmarks + run: cargo bench --workspace --exclude chia_rs + + - name: Display sccache stats + run: sccache --show-stats + + fuzz: + name: Fuzz + runs-on: ubuntu-latest + env: + CARGO_PROFILE_RELEASE_LTO: false + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@nightly + + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.5 + + - name: Install cargo-fuzz + run: cargo +nightly install cargo-fuzz + + - name: Fuzz chia-consensus + run: | + cd crates/chia-consensus + cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" + + - name: Fuzz chia-bls + env: + # We disable leak reports here because blspy appears to be allocating + # memory that's not freed. It might be a false positive since python is + # not unloaded before exiting. + LSAN_OPTIONS: detect_leaks=0 + run: | + cd crates/chia-bls + python -m pip install blspy + cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=10 || exit 255" + + - name: Fuzz clvm-utils + run: | + cd crates/clvm-utils + cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" + + - name: Fuzz chia-protocol + run: | + cd crates/chia-protocol + cargo +nightly fuzz build + cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" + + - name: Fuzz chia-puzzles + run: | + cd crates/chia-puzzles + cargo +nightly fuzz build + cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=20 || exit 255" + + - name: Display sccache stats + run: sccache --show-stats diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 569512d24..7cae2b4e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,12 @@ repos: entry: cargo clippy --workspace --all-features --all-targets language: system pass_filenames: false + - id: machete + name: machete + description: check for unused dependencies + entry: cargo machete + language: system + pass_filenames: false - id: build name: build description: run cargo build on the workspace diff --git a/Cargo.lock b/Cargo.lock index e4ede321e..3c233d335 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -311,7 +311,6 @@ dependencies = [ name = "chia-bls" version = "0.10.0" dependencies = [ - "anyhow", "arbitrary", "blst", "chia-traits 0.10.0", @@ -359,7 +358,6 @@ dependencies = [ "chia-traits 0.10.0", "chia_py_streamable_macro", "chia_streamable_macro 0.10.0", - "clvm-derive", "clvm-traits", "clvm-utils", "clvmr", @@ -445,7 +443,6 @@ dependencies = [ "clvm-traits", "clvmr", "libfuzzer-sys", - "pyo3", ] [[package]] @@ -475,7 +472,6 @@ dependencies = [ "clvm-utils", "clvmr", "hex", - "hex-literal", "rusqlite", "zstd", ] @@ -519,15 +515,10 @@ dependencies = [ "chia-bls 0.10.0", "chia-consensus", "chia-protocol", - "chia-traits 0.10.0", - "chia_py_streamable_macro", - "chia_streamable_macro 0.10.0", - "clvm-traits", "clvm-utils", "clvmr", "hex", "pyo3", - "sha2", ] [[package]] diff --git a/crates/chia-bls/Cargo.toml b/crates/chia-bls/Cargo.toml index 8bb42ce23..f967eec1f 100644 --- a/crates/chia-bls/Cargo.toml +++ b/crates/chia-bls/Cargo.toml @@ -18,7 +18,6 @@ arbitrary = ["dep:arbitrary"] [dependencies] chia-traits = { workspace = true } chia_py_streamable_macro = { workspace = true, optional = true } -anyhow = { workspace = true } sha2 = { workspace = true } hkdf = { workspace = true } blst = { workspace = true } diff --git a/crates/chia-consensus/Cargo.toml b/crates/chia-consensus/Cargo.toml index 825dc1a31..5ff81e937 100644 --- a/crates/chia-consensus/Cargo.toml +++ b/crates/chia-consensus/Cargo.toml @@ -24,7 +24,6 @@ chia_py_streamable_macro = { workspace = true, optional = true } clvm-utils = { workspace = true } chia-traits = { workspace = true } clvm-traits = { workspace = true } -clvm-derive = { workspace = true } chia-protocol = { workspace = true } chia-puzzles = { workspace = true } chia-bls = { workspace = true } diff --git a/crates/chia-consensus/fuzz/Cargo.toml b/crates/chia-consensus/fuzz/Cargo.toml index 9f5567078..7374f557c 100644 --- a/crates/chia-consensus/fuzz/Cargo.toml +++ b/crates/chia-consensus/fuzz/Cargo.toml @@ -21,10 +21,6 @@ chia-traits = { workspace = true } chia-consensus = { workspace = true } hex-literal = { workspace = true } -[lib] -name = "fuzzing_utils" -crate-type = ["rlib"] - [[bin]] name = "puzzle-coin-solution" path = "fuzz_targets/puzzle-coin-solution.rs" diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs index c44abc911..73cf83112 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::conditions::parse_args; +use chia_fuzz::{make_list, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_list, BitCursor}; use chia_consensus::gen::flags::{ENABLE_MESSAGE_CONDITIONS, STRICT_ARGS_COUNT}; diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs index 031445e29..1214d138c 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs @@ -6,11 +6,11 @@ use chia_consensus::gen::conditions::{ parse_conditions, MempoolVisitor, ParseState, Spend, SpendBundleConditions, }; use chia_consensus::gen::spend_visitor::SpendVisitor; +use chia_fuzz::{make_list, BitCursor}; use chia_protocol::Bytes32; use chia_protocol::Coin; use clvm_utils::tree_hash; use clvmr::{Allocator, NodePtr}; -use fuzzing_utils::{make_list, BitCursor}; use std::collections::HashSet; use std::sync::Arc; diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs index 3567d4134..fbfb8e324 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::messages::SpendId; +use chia_fuzz::{make_list, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_list, BitCursor}; fuzz_target!(|data: &[u8]| { let mut a = Allocator::new(); diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs index 62e255fb9..f055c5740 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::get_puzzle_and_solution::parse_coin_spend; +use chia_fuzz::{make_list, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_list, BitCursor}; fuzz_target!(|data: &[u8]| { let mut a = Allocator::new(); diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs index 8839bba95..29db813cd 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::conditions::{parse_spends, MempoolVisitor}; +use chia_fuzz::{make_list, BitCursor}; use clvmr::{Allocator, NodePtr}; -use fuzzing_utils::{make_list, BitCursor}; use chia_consensus::consensus_constants::TEST_CONSTANTS; use chia_consensus::gen::flags::{ENABLE_MESSAGE_CONDITIONS, NO_UNKNOWN_CONDS, STRICT_ARGS_COUNT}; diff --git a/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs b/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs index 134ac76e7..8be826dde 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs @@ -4,8 +4,8 @@ use chia_consensus::gen::conditions::{ process_single_spend, MempoolVisitor, ParseState, SpendBundleConditions, }; use chia_consensus::gen::flags::{NO_UNKNOWN_CONDS, STRICT_ARGS_COUNT}; +use chia_fuzz::{make_tree, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_tree, BitCursor}; use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { diff --git a/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs b/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs index 956e02140..818c30f76 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::get_puzzle_and_solution::get_puzzle_and_solution_for_coin; +use chia_fuzz::{make_tree, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_tree, BitCursor}; const HASH: [u8; 32] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/crates/chia-puzzles/fuzz/Cargo.toml b/crates/chia-puzzles/fuzz/Cargo.toml index 3aa2860f2..df0c535a8 100644 --- a/crates/chia-puzzles/fuzz/Cargo.toml +++ b/crates/chia-puzzles/fuzz/Cargo.toml @@ -14,7 +14,6 @@ workspace = true [dependencies] libfuzzer-sys = { workspace = true } clvmr = { workspace = true } -pyo3 = { workspace = true, features = ["auto-initialize"]} chia-puzzles = { workspace = true, features = ["arbitrary"] } clvm-traits = { workspace = true } diff --git a/crates/chia-tools/Cargo.toml b/crates/chia-tools/Cargo.toml index 704815e3e..e2da3d39c 100644 --- a/crates/chia-tools/Cargo.toml +++ b/crates/chia-tools/Cargo.toml @@ -25,7 +25,6 @@ clap = { workspace = true, features = ["derive"] } zstd = { workspace = true } blocking-threadpool = { workspace = true } hex = { workspace = true } -hex-literal = { workspace = true } [lib] name = "chia_tools" diff --git a/crates/clvm-utils/fuzz/Cargo.toml b/crates/clvm-utils/fuzz/Cargo.toml index 800c79f93..433cf8220 100644 --- a/crates/clvm-utils/fuzz/Cargo.toml +++ b/crates/clvm-utils/fuzz/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [dependencies] libfuzzer-sys = { workspace = true } -clvmr ={ workspace = true } +clvmr = { workspace = true } chia-fuzz = { workspace = true } clvm-utils = { workspace = true } clvm-traits = { workspace = true } diff --git a/crates/clvm-utils/fuzz/fuzz_targets/curry.rs b/crates/clvm-utils/fuzz/fuzz_targets/curry.rs index d8b198830..877a660dd 100644 --- a/crates/clvm-utils/fuzz/fuzz_targets/curry.rs +++ b/crates/clvm-utils/fuzz/fuzz_targets/curry.rs @@ -2,9 +2,9 @@ use clvm_traits::{FromClvm, ToClvm}; use libfuzzer_sys::fuzz_target; +use chia_fuzz::{make_tree, BitCursor}; use clvm_utils::CurriedProgram; use clvmr::allocator::{Allocator, NodePtr}; -use fuzzing_utils::{make_tree, BitCursor}; fuzz_target!(|data: &[u8]| { let mut a = Allocator::new(); diff --git a/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs b/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs index 74f8e20cd..724957e06 100644 --- a/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs +++ b/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs @@ -1,9 +1,9 @@ #![no_main] use libfuzzer_sys::fuzz_target; +use chia_fuzz::{make_tree, BitCursor}; use clvm_utils::{tree_hash, tree_hash_cached, TreeHash}; use clvmr::{Allocator, NodePtr}; -use fuzzing_utils::{make_tree, BitCursor}; use std::collections::{HashMap, HashSet}; use clvmr::serde::{node_from_bytes_backrefs_record, node_to_bytes_backrefs}; diff --git a/package-lock.json b/package-lock.json index 4490e78c7..370e32ee8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,7 +4,7 @@ "requires": true, "packages": { "": { - "dependencies": { + "devDependencies": { "prettier": "^3.3.2" } }, @@ -12,6 +12,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" diff --git a/wheel/Cargo.toml b/wheel/Cargo.toml index fa7e9f2c5..e4c8b9e71 100644 --- a/wheel/Cargo.toml +++ b/wheel/Cargo.toml @@ -23,13 +23,8 @@ python-source = "python" [dependencies] clvmr = { workspace = true } hex = { workspace = true } -sha2 = { workspace = true } pyo3 = { workspace = true, features = ["multiple-pymethods"] } chia-consensus = { workspace = true, features = ["py-bindings"] } -chia-bls = { workspace = true, features = ["py-bindings"] } -chia-protocol = { workspace = true, features = ["py-bindings"] } -chia-traits = { workspace = true, features = ["py-bindings"] } -clvm-traits = { workspace = true, features = ["derive", "py-bindings"] } +chia-bls = { workspace = true, features = ["py-bindings"] } +chia-protocol = { workspace = true, features = ["py-bindings"] } clvm-utils = { workspace = true } -chia_py_streamable_macro = { workspace = true } -chia_streamable_macro = { workspace = true }