From f39cb35977d7c183d737056a7515afed8825b6bd Mon Sep 17 00:00:00 2001 From: Franco Giachetta Date: Thu, 24 Oct 2024 18:14:59 +0000 Subject: [PATCH] Blocks Running Workflow (#869) * execute block with native * add vm execution and diff checking * path native version in replay * fix ci * fix ci * fix ci * fix ci * changes features * fixes * fix typos * fix echo patch native version * fix echo patch native version * fix echo patch native version * fix echo patch native version * use sed to replace version * use sed to replace version * use sed to replace version * use sed to replace version * use sed to replace version * change runtime library path * adapt path script * adapt path script * adapt path script * change sed command * use replay's main * fix library path + add for macos * fix macos uploaded files * change library path * change library path * change library path * change library path * rework + add block exec concurrency * fix * fix cargo run command * fix cargo run command * fix cargo run command * fix cargo run command * fix cargo run command * fix cargo run command * fix action needs * fix action needs * fix action needs * fix upload dumps * fix sed accident * fix dump comparison * add more blocks * swap block * fix dump comparison * dont fail fast to check every block * ping replay version * better naming * make requested changes * run replay in release * make more requested changes * fix if * forgot to checkout * forgot to checkout * fix if * fix if * change blocks --- .github/workflows/starknet-blocks.yml | 133 ++++++++++++++++++++++++++ Cargo.lock | 102 ++++++++++---------- scripts/diff-check.sh | 32 +++++++ 3 files changed, 216 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/starknet-blocks.yml create mode 100755 scripts/diff-check.sh diff --git a/.github/workflows/starknet-blocks.yml b/.github/workflows/starknet-blocks.yml new file mode 100644 index 000000000..492c621a3 --- /dev/null +++ b/.github/workflows/starknet-blocks.yml @@ -0,0 +1,133 @@ +name: Execute blocks + +on: + push: + branches: [main] + pull_request: + merge_group: + types: [checks_requested] + +jobs: + run-blocks: + name: Run Blocks + runs-on: ubuntu-latest + env: + MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/ + LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/ + TABLEGEN_190_PREFIX: /usr/lib/llvm-19/ + RPC_ENDPOINT_TESTNET: ${{ secrets.RPC_ENDPOINT_TESTNET }} + RPC_ENDPOINT_MAINNET: ${{ secrets.RPC_ENDPOINT_MAINNET }} + strategy: + matrix: + runner: [native, vm] + block: [742001, 769597, 779328, 801008, 803072] + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.82.0 + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + + - name: Check and free hdd space left + if: ${{ matrix.runner == 'native' }} + run: | + echo "Listing 20 largest packages" + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20 + df -h + sudo apt-get update + sudo apt-get remove -y '^llvm-.*' + sudo apt-get remove -y 'php.*' + sudo apt-get remove -y '^dotnet-.*' + sudo apt-get remove -y '^temurin-.*' + sudo apt-get remove -y azure-cli microsoft-edge-stable google-chrome-stable firefox mono-devel + sudo apt-get autoremove -y + sudo apt-get clean + df -h + echo "Removing large directories" + # deleting 15GB + sudo rm -rf /usr/share/dotnet/ + sudo rm -rf /usr/local/lib/android + df -h + + - name: add llvm deb repository + 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 + 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.runner == 'native' }} + run: make deps + - name: Build Cairo Native project + if: ${{ matrix.runner == 'native' }} + run: cargo b --release --all-features + - name: Build runtime + if: ${{ matrix.runner == 'native' }} + run: | + make runtime + cargo update + echo "CAIRO_NATIVE_RUNTIME_LIBRARY=$(pwd)/libcairo_native_runtime.a" > $GITHUB_ENV + + - name: Checkout Starknet Replay + uses: actions/checkout@v4 + with: + repository: lambdaclass/starknet-replay + ref: 08aa133b11e1e319036354c9acd8270483c844b5 + path: replay + + - name: Install Starknet Replay deps + run: make deps + + - name: Patch Cairo Native's version + if: ${{ matrix.runner == 'native' }} + run: | + cd replay + sed -r -i 's/cairo_native.*rev.*[0-9a-z]+./cairo_native.git", rev = "${{ github.event.pull_request.head.sha }}"/' Cargo.toml + + - name: Run Blocks Native + if: ${{ matrix.runner == 'native' }} + run: | + cd replay + cargo build --release --bin replay + cargo run --release --features state_dump block mainnet ${{ matrix.block }} + + - name: Run Blocks VM + if: ${{ matrix.runner == 'vm' }} + run: | + cd replay + cargo build --release --bin replay + cargo run --release --features "state_dump,only_cairo_vm" block mainnet ${{ matrix.block }} + + - name: Upload dumps + uses: actions/upload-artifact@v4 + with: + name: dump-${{matrix.block}}-${{matrix.runner}} + path: replay/state_dumps/${{matrix.runner}} + + compare-dumps: + needs: [run-blocks] + runs-on: ubuntu-latest + strategy: + matrix: + block: [742001, 769597, 779328, 801008, 803072] + fail-fast: false + steps: + - uses: actions/checkout@v4 + + - name: Fetch Native dumps + uses: actions/download-artifact@v4 + with: + name: dump-${{matrix.block}}-native + path: state_dumps/native + + - name: Fetch VM dumps + uses: actions/download-artifact@v4 + with: + name: dump-${{matrix.block}}-vm + path: state_dumps/vm + + - name: Check Diffs + run: ./scripts/diff-check.sh diff --git a/Cargo.lock b/Cargo.lock index 6033835da..ad3bb9781 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "aquamarine" @@ -118,7 +118,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -310,7 +310,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.79", + "syn 2.0.83", "which", ] @@ -331,7 +331,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -620,7 +620,7 @@ checksum = "d72f17373740f242d6995e896b9195c2cedff7e8b14e496afdd16b405039d1fb" dependencies = [ "cairo-lang-debug", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1080,9 +1080,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -1183,7 +1183,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1406,7 +1406,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1417,7 +1417,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1484,7 +1484,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1494,7 +1494,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1565,7 +1565,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1612,7 +1612,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1727,7 +1727,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -1785,7 +1785,7 @@ checksum = "553630feadf7b76442b0849fd25fdf89b860d933623aec9693fed19af0400c78" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -2218,9 +2218,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libloading" @@ -2335,7 +2335,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.79", + "syn 2.0.83", "tblgen-alt", "unindent", ] @@ -2739,12 +2739,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.22" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" dependencies = [ "proc-macro2", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -2782,9 +2782,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -3007,7 +3007,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.79", + "syn 2.0.83", "unicode-ident", ] @@ -3037,7 +3037,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -3163,7 +3163,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -3183,22 +3183,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -3209,14 +3209,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -3371,7 +3371,7 @@ checksum = "bbc159a1934c7be9761c237333a57febe060ace2bc9e3b337a59a37af206d19f" dependencies = [ "starknet-curve 0.4.2", "starknet-ff", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -3463,9 +3463,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "01680f5d178a369f817f43f3d399650272873a8e7588a7872f7e90edc71d60a3" dependencies = [ "proc-macro2", "quote", @@ -3532,7 +3532,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -3543,28 +3543,28 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", "test-case-core", ] [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -3703,7 +3703,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -3917,7 +3917,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", "wasm-bindgen-shared", ] @@ -3939,7 +3939,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4208,7 +4208,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] @@ -4228,7 +4228,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.83", ] [[package]] diff --git a/scripts/diff-check.sh b/scripts/diff-check.sh new file mode 100755 index 000000000..5350934be --- /dev/null +++ b/scripts/diff-check.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +diffing=0 +skipping=0 + +for vm_dump in state_dumps/vm/*/*.json; do + [ -f "$vm_dump" ] || continue + + native_dump="${vm_dump//vm/native}" + + # Check if the corresponding native_dump file exists, if not, skip + if [ ! -f "$native_dump" ]; then + echo "Skipping: $native_dump (file not found)" + skipping=$((skipping+1)) + continue + fi + + base=$(basename "$vm_dump") + + if ! cmp -s \ + <(sed '/"reverted": /d' "$native_dump") \ + <(sed '/"reverted": /d' "$vm_dump") + then + echo "NATIVE DIFFING IN TX: $native_dump" + diffing=1 + fi +done + +if test $diffing == 1 || test $skipping != 0 +then + exit 1 +fi