@@ -44,7 +44,7 @@ std::optional<ContractInstance> HintingContractsDB::get_contract_instance(const
4444 // here we simply don't store any hint:
4545 if (instance.has_value ()) {
4646 // TODO(MW): Use/write instance to hint methods for ContractInstance, PublicKeys, ContractClass, etc.
47- mapped_hints .contract_instances [address] = ContractInstanceHint{
47+ contract_hints .contract_instances [address] = ContractInstanceHint{
4848 .address = address,
4949 .salt = instance->salt ,
5050 .deployer = instance->deployer_addr ,
@@ -69,15 +69,15 @@ std::optional<ContractClass> HintingContractsDB::get_contract_class(const Contra
6969 // here we simply don't store any hint:
7070 if (klass.has_value ()) {
7171 // TODO(MW): Use/write instance to hint methods for ContractInstance, PublicKeys, ContractClass, etc.
72- mapped_hints .contract_classes [class_id] = ContractClassHint{
72+ contract_hints .contract_classes [class_id] = ContractClassHint{
7373 .classId = class_id,
7474 .artifactHash = klass->artifact_hash ,
7575 .privateFunctionsRoot = klass->private_function_root ,
7676 .packedBytecode = klass->packed_bytecode ,
7777 };
7878 // Note: HintedRawContractDB accesses the bytecode commitment 'hint' during get_contract_class, so following
7979 // same logic here:
80- mapped_hints .bytecode_commitments [class_id] =
80+ contract_hints .bytecode_commitments [class_id] =
8181 BytecodeCommitmentHint{ .classId = class_id, .commitment = klass->public_bytecode_commitment };
8282 }
8383
@@ -87,13 +87,13 @@ std::optional<ContractClass> HintingContractsDB::get_contract_class(const Contra
8787void HintingContractsDB::dump_hints (ExecutionHints& hints)
8888{
8989 // TODO(MW): better way than to iterate? do we want push_back?
90- for (const auto & contract_instance : mapped_hints .contract_instances ) {
90+ for (const auto & contract_instance : contract_hints .contract_instances ) {
9191 hints.contractInstances .push_back (contract_instance.second );
9292 }
93- for (const auto & contract_class : mapped_hints .contract_classes ) {
93+ for (const auto & contract_class : contract_hints .contract_classes ) {
9494 hints.contractClasses .push_back (contract_class.second );
9595 }
96- for (const auto & bytecode_commitment : mapped_hints .bytecode_commitments ) {
96+ for (const auto & bytecode_commitment : contract_hints .bytecode_commitments ) {
9797 hints.bytecodeCommitments .push_back (bytecode_commitment.second );
9898 }
9999}
@@ -109,7 +109,8 @@ SiblingPath HintingRawDB::get_sibling_path(world_state::MerkleTreeId tree_id, in
109109 auto tree_info = get_tree_info (tree_id);
110110 auto path = db.get_sibling_path (tree_id, leaf_index);
111111 GetSiblingPathKey key = { tree_info, tree_id, leaf_index };
112- query_hints.get_sibling_path_hints [key] = path;
112+ merkle_hints.get_sibling_path_hints [key] =
113+ GetSiblingPathHint{ .hintKey = tree_info, .treeId = tree_id, .index = leaf_index, .path = path };
113114
114115 return path;
115116}
@@ -119,7 +120,14 @@ GetLowIndexedLeafResponse HintingRawDB::get_low_indexed_leaf(world_state::Merkle
119120 auto tree_info = get_tree_info (tree_id);
120121 auto resp = db.get_low_indexed_leaf (tree_id, value);
121122 GetPreviousValueIndexKey key = { tree_info, tree_id, value };
122- query_hints.get_previous_value_index_hints [key] = { resp.is_already_present , resp.index };
123+ merkle_hints.get_previous_value_index_hints [key] = GetPreviousValueIndexHint{
124+ .hintKey = tree_info,
125+ .treeId = tree_id,
126+ .value = value,
127+ .index = resp.index ,
128+ .alreadyPresent = resp.is_already_present ,
129+ };
130+
123131 // TODO(MW): We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
124132 get_sibling_path (tree_id, resp.index );
125133
@@ -146,7 +154,8 @@ FF HintingRawDB::get_leaf_value(world_state::MerkleTreeId tree_id, index_t leaf_
146154 auto tree_info = get_tree_info (tree_id);
147155 auto value = db.get_leaf_value (tree_id, leaf_index);
148156 GetLeafValueKey key = { tree_info, tree_id, leaf_index };
149- query_hints.get_leaf_value_hints [key] = value;
157+ merkle_hints.get_leaf_value_hints [key] =
158+ GetLeafValueHint{ .hintKey = tree_info, .treeId = tree_id, .index = leaf_index, .value = value };
150159 // TODO(MW): We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
151160 get_sibling_path (tree_id, leaf_index);
152161 return value;
@@ -158,7 +167,9 @@ IndexedLeaf<PublicDataLeafValue> HintingRawDB::get_leaf_preimage_public_data_tre
158167 auto preimage = db.get_leaf_preimage_public_data_tree (leaf_index);
159168
160169 GetLeafPreimageKey key = { tree_info, leaf_index };
161- query_hints.get_leaf_preimage_hints_public_data_tree [key] = preimage;
170+ merkle_hints.get_leaf_preimage_hints_public_data_tree [key] = GetLeafPreimageHint<PublicDataTreeLeafPreimage>{
171+ .hintKey = tree_info, .index = leaf_index, .leafPreimage = preimage
172+ };
162173 // TODO(MW): We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
163174 get_sibling_path (world_state::MerkleTreeId::PUBLIC_DATA_TREE, leaf_index);
164175 return preimage;
@@ -169,7 +180,9 @@ IndexedLeaf<NullifierLeafValue> HintingRawDB::get_leaf_preimage_nullifier_tree(i
169180 auto tree_info = get_tree_info (world_state::MerkleTreeId::NULLIFIER_TREE);
170181 auto preimage = db.get_leaf_preimage_nullifier_tree (leaf_index);
171182 GetLeafPreimageKey key = { tree_info, leaf_index };
172- query_hints.get_leaf_preimage_hints_nullifier_tree [key] = preimage;
183+ merkle_hints.get_leaf_preimage_hints_nullifier_tree [key] = GetLeafPreimageHint<NullifierTreeLeafPreimage>{
184+ .hintKey = tree_info, .index = leaf_index, .leafPreimage = preimage
185+ };
173186 // TODO(MW): We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
174187 get_sibling_path (world_state::MerkleTreeId::NULLIFIER_TREE, leaf_index);
175188 return preimage;
@@ -192,7 +205,7 @@ SequentialInsertionResult<PublicDataLeafValue> HintingRawDB::insert_indexed_leav
192205 .insertionWitnessData = result.insertion_witness_data .back (),
193206 .stateAfter = stateAfter
194207 };
195- sequential_insert_hints_public_data_tree[key] = sequential_insert_hint;
208+ merkle_hints. sequential_insert_hints_public_data_tree [key] = sequential_insert_hint;
196209
197210 return result;
198211}
@@ -214,7 +227,7 @@ SequentialInsertionResult<NullifierLeafValue> HintingRawDB::insert_indexed_leave
214227 .insertionWitnessData = result.insertion_witness_data .back (),
215228 .stateAfter = stateAfter
216229 };
217- sequential_insert_hints_nullifier_tree[key] = sequential_insert_hint;
230+ merkle_hints. sequential_insert_hints_nullifier_tree [key] = sequential_insert_hint;
218231
219232 return result;
220233}
@@ -308,58 +321,44 @@ AppendOnlyTreeSnapshot HintingRawDB::appendLeafInternal(AppendOnlyTreeSnapshot s
308321 AppendLeavesHintKey append_key = { state_before, tree_id, { leaf } };
309322 AppendOnlyTreeSnapshot state_after = { .root = root_after,
310323 .nextAvailableLeafIndex = state_before.nextAvailableLeafIndex + 1 };
311- append_leaves_hints[append_key] = state_after;
324+ merkle_hints.append_leaves_hints [append_key] =
325+ AppendLeavesHint{ .hintKey = state_before, .stateAfter = state_after, .treeId = tree_id, .leaves = { leaf } };
312326 // TODO(MW): Storing sibling path hint manually using the result since a get_sibling_path() call here will use the
313327 // /current/ db.get_tree_info() (post full append_leaves), which may not match that at result.root. We may not care
314328 // about this (see comment in PureRawMerkleDB::append_leaves())
315329 GetSiblingPathKey path_key = { state_after, tree_id, state_before.nextAvailableLeafIndex };
316- query_hints.get_sibling_path_hints [path_key] = path;
330+ merkle_hints.get_sibling_path_hints [path_key] = GetSiblingPathHint{
331+ .hintKey = state_after, .treeId = tree_id, .index = state_before.nextAvailableLeafIndex , .path = path
332+ };
317333 return state_after;
318334}
319335
320336void HintingRawDB::dump_hints (ExecutionHints& hints)
321337{
322338 // TODO(MW): better way than to iterate? do we want push_back?
323- for (const auto & get_sibling_path_hint : query_hints.get_sibling_path_hints ) {
324- auto [hint_key, tree_id, index] = get_sibling_path_hint.first ;
325- hints.getSiblingPathHints .push_back (GetSiblingPathHint{
326- .hintKey = hint_key, .treeId = tree_id, .index = index, .path = get_sibling_path_hint.second });
339+ for (const auto & get_sibling_path_hint : merkle_hints.get_sibling_path_hints ) {
340+ hints.getSiblingPathHints .push_back (get_sibling_path_hint.second );
327341 }
328- for (const auto & get_previous_value_index_hint : query_hints.get_previous_value_index_hints ) {
329- auto [hint_key, tree_id, value] = get_previous_value_index_hint.first ;
330- hints.getPreviousValueIndexHints .push_back (GetPreviousValueIndexHint{
331- .hintKey = hint_key,
332- .treeId = tree_id,
333- .value = value,
334- .index = get_previous_value_index_hint.second .index ,
335- .alreadyPresent = get_previous_value_index_hint.second .is_already_present ,
336- });
342+ for (const auto & get_previous_value_index_hint : merkle_hints.get_previous_value_index_hints ) {
343+ hints.getPreviousValueIndexHints .push_back (get_previous_value_index_hint.second );
337344 }
338- for (const auto & get_leaf_preimage_hint : query_hints.get_leaf_preimage_hints_public_data_tree ) {
339- auto [hint_key, index] = get_leaf_preimage_hint.first ;
340- hints.getLeafPreimageHintsPublicDataTree .push_back (
341- { .hintKey = hint_key, .index = index, .leafPreimage = get_leaf_preimage_hint.second });
345+ for (const auto & get_leaf_preimage_hint : merkle_hints.get_leaf_preimage_hints_public_data_tree ) {
346+ hints.getLeafPreimageHintsPublicDataTree .push_back (get_leaf_preimage_hint.second );
342347 }
343- for (const auto & get_leaf_preimage_hint : query_hints.get_leaf_preimage_hints_nullifier_tree ) {
344- auto [hint_key, index] = get_leaf_preimage_hint.first ;
345- hints.getLeafPreimageHintsNullifierTree .push_back (
346- { .hintKey = hint_key, .index = index, .leafPreimage = get_leaf_preimage_hint.second });
348+ for (const auto & get_leaf_preimage_hint : merkle_hints.get_leaf_preimage_hints_nullifier_tree ) {
349+ hints.getLeafPreimageHintsNullifierTree .push_back (get_leaf_preimage_hint.second );
347350 }
348- for (const auto & get_leaf_value_hint : query_hints.get_leaf_value_hints ) {
349- auto [hint_key, tree_id, index] = get_leaf_value_hint.first ;
350- hints.getLeafValueHints .push_back (GetLeafValueHint{
351- .hintKey = hint_key, .treeId = tree_id, .index = index, .value = get_leaf_value_hint.second });
351+ for (const auto & get_leaf_value_hint : merkle_hints.get_leaf_value_hints ) {
352+ hints.getLeafValueHints .push_back (get_leaf_value_hint.second );
352353 }
353- for (const auto & sequential_insert_hint : sequential_insert_hints_public_data_tree) {
354+ for (const auto & sequential_insert_hint : merkle_hints. sequential_insert_hints_public_data_tree ) {
354355 hints.sequentialInsertHintsPublicDataTree .push_back (sequential_insert_hint.second );
355356 }
356- for (const auto & sequential_insert_hint : sequential_insert_hints_nullifier_tree) {
357+ for (const auto & sequential_insert_hint : merkle_hints. sequential_insert_hints_nullifier_tree ) {
357358 hints.sequentialInsertHintsNullifierTree .push_back (sequential_insert_hint.second );
358359 }
359- for (const auto & append_leaves_hint : append_leaves_hints) {
360- auto [hint_key, tree_id, leaves] = append_leaves_hint.first ;
361- hints.appendLeavesHints .push_back (AppendLeavesHint{
362- .hintKey = hint_key, .stateAfter = append_leaves_hint.second , .treeId = tree_id, .leaves = leaves });
360+ for (const auto & append_leaves_hint : merkle_hints.append_leaves_hints ) {
361+ hints.appendLeavesHints .push_back (append_leaves_hint.second );
363362 }
364363 for (const auto & create_checkpoint_hint : create_checkpoint_hints) {
365364 hints.createCheckpointHints .push_back (create_checkpoint_hint.second );
0 commit comments