Skip to content

Commit

Permalink
add vm execution and diff checking
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoGiachetta committed Oct 18, 2024
1 parent 8b25ab6 commit e02e677
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 6 deletions.
54 changes: 48 additions & 6 deletions .github/workflows/starknet-blocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [checks_requested]

jobs:
native-vm-dump:
native-vm-blocks-dump:
name: Check Dump Naitve vs VM
runs-on: ubuntu-latest
env:
Expand All @@ -17,10 +17,16 @@ jobs:
TABLEGEN_190_PREFIX: /usr/lib/llvm-19/
RPC_ENDPOINT_TESTNET: ${{ secrets.RPC_ENDPOINT_TESTNET }}
RPC_ENDPOINT_MAINNET: ${{ secrets.RPC_ENDPOINT_MAINNET }}
strategy:
matrix:
strategy: [native, vm]
features: ["state-dump", "state-dump,only_cairo_vm"]
dump-path: ["state_dumps/native", "state_dumps/vm"]
steps:
- uses: actions/checkout@v4

- name: check and free hdd space left
- name: Check and free hdd space left
if: ${{ matrix.dump == native }}
run: |
echo "Listing 20 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
Expand All @@ -45,19 +51,24 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: add llvm deb repository
if: ${{ matrix.dump == native }}
uses: myci-actions/add-deb-repo@11
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main
repo-name: llvm-repo
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
- name: Install LLVM
if: ${{ matrix.dump == native }}
run: sudo apt-get install llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools

- name: Install Cairo Native deps
if: ${{ matrix.dump == native }}
run: make deps
- name: Build Cairo Native project
if: ${{ matrix.dump == native }}
run: make build
- name: Build runtime subproject
if: ${{ matrix.dump == native }}
run: |
make runtime-ci
export CAIRO_NATIVE_RUNTIME_LIBRARY=libcairo_native_runtime.a
Expand All @@ -66,13 +77,44 @@ jobs:
uses: actions/checkout@v4
with:
repository: lambdaclass/starknet-replay
ref: main
ref: e125989afa77022995b3989c1d64292755312a87

- name: Install Starknet Replay deps
run: make deps
- name: Build Starknet Replay project
run: make build

- name: Run Blocks
run: |
cargo run block-range 807301 807301 mainnet
cargo run --features ${{matrix.features}} block-range 807301 807301 mainnet
- name: Upload generated Dump
uses: actions/upload-artifact@v4
with:
name: dump-{{matrix.dump}}
path: ${{matrix.dump-path}}

compare-dump:
needs: native-vm-blocks-dump
runs-on: ubuntu-latest

steps:
- name: Checkout Starknet Replay
uses: actions/checkout@v4
with:
repository: lambdaclass/starknet-replay
ref: e125989afa77022995b3989c1d64292755312a87

- name: Fetch Native dumps
uses: actions/upload-artifact@v4
with:
name: dump-native
path: state_dumps/native

- name: Fetch VM dumps
uses: actions/upload-artifact@v4
with:
name: dump-vm
path: state_dumps/vm

- name: Check Diffs
run: |
if [./scripts/cmp_state_dumps.sh | grep Matching == ]
21 changes: 21 additions & 0 deletions scripts/diff-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

diffing=0

for vm_dump in state_dumps/vm/*/*.json; do
[ -f "$vm_dump" ] || continue

native_dump="${vm_dump//vm/native}"

base=$(basename "$native_dump")

if ! cmp -s \
<(sed '/"reverted": /d' "$native_dump") \
<(sed '/"reverted": /d' "$vm_dump")
then
diffing=1
break
fi
done

echo $diffing

0 comments on commit e02e677

Please sign in to comment.