pot-o-validator 0.2.0

PoT-O (Proof of Tensor Optimizations) Validator Service
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
name: Upstream Release - Update Downstream Repos

on:
  push:
    tags:
      - 'pot-o-validator-v*'

env:
  RUST_BACKTRACE: 1
  CARGO_TERM_COLOR: always

jobs:
  # Stage 1: Validate the release
  validate:
    name: Validate Release
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.extract-version.outputs.version }}
      core-version: ${{ steps.get-versions.outputs.core-version }}
      ai3-version: ${{ steps.get-versions.outputs.ai3-version }}
      mining-version: ${{ steps.get-versions.outputs.mining-version }}
      extensions-version: ${{ steps.get-versions.outputs.extensions-version }}
    steps:
      - name: Check TRIBEWAREZ_PAT secret
        run: |
          if [ -z "${{ secrets.TRIBEWAREZ_PAT }}" ]; then
            echo "ERROR: TRIBEWAREZ_PAT secret is not set in this repository.\n\nSet it in GitHub -> Settings -> Secrets and variables -> Actions or use 'gh secret set TRIBEWAREZ_PAT' and re-run the workflow." >&2
            exit 1
          else
            echo "TRIBEWAREZ_PAT is set"
          fi

      - name: Checkout main repo
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Extract version from tag
        id: extract-version
        run: |
          TAG=${{ github.ref_name }}
          VERSION=${TAG#pot-o-validator-v}
          echo "version=${VERSION}" >> $GITHUB_OUTPUT
          echo "Extracted version: ${VERSION}"

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2

      - name: Get workspace crate versions
        id: get-versions
        run: |
          CORE_VERSION=$(grep '^version' core/Cargo.toml | head -1 | sed 's/version = "\(.*\)".*/\1/')
          AI3_VERSION=$(grep '^version' ai3-lib/Cargo.toml | head -1 | sed 's/version = "\(.*\)".*/\1/')
          MINING_VERSION=$(grep '^version' mining/Cargo.toml | head -1 | sed 's/version = "\(.*\)".*/\1/')
          EXT_VERSION=$(grep '^version' extensions/Cargo.toml | head -1 | sed 's/version = "\(.*\)".*/\1/')
          
          echo "core-version=${CORE_VERSION}" >> $GITHUB_OUTPUT
          echo "ai3-version=${AI3_VERSION}" >> $GITHUB_OUTPUT
          echo "mining-version=${MINING_VERSION}" >> $GITHUB_OUTPUT
          echo "extensions-version=${EXT_VERSION}" >> $GITHUB_OUTPUT
          
          echo "Core version: ${CORE_VERSION}"
          echo "AI3 version: ${AI3_VERSION}"
          echo "Mining version: ${MINING_VERSION}"
          echo "Extensions version: ${EXT_VERSION}"

      - name: Validate Cargo.lock
        run: cargo update --locked --dry-run

      - name: Build and test validator
        run: |
          cargo build --release
          cargo test --release

      - name: Create release summary
        run: |
          cat > /tmp/release-summary.txt << 'EOF'
          Release: pot-o-validator-v${{ steps.extract-version.outputs.version }}
          
          Workspace versions:
          - pot-o-core: ${{ steps.get-versions.outputs.core-version }}
          - ai3-lib: ${{ steps.get-versions.outputs.ai3-version }}
          - pot-o-mining: ${{ steps.get-versions.outputs.mining-version }}
          - pot-o-extensions: ${{ steps.get-versions.outputs.extensions-version }}
          
          Validation: PASSED
          EOF
          cat /tmp/release-summary.txt

  # Stage 2: Update pot-o-core
  update-pot-o-core:
    name: Update pot-o-core
    needs: validate
    runs-on: ubuntu-latest
    steps:
      - name: Checkout pot-o-core repo
        uses: actions/checkout@v4
        with:
          repository: TribeWarez/pot-o-core
          token: ${{ secrets.GH_PAT }}
          fetch-depth: 0

      - name: Configure git
        run: |
          git config user.name "TribeWarez Release Bot"
          git config user.email "release@tribewarez.com"

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Update dependencies
        env:
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
        run: |
          echo "Current core version: ${CORE_VERSION}"
          echo "Validator release: v${VALIDATOR_VERSION}"
          
          # Bump the package version to match the workspace version
          sed -i "s/^version = \".*\"/version = \"${CORE_VERSION}\"/" Cargo.toml
          
          cargo update

      - name: Build and test
        run: |
          cargo build --release
          cargo test --release

      - name: Commit and push
        env:
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
        run: |
          if [[ -n $(git status -s) ]]; then
            git add -A
            git commit -m "chore(release): bump version to ${CORE_VERSION}, sync with pot-o-validator upstream v${VALIDATOR_VERSION}"
            git push origin main
          else
            echo "No changes to commit"
          fi

      - name: Create release tag
        env:
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
        run: |
          git tag "pot-o-core-v${CORE_VERSION}" || echo "Tag already exists"
          git push origin "pot-o-core-v${CORE_VERSION}" 2>&1 || echo "Tag push skipped (might already exist)"

  # Stage 3: Update ai3-lib
  update-ai3-lib:
    name: Update ai3-lib
    needs: validate
    runs-on: ubuntu-latest
    steps:
      - name: Checkout ai3-lib repo
        uses: actions/checkout@v4
        with:
          repository: TribeWarez/ai3-lib
          token: ${{ secrets.GH_PAT }}
          fetch-depth: 0

      - name: Configure git
        run: |
          git config user.name "TribeWarez Release Bot"
          git config user.email "release@tribewarez.com"

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Update dependencies
        env:
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
          AI3_VERSION: ${{ needs.validate.outputs.ai3-version }}
        run: |
          echo "Current ai3-lib version: ${AI3_VERSION}"
          echo "Validator release: v${VALIDATOR_VERSION}"
          echo "pot-o-core version: ${CORE_VERSION}"
          
          # Bump the package version to match the workspace version
          sed -i "s/^version = \".*\"/version = \"${AI3_VERSION}\"/" Cargo.toml
          
          # Update pot-o-core dependency to match workspace version
          sed -i "s/pot-o-core = \".*\"/pot-o-core = \"${CORE_VERSION}\"/" Cargo.toml
          
          cargo update

      - name: Build and test
        run: |
          cargo build --release
          cargo test --release

      - name: Commit and push
        env:
          AI3_VERSION: ${{ needs.validate.outputs.ai3-version }}
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
        run: |
          if [[ -n $(git status -s) ]]; then
            git add -A
            git commit -m "chore(release): bump version to ${AI3_VERSION}, update pot-o-core to ${CORE_VERSION}, sync with pot-o-validator upstream v${VALIDATOR_VERSION}"
            git push origin main
          else
            echo "No changes to commit"
          fi

      - name: Create release tag
        env:
          AI3_VERSION: ${{ needs.validate.outputs.ai3-version }}
        run: |
          git tag "ai3-lib-v${AI3_VERSION}" || echo "Tag already exists"
          git push origin "ai3-lib-v${AI3_VERSION}" 2>&1 || echo "Tag push skipped (might already exist)"

  # Stage 4: Update pot-o-mining (depends on pot-o-core and ai3-lib)
  update-pot-o-mining:
    name: Update pot-o-mining
    needs: [validate, update-pot-o-core, update-ai3-lib]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout pot-o-mining repo
        uses: actions/checkout@v4
        with:
          repository: TribeWarez/pot-o-mining
          token: ${{ secrets.GH_PAT }}
          fetch-depth: 0

      - name: Configure git
        run: |
          git config user.name "TribeWarez Release Bot"
          git config user.email "release@tribewarez.com"

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Update dependencies
        env:
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
          AI3_VERSION: ${{ needs.validate.outputs.ai3-version }}
          MINING_VERSION: ${{ needs.validate.outputs.mining-version }}
        run: |
          echo "Current pot-o-mining version: ${MINING_VERSION}"
          echo "Validator release: v${VALIDATOR_VERSION}"
          
          # Bump the package version to match the workspace version
          sed -i "s/^version = \".*\"/version = \"${MINING_VERSION}\"/" Cargo.toml
          
          # Update dependencies
          sed -i "s/pot-o-core = \".*\"/pot-o-core = \"${CORE_VERSION}\"/" Cargo.toml
          sed -i "s/ai3-lib = \".*\"/ai3-lib = \"${AI3_VERSION}\"/" Cargo.toml
          
          cargo update

      - name: Build and test
        run: |
          cargo build --release
          cargo test --release

      - name: Commit and push
        env:
          MINING_VERSION: ${{ needs.validate.outputs.mining-version }}
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
          AI3_VERSION: ${{ needs.validate.outputs.ai3-version }}
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
        run: |
          if [[ -n $(git status -s) ]]; then
            git add -A
            git commit -m "chore(release): bump version to ${MINING_VERSION}, update pot-o-core to ${CORE_VERSION}, ai3-lib to ${AI3_VERSION}, sync with pot-o-validator upstream v${VALIDATOR_VERSION}"
            git push origin main
          else
            echo "No changes to commit"
          fi

      - name: Create release tag
        env:
          MINING_VERSION: ${{ needs.validate.outputs.mining-version }}
        run: |
          git tag "pot-o-mining-v${MINING_VERSION}" || echo "Tag already exists"
          git push origin "pot-o-mining-v${MINING_VERSION}" 2>&1 || echo "Tag push skipped (might already exist)"

  # Stage 5: Update pot-o-extensions (depends on all previous crates)
  update-pot-o-extensions:
    name: Update pot-o-extensions
    needs: [validate, update-pot-o-core, update-ai3-lib, update-pot-o-mining]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout pot-o-extensions repo
        uses: actions/checkout@v4
        with:
          repository: TribeWarez/pot-o-extensions
          token: ${{ secrets.GH_PAT }}
          fetch-depth: 0

      - name: Configure git
        run: |
          git config user.name "TribeWarez Release Bot"
          git config user.email "release@tribewarez.com"

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Update dependencies
        env:
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
          AI3_VERSION: ${{ needs.validate.outputs.ai3-version }}
          MINING_VERSION: ${{ needs.validate.outputs.mining-version }}
          EXT_VERSION: ${{ needs.validate.outputs.extensions-version }}
        run: |
          echo "Current pot-o-extensions version: ${EXT_VERSION}"
          echo "Validator release: v${VALIDATOR_VERSION}"
          
          # Bump the package version to match the workspace version
          sed -i "s/^version = \".*\"/version = \"${EXT_VERSION}\"/" Cargo.toml
          
          # Update all dependencies
          sed -i "s/pot-o-core = \".*\"/pot-o-core = \"${CORE_VERSION}\"/" Cargo.toml
          sed -i "s/ai3-lib = \".*\"/ai3-lib = \"${AI3_VERSION}\"/" Cargo.toml
          sed -i "s/pot-o-mining = \".*\"/pot-o-mining = \"${MINING_VERSION}\"/" Cargo.toml
          
          cargo update

      - name: Build and test
        run: |
          cargo build --release
          cargo test --release

      - name: Commit and push
        env:
          EXT_VERSION: ${{ needs.validate.outputs.extensions-version }}
          CORE_VERSION: ${{ needs.validate.outputs.core-version }}
          AI3_VERSION: ${{ needs.validate.outputs.ai3-version }}
          MINING_VERSION: ${{ needs.validate.outputs.mining-version }}
          VALIDATOR_VERSION: ${{ needs.validate.outputs.version }}
        run: |
          if [[ -n $(git status -s) ]]; then
            git add -A
            git commit -m "chore(release): bump version to ${EXT_VERSION}, update pot-o-core to ${CORE_VERSION}, ai3-lib to ${AI3_VERSION}, pot-o-mining to ${MINING_VERSION}, sync with pot-o-validator upstream v${VALIDATOR_VERSION}"
            git push origin main
          else
            echo "No changes to commit"
          fi

      - name: Create release tag
        env:
          EXT_VERSION: ${{ needs.validate.outputs.extensions-version }}
        run: |
          git tag "pot-o-extensions-v${EXT_VERSION}" || echo "Tag already exists"
          git push origin "pot-o-extensions-v${EXT_VERSION}" 2>&1 || echo "Tag push skipped (might already exist)"

  # Stage 6: Verification and notification
  verify-and-notify:
    name: Verify Release Completion
    needs: [validate, update-pot-o-core, update-ai3-lib, update-pot-o-mining, update-pot-o-extensions]
    runs-on: ubuntu-latest
    if: always()
    permissions:
      contents: write
    steps:
      - name: Check all stages completed
        run: |
          echo "=== Upstream Release Completion Report ==="
          echo "Validator Release: v${{ needs.validate.outputs.version }}"
          echo ""
          echo "Updated Crates:"
          echo "- pot-o-core: v${{ needs.validate.outputs.core-version }}"
          echo "- ai3-lib: v${{ needs.validate.outputs.ai3-version }}"
          echo "- pot-o-mining: v${{ needs.validate.outputs.mining-version }}"
          echo "- pot-o-extensions: v${{ needs.validate.outputs.extensions-version }}"
          echo ""
          echo "Job Status Summary:"
          echo "- validate: ${{ needs.validate.result }}"
          echo "- update-pot-o-core: ${{ needs.update-pot-o-core.result }}"
          echo "- update-ai3-lib: ${{ needs.update-ai3-lib.result }}"
          echo "- update-pot-o-mining: ${{ needs.update-pot-o-mining.result }}"
          echo "- update-pot-o-extensions: ${{ needs.update-pot-o-extensions.result }}"

      - name: Create GitHub Release (on success)
        if: |
          needs.validate.result == 'success' &&
          needs.update-pot-o-core.result == 'success' &&
          needs.update-ai3-lib.result == 'success' &&
          needs.update-pot-o-mining.result == 'success' &&
          needs.update-pot-o-extensions.result == 'success'
        uses: softprops/action-gh-release@v1
        with:
          draft: false
          prerelease: false
          body: |
            # pot-o-validator Release v${{ needs.validate.outputs.version }}
            
            ## Downstream Crate Updates
            This release triggered automatic updates to all downstream repositories:
            
            - **pot-o-core**: v${{ needs.validate.outputs.core-version }}
            - **ai3-lib**: v${{ needs.validate.outputs.ai3-version }}
            - **pot-o-mining**: v${{ needs.validate.outputs.mining-version }}
            - **pot-o-extensions**: v${{ needs.validate.outputs.extensions-version }}
            
            All downstream repositories have been updated and tested.
            
            ## Release Timeline
            - ✅ Validator validation and tests completed
            - ✅ pot-o-core updated and released
            - ✅ ai3-lib updated and released
            - ✅ pot-o-mining updated and released
            - ✅ pot-o-extensions updated and released

      - name: Workflow failure notification
        if: failure()
        run: |
          echo "❌ One or more release stages failed"
          exit 1