From 82e6edf67379f05f039589cfdc0dd09f5275e120 Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Thu, 1 Aug 2024 14:18:34 +0300 Subject: [PATCH 01/10] feat(ci): build native blockifier artifacts on every merge (#248) Signed-off-by: Dori Medini --- .github/workflows/blockifier_ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/blockifier_ci.yml b/.github/workflows/blockifier_ci.yml index 52a1062e92..2b4ea730eb 100644 --- a/.github/workflows/blockifier_ci.yml +++ b/.github/workflows/blockifier_ci.yml @@ -1,5 +1,7 @@ name: Blockifier-CI +# TODO(Dori, 15/8/2024): Split this job, so the feature-less build doesn't run on every push to main +# branches. on: push: branches: @@ -7,11 +9,6 @@ on: - main-v[0-9].** tags: - v[0-9].** - paths: - - 'crates/blockifier/**' - - 'crates/native_blockifier/**' - - 'build_native_blockifier_in_docker.sh' - - 'scripts/build_native_blockifier.sh' pull_request: types: From acad65077cdfb5d4ec3baab9c7a409b8692220e0 Mon Sep 17 00:00:00 2001 From: alon-dotan-starkware Date: Thu, 1 Aug 2024 14:48:46 +0300 Subject: [PATCH 02/10] chore: add merge gate keeper (#253) --- .github/workflows/main.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2337750bff..e5f01bd898 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -165,3 +165,24 @@ jobs: with: version: ${{env.PROTOC_VERSION}} - run: cargo check --workspace -r --all-features + + merge-gatekeeper: + runs-on: ubuntu-latest + # Restrict permissions of the GITHUB_TOKEN. + # Docs: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs + permissions: + checks: read + statuses: read + steps: + - name: Run Merge Gatekeeper + if: github.event_name != 'merge_group' + uses: upsidr/merge-gatekeeper@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run Merge Gatekeeper in Merge Queue + if: github.event_name == 'merge_group' + uses: upsidr/merge-gatekeeper@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + ref: ${{github.ref}} From 8844718a71206fdcf19edb381fcf413dbdcdc065 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware <141143145+AvivYossef-starkware@users.noreply.github.com> Date: Sun, 4 Aug 2024 11:08:21 +0300 Subject: [PATCH 03/10] refactor: make external tests generic (#140) --- .../external_test_utils.rs | 31 +++++++++++-------- .../internal_test_utils.rs | 2 +- .../original_skeleton_tree/config.rs | 6 ++-- .../updated_skeleton_tree/hash_function.rs | 4 +-- .../committer_cli/benches/committer_bench.rs | 7 +++-- .../committer_cli/src/tests/python_tests.rs | 9 +++++- .../src/tests/regression_tests.rs | 12 +++++-- 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/crates/committer/src/patricia_merkle_tree/external_test_utils.rs b/crates/committer/src/patricia_merkle_tree/external_test_utils.rs index 213cdc98e0..cf1f236f22 100644 --- a/crates/committer/src/patricia_merkle_tree/external_test_utils.rs +++ b/crates/committer/src/patricia_merkle_tree/external_test_utils.rs @@ -5,14 +5,13 @@ use ethnum::U256; use rand::Rng; use serde_json::json; -use super::filled_tree::tree::{FilledTree, StorageTrie}; +use super::filled_tree::tree::{FilledTree, FilledTreeImpl}; use super::node_data::leaf::{Leaf, LeafModifications, SkeletonLeaf}; -use super::original_skeleton_tree::config::OriginalSkeletonStorageTrieConfig; +use super::original_skeleton_tree::config::OriginalSkeletonTreeConfig; use super::original_skeleton_tree::tree::{OriginalSkeletonTree, OriginalSkeletonTreeImpl}; use super::types::{NodeIndex, SortedLeafIndices}; -use super::updated_skeleton_tree::hash_function::TreeHashFunctionImpl; +use super::updated_skeleton_tree::hash_function::TreeHashFunction; use super::updated_skeleton_tree::tree::{UpdatedSkeletonTree, UpdatedSkeletonTreeImpl}; -use crate::block_committer::input::StarknetStorageValue; use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::errors::TypesError; @@ -63,12 +62,16 @@ pub fn get_random_u256(rng: &mut R, low: U256, high: U256) -> U256 { result } -pub async fn tree_computation_flow( - leaf_modifications: Arc>, +pub async fn tree_computation_flow( + leaf_modifications: Arc>, storage: &MapStorage, root_hash: HashOutput, -) -> StorageTrie { - let config = OriginalSkeletonStorageTrieConfig::new(&leaf_modifications, false); + config: impl OriginalSkeletonTreeConfig, +) -> FilledTreeImpl +where + TH: TreeHashFunction + 'static, + L: Leaf + 'static, +{ let mut sorted_leaf_indices: Vec = leaf_modifications.keys().copied().collect(); let sorted_leaf_indices = SortedLeafIndices::new(&mut sorted_leaf_indices); let mut original_skeleton = @@ -92,24 +95,26 @@ pub async fn tree_computation_flow( ) .expect("Failed to create the updated skeleton tree"); - StorageTrie::create::(updated_skeleton.into(), leaf_modifications) + FilledTreeImpl::::create::(updated_skeleton.into(), leaf_modifications) .await .expect("Failed to create the filled tree") } -pub async fn single_tree_flow_test( - leaf_modifications: LeafModifications, +pub async fn single_tree_flow_test + 'static>( + leaf_modifications: LeafModifications, storage: MapStorage, root_hash: HashOutput, + config: impl OriginalSkeletonTreeConfig, ) -> String { // Move from leaf number to actual index. let leaf_modifications = leaf_modifications .into_iter() .map(|(k, v)| (NodeIndex::FIRST_LEAF + k, v)) - .collect::>(); + .collect::>(); let filled_tree = - tree_computation_flow(Arc::new(leaf_modifications), &storage, root_hash).await; + tree_computation_flow::(Arc::new(leaf_modifications), &storage, root_hash, config) + .await; let hash_result = filled_tree.get_root_hash(); diff --git a/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs b/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs index 688b3e4af5..7d354eeb8f 100644 --- a/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs +++ b/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs @@ -28,7 +28,7 @@ use crate::storage::db_object::{DBObject, Deserializable}; use crate::storage::storage_trait::StorageValue; #[derive(Debug, PartialEq, Clone, Copy, Default, Eq)] -pub(crate) struct MockLeaf(pub(crate) Felt); +pub struct MockLeaf(pub(crate) Felt); impl DBObject for MockLeaf { fn serialize(&self) -> StorageValue { diff --git a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/config.rs b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/config.rs index c38b138b4b..f472f69edf 100644 --- a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/config.rs +++ b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/config.rs @@ -6,7 +6,7 @@ use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonT use crate::patricia_merkle_tree::types::NodeIndex; /// Configures the creation of an original skeleton tree. -pub(crate) trait OriginalSkeletonTreeConfig { +pub trait OriginalSkeletonTreeConfig { /// Configures whether modified leaves should be compared to the previous leaves and log out a /// warning when encountering a trivial modification. fn compare_modified_leaves(&self) -> bool; @@ -22,14 +22,14 @@ pub(crate) trait OriginalSkeletonTreeConfig { #[macro_export] macro_rules! generate_trie_config { ($struct_name:ident, $leaf_type:ty) => { - pub(crate) struct $struct_name<'a> { + pub struct $struct_name<'a> { modifications: &'a LeafModifications<$leaf_type>, compare_modified_leaves: bool, } impl<'a> $struct_name<'a> { #[allow(dead_code)] - pub(crate) fn new( + pub fn new( modifications: &'a LeafModifications<$leaf_type>, compare_modified_leaves: bool, ) -> Self { diff --git a/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs b/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs index 8c1b38fd4d..f203c6decf 100644 --- a/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs +++ b/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs @@ -17,7 +17,7 @@ use crate::patricia_merkle_tree::node_data::leaf::{ContractState, Leaf}; pub mod hash_function_test; /// Trait for hash functions. -pub(crate) trait HashFunction { +pub trait HashFunction { /// Computes the hash of the given input. fn hash(left: &Felt, right: &Felt) -> HashOutput; } @@ -38,7 +38,7 @@ impl HashFunction for PoseidonHashFunction { } } -pub(crate) trait TreeHashFunction { +pub trait TreeHashFunction { /// Computes the hash of the given leaf. fn compute_leaf_hash(leaf_data: &L) -> HashOutput; diff --git a/crates/committer_cli/benches/committer_bench.rs b/crates/committer_cli/benches/committer_bench.rs index cc5ef55480..b7a789818a 100644 --- a/crates/committer_cli/benches/committer_bench.rs +++ b/crates/committer_cli/benches/committer_bench.rs @@ -13,7 +13,9 @@ use std::sync::Arc; use committer::block_committer::input::StarknetStorageValue; use committer::patricia_merkle_tree::external_test_utils::tree_computation_flow; use committer::patricia_merkle_tree::node_data::leaf::LeafModifications; +use committer::patricia_merkle_tree::original_skeleton_tree::config::OriginalSkeletonStorageTrieConfig; use committer::patricia_merkle_tree::types::NodeIndex; +use committer::patricia_merkle_tree::updated_skeleton_tree::hash_function::TreeHashFunctionImpl; use committer_cli::commands::parse_and_commit; use committer_cli::tests::utils::parse_from_python::TreeFlowInput; use criterion::{criterion_group, criterion_main, Criterion}; @@ -36,14 +38,15 @@ pub fn single_tree_flow_benchmark(criterion: &mut Criterion) { .into_iter() .map(|(k, v)| (NodeIndex::FIRST_LEAF + k, v)) .collect::>(); - let arc_leaf_modifications = Arc::new(leaf_modifications); + let arc_leaf_modifications = Arc::new(leaf_modifications.clone()); criterion.bench_function("tree_computation_flow", |benchmark| { benchmark.iter(|| { - runtime.block_on(tree_computation_flow( + runtime.block_on(tree_computation_flow::( Arc::clone(&arc_leaf_modifications), &storage, root_hash, + OriginalSkeletonStorageTrieConfig::new(&leaf_modifications, false), )); }) }); diff --git a/crates/committer_cli/src/tests/python_tests.rs b/crates/committer_cli/src/tests/python_tests.rs index f4d1a55e2e..095d20dd57 100644 --- a/crates/committer_cli/src/tests/python_tests.rs +++ b/crates/committer_cli/src/tests/python_tests.rs @@ -26,6 +26,7 @@ use committer::patricia_merkle_tree::node_data::inner_node::{ PathToBottom, }; use committer::patricia_merkle_tree::node_data::leaf::ContractState; +use committer::patricia_merkle_tree::original_skeleton_tree::config::OriginalSkeletonStorageTrieConfig; use committer::patricia_merkle_tree::types::SubTreeHeight; use committer::patricia_merkle_tree::updated_skeleton_tree::hash_function::TreeHashFunctionImpl; use committer::storage::db_object::DBObject; @@ -197,7 +198,13 @@ impl PythonTest { let TreeFlowInput { leaf_modifications, storage, root_hash } = serde_json::from_str(Self::non_optional_input(input)?)?; // 2. Run the test. - let output = single_tree_flow_test(leaf_modifications, storage, root_hash).await; + let output = single_tree_flow_test::( + leaf_modifications.clone(), + storage, + root_hash, + OriginalSkeletonStorageTrieConfig::new(&leaf_modifications, false), + ) + .await; // 3. Serialize and return output. Ok(output) } diff --git a/crates/committer_cli/src/tests/regression_tests.rs b/crates/committer_cli/src/tests/regression_tests.rs index 26b5df09ac..0b418eb059 100644 --- a/crates/committer_cli/src/tests/regression_tests.rs +++ b/crates/committer_cli/src/tests/regression_tests.rs @@ -2,8 +2,10 @@ use std::collections::HashMap; use std::fs; use clap::Error; -use committer::block_committer::input::{ConfigImpl, Input}; +use committer::block_committer::input::{ConfigImpl, Input, StarknetStorageValue}; use committer::patricia_merkle_tree::external_test_utils::single_tree_flow_test; +use committer::patricia_merkle_tree::original_skeleton_tree::config::OriginalSkeletonStorageTrieConfig; +use committer::patricia_merkle_tree::updated_skeleton_tree::hash_function::TreeHashFunctionImpl; use serde::{Deserialize, Deserializer}; use serde_json::{Map, Value}; use tempfile::NamedTempFile; @@ -108,7 +110,13 @@ pub async fn test_regression_single_tree() { let start = std::time::Instant::now(); // Benchmark the single tree flow test. - let output = single_tree_flow_test(leaf_modifications, storage, root_hash).await; + let output = single_tree_flow_test::( + leaf_modifications.clone(), + storage, + root_hash, + OriginalSkeletonStorageTrieConfig::new(&leaf_modifications, false), + ) + .await; let execution_time = std::time::Instant::now() - start; // Assert correctness of the output of the single tree flow test. From aa57ea3fa3bc0794abbf1968aef2ba39faebe149 Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Mon, 5 Aug 2024 10:17:49 +0300 Subject: [PATCH 04/10] chore(ci): move papyrus_config dep to root toml (#255) --- Cargo.toml | 1 + crates/gateway/Cargo.toml | 2 +- crates/mempool_node/Cargo.toml | 2 +- crates/papyrus_base_layer/Cargo.toml | 2 +- crates/papyrus_execution/Cargo.toml | 2 +- crates/papyrus_monitoring_gateway/Cargo.toml | 2 +- crates/papyrus_network/Cargo.toml | 2 +- crates/papyrus_node/Cargo.toml | 2 +- crates/papyrus_p2p_sync/Cargo.toml | 2 +- crates/papyrus_rpc/Cargo.toml | 2 +- crates/papyrus_storage/Cargo.toml | 2 +- crates/papyrus_sync/Cargo.toml | 2 +- crates/sequencing/papyrus_consensus/Cargo.toml | 2 +- crates/starknet_client/Cargo.toml | 2 +- 14 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7d7f6505c3..9fe9e389f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,6 +118,7 @@ num-traits = "0.2.15" once_cell = "1.19.0" os_info = "3.6.0" page_size = "0.6.0" +papyrus_config = { path = "crates/papyrus_config", version = "0.4.0-rc.0" } parity-scale-codec = "=3.6.9" parity-scale-codec-derive = "=3.6.9" paste = "1.0.15" diff --git a/crates/gateway/Cargo.toml b/crates/gateway/Cargo.toml index 3bb8317f72..04820f4066 100644 --- a/crates/gateway/Cargo.toml +++ b/crates/gateway/Cargo.toml @@ -20,7 +20,7 @@ cairo-vm.workspace = true hyper.workspace = true mempool_test_utils = { path = "../mempool_test_utils", version = "0.0" } num-traits.workspace = true -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_rpc = { path = "../papyrus_rpc", version = "0.4.0-rc.0" } reqwest.workspace = true serde.workspace = true diff --git a/crates/mempool_node/Cargo.toml b/crates/mempool_node/Cargo.toml index 5f4a308204..252e361bc7 100644 --- a/crates/mempool_node/Cargo.toml +++ b/crates/mempool_node/Cargo.toml @@ -13,7 +13,7 @@ anyhow.workspace = true clap.workspace = true const_format.workspace = true futures.workspace = true -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true serde.workspace = true starknet_gateway = { path = "../gateway", version = "0.0" } starknet_mempool = { path = "../mempool", version = "0.0" } diff --git a/crates/papyrus_base_layer/Cargo.toml b/crates/papyrus_base_layer/Cargo.toml index adee0a6b0a..e8b9a48ada 100644 --- a/crates/papyrus_base_layer/Cargo.toml +++ b/crates/papyrus_base_layer/Cargo.toml @@ -8,7 +8,7 @@ license-file.workspace = true [dependencies] async-trait.workspace = true ethers.workspace = true -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true rustc-hex.workspace = true serde.workspace = true serde_json.workspace = true diff --git a/crates/papyrus_execution/Cargo.toml b/crates/papyrus_execution/Cargo.toml index 0ccb4ad428..182e747ed6 100644 --- a/crates/papyrus_execution/Cargo.toml +++ b/crates/papyrus_execution/Cargo.toml @@ -19,7 +19,7 @@ itertools.workspace = true lazy_static.workspace = true once_cell.workspace = true papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_storage = { path = "../papyrus_storage", version = "0.4.0-rc.0" } rand = { workspace = true, optional = true } rand_chacha = { workspace = true, optional = true } diff --git a/crates/papyrus_monitoring_gateway/Cargo.toml b/crates/papyrus_monitoring_gateway/Cargo.toml index 75ceb6c6a9..3b8e209c6d 100644 --- a/crates/papyrus_monitoring_gateway/Cargo.toml +++ b/crates/papyrus_monitoring_gateway/Cargo.toml @@ -10,7 +10,7 @@ axum.workspace = true hyper = { workspace = true, features = ["full"] } metrics-exporter-prometheus = { version = "0.12.1" } metrics-process = { version = "1.0.11" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_storage = { path = "../papyrus_storage", version = "0.4.0-rc.0" } rand.workspace = true serde = { workspace = true, features = ["derive"] } diff --git a/crates/papyrus_network/Cargo.toml b/crates/papyrus_network/Cargo.toml index 67163c58e6..a4472aba8d 100644 --- a/crates/papyrus_network/Cargo.toml +++ b/crates/papyrus_network/Cargo.toml @@ -34,7 +34,7 @@ libp2p = { workspace = true, features = [ ] } metrics.workspace = true papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true replace_with.workspace = true serde = { workspace = true, features = ["derive"] } thiserror.workspace = true diff --git a/crates/papyrus_node/Cargo.toml b/crates/papyrus_node/Cargo.toml index 5d6a82e523..92d3419ead 100644 --- a/crates/papyrus_node/Cargo.toml +++ b/crates/papyrus_node/Cargo.toml @@ -27,7 +27,7 @@ lazy_static.workspace = true once_cell.workspace = true papyrus_base_layer = { path = "../papyrus_base_layer", version = "0.4.0-rc.0" } papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_consensus = { path = "../sequencing/papyrus_consensus", version = "0.4.0-rc.0" } papyrus_monitoring_gateway = { path = "../papyrus_monitoring_gateway", version = "0.4.0-rc.0" } papyrus_network = { path = "../papyrus_network", version = "0.4.0-rc.0" } diff --git a/crates/papyrus_p2p_sync/Cargo.toml b/crates/papyrus_p2p_sync/Cargo.toml index 969ce5dc80..5c7cf77318 100644 --- a/crates/papyrus_p2p_sync/Cargo.toml +++ b/crates/papyrus_p2p_sync/Cargo.toml @@ -13,7 +13,7 @@ indexmap.workspace = true lazy_static.workspace = true metrics.workspace = true papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_network = { path = "../papyrus_network", version = "0.4.0-rc.0" } papyrus_proc_macros = { path = "../papyrus_proc_macros", version = "0.4.0-rc.0" } papyrus_protobuf = { path = "../papyrus_protobuf", version = "0.4.0-rc.0" } diff --git a/crates/papyrus_rpc/Cargo.toml b/crates/papyrus_rpc/Cargo.toml index d96ba0e446..167fda2fd5 100644 --- a/crates/papyrus_rpc/Cargo.toml +++ b/crates/papyrus_rpc/Cargo.toml @@ -19,7 +19,7 @@ jsonrpsee = { workspace = true, features = ["full"] } lazy_static.workspace = true metrics.workspace = true papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_execution = { path = "../papyrus_execution", version = "0.4.0-rc.0" } papyrus_proc_macros = { path = "../papyrus_proc_macros", version = "0.4.0-rc.0" } papyrus_storage = { path = "../papyrus_storage", version = "0.4.0-rc.0" } diff --git a/crates/papyrus_storage/Cargo.toml b/crates/papyrus_storage/Cargo.toml index 02caac570f..5560fb3edf 100644 --- a/crates/papyrus_storage/Cargo.toml +++ b/crates/papyrus_storage/Cargo.toml @@ -35,7 +35,7 @@ metrics.workspace = true num-bigint.workspace = true page_size.workspace = true papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_proc_macros = { path = "../papyrus_proc_macros", version = "0.4.0-rc.0" } parity-scale-codec.workspace = true primitive-types.workspace = true diff --git a/crates/papyrus_sync/Cargo.toml b/crates/papyrus_sync/Cargo.toml index 81fbc54a1f..f1f444b1df 100644 --- a/crates/papyrus_sync/Cargo.toml +++ b/crates/papyrus_sync/Cargo.toml @@ -18,7 +18,7 @@ lru.workspace = true metrics.workspace = true papyrus_base_layer = { path = "../papyrus_base_layer", version = "0.4.0-rc.0" } papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true papyrus_proc_macros = { path = "../papyrus_proc_macros", version = "0.4.0-rc.0" } papyrus_storage = { path = "../papyrus_storage", version = "0.4.0-rc.0" } reqwest = { workspace = true, features = ["blocking", "json"] } diff --git a/crates/sequencing/papyrus_consensus/Cargo.toml b/crates/sequencing/papyrus_consensus/Cargo.toml index 4f5be1c80b..6304554e19 100644 --- a/crates/sequencing/papyrus_consensus/Cargo.toml +++ b/crates/sequencing/papyrus_consensus/Cargo.toml @@ -11,7 +11,7 @@ async-trait.workspace = true futures.workspace = true metrics.workspace = true papyrus_common = { path = "../../papyrus_common", version = "0.4.0-dev.2" } -papyrus_config = { path = "../../papyrus_config", version = "0.4.0-dev.2" } +papyrus_config.workspace = true papyrus_network = { path = "../../papyrus_network", version = "0.4.0-dev.2" } papyrus_protobuf = { path = "../../papyrus_protobuf", version = "0.4.0-dev.2" } papyrus_storage = { path = "../../papyrus_storage", version = "0.4.0-dev.2" } diff --git a/crates/starknet_client/Cargo.toml b/crates/starknet_client/Cargo.toml index 0454e7eb3b..57ffe7db59 100644 --- a/crates/starknet_client/Cargo.toml +++ b/crates/starknet_client/Cargo.toml @@ -18,7 +18,7 @@ indexmap = { workspace = true, features = ["serde"] } mockall = { workspace = true, optional = true } os_info.workspace = true papyrus_common = { path = "../papyrus_common", version = "0.4.0-rc.0" } -papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" } +papyrus_config.workspace = true rand = { workspace = true, optional = true } rand_chacha = { workspace = true, optional = true } reqwest = { workspace = true, features = ["blocking", "json"] } From 87e6d3f2ccd6d20f65af1392b66c212359dca26d Mon Sep 17 00:00:00 2001 From: alon-dotan-starkware Date: Mon, 5 Aug 2024 11:34:27 +0300 Subject: [PATCH 05/10] chore(ci): fix gatekeeper config (#310) --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e5f01bd898..f82154e63a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -179,6 +179,8 @@ jobs: uses: upsidr/merge-gatekeeper@v1 with: token: ${{ secrets.GITHUB_TOKEN }} + timeout: 1200 + ignored: "code-review/reviewable" - name: Run Merge Gatekeeper in Merge Queue if: github.event_name == 'merge_group' @@ -186,3 +188,5 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} ref: ${{github.ref}} + timeout: 1200 + ignored: "code-review/reviewable" From 6de6b81f6e0fc87027fbc9fd9abc6ee2af0d45d7 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware <141143145+AvivYossef-starkware@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:35:01 +0300 Subject: [PATCH 06/10] refactor: tree hash function impl (#156) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change is [Reviewable](https://reviewable.io/reviews/starkware-libs/sequencer/156) --- .../patricia_merkle_tree/filled_tree/tree_test.rs | 15 +++++++++------ .../patricia_merkle_tree/internal_test_utils.rs | 5 +++-- .../create_tree_helper_test.rs | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/committer/src/patricia_merkle_tree/filled_tree/tree_test.rs b/crates/committer/src/patricia_merkle_tree/filled_tree/tree_test.rs index 058ca30267..276568cd07 100644 --- a/crates/committer/src/patricia_merkle_tree/filled_tree/tree_test.rs +++ b/crates/committer/src/patricia_merkle_tree/filled_tree/tree_test.rs @@ -5,7 +5,11 @@ use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::filled_tree::node::FilledNode; use crate::patricia_merkle_tree::filled_tree::tree::{FilledTree, FilledTreeImpl}; -use crate::patricia_merkle_tree::internal_test_utils::{MockLeaf, OriginalSkeletonMockTrieConfig}; +use crate::patricia_merkle_tree::internal_test_utils::{ + MockLeaf, + OriginalSkeletonMockTrieConfig, + TestTreeHashFunction, +}; use crate::patricia_merkle_tree::node_data::inner_node::{ BinaryData, EdgeData, @@ -16,7 +20,6 @@ use crate::patricia_merkle_tree::node_data::inner_node::{ use crate::patricia_merkle_tree::node_data::leaf::SkeletonLeaf; use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTreeImpl; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices}; -use crate::patricia_merkle_tree::updated_skeleton_tree::hash_function::TreeHashFunctionImpl; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::{ UpdatedSkeletonNodeMap, @@ -35,7 +38,7 @@ async fn test_filled_tree_sanity() { skeleton_tree.insert(new_leaf_index, UpdatedSkeletonNode::Leaf); let modifications = HashMap::from([(new_leaf_index, new_filled_leaf)]); let updated_skeleton_tree = UpdatedSkeletonTreeImpl { skeleton_tree }; - let root_hash = FilledTreeImpl::create::( + let root_hash = FilledTreeImpl::create::( Arc::new(updated_skeleton_tree), Arc::new(modifications), ) @@ -89,7 +92,7 @@ async fn test_small_filled_tree() { .collect(); // Compute the hash values. - let filled_tree = FilledTreeImpl::create::( + let filled_tree = FilledTreeImpl::create::( Arc::new(updated_skeleton_tree), Arc::new(modifications), ) @@ -152,7 +155,7 @@ async fn test_small_tree_with_unmodified_nodes() { )]); // Compute the hash values. - let filled_tree = FilledTreeImpl::create::( + let filled_tree = FilledTreeImpl::create::( Arc::new(updated_skeleton_tree), Arc::new(modifications), ) @@ -201,7 +204,7 @@ async fn test_delete_leaf_from_empty_tree() { let leaf_modifications = HashMap::from([(NodeIndex::FIRST_LEAF, MockLeaf(Felt::ZERO))]); // Compute the filled tree. - let filled_tree = FilledTreeImpl::create::( + let filled_tree = FilledTreeImpl::create::( updated_skeleton_tree.into(), leaf_modifications.into(), ) diff --git a/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs b/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs index 7d354eeb8f..1d42d8a989 100644 --- a/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs +++ b/crates/committer/src/patricia_merkle_tree/internal_test_utils.rs @@ -20,7 +20,6 @@ use crate::patricia_merkle_tree::types::{NodeIndex, SubTreeHeight}; use crate::patricia_merkle_tree::updated_skeleton_tree::hash_function::{ HashFunction, TreeHashFunction, - TreeHashFunctionImpl, }; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::UpdatedSkeletonTreeImpl; @@ -65,7 +64,9 @@ impl Leaf for MockLeaf { } } -impl TreeHashFunction for TreeHashFunctionImpl { +pub(crate) struct TestTreeHashFunction; + +impl TreeHashFunction for TestTreeHashFunction { fn compute_leaf_hash(leaf_data: &MockLeaf) -> HashOutput { HashOutput(leaf_data.0) } diff --git a/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs b/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs index 520d6e54bc..94435db77b 100644 --- a/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs +++ b/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs @@ -15,6 +15,7 @@ use crate::patricia_merkle_tree::internal_test_utils::{ MockLeaf, MockTrie, OriginalSkeletonMockTrieConfig, + TestTreeHashFunction, }; use crate::patricia_merkle_tree::node_data::inner_node::{EdgePathLength, PathToBottom}; use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; @@ -28,7 +29,6 @@ use crate::patricia_merkle_tree::updated_skeleton_tree::create_tree_helper::{ has_leaves_on_both_sides, TempSkeletonNode, }; -use crate::patricia_merkle_tree::updated_skeleton_tree::hash_function::TreeHashFunctionImpl; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::{ UpdatedSkeletonTree, @@ -507,7 +507,7 @@ async fn test_update_non_modified_storage_tree(#[case] root_hash: HashOutput) { .unwrap(); let updated = UpdatedSkeletonTreeImpl::create(&mut original_skeleton_tree, &HashMap::new()).unwrap(); - let filled = MockTrie::create::(Arc::new(updated), Arc::new(empty_map)) + let filled = MockTrie::create::(Arc::new(updated), Arc::new(empty_map)) .await .unwrap(); assert_eq!(root_hash, filled.get_root_hash()); From 516f0cef6c9dd49b847d9b5a57d82d642b818c41 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware <141143145+AvivYossef-starkware@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:39:40 +0300 Subject: [PATCH 07/10] refactor: committer node index (#160) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change is [Reviewable](https://reviewable.io/reviews/starkware-libs/sequencer/160) --- .../committer/src/block_committer/commit.rs | 26 ++++++----------- crates/committer/src/block_committer/input.rs | 29 ++++++++++++------- .../filled_tree/forest.rs | 5 ++-- .../patricia_merkle_tree/filled_tree/node.rs | 7 +++++ .../original_skeleton_tree/skeleton_forest.rs | 2 +- .../skeleton_forest_test.rs | 2 +- .../src/patricia_merkle_tree/types.rs | 16 +--------- .../src/patricia_merkle_tree/types_test.rs | 6 ++-- .../updated_skeleton_tree/skeleton_forest.rs | 4 +-- 9 files changed, 44 insertions(+), 53 deletions(-) diff --git a/crates/committer/src/block_committer/commit.rs b/crates/committer/src/block_committer/commit.rs index a80806e22d..d5c33d6ba6 100644 --- a/crates/committer/src/block_committer/commit.rs +++ b/crates/committer/src/block_committer/commit.rs @@ -78,7 +78,7 @@ fn check_trivial_nonce_and_class_hash_updates( ) { for (address, nonce) in address_to_nonce.iter() { if original_contracts_trie_leaves - .get(&NodeIndex::from_contract_address(address)) + .get(&address.into()) .is_some_and(|previous_contract_state| previous_contract_state.nonce == *nonce) { warn!("Encountered a trivial nonce update of contract {:?}", address) @@ -86,12 +86,9 @@ fn check_trivial_nonce_and_class_hash_updates( } for (address, class_hash) in address_to_class_hash.iter() { - if original_contracts_trie_leaves - .get(&NodeIndex::from_contract_address(address)) - .is_some_and(|previous_contract_state| { - previous_contract_state.class_hash == *class_hash - }) - { + if original_contracts_trie_leaves.get(&address.into()).is_some_and( + |previous_contract_state| previous_contract_state.class_hash == *class_hash, + ) { warn!("Encountered a trivial class hash update of contract {:?}", address) } } @@ -106,20 +103,15 @@ pub(crate) fn get_all_modified_indices( state_diff: &StateDiff, ) -> (StorageTriesIndices, ContractsTrieIndices, ClassesTrieIndices) { let accessed_addresses = state_diff.accessed_addresses(); - let contracts_trie_indices: Vec = accessed_addresses - .iter() - .map(|address| NodeIndex::from_contract_address(address)) - .collect(); - let classes_trie_indices: Vec = state_diff - .class_hash_to_compiled_class_hash - .keys() - .map(NodeIndex::from_class_hash) - .collect(); + let contracts_trie_indices: Vec = + accessed_addresses.iter().map(|address| NodeIndex::from(*address)).collect(); + let classes_trie_indices: Vec = + state_diff.class_hash_to_compiled_class_hash.keys().map(NodeIndex::from).collect(); let storage_tries_indices: HashMap> = accessed_addresses .iter() .map(|address| { let indices: Vec = match state_diff.storage_updates.get(address) { - Some(updates) => updates.keys().map(NodeIndex::from_starknet_storage_key).collect(), + Some(updates) => updates.keys().map(NodeIndex::from).collect(), None => Vec::new(), }; (**address, indices) diff --git a/crates/committer/src/block_committer/input.rs b/crates/committer/src/block_committer/input.rs index 18023bfe45..6833c881e0 100644 --- a/crates/committer/src/block_committer/input.rs +++ b/crates/committer/src/block_committer/input.rs @@ -14,11 +14,23 @@ use crate::storage::storage_trait::{StorageKey, StorageValue}; // TODO(Nimrod, 1/6/2025): Use the ContractAddress defined in starknet-types-core when available. pub struct ContractAddress(pub Felt); +impl From<&ContractAddress> for NodeIndex { + fn from(address: &ContractAddress) -> NodeIndex { + NodeIndex::from_leaf_felt(&address.0) + } +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] // TODO(Nimrod, 1/6/2025): Use the StarknetStorageValue defined in starknet-types-core when // available. pub struct StarknetStorageKey(pub Felt); +impl From<&StarknetStorageKey> for NodeIndex { + fn from(key: &StarknetStorageKey) -> NodeIndex { + NodeIndex::from_leaf_felt(&key.0) + } +} + #[derive(Clone, Copy, Default, Debug, Eq, PartialEq)] pub struct StarknetStorageValue(pub Felt); @@ -94,9 +106,7 @@ impl StateDiff { let updates = match self.storage_updates.get(address) { Some(inner_updates) => inner_updates .iter() - .map(|(key, value)| { - (NodeIndex::from_starknet_storage_key(key), SkeletonLeaf::from(value.0)) - }) + .map(|(key, value)| (key.into(), SkeletonLeaf::from(value.0))) .collect(), None => HashMap::new(), }; @@ -109,7 +119,7 @@ impl StateDiff { self.class_hash_to_compiled_class_hash .iter() .map(|(class_hash, compiled_class_hash)| { - (NodeIndex::from_class_hash(class_hash), SkeletonLeaf::from(compiled_class_hash.0)) + (class_hash.into(), SkeletonLeaf::from(compiled_class_hash.0)) }) .collect() } @@ -121,10 +131,9 @@ impl StateDiff { .iter() .map(|address| { let updates = match self.storage_updates.get(address) { - Some(inner_updates) => inner_updates - .iter() - .map(|(key, value)| (NodeIndex::from_starknet_storage_key(key), *value)) - .collect(), + Some(inner_updates) => { + inner_updates.iter().map(|(key, value)| (key.into(), *value)).collect() + } None => HashMap::new(), }; (**address, updates) @@ -135,9 +144,7 @@ impl StateDiff { pub(crate) fn actual_classes_updates(&self) -> LeafModifications { self.class_hash_to_compiled_class_hash .iter() - .map(|(class_hash, compiled_class_hash)| { - (NodeIndex::from_class_hash(class_hash), *compiled_class_hash) - }) + .map(|(class_hash, compiled_class_hash)| (class_hash.into(), *compiled_class_hash)) .collect() } } diff --git a/crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs b/crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs index 9dc41ea72b..effa59490b 100644 --- a/crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs +++ b/crates/committer/src/patricia_merkle_tree/filled_tree/forest.rs @@ -73,7 +73,7 @@ impl FilledForest { .ok_or(ForestError::MissingUpdatedSkeleton(address))?; let original_contract_state = original_contracts_trie_leaves - .get(&NodeIndex::from_contract_address(&address)) + .get(&((&address).into())) .ok_or(ForestError::MissingContractCurrentState(address))?; contracts_state_tasks.spawn(Self::new_contract_state::( address, @@ -88,8 +88,7 @@ impl FilledForest { while let Some(result) = contracts_state_tasks.join_next().await { let (address, new_contract_state, filled_storage_trie) = result??; - contracts_trie_modifications - .insert(NodeIndex::from_contract_address(&address), new_contract_state); + contracts_trie_modifications.insert((&address).into(), new_contract_state); filled_storage_tries.insert(address, filled_storage_trie); } diff --git a/crates/committer/src/patricia_merkle_tree/filled_tree/node.rs b/crates/committer/src/patricia_merkle_tree/filled_tree/node.rs index 116209c558..62aaa93877 100644 --- a/crates/committer/src/patricia_merkle_tree/filled_tree/node.rs +++ b/crates/committer/src/patricia_merkle_tree/filled_tree/node.rs @@ -5,12 +5,19 @@ use crate::hash::hash_trait::HashOutput; use crate::impl_from_hex_for_felt_wrapper; use crate::patricia_merkle_tree::node_data::inner_node::NodeData; use crate::patricia_merkle_tree::node_data::leaf::Leaf; +use crate::patricia_merkle_tree::types::NodeIndex; // TODO(Nimrod, 1/6/2024): Use the ClassHash defined in starknet-types-core when available. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct ClassHash(pub Felt); +impl From<&ClassHash> for NodeIndex { + fn from(class_hash: &ClassHash) -> NodeIndex { + NodeIndex::from_leaf_felt(&class_hash.0) + } +} + impl_from_hex_for_felt_wrapper!(ClassHash); #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub struct Nonce(pub Felt); diff --git a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest.rs b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest.rs index 8b8c09f4c1..8b0829c60b 100644 --- a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest.rs +++ b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest.rs @@ -95,7 +95,7 @@ impl<'a> OriginalSkeletonForest<'a> { .get(address) .ok_or(ForestError::MissingSortedLeafIndices(*address))?; let contract_state = original_contracts_trie_leaves - .get(&NodeIndex::from_contract_address(address)) + .get(&address.into()) .ok_or(ForestError::MissingContractCurrentState(*address))?; let config = OriginalSkeletonStorageTrieConfig::new( updates, diff --git a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs index 263d6f1462..d6eb5a3b19 100644 --- a/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs +++ b/crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs @@ -317,7 +317,7 @@ fn test_create_original_skeleton_forest( .unwrap(); let expected_original_contracts_trie_leaves = expected_original_contracts_trie_leaves .into_iter() - .map(|(address, state)| (NodeIndex::from_contract_address(&address), state)) + .map(|(address, state)| ((&address).into(), state)) .collect(); assert_eq!(original_contracts_trie_leaves, expected_original_contracts_trie_leaves); diff --git a/crates/committer/src/patricia_merkle_tree/types.rs b/crates/committer/src/patricia_merkle_tree/types.rs index 690de8e913..4445253d16 100644 --- a/crates/committer/src/patricia_merkle_tree/types.rs +++ b/crates/committer/src/patricia_merkle_tree/types.rs @@ -1,9 +1,7 @@ use ethnum::U256; -use crate::block_committer::input::{ContractAddress, StarknetStorageKey}; use crate::felt::Felt; use crate::patricia_merkle_tree::errors::TypesError; -use crate::patricia_merkle_tree::filled_tree::node::ClassHash; use crate::patricia_merkle_tree::node_data::inner_node::{EdgePathLength, PathToBottom}; #[cfg(test)] @@ -128,19 +126,7 @@ impl NodeIndex { .expect("Illegal PathToBottom") } - pub(crate) fn from_starknet_storage_key(key: &StarknetStorageKey) -> Self { - Self::from_leaf_felt(&key.0) - } - - pub(crate) fn from_contract_address(address: &ContractAddress) -> Self { - Self::from_leaf_felt(&address.0) - } - - pub(crate) fn from_class_hash(class_hash: &ClassHash) -> Self { - Self::from_leaf_felt(&class_hash.0) - } - - fn from_leaf_felt(felt: &Felt) -> Self { + pub(crate) fn from_leaf_felt(felt: &Felt) -> Self { Self::FIRST_LEAF + Self::from_felt_value(felt) } diff --git a/crates/committer/src/patricia_merkle_tree/types_test.rs b/crates/committer/src/patricia_merkle_tree/types_test.rs index c5657d02cd..2caef578ee 100644 --- a/crates/committer/src/patricia_merkle_tree/types_test.rs +++ b/crates/committer/src/patricia_merkle_tree/types_test.rs @@ -35,10 +35,10 @@ fn test_cast_to_node_index( #[values(true, false)] from_contract_address: bool, ) { let expected_node_index = NodeIndex::FIRST_LEAF + leaf_index; - let actual = if from_contract_address { - NodeIndex::from_contract_address(&ContractAddress(Felt::from(leaf_index))) + let actual: NodeIndex = if from_contract_address { + (&ContractAddress(Felt::from(leaf_index))).into() } else { - NodeIndex::from_starknet_storage_key(&StarknetStorageKey(Felt::from(leaf_index))) + (&StarknetStorageKey(Felt::from(leaf_index))).into() }; assert_eq!(actual, expected_node_index); } diff --git a/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/skeleton_forest.rs b/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/skeleton_forest.rs index d3257e1d1f..0d6316fa08 100644 --- a/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/skeleton_forest.rs +++ b/crates/committer/src/patricia_merkle_tree/updated_skeleton_tree/skeleton_forest.rs @@ -57,7 +57,7 @@ impl UpdatedSkeletonForest { storage_tries.insert(*address, updated_storage_trie); let current_leaf = original_contracts_trie_leaves - .get(&NodeIndex::from_contract_address(address)) + .get(&address.into()) .ok_or(ForestError::MissingContractCurrentState(*address))?; let skeleton_leaf = Self::updated_contract_skeleton_leaf( @@ -66,7 +66,7 @@ impl UpdatedSkeletonForest { current_leaf, storage_trie_becomes_empty, ); - contracts_trie_leaves.insert(NodeIndex::from_contract_address(address), skeleton_leaf); + contracts_trie_leaves.insert(address.into(), skeleton_leaf); } // Contracts trie. From ff11dd774a3aeac9e7b58f8867a357886f75f581 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware <141143145+AvivYossef-starkware@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:43:29 +0300 Subject: [PATCH 08/10] refactor: remove async fun from create (#167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change is [Reviewable](https://reviewable.io/reviews/starkware-libs/sequencer/167) --- .../committer/src/patricia_merkle_tree/filled_tree/tree.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs b/crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs index 70df1a268c..21d2551e56 100644 --- a/crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs +++ b/crates/committer/src/patricia_merkle_tree/filled_tree/tree.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::future::Future; use std::sync::{Arc, Mutex}; use async_recursion::async_recursion; @@ -26,10 +27,10 @@ pub(crate) type FilledTreeResult = Result>; /// data and hashes. pub(crate) trait FilledTree: Sized { /// Computes and returns the filled tree. - async fn create<'a, TH: TreeHashFunction + 'static>( + fn create<'a, TH: TreeHashFunction + 'static>( updated_skeleton: Arc + 'static>, leaf_modifications: Arc>, - ) -> FilledTreeResult; + ) -> impl Future> + Send; /// Serializes the current state of the tree into a hashmap, /// where each key-value pair corresponds From 40b9492841a5ff33e6ca9a9059dabbd5e1b880f2 Mon Sep 17 00:00:00 2001 From: Yoni <78365039+Yoni-Starkware@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:15:26 +0300 Subject: [PATCH 09/10] chore: bump compiler to 2.7.0 and vm to 1.0.0-rc6 (#304) --- Cargo.lock | 112 +++++++++--------- Cargo.toml | 12 +- .../deprecated_syscalls/hint_processor.rs | 3 +- .../src/execution/entry_point_execution.rs | 2 +- .../src/execution/execution_utils.rs | 2 +- .../src/execution/syscalls/hint_processor.rs | 2 +- .../blockifier/src/execution/syscalls/mod.rs | 2 +- 7 files changed, 68 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc8e8d9160..97932559bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1150,9 +1150,9 @@ checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cairo-lang-casm" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5abf875e93f696e783412d3f2a7c6f66e94e07c30b01559380b4d0707dc0050e" +checksum = "4a43421bf72645b3a562d264747166d6f093e960a69dfa38b67bb3209e370366" dependencies = [ "cairo-lang-utils", "indoc 2.0.5", @@ -1165,9 +1165,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f135e1768e199e88b04f824e34b9411ff49fc31970e77cbf5c6f448170441d18" +checksum = "24242af537265add372896d9ab0678c86a68d3484281fbeb6d8a9d4d5bacf7c8" dependencies = [ "anyhow", "cairo-lang-defs", @@ -1189,18 +1189,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e2bf0a6caf1e54938bc67ca082cbeb5385969784bfb1109c187ca9dc5e1806" +checksum = "2d28f38e1c62fed15a4de9f3c95741d6b24ef2a9e67a2b88a047eb6ea7de992e" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65bb0e855afeb88d11585605f836bd0cd444375b234103e87342df2c91aba1b" +checksum = "712206b7be3fb1a33e50e1c30aa8502b4a461155fd93ad26213d0d8b242cb08d" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -1215,9 +1215,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab96083f60a077d300d0b89bd4b9c31731c95f5db355a11c4657ee25f3acc198" +checksum = "9a3c8dc2bff2411fbf602d80a83b719e6e3955c1c5d767ec18b295fc92e8616a" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1227,9 +1227,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf2aaa50fa5b15070b2bf02c60a62f917f9aa1ff6dedf5a2627ecafe8e33cfa" +checksum = "eaa8ac24c97770739f5a78d630b8515273c8b9f4aff34e1f88b988fac50340de" dependencies = [ "cairo-lang-utils", "good_lp", @@ -1237,9 +1237,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8094bcf7e44204c2fc2f10760e7e2e5769a6267cba5d8a303c0331dd480d5663" +checksum = "4596331565fe61d10a0a6a03ace2b9d0ba93f03ee12a8450fe9252a6fee770f3" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -1251,9 +1251,9 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a1d92f1163b3b0e22e6392d22f7a275b9e64ab453f32b8b62bb1aeedbe73e04" +checksum = "69b8eb08e511d6e6df51370cdc7d85f0de9a38c8b14a15762665c60c2df6d32d" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -1272,9 +1272,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25eb629a773c07c2863717d1711fd3ecc17807c1fc094bb90cccac56061056a4" +checksum = "6d535dc591513875b39b799270df21db10540033fd7710917760c22fc063a4ae" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1297,9 +1297,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff7b1d7af8e1bff971b8b9bbce796650a57de93dfb092bc0c17c2f85d915de6e" +checksum = "73019d5873715964f428ff10467efb607d6dc007ae164a21547bf20d9b5dcc72" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1317,9 +1317,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eccf06d643d155a72057dc93c40cf34dabe11e8c629dbf3111c528a3d750a66" +checksum = "96e52fca18bc696011a47a4ded0dc00e2e0ac7c81a8052eddd4ad546c46b818e" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1336,9 +1336,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffa10434f9ce0828e8d77f3a13ae2f878da453345b14d54a66de3e196c0e4674" +checksum = "3d55dcf98a6e1a03e0b36129fad4253f9e6666a1746ab9c075d212ba68a4e9c1" dependencies = [ "cairo-lang-debug", "quote", @@ -1347,9 +1347,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4882d2263fb7c95dbab0c3b5578d8c0e2417fd680df8cc61aa50321b6a5a40d" +checksum = "e3ddb432e5199a65e37bab97ef6322afabd60e0e638ada31178d9c23d237219d" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -1361,9 +1361,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ab7b0e0640adaed21b9d9b9b94b3edf7f7ab95514b1dd40c679317a33dabea" +checksum = "ef5bbbabd509ce88abc67436973d3377e099269dbd14578fa84fce884a74fa23" dependencies = [ "ark-ff", "ark-secp256k1", @@ -1392,9 +1392,9 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba49614f98322e1ccda33265f8193f66cbd88eff23b0deb94db981aa0666650" +checksum = "393325820207491a7475269e98163e0db7e85e4b215f4d801ca537ce1cd6daa7" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1419,9 +1419,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a41d56c6afebdbe2c5ffb4e216f60b07391c29c91fccf0a60790817f49ba68" +checksum = "918fb0611203fb8cdd1fcdb434f395a59e0ebb0db64b11a0e15bfbfb03552821" dependencies = [ "anyhow", "cairo-lang-utils", @@ -1447,9 +1447,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "667050b93db661ebce0b33c92ce44abffebde37c5645e4761722ad3c49a1c34f" +checksum = "7fa1834ec729e89fcbd00df03f2a64a18515fcf07eb18dfef39afe020a10955d" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1463,9 +1463,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27fcbf81e8ed4efe7e9c30bbdfa8074b9af01a5e16154999dd9527baba27f1fb" +checksum = "6b00927d39f910dd5ae1047cef9b46b2ee11617d33d290f875bc00dfc7e3d992" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1479,9 +1479,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058c05d10913a130fb21964f0bf1a37b05eafcf2f50a73cd4aa3e11da7e4cfc7" +checksum = "7620a6a7becf5997093a83d289a5e3b3162bc8fd031ad75df82a5bc04f8cc954" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1504,9 +1504,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8607cc5cf16f3a930ad4b3799e986b0ca36ada2c0da1dd6bd2ef35cbb1eb9e74" +checksum = "67bd155770abf91d4290a31b0c0a1fb393ecee85eb0af40c16893b4601eff4d6" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -1525,9 +1525,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224624b1e279b3eea7693680f577335e66e6dd5fbfbd2576f4a7d0b5d697f61d" +checksum = "fbae9458999da692c272501678b6cfec358a6bcadb54921bf35d21afdcd91251" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1535,9 +1535,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a54ebea4ea990a33a2158ecdf46ffb3cb1af8fff6a79c3dd310c6a9ed43e82" +checksum = "f242d889180386d35935597f9d1cac07d4f3d60bd0f10558660ae4a77da701b6" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1566,9 +1566,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb66ae799e1963318e1bab782848f53797787c396dfd590be539f3f12d56ac4" +checksum = "aa17b313f46fcf7ff4de32b86c250eaf584d1e2c8e37ed16db155b221721e735" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -1590,9 +1590,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e673dc1058a8639c094a330a701e8902cbd34defe659a3d95bcf6c3f3de249d" +checksum = "0d0ca518ed7c3674d9b62470f7482f4b07553eb3a02d83e0ae61bd6b5ecb4ec8" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1606,9 +1606,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0dd466dbac4263573b81b83e22534285da30a4e7c15b888407fbb33d8accb9" +checksum = "7f12bdff5c265edb5a76084bfde2bc8270a7fdaf16ac58aa0d54ea6a20c29023" dependencies = [ "genco", "xshell", @@ -1616,9 +1616,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09431da22acc1cf081b1802b73ff484bdc75ca1cd5ad6fa9b84fba8753b2e08f" +checksum = "e6a2365bd502a657437f9d0d665e32e017054d0effdbecb1dda776bfcc11235d" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -1629,9 +1629,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.7.0-rc.3" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97498c08958be8d569c16982cac431d785adc3effdfa6d0775c65aec578dfd91" +checksum = "8bd5c8c127b9362a12ffb9dede38e792c81b4ded5a98b448baec157b745f47d1" dependencies = [ "hashbrown 0.14.5", "indexmap 2.2.6", @@ -1645,9 +1645,9 @@ dependencies = [ [[package]] name = "cairo-vm" -version = "1.0.0-rc5" +version = "1.0.0-rc6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e09134ea1e0be6c1fbd330f0945df0512fa70944fd0b3ecc2f74a6008f01e9da" +checksum = "f905a936b3287d085706d3d68e405be4844ec7bc1c95eaa3d53220dd33efd4ff" dependencies = [ "anyhow", "bincode 2.0.0-rc.3", diff --git a/Cargo.toml b/Cargo.toml index 9fe9e389f0..f190cb5610 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,12 +67,12 @@ byteorder = "1.4.3" bytes = "1" cached = "0.44.0" cairo-felt = "0.9.1" -cairo-lang-casm = "2.7.0-rc.3" -cairo-lang-runner = "2.7.0-rc.3" -cairo-lang-sierra = "=2.7.0-rc.3" -cairo-lang-starknet-classes = "2.7.0-rc.3" -cairo-lang-utils = "2.7.0-rc.3" -cairo-vm = "=1.0.0-rc5" +cairo-lang-casm = "2.7.0" +cairo-lang-runner = "2.7.0" +cairo-lang-sierra = "=2.7.0" +cairo-lang-starknet-classes = "2.7.0" +cairo-lang-utils = "2.7.0" +cairo-vm = "=1.0.0-rc6" camelpaste = "0.1.0" chrono = "0.4.26" clap = "4.3.10" diff --git a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs index f39d4f6401..d11ba19302 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs @@ -374,7 +374,8 @@ impl<'a> DeprecatedSyscallHintProcessor<'a> { vm: &mut VirtualMachine, ) -> DeprecatedSyscallResult { let signature = &self.context.tx_context.tx_info.signature().0; - let signature = signature.iter().map(|&x| MaybeRelocatable::from(x)).collect(); + let signature: Vec = + signature.iter().map(|&x| MaybeRelocatable::from(x)).collect(); let signature_segment_start_ptr = self.read_only_segments.allocate(vm, &signature)?; Ok(signature_segment_start_ptr) diff --git a/crates/blockifier/src/execution/entry_point_execution.rs b/crates/blockifier/src/execution/entry_point_execution.rs index 9e5bae7245..a2b546b495 100644 --- a/crates/blockifier/src/execution/entry_point_execution.rs +++ b/crates/blockifier/src/execution/entry_point_execution.rs @@ -125,7 +125,7 @@ fn register_visited_pcs( // after it. // TODO(lior): Avoid unnecessary relocation once the VM has a non-relocated `get_trace()` // function. - runner.relocate_trace(&[1, 1 + program_segment_size].into())?; + runner.relocate_trace(&[1, 1 + program_segment_size])?; for trace_entry in runner.relocated_trace.as_ref().expect("Relocated trace not found") { let pc = trace_entry.pc; if pc < 1 { diff --git a/crates/blockifier/src/execution/execution_utils.rs b/crates/blockifier/src/execution/execution_utils.rs index a433a34574..7824e13873 100644 --- a/crates/blockifier/src/execution/execution_utils.rs +++ b/crates/blockifier/src/execution/execution_utils.rs @@ -164,7 +164,7 @@ impl ReadOnlySegments { pub fn allocate( &mut self, vm: &mut VirtualMachine, - data: &Vec, + data: &[MaybeRelocatable], ) -> Result { let start_ptr = vm.add_memory_segment(); self.0.push(ReadOnlySegment { start_ptr, length: data.len() }); diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index 0ed6f2868b..1c1a9cb9c9 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -608,7 +608,7 @@ impl<'a> SyscallHintProcessor<'a> { vm: &mut VirtualMachine, data: &[Felt], ) -> SyscallResult<(Relocatable, Relocatable)> { - let data = data.iter().map(|&x| MaybeRelocatable::from(x)).collect(); + let data: Vec = data.iter().map(|&x| MaybeRelocatable::from(x)).collect(); let data_segment_start_ptr = self.read_only_segments.allocate(vm, &data)?; let data_segment_end_ptr = (data_segment_start_ptr + data.len())?; Ok((data_segment_start_ptr, data_segment_end_ptr)) diff --git a/crates/blockifier/src/execution/syscalls/mod.rs b/crates/blockifier/src/execution/syscalls/mod.rs index 27ea5377df..9e31c9ab9b 100644 --- a/crates/blockifier/src/execution/syscalls/mod.rs +++ b/crates/blockifier/src/execution/syscalls/mod.rs @@ -110,7 +110,7 @@ impl SyscallResponse for SyscallResponseWrapper { let revert_reason_start = vm.add_memory_segment(); let revert_reason_end = vm.load_data( revert_reason_start, - &error_data.into_iter().map(Into::into).collect(), + &error_data.into_iter().map(Into::into).collect::>(), )?; // Write the start and end pointers of the error data. From 15f79826f4baaab1df1e43fb65d071e62a5426d5 Mon Sep 17 00:00:00 2001 From: Yonatan Iluz Date: Mon, 5 Aug 2024 14:42:41 +0300 Subject: [PATCH 10/10] chore: resolve conflicts --- .github/workflows/main.yml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bca9455c6f..f82154e63a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -165,30 +165,6 @@ jobs: with: version: ${{env.PROTOC_VERSION}} - run: cargo check --workspace -r --all-features -<<<<<<< HEAD - - merge-gatekeeper: - runs-on: ubuntu-latest - # Restrict permissions of the GITHUB_TOKEN. - # Docs: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs - permissions: - checks: read - statuses: read - steps: - - name: Run Merge Gatekeeper - if: github.event_name != 'merge_group' - uses: upsidr/merge-gatekeeper@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Run Merge Gatekeeper in Merge Queue - if: github.event_name == 'merge_group' - uses: upsidr/merge-gatekeeper@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - ref: ${{github.ref}} -||||||| 2b181fbc -======= merge-gatekeeper: runs-on: ubuntu-latest @@ -214,4 +190,3 @@ jobs: ref: ${{github.ref}} timeout: 1200 ignored: "code-review/reviewable" ->>>>>>> origin/main-v0.13.2