From e172d514088308d19e5e5a2ae911c5136b707394 Mon Sep 17 00:00:00 2001 From: Julian Gonzalez Calderon Date: Fri, 5 Jul 2024 06:28:07 -0900 Subject: [PATCH] Add actions (#17) * Add ci.yml * Fix clippy * Format and ignore failing tests * Fix udep * Remove dup test * Fix some comments * Add tests * Unignore test that runs on linux --- .github/workflows/ci.yml | 167 ++++++++++++ Cargo.lock | 92 +------ replay/Cargo.toml | 1 - replay/src/main.rs | 14 +- rpc-state-reader/Cargo.toml | 11 +- .../src/blockifier_state_reader.rs | 253 ++++++++++-------- rpc-state-reader/src/rpc_state.rs | 2 +- 7 files changed, 330 insertions(+), 210 deletions(-) create mode 100644 .github/workflows/ci.yml 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..0ce6b7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" @@ -2801,12 +2769,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 +3016,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 +3247,6 @@ dependencies = [ "anyhow", "blockifier", "clap", - "indicatif", "rpc-state-reader", "starknet_api", "tracing", @@ -3388,7 +3343,6 @@ dependencies = [ "pretty_assertions_sorted", "serde", "serde_json", - "serde_with 3.8.1", "starknet", "starknet_api", "test-case", @@ -3726,25 +3680,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 +3696,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 +3857,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 +3876,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 +3894,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 +4008,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "serde_with 2.3.3", + "serde_with", "starknet-core 0.7.2", "thiserror", "url", @@ -4689,12 +4613,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/replay/Cargo.toml b/replay/Cargo.toml index 65252c1..6043ff0 100644 --- a/replay/Cargo.toml +++ b/replay/Cargo.toml @@ -13,7 +13,6 @@ 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 = { workspace = true } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } diff --git a/replay/src/main.rs b/replay/src/main.rs index 7434c4f..bc3a87e 100644 --- a/replay/src/main.rs +++ b/replay/src/main.rs @@ -1,19 +1,15 @@ -use blockifier::{ - execution, state::cached_state::CachedState, transaction::objects::TransactionExecutionInfo, -}; +use blockifier::state::cached_state::CachedState; use clap::{Parser, Subcommand}; use rpc_state_reader::{ blockifier_state_reader::RpcStateReader, - rpc_state::{self, BlockValue, RpcChain, RpcState, RpcTransactionReceipt}, + rpc_state::{BlockValue, RpcChain, RpcState}, rpc_state_errors::RpcStateError, }; use rpc_state_reader::blockifier_state_reader::execute_tx_configurable; #[cfg(feature = "benchmark")] use rpc_state_reader::{ - execute_tx_configurable_with_state, - rpc_state::{RpcBlockInfo, RpcState}, - RpcStateReader, + execute_tx_configurable_with_state, rpc_state::RpcBlockInfo, RpcStateReader, }; use starknet_api::block::BlockNumber; #[cfg(feature = "benchmark")] @@ -36,7 +32,7 @@ use std::ops::Div; use std::str::FromStr; #[cfg(feature = "benchmark")] use std::{collections::HashMap, sync::Arc, time::Instant}; -use tracing::{debug, error, field, info, info_span, span}; +use tracing::{debug, error, info, info_span}; use tracing_subscriber::filter::Directive; use tracing_subscriber::{util::SubscriberInitExt, EnvFilter}; @@ -263,7 +259,7 @@ fn parse_network(network: &str) -> RpcChain { fn build_cached_state(network: &str, block_number: u64) -> CachedState { let previous_block_number = BlockNumber(block_number); - let rpc_chain = parse_network(&network); + let rpc_chain = parse_network(network); let rpc_reader = RpcStateReader( RpcState::new_rpc(rpc_chain, previous_block_number.into()) .expect("failed to create state reader"), diff --git a/rpc-state-reader/Cargo.toml b/rpc-state-reader/Cargo.toml index 373f831..fae7868 100644 --- a/rpc-state-reader/Cargo.toml +++ b/rpc-state-reader/Cargo.toml @@ -7,20 +7,19 @@ edition = "2021" ureq = { version = "2.7.1", features = ["json"] } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = [ - "arbitrary_precision", - "raw_value", + "arbitrary_precision", + "raw_value", ] } -starknet_api = {workspace = true} +starknet_api = { workspace = true } cairo-lang-starknet = "=2.6.3" cairo-lang-starknet-classes = "=2.6.3" cairo-lang-utils = "=2.6.3" -starknet = "0.7.0" +starknet = "0.7.0" thiserror = { workspace = true } flate2 = "1.0.25" -serde_with = "3.0.0" dotenv = "0.15.0" cairo-vm = "0.9.2" -blockifier = {workspace = true} +blockifier = { workspace = true } [dev-dependencies] pretty_assertions_sorted = "1.2.3" diff --git a/rpc-state-reader/src/blockifier_state_reader.rs b/rpc-state-reader/src/blockifier_state_reader.rs index eb481d9..0099fdc 100644 --- a/rpc-state-reader/src/blockifier_state_reader.rs +++ b/rpc-state-reader/src/blockifier_state_reader.rs @@ -1,14 +1,10 @@ use blockifier::{ blockifier::block::BlockInfo, context::{BlockContext, ChainInfo, FeeTokenAddresses}, - execution::contract_class::{ - ClassInfo, ContractClass, ContractClassV0, ContractClassV0Inner, SierraContractClassV1, - SierraContractClassV1Inner, - }, + execution::contract_class::{ClassInfo, ContractClass, ContractClassV0, ContractClassV0Inner}, state::{ cached_state::CachedState, errors::StateError, - global_cache::GlobalContractCache, state_api::{StateReader, StateResult}, }, transaction::{ @@ -21,22 +17,17 @@ use blockifier::{ }, versioned_constants::VersionedConstants, }; -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use cairo_vm::types::program::Program; use starknet::core::types::ContractClass as SNContractClass; use starknet_api::{ block::BlockNumber, - contract_address, - core::{ - calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce, - PatriciaKey, - }, - hash::{StarkFelt, StarkHash}, - patricia_key, stark_felt, + core::{calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce}, + hash::StarkFelt, + stark_felt, state::StorageKey, transaction::{Transaction as SNTransaction, TransactionHash}, }; -use std::{collections::HashMap, sync::Arc}; +use std::sync::Arc; use crate::{ rpc_state::{RpcBlockInfo, RpcChain, RpcState, RpcTransactionReceipt, TransactionTrace}, @@ -152,25 +143,24 @@ pub fn execute_tx( // Create state from RPC reader let mut state = CachedState::new(rpc_reader); - let fee_token_address = - contract_address!("049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"); - - const N_STEPS_FEE_WEIGHT: f64 = 0.01; - let vm_resource_fee_cost = Arc::new(HashMap::from([ - ("n_steps".to_string(), N_STEPS_FEE_WEIGHT), - ("output_builtin".to_string(), 0.0), - ("pedersen_builtin".to_string(), N_STEPS_FEE_WEIGHT * 32.0), - ("range_check_builtin".to_string(), N_STEPS_FEE_WEIGHT * 16.0), - ("ecdsa_builtin".to_string(), N_STEPS_FEE_WEIGHT * 2048.0), - ("bitwise_builtin".to_string(), N_STEPS_FEE_WEIGHT * 64.0), - ("ec_op_builtin".to_string(), N_STEPS_FEE_WEIGHT * 1024.0), - ("poseidon_builtin".to_string(), N_STEPS_FEE_WEIGHT * 32.0), - ( - "segment_arena_builtin".to_string(), - N_STEPS_FEE_WEIGHT * 10.0, - ), - ("keccak_builtin".to_string(), N_STEPS_FEE_WEIGHT * 2048.0), // 2**11 - ])); + // let fee_token_address = + // contract_address!("049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"); + // const N_STEPS_FEE_WEIGHT: f64 = 0.01; + // let vm_resource_fee_cost = Arc::new(HashMap::from([ + // ("n_steps".to_string(), N_STEPS_FEE_WEIGHT), + // ("output_builtin".to_string(), 0.0), + // ("pedersen_builtin".to_string(), N_STEPS_FEE_WEIGHT * 32.0), + // ("range_check_builtin".to_string(), N_STEPS_FEE_WEIGHT * 16.0), + // ("ecdsa_builtin".to_string(), N_STEPS_FEE_WEIGHT * 2048.0), + // ("bitwise_builtin".to_string(), N_STEPS_FEE_WEIGHT * 64.0), + // ("ec_op_builtin".to_string(), N_STEPS_FEE_WEIGHT * 1024.0), + // ("poseidon_builtin".to_string(), N_STEPS_FEE_WEIGHT * 32.0), + // ( + // "segment_arena_builtin".to_string(), + // N_STEPS_FEE_WEIGHT * 10.0, + // ), + // ("keccak_builtin".to_string(), N_STEPS_FEE_WEIGHT * 2048.0), // 2**11 + // ])); let block_info = BlockInfo { block_number, @@ -240,7 +230,7 @@ pub fn execute_tx( } SNTransaction::Declare(tx) => { // Fetch the contract_class from the next block (as we don't have it in the previous one) - let mut next_block_state_reader = RpcStateReader( + let next_block_state_reader = RpcStateReader( RpcState::new_rpc(network, (block_number.next()).unwrap().into()).unwrap(), ); let contract_class = next_block_state_reader @@ -293,16 +283,16 @@ pub fn execute_tx_configurable_with_state( tx_hash: &TransactionHash, tx: SNTransaction, block_info: BlockInfo, - skip_validate: bool, - skip_nonce_check: bool, + _skip_validate: bool, + _skip_nonce_check: bool, state: &mut CachedState, ) -> 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(); @@ -438,16 +428,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 (tx_info, trace, _) = execute_tx(hash, chain, BlockNumber(block_number)); @@ -460,35 +451,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( @@ -500,11 +487,13 @@ mod tests { "0x0528ec457cf8757f3eefdf3f0728ed09feeecc50fd97b1e4c5da94e27e9aa1d6", 169928, // real block 169929 RpcChain::MainNet + => ignore )] #[test_case( "0x0737677385a30ec4cbf9f6d23e74479926975b74db3d55dc5e46f4f8efee41cf", 169928, // real block 169929 RpcChain::MainNet + => ignore )] #[test_case( "0x026c17728b9cd08a061b1f17f08034eb70df58c1a96421e73ee6738ad258a94c", @@ -514,64 +503,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 638867 + RpcChain::MainNet + )] + #[test_case( + "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( - "0x41497e62fb6798ff66e4ad736121c0164cdb74005aa5dab025be3d90ad4ba06", - 638866, // real block 475946 - RpcChain::MainNet -)] + "0x5896b4db732cfc57ce5d56ece4dfa4a514bd435a0ee80dc79b37e60cdae5dd6", + 653000, // real block 653001 + RpcChain::MainNet + => ignore["takes to long"] + )] #[test_case( - "0x7805c2bf5abaf4fe0eb1db7b7be0486a14757b4bf96634c828d11c07e4a763c", - 641975, // real block 475946 - RpcChain::MainNet -)] + "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 (tx_info, trace, _receipt) = execute_tx(hash, chain, BlockNumber(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},