From ca1fd588231bb99ac8fd9436a907425817f87b74 Mon Sep 17 00:00:00 2001 From: AvivYossef-starkware Date: Wed, 17 Jul 2024 17:17:08 +0300 Subject: [PATCH] refactor: move starknet logic to a different crate --- Cargo.lock | 7 +++++++ Cargo.toml | 2 +- crates/committer/src/lib.rs | 2 +- crates/committer/src/patricia_merkle_tree/types.rs | 8 -------- crates/starknet-committer/Cargo.toml | 13 +++++++++++++ .../src/block_committer.rs | 0 .../src/block_committer/commit.rs | 0 .../src/block_committer/errors.rs | 0 .../src/block_committer/input.rs | 0 crates/starknet-committer/src/lib.rs | 2 ++ .../src/starknet_patricia_merkle_tree.rs | 2 ++ .../src/starknet_patricia_merkle_tree/leaf.rs | 0 .../src/starknet_patricia_merkle_tree/types.rs | 0 13 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 crates/starknet-committer/Cargo.toml rename crates/{committer => starknet-committer}/src/block_committer.rs (100%) rename crates/{committer => starknet-committer}/src/block_committer/commit.rs (100%) rename crates/{committer => starknet-committer}/src/block_committer/errors.rs (100%) rename crates/{committer => starknet-committer}/src/block_committer/input.rs (100%) create mode 100644 crates/starknet-committer/src/lib.rs create mode 100644 crates/starknet-committer/src/starknet_patricia_merkle_tree.rs create mode 100644 crates/starknet-committer/src/starknet_patricia_merkle_tree/leaf.rs create mode 100644 crates/starknet-committer/src/starknet_patricia_merkle_tree/types.rs diff --git a/Cargo.lock b/Cargo.lock index 2c8c141a..f61148ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2061,6 +2061,13 @@ dependencies = [ "num-traits 0.1.43", ] +[[package]] +name = "starknet-committer" +version = "0.1.0-rc.0" +dependencies = [ + "committer", +] + [[package]] name = "starknet-crypto" version = "0.5.2" diff --git a/Cargo.toml b/Cargo.toml index c306e1a4..6f4c4a60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ # https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2 resolver = "2" -members = ["crates/committer", "crates/committer_cli"] +members = ["crates/committer", "crates/committer_cli", "crates/starknet-committer"] [workspace.package] version = "0.1.0-rc.0" diff --git a/crates/committer/src/lib.rs b/crates/committer/src/lib.rs index d87fb198..4c62cb94 100644 --- a/crates/committer/src/lib.rs +++ b/crates/committer/src/lib.rs @@ -1,4 +1,4 @@ -pub mod block_committer; + pub mod felt; pub mod forest_errors; pub mod hash; diff --git a/crates/committer/src/patricia_merkle_tree/types.rs b/crates/committer/src/patricia_merkle_tree/types.rs index c014d3ae..90a9f585 100644 --- a/crates/committer/src/patricia_merkle_tree/types.rs +++ b/crates/committer/src/patricia_merkle_tree/types.rs @@ -133,14 +133,6 @@ 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) } diff --git a/crates/starknet-committer/Cargo.toml b/crates/starknet-committer/Cargo.toml new file mode 100644 index 00000000..c97d1e5c --- /dev/null +++ b/crates/starknet-committer/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "starknet-committer" +version.workspace = true +edition.workspace = true +repository.workspace = true +license.workspace = true +license-file.workspace = true + +[dependencies] +committer = { path = "../committer", features = ["testing"] } + +[lints] +workspace = true diff --git a/crates/committer/src/block_committer.rs b/crates/starknet-committer/src/block_committer.rs similarity index 100% rename from crates/committer/src/block_committer.rs rename to crates/starknet-committer/src/block_committer.rs diff --git a/crates/committer/src/block_committer/commit.rs b/crates/starknet-committer/src/block_committer/commit.rs similarity index 100% rename from crates/committer/src/block_committer/commit.rs rename to crates/starknet-committer/src/block_committer/commit.rs diff --git a/crates/committer/src/block_committer/errors.rs b/crates/starknet-committer/src/block_committer/errors.rs similarity index 100% rename from crates/committer/src/block_committer/errors.rs rename to crates/starknet-committer/src/block_committer/errors.rs diff --git a/crates/committer/src/block_committer/input.rs b/crates/starknet-committer/src/block_committer/input.rs similarity index 100% rename from crates/committer/src/block_committer/input.rs rename to crates/starknet-committer/src/block_committer/input.rs diff --git a/crates/starknet-committer/src/lib.rs b/crates/starknet-committer/src/lib.rs new file mode 100644 index 00000000..c500474c --- /dev/null +++ b/crates/starknet-committer/src/lib.rs @@ -0,0 +1,2 @@ +pub mod block_committer; +pub mod starknet_patricia_merkle_tree; diff --git a/crates/starknet-committer/src/starknet_patricia_merkle_tree.rs b/crates/starknet-committer/src/starknet_patricia_merkle_tree.rs new file mode 100644 index 00000000..c4c614be --- /dev/null +++ b/crates/starknet-committer/src/starknet_patricia_merkle_tree.rs @@ -0,0 +1,2 @@ +pub mod leaf; +pub mod types; diff --git a/crates/starknet-committer/src/starknet_patricia_merkle_tree/leaf.rs b/crates/starknet-committer/src/starknet_patricia_merkle_tree/leaf.rs new file mode 100644 index 00000000..e69de29b diff --git a/crates/starknet-committer/src/starknet_patricia_merkle_tree/types.rs b/crates/starknet-committer/src/starknet_patricia_merkle_tree/types.rs new file mode 100644 index 00000000..e69de29b