Update openvm patches #778
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Update openvm patches" | |
on: | |
workflow_dispatch: | |
inputs: | |
STARK_BACKEND_REV: | |
description: "Optional ref for openvm-stark-backend (defaults to what openvm uses)" | |
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 | |
host_flamegraph: | |
description: "Run profiling benchmark for host flamegraph" | |
type: boolean | |
required: false | |
default: false | |
guest_flamegraph: | |
description: "Run profiling benchmark for circuit flamegraphs" | |
type: boolean | |
required: false | |
default: false | |
benchmark_mode: | |
description: "Benchmark mode (if running benchmark)" | |
type: string | |
required: false | |
default: prove-evm | |
instance_family: | |
description: "Instance family to use for benchmark" | |
type: string | |
required: false | |
default: m8g.24xlarge | |
benchmark_block_number: | |
description: "Block number to run the benchmark on" | |
type: number | |
required: false | |
default: 23100006 | |
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 what openvm uses)" | |
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 | |
host_flamegraph: | |
description: "Run profiling benchmark for host flamegraph" | |
type: boolean | |
required: false | |
default: false | |
guest_flamegraph: | |
description: "Run profiling benchmark for circuit flamegraphs" | |
type: boolean | |
required: false | |
default: false | |
benchmark_mode: | |
type: string | |
required: false | |
description: "Benchmark mode (if running benchmark)" | |
default: prove-evm | |
instance_family: | |
type: string | |
required: false | |
description: "Instance family to use for benchmark" | |
default: m8g.24xlarge | |
benchmark_block_number: | |
type: number | |
required: false | |
description: "Block number to run the benchmark on" | |
default: 23100006 | |
# 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 }} | |
branch_name: | |
description: "Name of the created branch" | |
value: ${{ jobs.patch.outputs.branch_name }} | |
tag: | |
description: "Tag" | |
value: ${{ jobs.patch.outputs.tag }} | |
jobs: | |
patch: | |
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: Get default OPENVM_REV from main (if none provided) | |
id: get-openvm-rev | |
env: | |
OPENVM_REV: "${{ inputs.OPENVM_REV || github.event.inputs.OPENVM_REV }}" | |
run: | | |
echo "result=${OPENVM_REV:-$(git ls-remote https://github.com/openvm-org/openvm.git HEAD | cut -f1)}" >> "$GITHUB_OUTPUT" | |
- name: Check out openvm repository | |
uses: actions/checkout@v4 | |
with: | |
repository: "openvm-org/openvm" | |
ref: ${{ steps.get-openvm-rev.outputs.result }} | |
- name: Get STARK_BACKEND_REV from openvm | |
id: get-stark-backend-rev | |
env: | |
STARK_BACKEND_REV: "${{ inputs.STARK_BACKEND_REV || github.event.inputs.STARK_BACKEND_REV }}" | |
run: | | |
RESULT=${STARK_BACKEND_REV:-$(cargo metadata --format-version=1 | jq -r '.packages[] | select(.name=="openvm-stark-sdk") | .source | split("#") | .[1]')} | |
echo "result=${RESULT}" >> "$GITHUB_OUTPUT" | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- 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 | |
# Update bin/client-eth/Cargo.toml patches | |
cd bin/client-eth | |
# Create a temporary file with the replacements | |
sed -e "/^\[patch\.crates-io\]/,/^\[/ { | |
s|^k256 = { git = \"https://github.com/openvm-org/openvm.git\", branch = \"main\" }$|k256 = { git = \"ssh://git@github.com/openvm-org/openvm.git\", rev = \"${OPENVM_REV}\" }| | |
s|^p256 = { git = \"https://github.com/openvm-org/openvm.git\", branch = \"main\" }$|p256 = { git = \"ssh://git@github.com/openvm-org/openvm.git\", rev = \"${OPENVM_REV}\" }| | |
s|^ruint = { git = \"https://github.com/openvm-org/openvm.git\", branch = \"main\" }$|ruint = { git = \"ssh://git@github.com/openvm-org/openvm.git\", rev = \"${OPENVM_REV}\" }| | |
}" Cargo.toml > Cargo.toml.tmp | |
mv Cargo.toml.tmp Cargo.toml | |
cd ../.. | |
- 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.toml | |
git add -f bin/client-eth/Cargo.lock | |
git commit -m "Patch openvm commits in .cargo/config.toml and bin/client-eth/Cargo.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 && github.event_name != 'schedule' && !(github.event.inputs.run_benchmark == 'true' || inputs.run_benchmark) }} | |
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: patch | |
if: ${{ github.event.inputs.run_benchmark == 'true' || inputs.run_benchmark || github.event_name == 'schedule' }} | |
uses: ./.github/workflows/reth-benchmark.yml | |
with: | |
mode: ${{ inputs.benchmark_mode || github.event.inputs.benchmark_mode || 'prove-evm' }} | |
instance_family: ${{ inputs.instance_family || github.event.inputs.instance_family || 'm8g.24xlarge' }} | |
ref: ${{ needs.patch.outputs.branch_name }} | |
tag: ${{ needs.patch.outputs.tag }} | |
block_number: ${{ fromJSON(inputs.benchmark_block_number || github.event.inputs.benchmark_block_number || '23100006') }} | |
profiling: none | |
secrets: inherit | |
host-flamegraph: | |
needs: patch | |
if: ${{ github.event.inputs.host_flamegraph == 'true' || inputs.host_flamegraph || github.event_name == 'schedule' }} | |
uses: ./.github/workflows/reth-benchmark.yml | |
with: | |
mode: ${{ inputs.benchmark_mode || github.event.inputs.benchmark_mode || 'prove-evm' }} | |
instance_family: ${{ inputs.instance_family || github.event.inputs.instance_family || 'm8g.24xlarge' }} | |
ref: ${{ needs.patch.outputs.branch_name }} | |
tag: ${{ needs.patch.outputs.tag }} | |
block_number: ${{ fromJSON(inputs.benchmark_block_number || github.event.inputs.benchmark_block_number || '23100006') }} | |
profiling: host | |
secrets: inherit | |
guest-flamegraph: | |
needs: patch | |
if: ${{ github.event.inputs.guest_flamegraph == 'true' || inputs.guest_flamegraph || github.event_name == 'schedule' }} | |
uses: ./.github/workflows/reth-benchmark.yml | |
with: | |
mode: ${{ inputs.benchmark_mode || github.event.inputs.benchmark_mode || 'prove-evm' }} | |
instance_family: ${{ inputs.instance_family || github.event.inputs.instance_family || 'm8g.24xlarge' }} | |
ref: ${{ needs.patch.outputs.branch_name }} | |
tag: ${{ needs.patch.outputs.tag }} | |
block_number: ${{ fromJSON(inputs.benchmark_block_number || github.event.inputs.benchmark_block_number || '23100006') }} | |
profiling: guest | |
secrets: inherit | |
close-pr: | |
needs: [patch, run-benchmark] | |
if: | | |
always() && | |
needs.patch.outputs.pr_number != '' && | |
needs.patch.outputs.pr_number != null | |
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.patch.outputs.pr_number }}, | |
state: 'closed' | |
}); |