Skip to content

Commit

Permalink
Merge pull request #217 from starkware-libs/dan/merge-main-v0.13.2-in…
Browse files Browse the repository at this point in the history
…to-main-1722412479

Merge main-v0.13.2 into main
  • Loading branch information
dorimedini-starkware authored Jul 31, 2024
2 parents c859c5e + 70e64a7 commit 20479ec
Show file tree
Hide file tree
Showing 42 changed files with 248 additions and 210 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/blockifier_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- v[0-9].**
paths:
- 'crates/blockifier/**'
- 'crates/native_blockifier/.cargo/config.toml'

pull_request:
types:
Expand All @@ -19,6 +20,7 @@ on:
- edited
paths:
- 'crates/blockifier/**'
- 'crates/native_blockifier/.cargo/config.toml'

jobs:
featureless-build:
Expand All @@ -40,7 +42,7 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust-ubuntu-20.04"
prefix-key: "v1-rust-ubuntu-20.04"

- name: Build native blockifier
run: ./build_native_blockifier.sh
Expand Down Expand Up @@ -77,12 +79,3 @@ jobs:
with:
path: "target/release/native_blockifier.pypy39-pp73-x86_64-linux-gnu.so"
destination: "native_blockifier_artifacts/${{ env.SHORT_HASH }}/release/"

# Keep the name 'udeps' to match original action name, so we don't need to define specific branch
# rules on Github for specific version branches.
udeps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Machete (detect unused dependencies)
uses: bnjbvr/cargo-machete@main
17 changes: 15 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
run: npm install --global @commitlint/cli @commitlint/config-conventional

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main'))
if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main'))
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: commitlint --from "$BASE_SHA" --to "$HEAD_SHA" --verbose

- name: Validate PR title with commitlint
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, '/merge-main') || contains(github.event.pull_request.title, '/merge main'))
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main'))
env:
TITLE: ${{ github.event.pull_request.title }}
run: echo "$TITLE" | commitlint --verbose
Expand Down Expand Up @@ -133,6 +133,19 @@ jobs:
env:
SEED: 0

taplo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: baptiste0928/cargo-install@v3
with:
crate: taplo-cli
version: '0.9.0'
locked: true
- run: scripts/taplo.sh

machete:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 33 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@
resolver = "2"

members = [
"crates/batcher",
"crates/blockifier",
"crates/committer",
"crates/committer_cli",
"crates/gateway",
"crates/mempool",
"crates/mempool_infra",
"crates/mempool_node",
"crates/mempool_test_utils",
"crates/mempool_types",
"crates/native_blockifier",
"crates/papyrus_base_layer",
"crates/papyrus_common",
"crates/papyrus_config",
"crates/papyrus_execution",
"crates/papyrus_load_test",
"crates/papyrus_monitoring_gateway",
"crates/papyrus_network",
"crates/papyrus_node",
"crates/papyrus_p2p_sync",
"crates/papyrus_proc_macros",
"crates/papyrus_protobuf",
"crates/papyrus_rpc",
"crates/papyrus_storage",
"crates/papyrus_sync",
"crates/papyrus_test_utils",
"crates/sequencing/papyrus_block_builder",
"crates/sequencing/papyrus_consensus",
"crates/starknet_api",
"crates/starknet_client",
"crates/starknet_sierra_compile",
"crates/task_executor",
"crates/tests-integration",
"crates/batcher",
"crates/blockifier",
"crates/committer",
"crates/committer_cli",
"crates/gateway",
"crates/mempool",
"crates/mempool_infra",
"crates/mempool_node",
"crates/mempool_test_utils",
"crates/mempool_types",
"crates/native_blockifier",
"crates/papyrus_base_layer",
"crates/papyrus_common",
"crates/papyrus_config",
"crates/papyrus_execution",
"crates/papyrus_load_test",
"crates/papyrus_monitoring_gateway",
"crates/papyrus_network",
"crates/papyrus_node",
"crates/papyrus_p2p_sync",
"crates/papyrus_proc_macros",
"crates/papyrus_protobuf",
"crates/papyrus_rpc",
"crates/papyrus_storage",
"crates/papyrus_sync",
"crates/papyrus_test_utils",
"crates/sequencing/papyrus_block_builder",
"crates/sequencing/papyrus_consensus",
"crates/starknet_api",
"crates/starknet_client",
"crates/starknet_sierra_compile",
"crates/task_executor",
"crates/tests-integration",
]

[workspace.package]
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const Configuration = {
'batcher',
'block_builder',
'block_hash',
'blockifier',
'ci',
'common',
'concurrency',
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ num-integer.workspace = true
num-rational.workspace = true
num-traits.workspace = true
once_cell.workspace = true
papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0"}
papyrus_config = { path = "../papyrus_config", version = "0.4.0-rc.0" }
paste.workspace = true
phf.workspace = true
rand = { workspace = true, optional = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ethnum::U256;
use strum_macros::{EnumDiscriminants, EnumIter};

use crate::felt::Felt;
use crate::hash::hash_trait::HashOutput;
Expand All @@ -12,8 +11,8 @@ use crate::patricia_merkle_tree::types::{NodeIndex, SubTreeHeight};
pub mod inner_node_test;

#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(any(test, feature = "testing"), derive(EnumDiscriminants))]
#[cfg_attr(any(test, feature = "testing"), strum_discriminants(derive(EnumIter)))]
#[cfg_attr(any(test, feature = "testing"), derive(strum_macros::EnumDiscriminants))]
#[cfg_attr(any(test, feature = "testing"), strum_discriminants(derive(strum_macros::EnumIter)))]
// A Patricia-Merkle tree node's data, i.e., the pre-image of its hash.
pub enum NodeData<L: Leaf> {
Binary(BinaryData),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ use pretty_assertions::assert_eq;
use rstest::rstest;

use super::OriginalSkeletonTreeImpl;
use crate::block_committer::input::StarknetStorageValue;
use crate::felt::Felt;
use crate::hash::hash_trait::HashOutput;
use crate::patricia_merkle_tree::filled_tree::node::{ClassHash, CompiledClassHash, Nonce};
use crate::patricia_merkle_tree::internal_test_utils::{
small_tree_index_to_full,
MockLeaf,
OriginalSkeletonMockTrieConfig,
};
use crate::patricia_merkle_tree::node_data::inner_node::{EdgePath, EdgePathLength, PathToBottom};
use crate::patricia_merkle_tree::node_data::leaf::{ContractState, LeafModifications};
use crate::patricia_merkle_tree::node_data::leaf::LeafModifications;
use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::SubTree;
use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode;
use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTree;
Expand Down Expand Up @@ -137,9 +135,9 @@ use crate::storage::storage_trait::{create_db_key, StarknetPrefix, StorageKey, S
/// / \
/// 26 90
/// / / \
/// * 25 65
/// / 25 65
/// / \ / \
/// 24 * 6 59
/// 24 \ 6 59
/// / \ \ / / \
/// 11 13 20 5 19 40
///
Expand All @@ -151,9 +149,9 @@ use crate::storage::storage_trait::{create_db_key, StarknetPrefix, StorageKey, S
/// / \
/// E B
/// / / \
/// * E B
/// / E B
/// / \ / \
/// 24 * E B
/// 24 \ E B
/// \ / \
/// 20 5 40
#[case::tree_of_height_4_with_long_edge(
Expand Down Expand Up @@ -295,7 +293,7 @@ fn test_create_tree(
///
/// 1
/// / \
/// * *
/// ^ /
/// / \ /
/// 4 5 6
/// / \ / \ /
Expand Down Expand Up @@ -412,26 +410,6 @@ pub(crate) fn create_mock_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_storage_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = StarknetStorageValue(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_compiled_class_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = CompiledClassHash(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_contract_state_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let felt = Felt::from(val);
let leaf = ContractState {
nonce: Nonce(felt),
storage_root_hash: HashOutput(felt),
class_hash: ClassHash(felt),
};
(leaf.get_db_key(&felt.to_bytes_be()), leaf.serialize())
}

fn create_patricia_key(val: u128) -> StorageKey {
create_db_key(StarknetPrefix::InnerNode.to_storage_prefix(), &U256::from(val).to_be_bytes())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ use crate::patricia_merkle_tree::original_skeleton_tree::create_tree::create_tre
create_32_bytes_entry,
create_binary_entry,
create_binary_skeleton_node,
create_compiled_class_leaf_entry,
create_contract_state_leaf_entry,
create_edge_entry,
create_edge_skeleton_node,
create_expected_skeleton_nodes,
create_root_edge_entry,
create_storage_leaf_entry,
create_unmodified_subtree_skeleton_node,
};
use crate::patricia_merkle_tree::original_skeleton_tree::skeleton_forest::ForestSortedIndices;
use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTreeImpl;
use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight};
use crate::storage::db_object::DBObject;
use crate::storage::map_storage::MapStorage;
use crate::storage::storage_trait::{StorageKey, StorageValue};

macro_rules! compare_skeleton_tree {
($actual_skeleton:expr, $expected_skeleton:expr, $expected_indices:expr) => {{
Expand All @@ -45,6 +44,26 @@ macro_rules! compare_skeleton_tree {
}};
}

pub(crate) fn create_storage_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = StarknetStorageValue(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_compiled_class_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let leaf = CompiledClassHash(Felt::from(val));
(leaf.get_db_key(&leaf.0.to_bytes_be()), leaf.serialize())
}

pub(crate) fn create_contract_state_leaf_entry(val: u128) -> (StorageKey, StorageValue) {
let felt = Felt::from(val);
let leaf = ContractState {
nonce: Nonce(felt),
storage_root_hash: HashOutput(felt),
class_hash: ClassHash(felt),
};
(leaf.get_db_key(&felt.to_bytes_be()), leaf.serialize())
}

// This test assumes for simplicity that hash is addition (i.e hash(a,b) = a + b).
// I.e., the value of a binary node is the sum of its children's values, and the value of an edge
// node is the sum of its path, bottom value and path length.
Expand Down Expand Up @@ -92,7 +111,7 @@ macro_rules! compare_skeleton_tree {
/// / \ /
/// E E B
/// / \ / \
/// * B B E
/// / B B E
/// / / \ \
/// 303 NZ 47 UB
///
Expand Down
6 changes: 4 additions & 2 deletions crates/committer_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ workspace = true

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
futures.workspace = true
pretty_assertions.workspace = true
tempfile.workspace = true

[dependencies]
clap = { version = "4.5.4", features = ["cargo", "derive"] }
clap = { version = "4.5.4", features = ["cargo", "derive"] }
committer = { path = "../committer", features = ["testing"] }
derive_more.workspace = true
ethnum.workspace = true
Expand All @@ -27,7 +29,7 @@ serde_json = "1.0.116"
serde_repr = "0.1.19"
simplelog.workspace = true
starknet-types-core.workspace = true
starknet_api = { path = "../starknet_api", version = "0.13.0-rc.0"}
starknet_api = { path = "../starknet_api", version = "0.13.0-rc.0" }
strum.workspace = true
strum_macros.workspace = true
thiserror.workspace = true
Expand Down
Loading

0 comments on commit 20479ec

Please sign in to comment.