@@ -86,16 +86,17 @@ std::optional<ContractClass> HintingContractsDB::get_contract_class(const Contra
8686
8787void HintingContractsDB::dump_hints (ExecutionHints& hints)
8888{
89- // TODO(MW): better way than to iterate? do we want push_back?
90- for (const auto & contract_instance : contract_hints.contract_instances ) {
91- hints.contractInstances .push_back (contract_instance.second );
92- }
93- for (const auto & contract_class : contract_hints.contract_classes ) {
94- hints.contractClasses .push_back (contract_class.second );
95- }
96- for (const auto & bytecode_commitment : contract_hints.bytecode_commitments ) {
97- hints.bytecodeCommitments .push_back (bytecode_commitment.second );
98- }
89+ std::ranges::transform (contract_hints.contract_instances ,
90+ std::back_inserter (hints.contractInstances ),
91+ [](const auto & mapped_contract_instance) { return mapped_contract_instance.second ; });
92+
93+ std::ranges::transform (contract_hints.contract_classes ,
94+ std::back_inserter (hints.contractClasses ),
95+ [](const auto & mapped_contract_class) { return mapped_contract_class.second ; });
96+
97+ std::ranges::transform (contract_hints.bytecode_commitments ,
98+ std::back_inserter (hints.bytecodeCommitments ),
99+ [](const auto & mapped_bytecode_commitment) { return mapped_bytecode_commitment.second ; });
99100}
100101
101102// Hinting MerkleDB starts.
@@ -128,21 +129,18 @@ GetLowIndexedLeafResponse HintingRawDB::get_low_indexed_leaf(world_state::Merkle
128129 .alreadyPresent = resp.is_already_present ,
129130 };
130131
131- // TODO(MW) : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
132+ // Note : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
132133 get_sibling_path (tree_id, resp.index );
133134
134135 if (tree_id == world_state::MerkleTreeId::NULLIFIER_TREE) {
135- // TODO(MW): We may need a GetLeafPreimageHint for the nullifier tree when calling nullifier_exists, so collect
136- // it
137- // in case.
138- // NB: The PureMerkleDB does not perform this, but the nullifier check gadget requires a leaf preimage. Ts
139- // gathers the hint: (state_manager -> checkNullifierExists() -> doMerkleOperations -> public_db_sources ->
136+ // Note: We may need a GetLeafPreimageHint for the nullifier tree when calling nullifier_exists, so collect it
137+ // in case. NB: The PureMerkleDB does not perform this, but the nullifier check gadget requires a leaf preimage.
138+ // Ts gathers the hint: (state_manager -> checkNullifierExists() -> doMerkleOperations -> public_db_sources ->
140139 // checkNullifierExists())
141140 get_leaf_preimage_nullifier_tree (resp.index );
142141 } else if ((tree_id == world_state::MerkleTreeId::PUBLIC_DATA_TREE) && (!resp.is_already_present )) {
143- // TODO(MW): We may need a GetLeafPreimageHint for the public data tree when calling storage_read, so collect it
144- // in case.
145- // NB: The PureMerkleDB does not perform this if !is_already_present, but MerkleDB and ts perform it
142+ // Note: We may need a GetLeafPreimageHint for the public data tree when calling storage_read, so collect it in
143+ // case. NB: The PureMerkleDB does not perform this if !is_already_present, but MerkleDB and ts perform it
146144 // unconditionally. Ts gathers the hint: (public_db_sources -> storageRead())
147145 get_leaf_preimage_public_data_tree (resp.index );
148146 }
@@ -156,7 +154,7 @@ FF HintingRawDB::get_leaf_value(world_state::MerkleTreeId tree_id, index_t leaf_
156154 GetLeafValueKey key = { tree_info, tree_id, leaf_index };
157155 merkle_hints.get_leaf_value_hints [key] =
158156 GetLeafValueHint{ .hintKey = tree_info, .treeId = tree_id, .index = leaf_index, .value = value };
159- // TODO(MW) : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
157+ // Note : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
160158 get_sibling_path (tree_id, leaf_index);
161159 return value;
162160}
@@ -170,7 +168,7 @@ IndexedLeaf<PublicDataLeafValue> HintingRawDB::get_leaf_preimage_public_data_tre
170168 merkle_hints.get_leaf_preimage_hints_public_data_tree [key] = GetLeafPreimageHint<PublicDataTreeLeafPreimage>{
171169 .hintKey = tree_info, .index = leaf_index, .leafPreimage = preimage
172170 };
173- // TODO(MW) : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
171+ // Note : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
174172 get_sibling_path (world_state::MerkleTreeId::PUBLIC_DATA_TREE, leaf_index);
175173 return preimage;
176174}
@@ -183,7 +181,7 @@ IndexedLeaf<NullifierLeafValue> HintingRawDB::get_leaf_preimage_nullifier_tree(i
183181 merkle_hints.get_leaf_preimage_hints_nullifier_tree [key] = GetLeafPreimageHint<NullifierTreeLeafPreimage>{
184182 .hintKey = tree_info, .index = leaf_index, .leafPreimage = preimage
185183 };
186- // TODO(MW) : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
184+ // Note : We may need a sibling path hint so must collect it in case - see comments in public_db_sources.ts
187185 get_sibling_path (world_state::MerkleTreeId::NULLIFIER_TREE, leaf_index);
188186 return preimage;
189187}
@@ -335,40 +333,59 @@ AppendOnlyTreeSnapshot HintingRawDB::appendLeafInternal(AppendOnlyTreeSnapshot s
335333
336334void HintingRawDB::dump_hints (ExecutionHints& hints)
337335{
338- // TODO(MW): better way than to iterate? do we want push_back?
339- for (const auto & get_sibling_path_hint : merkle_hints.get_sibling_path_hints ) {
340- hints.getSiblingPathHints .push_back (get_sibling_path_hint.second );
341- }
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 );
344- }
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 );
347- }
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 );
350- }
351- for (const auto & get_leaf_value_hint : merkle_hints.get_leaf_value_hints ) {
352- hints.getLeafValueHints .push_back (get_leaf_value_hint.second );
353- }
354- for (const auto & sequential_insert_hint : merkle_hints.sequential_insert_hints_public_data_tree ) {
355- hints.sequentialInsertHintsPublicDataTree .push_back (sequential_insert_hint.second );
356- }
357- for (const auto & sequential_insert_hint : merkle_hints.sequential_insert_hints_nullifier_tree ) {
358- hints.sequentialInsertHintsNullifierTree .push_back (sequential_insert_hint.second );
359- }
360- for (const auto & append_leaves_hint : merkle_hints.append_leaves_hints ) {
361- hints.appendLeavesHints .push_back (append_leaves_hint.second );
362- }
363- for (const auto & create_checkpoint_hint : create_checkpoint_hints) {
364- hints.createCheckpointHints .push_back (create_checkpoint_hint.second );
365- }
366- for (const auto & commit_checkpoint_hint : commit_checkpoint_hints) {
367- hints.commitCheckpointHints .push_back (commit_checkpoint_hint.second );
368- }
369- for (const auto & revert_checkpoint_hint : revert_checkpoint_hints) {
370- hints.revertCheckpointHints .push_back (revert_checkpoint_hint.second );
371- }
336+
337+ std::ranges::transform (
338+ merkle_hints.get_sibling_path_hints ,
339+ std::back_inserter (hints.getSiblingPathHints ),
340+ [](const auto & mapped_get_sibling_path_hint) { return mapped_get_sibling_path_hint.second ; });
341+
342+ std::ranges::transform (
343+ merkle_hints.get_previous_value_index_hints ,
344+ std::back_inserter (hints.getPreviousValueIndexHints ),
345+ [](const auto & mapped_get_previous_value_index_hint) { return mapped_get_previous_value_index_hint.second ; });
346+
347+ std::ranges::transform (
348+ merkle_hints.get_leaf_preimage_hints_public_data_tree ,
349+ std::back_inserter (hints.getLeafPreimageHintsPublicDataTree ),
350+ [](const auto & mapped_get_leaf_preimage_hint) { return mapped_get_leaf_preimage_hint.second ; });
351+
352+ std::ranges::transform (
353+ merkle_hints.get_leaf_preimage_hints_nullifier_tree ,
354+ std::back_inserter (hints.getLeafPreimageHintsNullifierTree ),
355+ [](const auto & mapped_get_leaf_preimage_hint) { return mapped_get_leaf_preimage_hint.second ; });
356+
357+ std::ranges::transform (merkle_hints.get_leaf_value_hints ,
358+ std::back_inserter (hints.getLeafValueHints ),
359+ [](const auto & mapped_get_leaf_value_hint) { return mapped_get_leaf_value_hint.second ; });
360+
361+ std::ranges::transform (
362+ merkle_hints.sequential_insert_hints_public_data_tree ,
363+ std::back_inserter (hints.sequentialInsertHintsPublicDataTree ),
364+ [](const auto & mapped_sequential_insert_hint) { return mapped_sequential_insert_hint.second ; });
365+
366+ std::ranges::transform (
367+ merkle_hints.sequential_insert_hints_nullifier_tree ,
368+ std::back_inserter (hints.sequentialInsertHintsNullifierTree ),
369+ [](const auto & mapped_sequential_insert_hint) { return mapped_sequential_insert_hint.second ; });
370+
371+ std::ranges::transform (merkle_hints.append_leaves_hints ,
372+ std::back_inserter (hints.appendLeavesHints ),
373+ [](const auto & mapped_append_leaves_hint) { return mapped_append_leaves_hint.second ; });
374+
375+ std::ranges::transform (
376+ create_checkpoint_hints,
377+ std::back_inserter (hints.createCheckpointHints ),
378+ [](const auto & mapped_create_checkpoint_hint) { return mapped_create_checkpoint_hint.second ; });
379+
380+ std::ranges::transform (
381+ commit_checkpoint_hints,
382+ std::back_inserter (hints.commitCheckpointHints ),
383+ [](const auto & mapped_commit_checkpoint_hint) { return mapped_commit_checkpoint_hint.second ; });
384+
385+ std::ranges::transform (
386+ revert_checkpoint_hints,
387+ std::back_inserter (hints.revertCheckpointHints ),
388+ [](const auto & mapped_revert_checkpoint_hint) { return mapped_revert_checkpoint_hint.second ; });
372389}
373390
374391} // namespace bb::avm2::simulation
0 commit comments