|
| 1 | +name: RV Run Proofs |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + proofs: |
| 7 | + description: Start symbols for proofs to run |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + default: "['test_ptoken_domain_data', 'this_will_fail']" |
| 11 | + kmir: |
| 12 | + description: KMIR to work with (must exist as a docker image tag, optional) |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + default: p-token-f8c403f # hard-wired now, retrieve from submodule later |
| 16 | + smir: |
| 17 | + description: Stable MIR JSON to work with (commit hash, optional) |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + default: # empty = master |
| 21 | +concurrency: |
| 22 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | + |
| 26 | +jobs: |
| 27 | + compile: |
| 28 | + name: "Compile P-Token to SMIR JSON" |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - name: "Git Checkout" |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: "Provide nightly Rust" # https://github.com/rust-lang/rustup/issues/3409 |
| 35 | + uses: dtolnay/rust-toolchain@master |
| 36 | + with: |
| 37 | + toolchain: nightly-2024-11-29 # Hardcoded version for stable-mir-json. TODO can we use nix? |
| 38 | + |
| 39 | + - name: "Provide Nix" |
| 40 | + uses: cachix/install-nix-action@v30 |
| 41 | + |
| 42 | + - name: "Set up nix shell" |
| 43 | + uses: rrbutani/use-nix-shell-action@v1 |
| 44 | + with: |
| 45 | + flakes: github:runtimeverification/stable-mir-json/${{ inputs.smir }} |
| 46 | + |
| 47 | + - name: "Build with stable_mir_json" |
| 48 | + run: | |
| 49 | + cd p-token |
| 50 | + RUSTC=stable_mir_json cargo build --features runtime-verification |
| 51 | +
|
| 52 | + - name: "Store SMIR JSON files" |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: p-token.smir |
| 56 | + path: ./target/debug/deps/*.smir.json |
| 57 | + if-no-files-found: error |
| 58 | + retention-days: 1 # only important during workflow run |
| 59 | + |
| 60 | + prepare_matrix: |
| 61 | + name: "Prepare proof matrix" |
| 62 | + runs-on: ubuntu-latest |
| 63 | + outputs: |
| 64 | + proofs: ${{ steps.split.outputs.matrix }} |
| 65 | + steps: |
| 66 | + - name: "Create Proof Array" |
| 67 | + id: split |
| 68 | + run: | |
| 69 | + echo "proofs = '${{ inputs.proofs }}'" |
| 70 | + echo "matrix=${{ inputs.proofs }}" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + run_proof: |
| 73 | + name: "Link SMIR and Run Proofs" |
| 74 | + needs: |
| 75 | + - compile |
| 76 | + - prepare_matrix |
| 77 | + runs-on: ubuntu-latest |
| 78 | + # container: |
| 79 | + # image: runtimeverificationinc/kmir:${{ inputs.kmir }} |
| 80 | + strategy: |
| 81 | + matrix: |
| 82 | + proof: ${{ fromJSON(needs.prepare_matrix.outputs.proofs) }} |
| 83 | + env: |
| 84 | + KMIR_CONTAINER_NAME: "kmir-${{ github.sha }}" |
| 85 | + steps: |
| 86 | + - name: debug matrix and docker image |
| 87 | + run: | |
| 88 | + echo "This is proof ${{ matrix.proof }}" |
| 89 | + echo "Running with $KMIR_CONTAINER_NAME, docker image runtimeverificationinc/kmir:${{ inputs.kmir }}" |
| 90 | +
|
| 91 | + - name: "Set up Docker Host" |
| 92 | + run: | |
| 93 | + mkdir -p $PWD/artefacts |
| 94 | + chmod a+rwx $PWD/artefacts |
| 95 | + docker run --rm --detach \ |
| 96 | + -v $PWD:/workdir --workdir /workdir \ |
| 97 | + --name "${KMIR_CONTAINER_NAME}" \ |
| 98 | + runtimeverificationinc/kmir:${{ inputs.kmir }} \ |
| 99 | + sleep 3600 |
| 100 | + sleep 10 |
| 101 | +
|
| 102 | + - name: "Get SMIR Files" |
| 103 | + uses: actions/download-artifact@v5 |
| 104 | + with: |
| 105 | + name: p-token.smir |
| 106 | + path: artefacts/ |
| 107 | + |
| 108 | + - name: "Link SMIR Files" |
| 109 | + run: | |
| 110 | + docker exec --workdir /workdir/artefacts/ "${KMIR_CONTAINER_NAME}" \ |
| 111 | + bash -c 'kmir link -o p-token.smir.json *.smir.json' |
| 112 | +
|
| 113 | + - name: "Run Proof ${{ matrix.proof }} and store resulting tree" |
| 114 | + run: | |
| 115 | + timeout 3600 \ |
| 116 | + docker exec --workdir /workdir "${KMIR_CONTAINER_NAME}" \ |
| 117 | + kmir prove-rs --smir artefacts/p-token.smir.json \ |
| 118 | + --start-symbol 'pinocchio_token_program::entrypoint::${{ matrix.proof }}' \ |
| 119 | + --verbose \ |
| 120 | + --max-iterations 100 \ |
| 121 | + --proof-dir artefacts/proof |
| 122 | + docker exec --workdir /workdir "${KMIR_CONTAINER_NAME}" \ |
| 123 | + kmir show --full-printer --proof-dir artefacts/proof \ |
| 124 | + 'p-token.smir.pinocchio_token_program::entrypoint::${{ matrix.proof }}' \ |
| 125 | + > artefacts/proof/${{ matrix.proof }}-full.txt |
| 126 | +
|
| 127 | + - name: "Save proof tree and smir" |
| 128 | + uses: actions/upload-artifact@v4 |
| 129 | + with: |
| 130 | + name: $artefacts-{{ matrix.proof }} |
| 131 | + path: | |
| 132 | + artefacts/p-token.smir.json |
| 133 | + artefacts/proof/*-full.txt |
| 134 | +
|
| 135 | + - name: "Shut down docker image" |
| 136 | + if: always() |
| 137 | + run: | |
| 138 | + docker stop ${KMIR_CONTAINER_NAME} |
| 139 | + sleep 5 |
| 140 | + docker rm -f ${KMIR_CONTAINER_NAME} |
0 commit comments