Skip to content

Update openvm patches #149

Update openvm patches

Update openvm patches #149

name: "Update openvm patches"
on:
workflow_dispatch:
inputs:
STARK_BACKEND_REV:
description: "Optional ref for openvm-stark-backend (defaults to main head)"
required: false
OPENVM_REV:
description: "Optional ref for openvm (defaults to main head)"
required: false
run_benchmark:
description: "Run reth benchmark after patching"
type: boolean
required: false
default: true
benchmark_mode:
description: "Benchmark mode (if running benchmark)"
type: string
required: false
default: prove-e2e
instance_family:
description: "Instance family to use for benchmark"
type: string
required: false
default: m8g.24xlarge
schedule:
- cron: "0 */12 * * *" # Run every 12 hours
workflow_call:
inputs:
STARK_BACKEND_REV:
type: string
required: false
description: "Optional ref for openvm-stark-backend (defaults to main head)"
OPENVM_REV:
type: string
required: false
description: "Optional ref for openvm (defaults to main head)"
run_benchmark:
type: boolean
required: false
description: "Run reth benchmark after patching"
default: true
benchmark_mode:
type: string
required: false
description: "Benchmark mode (if running benchmark)"
default: prove-e2e
instance_family:
type: string
required: false
description: "Instance family to use for benchmark"
default: m8g.24xlarge
# https://github.com/actions/runner/discussions/1884
manual_call:
description: "To distinguish workflow_call from workflow_dispatch"
type: boolean
required: false
default: true
secrets:
GH_ACTIONS_DEPLOY_PRIVATE_KEY:
required: true
RPC_URL_1:
required: true
BENCHER_API_TOKEN:
required: true
outputs:
metric_name:
description: "Name of the metric"
value: ${{ jobs.run-benchmark.outputs.metric_name }}
jobs:
update-config:
name: "Update .cargo/config.toml and open a pull request"
runs-on:
["runs-on", "runner=2cpu-linux-arm64", "run-id=${{ github.run_id }}"]
outputs:
branch_name: ${{ steps.create-branch.outputs.branch_name }}
pr_number: ${{ steps.create-pr.outputs.pr_number }}
tag: ${{ steps.set-tag.outputs.tag }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Get default STARK_BACKEND_REV from main (if none provided)
id: get-stark-backend-rev
uses: actions/github-script@v6
with:
script: |
const inputRef = "${{ inputs.STARK_BACKEND_REV || github.event.inputs.STARK_BACKEND_REV }}";
if (inputRef && inputRef.trim()) {
return inputRef;
} else {
const { data } = await github.rest.repos.getCommit({
owner: 'openvm-org',
repo: 'stark-backend',
ref: 'main'
});
return data.sha;
}
- name: Get default OPENVM_REV from main (if none provided)
id: get-openvm-rev
uses: actions/github-script@v6
with:
script: |
const inputRef = "${{ inputs.OPENVM_REV || github.event.inputs.OPENVM_REV }}";
if (inputRef && inputRef.trim()) {
return inputRef;
} else {
// Otherwise fetch latest commit of main
const { data } = await github.rest.repos.getCommit({
owner: 'openvm-org',
repo: 'openvm',
ref: 'main'
});
return data.sha;
}
- name: Replace placeholders in configuration
run: |
STARK_BACKEND_REV="${{ steps.get-stark-backend-rev.outputs.result }}"
OPENVM_REV="${{ steps.get-openvm-rev.outputs.result }}"
echo "Using STARK_BACKEND_REV=$STARK_BACKEND_REV"
echo "Using OPENVM_REV=$OPENVM_REV"
# Replace placeholders in template
sed "s|\$STARK_BACKEND_REV|${STARK_BACKEND_REV}|g" .cargo/config.template.toml > .cargo/config.tmp.toml
sed "s|\$OPENVM_REV|${OPENVM_REV}|g" .cargo/config.tmp.toml > .cargo/config.toml
rm .cargo/config.tmp.toml
- name: Load SSH key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: |
${{ secrets.GH_ACTIONS_DEPLOY_PRIVATE_KEY }}
- name: Update workspace Cargo.lock
run: |
cargo update -p openvm-sdk
cargo update -p openvm-stark-sdk
cargo tree
- name: Update guest Cargo.lock
working-directory: bin/client-eth
run: |
cargo update -p openvm
cargo update -p revm
cargo tree
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Set tag
id: set-tag
run: |
CARGO_LOCK_HASH=$(sha256sum Cargo.lock | cut -d' ' -f1 | cut -c1-8)
echo "tag=$(git rev-parse HEAD)-${CARGO_LOCK_HASH}" >> $GITHUB_OUTPUT
- name: Create or update branch
id: create-branch
run: |
if [ "${{ github.event_name == 'schedule' }}" = "true" ]; then
BRANCH_NAME="nightly"
else
BRANCH_NAME="patch-openvm-$(date +%Y%m%d%H%M%S)-${{ steps.set-tag.outputs.tag }}"
fi
# Delete local branch if it exists
git branch -D "$BRANCH_NAME" 2>/dev/null || true
# Create new branch
git checkout -b "$BRANCH_NAME"
git add -f .cargo/config.toml
git add -f Cargo.lock
git add -f bin/client-eth/Cargo.lock
git commit -m "Patch openvm commits in .cargo/config.toml"
git push -f origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "${{ github.event_name }}"
- name: Create pull request
if: ${{ !inputs.manual_call }}
uses: repo-sync/pull-request@v2
id: create-pr
with:
source_branch: ${{ steps.create-branch.outputs.branch_name }}
destination_branch: ${{ github.ref_name }}
pr_title: "Patch openvm to ${{ steps.get-openvm-rev.outputs.result }}"
pr_body: |
This pull request updates .cargo/config.toml using:
- STARK_BACKEND_REV = ${{ steps.get-stark-backend-rev.outputs.result }}
- OPENVM_REV = ${{ steps.get-openvm-rev.outputs.result }}
github_token: ${{ secrets.GITHUB_TOKEN }}
run-benchmark:
needs: update-config
if: ${{ github.event.inputs.run_benchmark == 'true' || github.event_name == 'schedule' || inputs.run_benchmark }}
uses: ./.github/workflows/reth-benchmark.yml
with:
mode: ${{ inputs.benchmark_mode || github.event.inputs.benchmark_mode || 'prove-e2e' }}
instance_family: ${{ inputs.instance_family || github.event.inputs.instance_family || 'm8g.24xlarge' }}
ref: ${{ needs.update-config.outputs.branch_name }}
tag: ${{ needs.update-config.outputs.tag }}
secrets:
GH_ACTIONS_DEPLOY_PRIVATE_KEY: ${{ secrets.GH_ACTIONS_DEPLOY_PRIVATE_KEY }}
RPC_URL_1: ${{ secrets.RPC_URL_1 }}
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
close-pr:
needs: [update-config, run-benchmark]
if: ${{ !inputs.manual_call }}
runs-on: ubuntu-latest
steps:
- name: Close PR
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ needs.update-config.outputs.pr_number }},
state: 'closed'
});