Skip to content

Commit 40f7e01

Browse files
committed
starknet_committer: move random structs from cli
1 parent ea03e49 commit 40f7e01

File tree

11 files changed

+39
-24
lines changed

11 files changed

+39
-24
lines changed

Cargo.lock

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/starknet_committer/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ license.workspace = true
77
description = "Computes and manages Starknet state."
88

99
[dependencies]
10+
ethnum.workspace = true
1011
hex.workspace = true
1112
pretty_assertions.workspace = true
13+
rand.workspace = true
14+
rand_distr.workspace = true
1215
rstest.workspace = true
1316
serde_json.workspace = true
1417
starknet-types-core = { workspace = true, features = ["hash"] }
1518
starknet_api.workspace = true
1619
starknet_patricia.workspace = true
1720
starknet_patricia_storage.workspace = true
21+
strum.workspace = true
22+
strum_macros.workspace = true
1823
thiserror.workspace = true
1924
tokio = { workspace = true, features = ["rt"] }
2025
tracing.workspace = true
@@ -25,3 +30,8 @@ starknet_patricia = { workspace = true, features = ["testing"] }
2530

2631
[lints]
2732
workspace = true
33+
34+
# Optional dependencies required for tests and the testing feature.
35+
# See [here](https://github.com/bnjbvr/cargo-machete/issues/128).
36+
[package.metadata.cargo-machete]
37+
ignored = ["strum_macros"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod commit;
22
pub mod errors;
33
pub mod input;
4+
pub mod random_structs;
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ use rand::Rng;
77
use rand_distr::num_traits::ToPrimitive;
88
use rand_distr::{Distribution, Geometric};
99
use starknet_api::core::{ClassHash, ContractAddress, Nonce, PATRICIA_KEY_UPPER_BOUND};
10-
use starknet_committer::block_committer::input::StarknetStorageValue;
11-
use starknet_committer::forest::filled_forest::FilledForest;
12-
use starknet_committer::patricia_merkle_tree::leaf::leaf_impl::ContractState;
13-
use starknet_committer::patricia_merkle_tree::types::{
14-
ClassesTrie,
15-
CompiledClassHash,
16-
ContractsTrie,
17-
StorageTrie,
18-
StorageTrieMap,
19-
};
2010
use starknet_patricia::felt::u256_from_felt;
2111
use starknet_patricia::hash::hash_trait::HashOutput;
2212
use starknet_patricia::patricia_merkle_tree::external_test_utils::{
@@ -37,6 +27,17 @@ use starknet_patricia::patricia_merkle_tree::types::NodeIndex;
3727
use starknet_types_core::felt::Felt;
3828
use strum::IntoEnumIterator;
3929

30+
use crate::block_committer::input::StarknetStorageValue;
31+
use crate::forest::filled_forest::FilledForest;
32+
use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState;
33+
use crate::patricia_merkle_tree::types::{
34+
ClassesTrie,
35+
CompiledClassHash,
36+
ContractsTrie,
37+
StorageTrie,
38+
StorageTrieMap,
39+
};
40+
4041
pub trait RandomValue {
4142
fn random<R: Rng>(rng: &mut R, max: Option<U256>) -> Self;
4243
}

crates/starknet_committer_and_os_cli/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ starknet_committer.workspace = true
4545
starknet_os = { workspace = true, features = ["deserialize", "testing"] }
4646
starknet_patricia = { workspace = true, features = ["testing"] }
4747
starknet_patricia_storage.workspace = true
48-
strum.workspace = true
49-
strum_macros.workspace = true
5048
thiserror.workspace = true
5149
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
5250
tracing-subscriber.workspace = true
@@ -60,4 +58,4 @@ path = "benches/main.rs"
6058
# Optional dependencies required for tests and the testing feature.
6159
# See [here](https://github.com/bnjbvr/cargo-machete/issues/128).
6260
[package.metadata.cargo-machete]
63-
ignored = ["hex", "strum_macros"]
61+
ignored = ["hex"]

crates/starknet_committer_and_os_cli/benches/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use starknet_committer::patricia_merkle_tree::tree::OriginalSkeletonStorageTrieC
1616
use starknet_committer_and_os_cli::committer_cli::commands::commit;
1717
use starknet_committer_and_os_cli::committer_cli::parse_input::cast::CommitterInputImpl;
1818
use starknet_committer_and_os_cli::committer_cli::parse_input::read::parse_input;
19-
use starknet_committer_and_os_cli::committer_cli::tests::utils::parse_from_python::TreeFlowInput;
19+
use starknet_committer_and_os_cli::committer_cli::tests::parse_from_python::TreeFlowInput;
2020
use starknet_patricia::patricia_merkle_tree::external_test_utils::tree_computation_flow;
2121
use starknet_patricia::patricia_merkle_tree::node_data::leaf::LeafModifications;
2222
use starknet_patricia::patricia_merkle_tree::types::NodeIndex;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
pub mod parse_from_python;
12
pub mod python_tests;
23
#[cfg(test)]
34
pub mod regression_tests;
4-
pub mod utils;
File renamed without changes.

crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use starknet_committer::block_committer::input::{
99
StarknetStorageValue,
1010
StateDiff,
1111
};
12+
use starknet_committer::block_committer::random_structs::DummyRandomValue;
1213
use starknet_committer::forest::filled_forest::FilledForest;
1314
use starknet_committer::hash_function::hash::TreeHashFunctionImpl;
1415
use starknet_committer::patricia_merkle_tree::leaf::leaf_impl::ContractState;
@@ -34,12 +35,13 @@ use starknet_types_core::hash::{Pedersen, StarkHash};
3435
use thiserror;
3536
use tracing::{debug, error, info, warn};
3637

37-
use super::utils::parse_from_python::TreeFlowInput;
3838
use crate::committer_cli::filled_tree_output::filled_forest::SerializedForest;
3939
use crate::committer_cli::parse_input::cast::CommitterInputImpl;
4040
use crate::committer_cli::parse_input::read::parse_input;
41-
use crate::committer_cli::tests::utils::parse_from_python::parse_input_single_storage_tree_flow_test;
42-
use crate::committer_cli::tests::utils::random_structs::DummyRandomValue;
41+
use crate::committer_cli::tests::parse_from_python::{
42+
parse_input_single_storage_tree_flow_test,
43+
TreeFlowInput,
44+
};
4345
use crate::shared_utils::types::{PythonTestError, PythonTestResult, PythonTestRunner};
4446

4547
pub type CommitterPythonTestError = PythonTestError<CommitterSpecificTestError>;

crates/starknet_committer_and_os_cli/src/committer_cli/tests/regression_tests.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ use starknet_committer::patricia_merkle_tree::tree::OriginalSkeletonStorageTrieC
1010
use starknet_patricia::patricia_merkle_tree::external_test_utils::single_tree_flow_test;
1111
use tempfile::NamedTempFile;
1212

13-
use super::utils::parse_from_python::parse_input_single_storage_tree_flow_test;
1413
use crate::committer_cli::commands::commit;
1514
use crate::committer_cli::parse_input::cast::CommitterInputImpl;
1615
use crate::committer_cli::parse_input::read::parse_input;
17-
use crate::committer_cli::tests::utils::parse_from_python::TreeFlowInput;
16+
use crate::committer_cli::tests::parse_from_python::{
17+
parse_input_single_storage_tree_flow_test,
18+
TreeFlowInput,
19+
};
1820

1921
// TODO(Aner, 20/06/2024): these tests needs to be fixed to be run correctly in the CI:
2022
// 1. Fix the test to measure cpu_time and not wall_time.

0 commit comments

Comments
 (0)