Skip to content

Commit

Permalink
feat(starknet_os,starknet_patricia,starknet_committer): deserializabl…
Browse files Browse the repository at this point in the history
…e commitment info
  • Loading branch information
dorimedini-starkware committed Feb 6, 2025
1 parent 97feeec commit 6a36944
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ starknet_mempool_p2p = { path = "crates/starknet_mempool_p2p", version = "0.0.0"
starknet_mempool_p2p_types = { path = "crates/starknet_mempool_p2p_types", version = "0.0.0" }
starknet_mempool_types = { path = "crates/starknet_mempool_types", version = "0.0.0" }
starknet_monitoring_endpoint = { path = "crates/starknet_monitoring_endpoint", version = "0.0.0" }
starknet_os = { path = "crates/starknet_os", version = "0.0.0" }
starknet_patricia = { path = "crates/starknet_patricia", version = "0.0.0" }
starknet_sequencer_infra = { path = "crates/starknet_sequencer_infra", version = "0.0.0" }
starknet_sequencer_metrics = { path = "crates/starknet_sequencer_metrics", version = "0.0.0" }
Expand Down
1 change: 0 additions & 1 deletion crates/starknet_committer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ repository.workspace = true
license.workspace = true
description = "Computes and manages Starknet state."


[dependencies]
hex.workspace = true
pretty_assertions.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/starknet_os/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ license-file.workspace = true
description = "The Starknet OS."

[features]
deserialize = ["serde", "starknet-types-core/serde", "starknet_patricia/deserialize"]
testing = ["dep:strum", "dep:strum_macros"]

[dependencies]
blockifier.workspace = true
cairo-vm.workspace = true
indoc.workspace = true
serde = { workspace = true, optional = true, features = ["derive"] }
starknet-types-core.workspace = true
starknet_api.workspace = true
starknet_patricia.workspace = true
strum = { workspace = true, optional = true }
strum_macros = { workspace = true, optional = true }
thiserror.workspace = true
Expand Down
27 changes: 26 additions & 1 deletion crates/starknet_os/src/io/os_input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
use std::collections::HashMap;

use starknet_api::core::ContractAddress;
use starknet_patricia::hash::hash_trait::HashOutput;
use starknet_patricia::patricia_merkle_tree::types::SubTreeHeight;
use starknet_types_core::felt::Felt;

#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct CommitmentInfo {
_previous_root: HashOutput,
_updated_root: HashOutput,
_tree_height: SubTreeHeight,
// TODO(Dori, 1/8/2025): The value type here should probably be more specific (NodeData<L> for
// L: Leaf). This poses a problem in deserialization, as a serialized edge node and a
// serialized contract state leaf are both currently vectors of 3 field elements; as the
// semantics of the values are unimportant for the OS commitments, we make do with a vector
// of field elements as values for now.
_commitment_facts: HashMap<HashOutput, Vec<Felt>>,
}

/// All input needed to initialize the execution helper.
// TODO(Dori): Add all fields needed to compute commitments, initialize a CachedState and other data
// required by the execution helper.
pub struct StarknetOsInput {}
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct StarknetOsInput {
_contract_state_commitment_info: CommitmentInfo,
_address_to_storage_commitment_info: HashMap<ContractAddress, CommitmentInfo>,
_contract_class_commitment_info: CommitmentInfo,
}
1 change: 1 addition & 0 deletions crates/starknet_patricia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description = "Library for computing and updating Patricia trees."
workspace = true

[features]
deserialize = ["ethnum/serde"]
testing = []

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_patricia/src/hash/hash_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use starknet_types_core::felt::FromStrError;
use crate::felt::Felt;
use crate::impl_from_hex_for_felt_wrapper;

#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct HashOutput(pub Felt);

Expand Down
1 change: 1 addition & 0 deletions crates/starknet_patricia/src/patricia_merkle_tree/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::patricia_merkle_tree::node_data::inner_node::{EdgePathLength, PathToB
#[path = "types_test.rs"]
pub mod types_test;

#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
#[derive(Clone, Copy, Debug, Eq, PartialEq, derive_more::Sub, derive_more::Display)]
pub struct SubTreeHeight(pub(crate) u8);

Expand Down

0 comments on commit 6a36944

Please sign in to comment.