Skip to content

Commit 54d46e7

Browse files
starknet_committer: add a field indicating if storage tries should be created concurrently
1 parent 5175a12 commit 54d46e7

File tree

7 files changed

+41
-12
lines changed

7 files changed

+41
-12
lines changed

crates/apollo_deployments/resources/app_configs/committer_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"committer_config.db_path": "/data/committer",
33
"committer_config.reader_config.warn_on_trivial_modifications": false,
4+
"committer_config.reader_config.build_storage_tries_concurrently": false,
45
"committer_config.storage_config.cache_on_write": true,
56
"committer_config.storage_config.cache_size": 1000000,
67
"committer_config.storage_config.include_inner_stats": true,

crates/apollo_deployments/resources/app_configs/replacer_committer_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"committer_config.db_path": "/data/committer",
33
"committer_config.reader_config.warn_on_trivial_modifications": false,
4+
"committer_config.reader_config.build_storage_tries_concurrently": false,
45
"committer_config.storage_config.cache_on_write": true,
56
"committer_config.storage_config.cache_size": "$$$_COMMITTER_CONFIG-STORAGE_CONFIG-CACHE_SIZE_$$$",
67
"committer_config.storage_config.include_inner_stats": true,

crates/apollo_node/resources/config_schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@
499499
"privacy": "Public",
500500
"value": false
501501
},
502+
"committer_config.reader_config.build_storage_tries_concurrently": {
503+
"description": "Whether to build the storage tries concurrently or sequentially.",
504+
"privacy": "Public",
505+
"value": false
506+
},
502507
"committer_config.storage_config.cache_on_write": {
503508
"description": "If true, the cache is updated on write operations",
504509
"privacy": "Public",

crates/starknet_committer/src/block_committer/input.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,15 @@ impl From<ThinStateDiff> for StateDiff {
122122
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
123123
pub struct ReaderConfig {
124124
warn_on_trivial_modifications: bool,
125+
build_storage_tries_concurrently: bool,
125126
}
126127

127128
impl ReaderConfig {
128-
pub fn new(warn_on_trivial_modifications: bool) -> Self {
129-
Self { warn_on_trivial_modifications }
129+
pub fn new(
130+
warn_on_trivial_modifications: bool,
131+
build_storage_tries_concurrently: bool,
132+
) -> Self {
133+
Self { warn_on_trivial_modifications, build_storage_tries_concurrently }
130134
}
131135

132136
/// Indicates whether a warning should be given in case of a trivial state update.
@@ -135,16 +139,29 @@ impl ReaderConfig {
135139
pub fn warn_on_trivial_modifications(&self) -> bool {
136140
self.warn_on_trivial_modifications
137141
}
142+
143+
/// Indicates whether to build the storage tries concurrently or sequentially.
144+
pub fn build_storage_tries_concurrently(&self) -> bool {
145+
self.build_storage_tries_concurrently
146+
}
138147
}
139148

140149
impl SerializeConfig for ReaderConfig {
141150
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
142-
BTreeMap::from_iter([ser_param(
143-
"warn_on_trivial_modifications",
144-
&self.warn_on_trivial_modifications,
145-
"Whether to warn on trivial state update.",
146-
ParamPrivacyInput::Public,
147-
)])
151+
BTreeMap::from_iter([
152+
ser_param(
153+
"warn_on_trivial_modifications",
154+
&self.warn_on_trivial_modifications,
155+
"Whether to warn on trivial state update.",
156+
ParamPrivacyInput::Public,
157+
),
158+
ser_param(
159+
"build_storage_tries_concurrently",
160+
&self.build_storage_tries_concurrently,
161+
"Whether to build the storage tries concurrently or sequentially.",
162+
ParamPrivacyInput::Public,
163+
),
164+
])
148165
}
149166
}
150167

crates/starknet_committer/src/forest/skeleton_forest_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub(crate) fn create_contract_state_leaf_entry(
167167
contracts_trie_root_hash: HashOutput(Felt::from(861_u128 + 248_u128)),
168168
classes_trie_root_hash: HashOutput(Felt::from(155_u128 + 248_u128)),
169169
}),
170-
config: ReaderConfig::new(true),
170+
config: ReaderConfig::new(true, false),
171171
},
172172
MapStorage(DbHashMap::from([
173173
// Roots.
@@ -420,7 +420,7 @@ async fn test_create_original_skeleton_forest<Reader: ForestReader>(
420420
&actual_storage_updates,
421421
&actual_classes_updates,
422422
&forest_sorted_indices,
423-
ReaderConfig::new(false),
423+
ReaderConfig::new(false, false),
424424
)
425425
.await
426426
.unwrap();

crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/cast.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ impl TryFrom<RawInput> for CommitterFactsDbInputImpl {
8585
inner_map,
8686
)?;
8787
}
88+
// TODO(Nimrod): Get this by adding a field to `RawInput`.
89+
let build_storage_tries_concurrently = false;
8890
let input = Input {
8991
initial_read_context: FactsDbInitialRead(StateRoots {
9092
contracts_trie_root_hash: HashOutput(Felt::from_bytes_be_slice(
@@ -100,7 +102,10 @@ impl TryFrom<RawInput> for CommitterFactsDbInputImpl {
100102
class_hash_to_compiled_class_hash,
101103
storage_updates,
102104
},
103-
config: ReaderConfig::new(raw_input.config.warn_on_trivial_modifications),
105+
config: ReaderConfig::new(
106+
raw_input.config.warn_on_trivial_modifications,
107+
build_storage_tries_concurrently,
108+
),
104109
};
105110
Ok(Self { input, log_level: raw_input.config.log_level.into(), storage })
106111
}

crates/starknet_committer_and_os_cli/src/committer_cli/parse_input/read_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn test_simple_input_parsing() {
220220
contracts_trie_root_hash: expected_contracts_trie_root_hash,
221221
classes_trie_root_hash: expected_classes_trie_root_hash,
222222
}),
223-
config: ReaderConfig::new(true),
223+
config: ReaderConfig::new(true, false),
224224
};
225225
assert_eq!(
226226
parse_input(input).unwrap(),

0 commit comments

Comments
 (0)