diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..16f4dc2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,167 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + merge_group: + types: [checks_requested] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + check: + name: clippy + runs-on: ubuntu-latest + env: + MLIR_SYS_180_PREFIX: /usr/lib/llvm-18/ + LLVM_SYS_180_PREFIX: /usr/lib/llvm-18/ + TABLEGEN_180_PREFIX: /usr/lib/llvm-18/ + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.79.0 + with: + components: clippy, rustfmt + - uses: Swatinem/rust-cache@v2 + - name: Add LLVM Debian repository + uses: myci-actions/add-deb-repo@10 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Install LLVM + run: sudo apt-get install llvm-18 llvm-18-dev llvm-18-runtime clang-18 clang-tools-18 lld-18 libpolly-18-dev libmlir-18-dev mlir-18-tools + - name: Clippy + run: cargo clippy --all-targets -- -D warnings + + format: + name: rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.79.0 + with: + components: rustfmt + - run: cargo fmt --all -- --check + - name: Find Comment + continue-on-error: true + if: success() || failure() + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: thiscommentistofindthisformatcomment + - name: Create or update comment + continue-on-error: true + if: failure() + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ❌ Code is not formatted! Please run `cargo format` and push the changes. + + + edit-mode: replace + - name: Create or update comment + continue-on-error: true + if: ${{ success() && steps.fc.outputs.comment-id != null }} + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ✅ Code is now correctly formatted. + + + edit-mode: replace + + # Check for unnecessary dependencies. + udeps: + runs-on: ubuntu-latest + env: + MLIR_SYS_180_PREFIX: /usr/lib/llvm-18/ + LLVM_SYS_180_PREFIX: /usr/lib/llvm-18/ + TABLEGEN_180_PREFIX: /usr/lib/llvm-18/ + RUSTUP_TOOLCHAIN: nightly-2024-02-01 # udeps needs nightly + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2024-02-01 + components: rustfmt + + - name: Add llvm deb repository + uses: myci-actions/add-deb-repo@10 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - name: Install LLVM + run: sudo apt-get install llvm-18 llvm-18-dev llvm-18-runtime clang-18 clang-tools-18 lld-18 libpolly-18-dev libmlir-18-dev mlir-18-tools + - name: Download and run cargo-udeps + run: | + wget -O - -c https://github.com/est31/cargo-udeps/releases/download/v0.1.45/cargo-udeps-v0.1.45-x86_64-unknown-linux-gnu.tar.gz | tar -xz + cargo-udeps-*/cargo-udeps udeps --all-targets + + test: + name: test (linux, amd64) + runs-on: ubuntu-latest + env: + MLIR_SYS_180_PREFIX: /usr/lib/llvm-18/ + LLVM_SYS_180_PREFIX: /usr/lib/llvm-18/ + TABLEGEN_180_PREFIX: /usr/lib/llvm-18/ + RPC_ENDPOINT_TESTNET: ${{ secrets.RPC_ENDPOINT_TESTNET }} + RPC_ENDPOINT_MAINNET: ${{ secrets.RPC_ENDPOINT_MAINNET }} + RUST_LOG: debug,replay=trace,rpc-state-reader=trace + steps: + - uses: actions/checkout@v4 + - name: Free HDD space + 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 google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell 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: Setup rust env + uses: dtolnay/rust-toolchain@1.79.0 + - name: Retreive cached dependecies + uses: Swatinem/rust-cache@v2 + - name: Add LLVM Debian repository + uses: myci-actions/add-deb-repo@11 + with: + repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main + repo-name: llvm-repo + keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key + - run: sudo apt-get update && sudo apt-get upgrade -y + - name: Install LLVM + run: sudo apt-get install llvm-18 llvm-18-dev llvm-18-runtime clang-18 clang-tools-18 lld-18 libpolly-18-dev libmlir-18-dev mlir-18-tools + - name: Checkout cairo_native + uses: actions/checkout@v4 + with: + repository: lambdaclass/cairo_native + ref: 66e9b5e053faf3b2a9129de5b15205d1cfe686eb + path: cairo_native + - name: Build Cairo Native Runtime Library + shell: bash + run: | + cd cairo_native + make runtime + echo "CAIRO_NATIVE_RUNTIME_LIBRARY=$(pwd)/libcairo_native_runtime.a" > $GITHUB_ENV + - name: Test + run: cargo test diff --git a/Cargo.lock b/Cargo.lock index 7d14692..9cc5307 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -442,7 +442,7 @@ dependencies = [ [[package]] name = "blockifier" version = "0.7.0-dev.1" -source = "git+https://github.com/lambdaclass/blockifier?rev=e8c166195e601ef6c4951f135fdf660a9b795819#e8c166195e601ef6c4951f135fdf660a9b795819" +source = "git+https://github.com/lambdaclass/blockifier?rev=d458a8d64b6d31da49c447576894ce013af862c2#d458a8d64b6d31da49c447576894ce013af862c2" dependencies = [ "anyhow", "ark-ec", @@ -474,7 +474,7 @@ dependencies = [ "serde_json", "sha3", "starknet-crypto 0.6.2", - "starknet-types-core 0.1.4", + "starknet-types-core 0.1.2", "starknet_api", "strum", "strum_macros", @@ -556,9 +556,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d9c31baeb6b52586b5adc88f01e90f86389d63d94363c562de5c79352e545b" +checksum = "6296d5748288d9fb97175d31aff9f68ea3f602456923895e512b078e9a2210a0" dependencies = [ "cairo-lang-utils", "indoc", @@ -570,9 +570,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7148cb2d72a3db24a6d2ef2b2602102cc5099cb9f6b913e5047fb009cb3a22a1" +checksum = "a7be5083c3328dad2248a94f0a24b3520c588e7d3bd5891770e4c91d3facade3" dependencies = [ "anyhow", "cairo-lang-defs", @@ -593,18 +593,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a761eb8e31ea65a2dd45f729c74f1770315f97124dad93d1f6853a10d460c6b" +checksum = "2a3cbf67fd766cb7ed48b72e6abf7041857518c9b9fd42475a60c138671c6603" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d60bc5d72fe7a95ba34e041dcbdf1cf3bfccb87008a515514b74913fa8ff05" +checksum = "7b284e41dfc158dfbdc02612dbfdb27a55547d23063bdc53105eeec41d8df006" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -619,9 +619,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356089e1b0a0ba9e115566191745613b3806a20259ad76764df82ab534d5412a" +checksum = "c6314b24901af8be75cd0e1363e3ff1a8020066372501f4cfc9161726b06ec2a" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -631,9 +631,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc43246cc2e5afd5a028bcdd63876ac3f8b1f4fb3ff785daaa0f0fbb51c9d906" +checksum = "4f95f5c8f7ea75580d164b5304251022e3d47f43fc1c778a01381b55ca9f268c" dependencies = [ "cairo-lang-utils", "good_lp", @@ -641,9 +641,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bcb9a4a40e53fa099774bd08bbcc3430f51213cc7fb1b50c2e9d01155731798" +checksum = "d3e58b80f0b413ef1320358fde1a0877fc3fbf740f5cead0de3e947a1bc3bfd4" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -655,9 +655,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba60e1e2477aa0f610ccf29189097d580464607c94b51741e1c18e64d6cee5f" +checksum = "abe6d604a06ea96c05b3666f2e8fac63cb8709e13667de272912f81db004a16b" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -680,9 +680,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f16ba1535e0cc5e79c2eff6592859bbdac03dc53d4dcdd26dbdbc04a77c3f5c" +checksum = "eaf1c279de47a77422f81b8a98023cd523cf0ae79f7153d60c4cf8b62b8ece2f" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -700,9 +700,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81c8cf6e0ee3d6b19429cc1663738b22f1ecea7d51bf7452e8e1086f08798baf" +checksum = "a1177a07498bdf45cba62f0c727388ff7433072847dbf701c58fa3c3e358154e" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -719,9 +719,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67f9da66325ce7ed6c002360f26106fe79deb9f8a2fca30abdbb8d388da7bb46" +checksum = "0c90d812ec983c5a8e3173aca3fc55036b9739201c89f30271ee14a4c1189379" dependencies = [ "cairo-lang-debug", "quote", @@ -730,9 +730,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e198af1ab3d05c7fb8b6a9a7a2e9bce245a6c855df5f770b751d29874a23b152" +checksum = "3985495d7e9dc481e97135d7139cfa098024351fb51d5feef8366b5fbc104807" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -744,9 +744,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf211f5431e2a6f4802b1b6483bf8e998e506a3be5369ed54a8807aae6e4dbf" +checksum = "fcc7c5969d107d24dbd7612ab7afec65d25475fe51d4bb708e3c773f2346c92b" dependencies = [ "ark-ff", "ark-secp256k1", @@ -775,9 +775,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7df81521c2125e3e95b683cc99374db1aebd7ddb317c5ca3dd92a235a9eb13" +checksum = "d5cfadbb9ca3479a6b5c02c0a125a5747835ba57a2de9c4e9764f42d85abe059" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -800,9 +800,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07da3ca1434c62a7cc7cd77d2941ef47a1c23b37325781b59407b78d8c61d863" +checksum = "74a57492267a5a8891866b6e48cdefa508b5f05931a5f8eaf004b9de15b1ffd6" dependencies = [ "anyhow", "cairo-felt", @@ -826,9 +826,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122c9055eb609a511178e3dce577de061819fd4c4c6b7452804557f76ca43bbf" +checksum = "6fdbb4bd95477123653b9200bd4e9dceae95a914f6fe85b2bed83b223e36fb5a" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -841,9 +841,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf049d9aea65c6e38da219a3700c72f78795d11449d9adcec28047ef8d63bd23" +checksum = "882cb178f1b79aabf70acce1d87b08d569d8a4b0ce8b1d8f538a02cdb36789db" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -856,9 +856,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e1d75e0830279ca1bd0189e3326720d6e081225f7d81ed060bbd22c6b37e980" +checksum = "4d80c9d29e6d3f4ab60e698ebe2de84dcf90570c3dd1cfa7b01bd5c42470331c" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -879,9 +879,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a3c3be88c8562fbf93b0803c186e7282f6daad93576c07f61b04a591fde468f" +checksum = "3ac02c90be2630ae861db6af226090da92741020519768332dd2c07e24d94c75" dependencies = [ "assert_matches", "cairo-felt", @@ -900,9 +900,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38da6f98c6b16945c89d2ae351c82d636ed38d3e6eb02f7c8679e3e03a63988" +checksum = "d102b10989f9637b1c916dd950cbd1bd8bb1b6a7aaa1a3035390be0683b92d85" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -910,9 +910,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9ffa8b3b8c47138c36b1907cebb5047dfc4de29ec10ece5bd6d6853243ec50" +checksum = "a27921a2bf82d191d28afd570b913341080c8fc25c83bf870dbf1252570b1b41" dependencies = [ "anyhow", "cairo-felt", @@ -941,9 +941,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47c64ae2bb00173e3a88760128bf72de356fa80eb19fa47602479063648b4003" +checksum = "8623b076ef3569e4262da5da270a84658b1ff242fe0c9624fbe432e7a937d101" dependencies = [ "cairo-felt", "cairo-lang-casm", @@ -966,9 +966,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8262c426a57e1e5ec297db24278464841500613445e2cb1c43d5f71ad91ee8d6" +checksum = "4c62f5bd74e249636e7c48d8b95e6cc0ee991206d4a6cbe5c2624184a828e70b" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -992,9 +992,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c2d77976328ac79509b9c33e4380d15aeff7c8ee07fbaea6b41dd469084738" +checksum = "592e7e5f875d69428aae446e299d3c4618c7fb326adafc5d3a83bd8a5a916111" dependencies = [ "anyhow", "cairo-felt", @@ -1020,9 +1020,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf733a7cdc4166d0baf0ed8a98d9ada827daee6653b37d9326e334e53481c6d3" +checksum = "e6f98e8769412907ceb106c21c70907cc0c87ca0a2a44c82b6229a695a6f9b48" dependencies = [ "hashbrown 0.14.5", "indexmap 2.2.6", @@ -1037,7 +1037,7 @@ dependencies = [ [[package]] name = "cairo-native" version = "0.2.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=c64f5ee86391574d2ee63f9df65a0c2789942778#c64f5ee86391574d2ee63f9df65a0c2789942778" +source = "git+https://github.com/lambdaclass/cairo_native?rev=905d6959662edfec4829568f995206fcb8bf64d0#905d6959662edfec4829568f995206fcb8bf64d0" dependencies = [ "anyhow", "bumpalo", @@ -1076,7 +1076,7 @@ dependencies = [ "num-traits 0.2.19", "p256", "sec1", - "starknet-types-core 0.1.4", + "starknet-types-core 0.1.2", "stats_alloc", "tempfile", "thiserror", @@ -1087,7 +1087,7 @@ dependencies = [ [[package]] name = "cairo-native-runtime" version = "0.2.0" -source = "git+https://github.com/lambdaclass/cairo_native?rev=c64f5ee86391574d2ee63f9df65a0c2789942778#c64f5ee86391574d2ee63f9df65a0c2789942778" +source = "git+https://github.com/lambdaclass/cairo_native?rev=905d6959662edfec4829568f995206fcb8bf64d0#905d6959662edfec4829568f995206fcb8bf64d0" dependencies = [ "cairo-lang-runner", "cairo-lang-sierra-gas", @@ -1095,7 +1095,7 @@ dependencies = [ "libc", "starknet-crypto 0.6.2", "starknet-curve 0.4.2", - "starknet-types-core 0.1.4", + "starknet-types-core 0.1.2", ] [[package]] @@ -1257,19 +1257,6 @@ dependencies = [ "unicode_categories", ] -[[package]] -name = "console" -version = "0.15.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "unicode-width", - "windows-sys 0.52.0", -] - [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -1684,12 +1671,6 @@ dependencies = [ "log", ] -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "encoding_rs" version = "0.8.34" @@ -2277,19 +2258,6 @@ dependencies = [ "serde", ] -[[package]] -name = "indicatif" -version = "0.17.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" -dependencies = [ - "console", - "instant", - "number_prefix", - "portable-atomic", - "unicode-width", -] - [[package]] name = "indoc" version = "2.0.5" @@ -2443,6 +2411,18 @@ dependencies = [ "sha3", ] +[[package]] +name = "lambdaworks-crypto" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb5d4f22241504f7c7b8d2c3a7d7835d7c07117f10bff2a7d96a9ef6ef217c3" +dependencies = [ + "lambdaworks-math 0.7.0", + "serde", + "sha2", + "sha3", +] + [[package]] name = "lambdaworks-math" version = "0.6.0" @@ -2458,6 +2438,10 @@ name = "lambdaworks-math" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "358e172628e713b80a530a59654154bfc45783a6ed70ea284839800cebdf8f97" +dependencies = [ + "serde", + "serde_json", +] [[package]] name = "lazy_static" @@ -2518,9 +2502,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "llvm-sys" -version = "180.0.0" +version = "181.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778fa5fa02e32728e718f11eec147e6f134137399ab02fd2c13d32476337affa" +checksum = "890e59e3db86b787af9d9b53c6accc0193e9b698293dda178c0821dbc3fb6217" dependencies = [ "anyhow", "cc", @@ -2801,12 +2785,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "object" version = "0.36.0" @@ -3054,12 +3032,6 @@ dependencies = [ "spki", ] -[[package]] -name = "portable-atomic" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" - [[package]] name = "powerfmt" version = "0.2.0" @@ -3291,7 +3263,6 @@ dependencies = [ "anyhow", "blockifier", "clap", - "indicatif", "rpc-state-reader", "starknet_api", "tracing", @@ -3388,7 +3359,6 @@ dependencies = [ "pretty_assertions_sorted", "serde", "serde_json", - "serde_with 3.8.1", "starknet", "starknet_api", "test-case", @@ -3726,25 +3696,7 @@ dependencies = [ "indexmap 1.9.3", "serde", "serde_json", - "serde_with_macros 2.3.3", - "time", -] - -[[package]] -name = "serde_with" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" -dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.2.6", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros 3.8.1", + "serde_with_macros", "time", ] @@ -3760,18 +3712,6 @@ dependencies = [ "syn 2.0.68", ] -[[package]] -name = "serde_with_macros" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" -dependencies = [ - "darling 0.20.9", - "proc-macro2", - "quote", - "syn 2.0.68", -] - [[package]] name = "sha2" version = "0.10.8" @@ -3933,7 +3873,7 @@ checksum = "d858efc93d85de95065a5732cb3e94d0c746674964c0859aab442ffbb9de76b4" dependencies = [ "serde", "serde_json", - "serde_with 2.3.3", + "serde_with", "starknet-accounts", "starknet-core 0.7.2", "starknet-providers", @@ -3952,7 +3892,7 @@ dependencies = [ "serde", "serde_json", "serde_json_pythonic", - "serde_with 2.3.3", + "serde_with", "sha3", "starknet-crypto 0.6.2", "starknet-ff", @@ -3970,7 +3910,7 @@ dependencies = [ "serde", "serde_json", "serde_json_pythonic", - "serde_with 2.3.3", + "serde_with", "sha3", "starknet-crypto 0.6.2", "starknet-ff", @@ -4084,7 +4024,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "serde_with 2.3.3", + "serde_with", "starknet-core 0.7.2", "thiserror", "url", @@ -4113,7 +4053,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1e16522c1c9aa7fc149a46816cd18aa12a5fc2b2b75a018089022db473a9237" dependencies = [ "bitvec", - "lambdaworks-crypto", + "lambdaworks-crypto 0.6.0", "lambdaworks-math 0.6.0", "lazy_static", "num-bigint", @@ -4124,10 +4064,11 @@ dependencies = [ [[package]] name = "starknet-types-core" -version = "0.1.4" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65799574816ba83cb04b21a3cb16f791b9882687cd9093415fd1b3821dbac29d" +checksum = "4098ac4ad57621cc7ec133b80fe72814d2cc4bee63ca8e7be4450ba6f42a07e8" dependencies = [ + "lambdaworks-crypto 0.7.0", "lambdaworks-math 0.7.0", "num-bigint", "num-integer", @@ -4689,12 +4630,6 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" -[[package]] -name = "unicode-width" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" - [[package]] name = "unicode-xid" version = "0.2.4" diff --git a/Cargo.toml b/Cargo.toml index 1e333f0..073b3a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,5 @@ [workspace] -members = [ - "rpc-state-reader", - "replay", -] +members = ["rpc-state-reader", "replay"] # Explicitly set the resolver to the default for edition >= 2021 @@ -12,4 +9,5 @@ resolver = "2" [workspace.dependencies] thiserror = "1.0.32" starknet_api = "=0.12.0-dev.1" -blockifier = { git = "https://github.com/lambdaclass/blockifier", rev = "e8c166195e601ef6c4951f135fdf660a9b795819" } +blockifier = { git = "https://github.com/lambdaclass/blockifier", rev = "d458a8d64b6d31da49c447576894ce013af862c2" } +tracing = "0.1" diff --git a/README.md b/README.md index 3545619..a9f86d6 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,12 @@ You can use the replay crate to execute transactions or blocks via the CLI. For * cargo run block mainnet 648655 * cargo run block-range 90000 90002 mainnet ``` + +### Logging + +This projects uses tracing with env-filter, so logging can be modified by the RUST_LOG environment variable. By default, only info events from the replay crate are shown. + +As an example, to show only error messages from the replay crate, run: +```bash +RUST_LOG=replay=error cargo run block mainnet 648461 +``` diff --git a/replay/Cargo.toml b/replay/Cargo.toml index 526ccf2..6043ff0 100644 --- a/replay/Cargo.toml +++ b/replay/Cargo.toml @@ -8,15 +8,13 @@ benchmark = [] [dependencies] # starknet specific crates -blockifier = {workspace = true} +blockifier = { workspace = true } rpc-state-reader = { path = "../rpc-state-reader" } starknet_api = { workspace = true } # CLI specific crates clap = { version = "4.4.6", features = ["derive"] } -indicatif = "0.17.7" # logs -tracing = "0.1" -tracing-subscriber = "0.3.17" +tracing = { workspace = true } +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } # error handling anyhow = "1.0" - diff --git a/replay/src/main.rs b/replay/src/main.rs index 6fdfea1..73951cb 100644 --- a/replay/src/main.rs +++ b/replay/src/main.rs @@ -1,6 +1,4 @@ -use blockifier::{ - state::cached_state::CachedState, transaction::objects::TransactionExecutionInfo, -}; +use blockifier::state::cached_state::CachedState; use clap::{Parser, Subcommand}; use rpc_state_reader::{ blockifier_state_reader::{build_cached_state, parse_network, RpcStateReader}, @@ -33,8 +31,12 @@ use starknet_in_rust::{ }; #[cfg(feature = "benchmark")] use std::ops::Div; +use std::str::FromStr; #[cfg(feature = "benchmark")] use std::{collections::HashMap, sync::Arc, time::Instant}; +use tracing::{debug, error, info, info_span}; +use tracing_subscriber::filter::Directive; +use tracing_subscriber::{util::SubscriberInitExt, EnvFilter}; #[derive(Debug, Parser)] #[command(about = "Replay is a tool for executing Starknet transactions.", long_about = None)] @@ -50,20 +52,14 @@ enum ReplayExecute { tx_hash: String, chain: String, block_number: u64, - silent: Option, }, #[clap(about = "Execute all the transactions in a given block.")] - Block { - chain: String, - block_number: u64, - silent: Option, - }, + Block { chain: String, block_number: u64 }, #[clap(about = "Execute all the transactions in a given range of blocks.")] BlockRange { block_start: u64, block_end: u64, chain: String, - silent: Option, }, #[cfg(feature = "benchmark")] #[clap( @@ -79,50 +75,49 @@ Caches all rpc data before the benchmark runs to provide accurate results" } fn main() { - let cli = ReplayCLI::parse(); + set_global_subscriber(); + let cli = ReplayCLI::parse(); match cli.subcommand { ReplayExecute::Tx { tx_hash, chain, block_number, - silent, } => { - let mut state = build_cached_state(&chain, block_number); - show_execution_data(&mut state, tx_hash, &chain, block_number, silent); + let mut state = build_cached_state(&chain, block_number - 1); + show_execution_data(&mut state, tx_hash, &chain, block_number); } ReplayExecute::Block { block_number, chain, - silent, } => { - println!("Executing block number: {}", block_number); + let _block_span = info_span!("block", number = block_number).entered(); - let mut state = build_cached_state(&chain, block_number); + let mut state = build_cached_state(&chain, block_number - 1); let transaction_hashes = get_transaction_hashes(&chain, block_number) .expect("Unable to fetch the transaction hashes."); - for tx_hash in transaction_hashes { - show_execution_data(&mut state, tx_hash, &chain, block_number, silent); + show_execution_data(&mut state, tx_hash, &chain, block_number); } } ReplayExecute::BlockRange { block_start, block_end, chain, - silent, } => { - println!("Executing block range: {} - {}", block_start, block_end); + info!("executing block range: {} - {}", block_start, block_end); for block_number in block_start..=block_end { - let mut state = build_cached_state(&chain, block_number); + let _block_span = info_span!("block", number = block_number).entered(); + + let mut state = build_cached_state(&chain, block_number - 1); let transaction_hashes = get_transaction_hashes(&chain, block_number) .expect("Unable to fetch the transaction hashes."); for tx_hash in transaction_hashes { - show_execution_data(&mut state, tx_hash, &chain, block_number, silent); + show_execution_data(&mut state, tx_hash, &chain, block_number); } } } @@ -260,48 +255,52 @@ fn show_execution_data( tx_hash: String, chain: &str, block_number: u64, - silent: Option, ) { - if silent.is_none() || !silent.unwrap() { - println!("Executing transaction with hash: {}", tx_hash); - println!("Block number: {}", block_number); - println!("Chain: {}", chain); - } + let _transaction_execution_span = info_span!("transaction", hash = tx_hash, chain).entered(); + + info!("starting execution"); + let previous_block_number = BlockNumber(block_number - 1); - let (tx_info, _trace, receipt) = + let (execution_info, _trace, rpc_receipt) = match execute_tx_configurable(state, &tx_hash, previous_block_number, false, true) { Ok(x) => x, Err(error_reason) => { - println!("Error: {}", error_reason); + error!("execution failed unexpectedly: {}", error_reason); return; } }; - let TransactionExecutionInfo { - revert_error, - actual_fee, - .. - } = tx_info; - let blockifier_actual_fee = actual_fee; + let execution_status = match &execution_info.revert_error { + Some(_) => "REVERTED", + None => "SUCCEEDED", + }; + let rpc_execution_status = rpc_receipt.execution_status; + let status_matches = execution_status == rpc_execution_status; - let RpcTransactionReceipt { - actual_fee, - execution_status, - .. - } = receipt; - - if silent.is_none() || !silent.unwrap() { - println!("[RPC] Execution status: {:?}", execution_status); - if let Some(revert_error) = revert_error { - println!("[Blockifier] Revert error: {}", revert_error); - } - println!( - "[RPC] Actual fee: {} {}", - actual_fee.amount, actual_fee.unit + if !status_matches { + error!( + transaction_hash = tx_hash, + chain = chain, + execution_status, + rpc_execution_status, + execution_error_message = execution_info.revert_error, + "rpc and execution status diverged" + ) + } else { + info!( + transaction_hash = tx_hash, + chain = chain, + execution_status, + rpc_execution_status, + execution_error_message = execution_info.revert_error, + "execution finished successfully" ); - println!("[Blockifier] Actual fee: {:?} wei", blockifier_actual_fee); } + + let execution_gas = execution_info.actual_fee; + let rpc_gas = rpc_receipt.actual_fee; + debug!(?execution_gas, ?rpc_gas, "execution actual fee"); } fn get_transaction_hashes(network: &str, block_number: u64) -> Result, RpcStateError> { @@ -310,3 +309,19 @@ fn get_transaction_hashes(network: &str, block_number: u64) -> Result, ) -> TransactionExecutionResult { - let fee_token_address = FeeTokenAddresses { - strk_fee_token_address: ContractAddress::default(), - eth_fee_token_address: ContractAddress(starknet_api::patricia_key!( - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" - )), - }; + // let _fee_token_address = FeeTokenAddresses { + // strk_fee_token_address: ContractAddress::default(), + // eth_fee_token_address: ContractAddress(starknet_api::patricia_key!( + // "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" + // )), + // }; // Get values for block context before giving ownership of the reader let chain_id = state.state.0.get_chain_name(); @@ -298,16 +289,17 @@ mod tests { } #[test_case( - "0x00b6d59c19d5178886b4c939656167db0660fe325345138025a3cc4175b21897", - 200303, // real block 200304 - RpcChain::MainNet => ignore["Doesn't revert in newest blockifier version"] + "0x00b6d59c19d5178886b4c939656167db0660fe325345138025a3cc4175b21897", + 200303, // real block 200304 + RpcChain::MainNet + => ignore["Doesn't revert in newest blockifier version"] )] #[test_case( - "0x02b28b4846a756e0cec6385d6d13f811e745a88c7e75a3ebc5fead5b4af152a3", - 200302, // real block 200304 - RpcChain::MainNet - => ignore["broken on both due to a cairo-vm error"] -)] + "0x02b28b4846a756e0cec6385d6d13f811e745a88c7e75a3ebc5fead5b4af152a3", + 200302, // real block 200303 + RpcChain::MainNet + => ignore["broken on both due to a cairo-vm error"] + )] fn blockifier_test_case_reverted_tx(hash: &str, block_number: u64, chain: RpcChain) { let mut state = build_cached_state(&chain.to_string(), block_number); let (tx_info, trace, _) = execute_tx_configurable(&mut state, hash, BlockNumber(block_number), false, false).unwrap(); @@ -321,35 +313,31 @@ mod tests { } #[test_case( - "0x05d200ef175ba15d676a68b36f7a7b72c17c17604eda4c1efc2ed5e4973e2c91", - 169928, - RpcChain::MainNet => ignore["Current blockifier version is not currently in production, no recent tx available for testing"] - )] - #[test_case( - // Declare tx - "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", - 347899, // real block 347900 - RpcChain::MainNet -)] + // Declare tx + "0x60506c49e65d84e2cdd0e9142dc43832a0a59cb6a9cbcce1ab4f57c20ba4afb", + 347899, // real block 347900 + RpcChain::MainNet + => ignore + )] #[test_case( - // Declare tx - "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", - 271887, // real block 271888 - RpcChain::MainNet -)] + // Declare tx + "0x1088aa18785779e1e8eef406dc495654ad42a9729b57969ad0dbf2189c40bee", + 271887, // real block 271888 + RpcChain::MainNet + )] #[test_case( "0x014640564509873cf9d24a311e1207040c8b60efd38d96caef79855f0b0075d5", - 90006, + 90006, // real block 90007 RpcChain::MainNet )] #[test_case( "0x025844447697eb7d5df4d8268b23aef6c11de4087936048278c2559fc35549eb", - 197000, + 197000, // real block 197001 RpcChain::MainNet )] #[test_case( "0x00164bfc80755f62de97ae7c98c9d67c1767259427bcf4ccfcc9683d44d54676", - 197000, + 197000, // real block 197001 RpcChain::MainNet )] #[test_case( @@ -361,11 +349,13 @@ mod tests { "0x0528ec457cf8757f3eefdf3f0728ed09feeecc50fd97b1e4c5da94e27e9aa1d6", 169928, // real block 169929 RpcChain::MainNet + => ignore )] #[test_case( "0x0737677385a30ec4cbf9f6d23e74479926975b74db3d55dc5e46f4f8efee41cf", 169928, // real block 169929 RpcChain::MainNet + => ignore )] #[test_case( "0x026c17728b9cd08a061b1f17f08034eb70df58c1a96421e73ee6738ad258a94c", @@ -375,64 +365,116 @@ mod tests { #[test_case( // review later "0x0743092843086fa6d7f4a296a226ee23766b8acf16728aef7195ce5414dc4d84", - 186548, // real block 186549 + 186548, // real block 186549 RpcChain::MainNet )] #[test_case( // fails in blockifier "0x00724fc4a84f489ed032ebccebfc9541eb8dc64b0e76b933ed6fc30cd6000bd1", - 186551, // real block 186552 + 186551, // real block 186552 RpcChain::MainNet + => ignore )] #[test_case( - "0x176a92e8df0128d47f24eebc17174363457a956fa233cc6a7f8561bfbd5023a", - 317092, // real block 317093 - RpcChain::MainNet -)] + "0x176a92e8df0128d47f24eebc17174363457a956fa233cc6a7f8561bfbd5023a", + 317092, // real block 317093 + RpcChain::MainNet + )] #[test_case( - "0x04db9b88e07340d18d53b8b876f28f449f77526224afb372daaf1023c8b08036", - 398051, // real block 398052 - RpcChain::MainNet -)] + "0x04db9b88e07340d18d53b8b876f28f449f77526224afb372daaf1023c8b08036", + 398051, // real block 398052 + RpcChain::MainNet + )] #[test_case( - "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", - 281513, // real block 281514 - RpcChain::MainNet -)] + "0x5a5de1f42f6005f3511ea6099daed9bcbcf9de334ee714e8563977e25f71601", + 281513, // real block 281514 + RpcChain::MainNet + )] #[test_case( - "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", - 351268, // real block 351269 - RpcChain::MainNet -)] + "0x26be3e906db66973de1ca5eec1ddb4f30e3087dbdce9560778937071c3d3a83", + 351268, // real block 351269 + RpcChain::MainNet + )] #[test_case( - "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", - 351225, // real block 351226 - RpcChain::MainNet -)] + "0x4f552c9430bd21ad300db56c8f4cae45d554a18fac20bf1703f180fac587d7e", + 351225, // real block 351226 + RpcChain::MainNet + )] // DeployAccount for different account providers: // OpenZeppelin (v0.7.0) #[test_case( - "0x04df8a364233d995c33c7f4666a776bf458631bec2633e932b433a783db410f8", - 422881, // real block 422882 - RpcChain::MainNet -)] + "0x04df8a364233d995c33c7f4666a776bf458631bec2633e932b433a783db410f8", + 422881, // real block 422882 + RpcChain::MainNet + )] // Argent X (v5.7.0) #[test_case( - "0x74820d4a1ac6e832a51a8938959e6f15a247f7d34daea2860d4880c27bc2dfd", - 475945, // real block 475946 - RpcChain::MainNet - )] + "0x74820d4a1ac6e832a51a8938959e6f15a247f7d34daea2860d4880c27bc2dfd", + 475945, // real block 475946 + RpcChain::MainNet + => ignore + )] #[test_case( - "0x41497e62fb6798ff66e4ad736121c0164cdb74005aa5dab025be3d90ad4ba06", - 638866, // real block 475946 - RpcChain::MainNet -)] + "0x41497e62fb6798ff66e4ad736121c0164cdb74005aa5dab025be3d90ad4ba06", + 638866, // real block 638867 + RpcChain::MainNet + )] #[test_case( - "0x7805c2bf5abaf4fe0eb1db7b7be0486a14757b4bf96634c828d11c07e4a763c", - 641975, // real block 475946 - RpcChain::MainNet -)] + "0x7805c2bf5abaf4fe0eb1db7b7be0486a14757b4bf96634c828d11c07e4a763c", + 641975, // real block 641976 + RpcChain::MainNet + => ignore + )] + #[test_case( + "0x73ef9cde09f005ff6f411de510ecad4cdcf6c4d0dfc59137cff34a4fc74dfd", + 654000, // real block 654001 + RpcChain::MainNet + )] + #[test_case( + "0x75d7ef42a815e4d9442efcb509baa2035c78ea6a6272ae29e87885788d4c85e", + 654000, // real block 654001 + RpcChain::MainNet + )] + #[test_case( + "0x1ecb4b825f629eeb9816ddfd6905a85f6d2c89995907eacaf6dc64e27a2c917", + 654000, // real block 654001 + RpcChain::MainNet + )] + #[test_case( + "0x70d83cb9e25f1e9f7be2608f72c7000796e4a222c1ed79a0ea81abe5172557b", + 654000, // real block 654001 + RpcChain::MainNet + )] + #[test_case( + "0x670321c71835004fcab639e871ef402bb807351d126ccc4d93075ff2c31519d", + 654000, // real block 653001 + RpcChain::MainNet + )] + #[test_case( + "0x5896b4db732cfc57ce5d56ece4dfa4a514bd435a0ee80dc79b37e60cdae5dd6", + 653000, // real block 653001 + RpcChain::MainNet + => ignore["takes to long"] + )] + #[test_case( + "0x5a030fd81f14a1cf29a2e5259d3f2c9960018ade2d135269760e6fb4802ac02", + 653000, // real block 653001 + RpcChain::MainNet + => ignore["halts execution"] + )] + #[test_case( + "0x2d2bed435d0b43a820443aad2bc9e3d4fa110c428e65e422101dfa100ba5664", + 653000, // real block 653001 + RpcChain::MainNet + => ignore + )] + #[test_case( + "0x3330b29e8b99dedef79f5c7cdc2b510c590155add29dcc5e2f92d176d8e19d", + 653000, // real block 653001 + RpcChain::MainNet + => ignore + )] fn blockifier_tx(hash: &str, block_number: u64, chain: RpcChain) { // Execute using blockifier let mut state = build_cached_state(&chain.to_string(), block_number); diff --git a/rpc-state-reader/src/rpc_state.rs b/rpc-state-reader/src/rpc_state.rs index c3dfd63..814ca1c 100644 --- a/rpc-state-reader/src/rpc_state.rs +++ b/rpc-state-reader/src/rpc_state.rs @@ -10,7 +10,7 @@ use cairo_vm::vm::runners::{ use core::fmt; use dotenv::dotenv; use serde::{Deserialize, Deserializer}; -use serde_json::{json, Value}; +use serde_json::json; use starknet::core::types::ContractClass as SNContractClass; use starknet_api::{ block::{BlockNumber, BlockTimestamp},