Skip to content

Commit

Permalink
Testing: Allow proving of blocks in CI (#322)
Browse files Browse the repository at this point in the history
Problem: Currently there is no way to run the prove_block command against several blocks in the CI.
Solution: Implement a way to start pathfinder and prove blocks.
  • Loading branch information
whichqua authored Aug 28, 2024
1 parent bc8c68c commit da54de3
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/prove_blocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Sepolia integration tests

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "true"

- name: "Install Rust"
uses: "actions-rs/toolchain@v1"
with:
toolchain: "stable"

- name: "Cache cargo"
id: cache-cargo
uses: "actions/cache@v4"
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
save-always: true
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Create and activate Python virtual environment
run: |
python3 -m venv venv
source venv/bin/activate
- name: Setup the tests
run: |
source venv/bin/activate
pip install cairo-lang==0.13.1 "sympy<1.13.0"
bash scripts/setup-tests.sh
- name: Prove Blocks
run: bash scripts/prove-blocks.sh -p ${{ secrets.PATHFINDER_RPC_URL }} -b 76793,76766,76775
40 changes: 40 additions & 0 deletions scripts/prove-blocks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Function to show usage
usage() {
echo "Usage: $0 -p <rpc-provider> -b <block-number1,block-number2,...>"
exit 1
}

# Parse command-line options
while getopts "p:b:" opt; do
case ${opt} in
p )
PROVIDER=$OPTARG
;;
b )
IFS=',' read -r -a BLOCK_NUMBERS <<< "$OPTARG"
;;
* )
usage
;;
esac done

# Check if both provider and block numbers are provided
if [ -z "$PROVIDER" ] || [ -z "$BLOCK_NUMBERS" ]; then
usage
fi

# Loop through each block number and execute the cargo command
for BLOCK_NUMBER in "${BLOCK_NUMBERS[@]}"; do
echo "Executing for block number: $BLOCK_NUMBER"
cargo run -p prove_block --release -- --block-number "$BLOCK_NUMBER" --rpc-provider "$PROVIDER"

# Check if the cargo command failed
if [ $? -ne 0 ]; then
echo "Command failed for block number: $BLOCK_NUMBER. Exiting."
exit 1
fi
done

echo "All blocks proven successfully."

0 comments on commit da54de3

Please sign in to comment.