|
| 1 | +name: Soroban Fuzz (Smoke — 60 s per target) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'quantara/soroban/contracts/*/fuzz/**' |
| 8 | + - '.github/workflows/soroban_fuzz.yml' |
| 9 | + pull_request: |
| 10 | + branches: [main] |
| 11 | + paths: |
| 12 | + - 'quantara/soroban/contracts/*/fuzz/**' |
| 13 | + - '.github/workflows/soroban_fuzz.yml' |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + fuzz_time: |
| 17 | + description: 'Seconds to fuzz per target' |
| 18 | + default: '60' |
| 19 | + required: false |
| 20 | + |
| 21 | +env: |
| 22 | + CARGO_TERM_COLOR: always |
| 23 | + FUZZ_TIME: ${{ github.event.inputs.fuzz_time || '60' }} |
| 24 | + |
| 25 | +jobs: |
| 26 | + # ── Vault fuzz targets ──────────────────────────────────────────────────── |
| 27 | + fuzz-vault: |
| 28 | + name: Fuzz vault (${{ matrix.target }}) |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + target: |
| 34 | + - fuzz_vault_deposit |
| 35 | + - fuzz_vault_withdraw |
| 36 | + |
| 37 | + defaults: |
| 38 | + run: |
| 39 | + working-directory: quantara/soroban/contracts/vault |
| 40 | + |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Install latest Rust nightly |
| 45 | + uses: dtolnay/rust-toolchain@nightly |
| 46 | + |
| 47 | + - name: Cache Cargo registry |
| 48 | + uses: actions/cache@v4 |
| 49 | + with: |
| 50 | + path: | |
| 51 | + ~/.cargo/registry/index/ |
| 52 | + ~/.cargo/registry/cache/ |
| 53 | + ~/.cargo/git/db/ |
| 54 | + key: ${{ runner.os }}-cargo-fuzz-${{ github.sha }} |
| 55 | + restore-keys: ${{ runner.os }}-cargo-fuzz- |
| 56 | + |
| 57 | + - name: Install cargo-fuzz |
| 58 | + run: cargo install cargo-fuzz |
| 59 | + |
| 60 | + - name: Pin ed25519-dalek and rand_core to 0.6 family |
| 61 | + # soroban-env-host 22.1.3's testutils.rs passes `ChaCha20Rng` into |
| 62 | + # `ed25519_dalek::SigningKey::generate`, which requires CryptoRng |
| 63 | + # from the rand_core 0.6 family. ed25519-dalek 3.x bumped to |
| 64 | + # rand_core 0.10, breaking the trait bound. Pin ed25519-dalek to |
| 65 | + # 2.1.1 (last 2.x release) and rand_core to 0.6.4; fall through |
| 66 | + # with `|| true` for compatibility — cargo refuses to demote a |
| 67 | + # rand_core 0.10 instance to 0.6.4 directly, but the ed25519-dalek |
| 68 | + # pin upstream of it is the real lever. |
| 69 | + # The fuzz crate is an isolated workspace ([workspace] in |
| 70 | + # fuzz/Cargo.toml), so it has its OWN fuzz/Cargo.lock. Without |
| 71 | + # `cd fuzz`, `cargo update` would mutate the parent contract |
| 72 | + # workspace's lockfile, which `cargo fuzz run` ignores — hence |
| 73 | + # the silent failure of the previous (no-cd) variant. |
| 74 | + run: | |
| 75 | + cd fuzz |
| 76 | + cargo update -p ed25519-dalek@3.0.0 --precise 2.1.1 || true |
| 77 | + cargo update -p ed25519-dalek --precise 2.1.1 || true |
| 78 | + cargo update -p rand_core@0.10.1 --precise 0.6.4 || true |
| 79 | + cargo update -p rand_core@0.9.5 --precise 0.6.4 || true |
| 80 | +
|
| 81 | + - name: Run fuzz target for ${{ env.FUZZ_TIME }}s |
| 82 | + run: | |
| 83 | + cargo fuzz run ${{ matrix.target }} \ |
| 84 | + -- -max_total_time=${{ env.FUZZ_TIME }} -jobs=1 |
| 85 | +
|
| 86 | + - name: Upload crash corpus on failure |
| 87 | + if: failure() |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: vault-${{ matrix.target }}-crash-corpus |
| 91 | + path: fuzz/corpus/${{ matrix.target }} |
| 92 | + if-no-files-found: ignore |
| 93 | + |
| 94 | + # ── Looping fuzz targets ─────────────────────────────────────────────────── |
| 95 | + fuzz-looping: |
| 96 | + name: Fuzz looping (${{ matrix.target }}) |
| 97 | + runs-on: ubuntu-latest |
| 98 | + strategy: |
| 99 | + fail-fast: false |
| 100 | + matrix: |
| 101 | + target: |
| 102 | + - fuzz_looping_open_position |
| 103 | + |
| 104 | + defaults: |
| 105 | + run: |
| 106 | + working-directory: quantara/soroban/contracts/looping |
| 107 | + |
| 108 | + steps: |
| 109 | + - uses: actions/checkout@v4 |
| 110 | + |
| 111 | + - name: Install latest Rust nightly |
| 112 | + uses: dtolnay/rust-toolchain@nightly |
| 113 | + |
| 114 | + - name: Cache Cargo registry |
| 115 | + uses: actions/cache@v4 |
| 116 | + with: |
| 117 | + path: | |
| 118 | + ~/.cargo/registry/index/ |
| 119 | + ~/.cargo/registry/cache/ |
| 120 | + ~/.cargo/git/db/ |
| 121 | + key: ${{ runner.os }}-cargo-fuzz-${{ github.sha }} |
| 122 | + restore-keys: ${{ runner.os }}-cargo-fuzz- |
| 123 | + |
| 124 | + - name: Install cargo-fuzz |
| 125 | + run: cargo install cargo-fuzz |
| 126 | + |
| 127 | + - name: Pin ed25519-dalek and rand_core to 0.6 family |
| 128 | + # soroban-env-host 22.1.3's testutils.rs passes `ChaCha20Rng` into |
| 129 | + # `ed25519_dalek::SigningKey::generate`, which requires CryptoRng |
| 130 | + # from the rand_core 0.6 family. ed25519-dalek 3.x bumped to |
| 131 | + # rand_core 0.10, breaking the trait bound. Pin ed25519-dalek to |
| 132 | + # 2.1.1 (last 2.x release) and rand_core to 0.6.4; fall through |
| 133 | + # with `|| true` for compatibility — cargo refuses to demote a |
| 134 | + # rand_core 0.10 instance to 0.6.4 directly, but the ed25519-dalek |
| 135 | + # pin upstream of it is the real lever. |
| 136 | + # The fuzz crate is an isolated workspace ([workspace] in |
| 137 | + # fuzz/Cargo.toml), so it has its OWN fuzz/Cargo.lock. Without |
| 138 | + # `cd fuzz`, `cargo update` would mutate the parent contract |
| 139 | + # workspace's lockfile, which `cargo fuzz run` ignores — hence |
| 140 | + # the silent failure of the previous (no-cd) variant. |
| 141 | + run: | |
| 142 | + cd fuzz |
| 143 | + cargo update -p ed25519-dalek@3.0.0 --precise 2.1.1 || true |
| 144 | + cargo update -p ed25519-dalek --precise 2.1.1 || true |
| 145 | + cargo update -p rand_core@0.10.1 --precise 0.6.4 || true |
| 146 | + cargo update -p rand_core@0.9.5 --precise 0.6.4 || true |
| 147 | +
|
| 148 | + - name: Run fuzz target for ${{ env.FUZZ_TIME }}s |
| 149 | + run: | |
| 150 | + cargo fuzz run ${{ matrix.target }} \ |
| 151 | + -- -max_total_time=${{ env.FUZZ_TIME }} -jobs=1 |
| 152 | +
|
| 153 | + - name: Upload crash corpus on failure |
| 154 | + if: failure() |
| 155 | + uses: actions/upload-artifact@v4 |
| 156 | + with: |
| 157 | + name: looping-${{ matrix.target }}-crash-corpus |
| 158 | + path: fuzz/corpus/${{ matrix.target }} |
| 159 | + if-no-files-found: ignore |
| 160 | + |
| 161 | + # ── Rewards fuzz targets ─────────────────────────────────────────────────── |
| 162 | + fuzz-rewards: |
| 163 | + name: Fuzz rewards (${{ matrix.target }}) |
| 164 | + runs-on: ubuntu-latest |
| 165 | + strategy: |
| 166 | + fail-fast: false |
| 167 | + matrix: |
| 168 | + target: |
| 169 | + - fuzz_rewards_accrue_claim |
| 170 | + |
| 171 | + defaults: |
| 172 | + run: |
| 173 | + working-directory: quantara/soroban/contracts/rewards |
| 174 | + |
| 175 | + steps: |
| 176 | + - uses: actions/checkout@v4 |
| 177 | + |
| 178 | + - name: Install latest Rust nightly |
| 179 | + uses: dtolnay/rust-toolchain@nightly |
| 180 | + |
| 181 | + - name: Cache Cargo registry |
| 182 | + uses: actions/cache@v4 |
| 183 | + with: |
| 184 | + path: | |
| 185 | + ~/.cargo/registry/index/ |
| 186 | + ~/.cargo/registry/cache/ |
| 187 | + ~/.cargo/git/db/ |
| 188 | + key: ${{ runner.os }}-cargo-fuzz-${{ github.sha }} |
| 189 | + restore-keys: ${{ runner.os }}-cargo-fuzz- |
| 190 | + |
| 191 | + - name: Install cargo-fuzz |
| 192 | + run: cargo install cargo-fuzz |
| 193 | + |
| 194 | + - name: Pin ed25519-dalek and rand_core to 0.6 family |
| 195 | + # soroban-env-host 22.1.3's testutils.rs passes `ChaCha20Rng` into |
| 196 | + # `ed25519_dalek::SigningKey::generate`, which requires CryptoRng |
| 197 | + # from the rand_core 0.6 family. ed25519-dalek 3.x bumped to |
| 198 | + # rand_core 0.10, breaking the trait bound. Pin ed25519-dalek to |
| 199 | + # 2.1.1 (last 2.x release) and rand_core to 0.6.4; fall through |
| 200 | + # with `|| true` for compatibility — cargo refuses to demote a |
| 201 | + # rand_core 0.10 instance to 0.6.4 directly, but the ed25519-dalek |
| 202 | + # pin upstream of it is the real lever. |
| 203 | + # The fuzz crate is an isolated workspace ([workspace] in |
| 204 | + # fuzz/Cargo.toml), so it has its OWN fuzz/Cargo.lock. Without |
| 205 | + # `cd fuzz`, `cargo update` would mutate the parent contract |
| 206 | + # workspace's lockfile, which `cargo fuzz run` ignores — hence |
| 207 | + # the silent failure of the previous (no-cd) variant. |
| 208 | + run: | |
| 209 | + cd fuzz |
| 210 | + cargo update -p ed25519-dalek@3.0.0 --precise 2.1.1 || true |
| 211 | + cargo update -p ed25519-dalek --precise 2.1.1 || true |
| 212 | + cargo update -p rand_core@0.10.1 --precise 0.6.4 || true |
| 213 | + cargo update -p rand_core@0.9.5 --precise 0.6.4 || true |
| 214 | +
|
| 215 | + - name: Run fuzz target for ${{ env.FUZZ_TIME }}s |
| 216 | + run: | |
| 217 | + cargo fuzz run ${{ matrix.target }} \ |
| 218 | + -- -max_total_time=${{ env.FUZZ_TIME }} -jobs=1 |
| 219 | +
|
| 220 | + - name: Upload crash corpus on failure |
| 221 | + if: failure() |
| 222 | + uses: actions/upload-artifact@v4 |
| 223 | + with: |
| 224 | + name: rewards-${{ matrix.target }}-crash-corpus |
| 225 | + path: fuzz/corpus/${{ matrix.target }} |
| 226 | + if-no-files-found: ignore |
0 commit comments