Skip to content

Commit

Permalink
Merge branch 'main' into benches_vs_vm
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Nov 7, 2024
2 parents 6bd8a12 + 9791075 commit f21ffda
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/daily_failure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "Daily Workflow Failure: Block Range {{ env.BLOCK_START }}-{{ env.BLOCK_END }}"
labels: bug
---

Comparing VM execution against Native in the given block range produced diffs:

- Commit: {{ env.COMMIT_SHA }}
- Block Start: {{ env.BLOCK_START }}
- Block End: {{ env.BLOCK_END }}
- Workflow URL: {{ env.WORKFLOW_URL }}

## Compare Output

The transaction were not compared in order. You should rerun the whole block to find the error root

```
{{ env.OUTPUT }}
```
90 changes: 85 additions & 5 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ on:
- cron: "0 0 * * *"

env:
RANGE_SIZE: 50
RANGE_SIZE: 25
SEQUENCER_REV: 1b1b95cae7ae07b9bc778443ca75ee18008a6bc8

jobs:
run-and-compare:
run:
runs-on: ubuntu-latest
timeout-minutes: 1440
env:
LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/
MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/
Expand All @@ -32,6 +31,9 @@ jobs:
- 747000
- 748000
- 749000
runner:
- native
- vm
fail-fast: false
defaults:
run:
Expand Down Expand Up @@ -79,17 +81,95 @@ jobs:
grep $GIT Cargo.toml
- name: Run with Native
if: ${{ matrix.runner == 'native' }}
run: |
BLOCK_START=${{ matrix.block }}
BLOCK_END=$(($BLOCK_START + $RANGE_SIZE - 1))
cargo run --release --features state_dump block-range $BLOCK_START $BLOCK_END mainnet
continue-on-error: true
- name: Run with VM
if: ${{ matrix.runner == 'vm' }}
run: |
BLOCK_START=${{ matrix.block }}
BLOCK_END=$(($BLOCK_START + $RANGE_SIZE - 1))
cargo run --release --features state_dump,only_cairo_vm block-range $BLOCK_START $BLOCK_END mainnet
# We always upload the dump, even if the job fails
- name: Upload dumps
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: dump-${{matrix.block}}-${{matrix.runner}}
path: starknet-replay/state_dumps/${{matrix.runner}}


compare:
needs: [run]
runs-on: ubuntu-latest
# We always run the compare job, to ensure that a single run job failing
# would not cancel the whole comparison.
if: ${{ always() }}
strategy:
matrix:
block:
- 740000
- 741000
- 742000
- 743000
- 744000
- 745000
- 746000
- 747000
- 748000
- 749000
fail-fast: false
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4

- name: Fetch Native dumps
uses: actions/download-artifact@v4
with:
name: dump-${{matrix.block}}-native
path: state_dumps/native
continue-on-error: true
- name: Fetch VM dumps
uses: actions/download-artifact@v4
with:
name: dump-${{matrix.block}}-vm
path: state_dumps/vm
continue-on-error: true

- name: Compare states
run: ../cairo_native/scripts/cmp_state_dumps.sh
run: |
./scripts/cmp_state_dumps.sh | tee output
- name: Prepare env vars
if: ${{ always() }}
run: |
# Save blocks to env var
BLOCK_START=${{ matrix.block }}
BLOCK_END=$(($BLOCK_START + $RANGE_SIZE - 1))
echo "BLOCK_END=$BLOCK_END" | tee -a $GITHUB_ENV
echo "BLOCK_START=$BLOCK_START" | tee -a $GITHUB_ENV
# Save workflow url
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
echo "WORKFLOW_URL=$REPO_URL/actions/runs/${{ github.run_id }}" | tee -a $GITHUB_ENV
# Save output
{
echo 'OUTPUT<<EOF'
cat output
echo EOF
} >> "$GITHUB_ENV"
- name: Create Issue
if: ${{ failure() }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_SHA: ${{ github.sha }}
with:
filename: .github/ISSUE_TEMPLATE/daily_failure.md
4 changes: 4 additions & 0 deletions docs/sierra.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Sierra Resources

- [Cairo and Sierra](https://docs.starknet.io/architecture-and-concepts/smart-contracts/cairo-and-sierra/)
- [StarkWare Sessions 23 | Sierra - Enforcing Safety Using Typesystems | Shahar Papini](https://www.youtube.com/watch?v=-EHwaQuPuAA)
- [Reading Sierra: Starknet's secret sauce for Cairo 1.0](https://medium.com/yagi-fi/reading-sierra-starknets-secret-sauce-for-cairo-1-0-5bc73409e43c)
- [Under the hood of Cairo 1.0: Exploring Sierra Part 1](https://medium.com/nethermind-eth/under-the-hood-of-cairo-1-0-exploring-sierra-7f32808421f5)
- [Under the hood of Cairo 1.0: Exploring Sierra Part 2](https://medium.com/nethermind-eth/under-the-hood-of-cairo-1-0-exploring-sierra-9355d618b26f)
- [Under the hood of Cairo 1.0: Exploring Sierra Part 3](https://medium.com/nethermind-eth/under-the-hood-of-cairo-1-0-exploring-sierra-1220f6dbcf9)
- [Understanding Sierra: Gas accounting](https://blog.kakarot.org/understanding-sierra-gas-accounting-19d6141d28b9)
- [Equivalence Between Loops and Recursive Functions](https://book.cairo-lang.org/ch02-05-control-flow.html#equivalence-between-loops-and-recursive-functions)
- [Inlining in Cairo](https://book.cairo-lang.org/ch11-06-inlining-in-cairo.html)
- Crate documentation
- [docs.rs: cairo_lang_sierra](https://docs.rs/cairo-lang-sierra/latest/cairo_lang_sierra/)
- [docs.rs: cairo_lang_sierra_ap_change](https://docs.rs/cairo-lang-sierra-ap-change/latest/cairo_lang_sierra_ap_change/)
Expand Down
7 changes: 5 additions & 2 deletions scripts/cmp_state_dumps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ for vm_dump in state_dumps/vm/*/*.json; do
continue
fi

base=$(basename "$vm_dump")
tx_name=$(basename "$vm_dump")
tx=${tx_name//.*/}
block_name=$(basename "$(dirname "$vm_dump")")
block=${block_name//block/}

if ! cmp -s \
<(sed '/"reverted": /d' "$native_dump") \
<(sed '/"reverted": /d' "$vm_dump")
then
echo "diff: $base"
echo "Diff at block $block, tx $tx"
diffing=$((diffing+1))
else
matching=$((matching+1))
Expand Down

0 comments on commit f21ffda

Please sign in to comment.