Skip to content

Commit 33284df

Browse files
authored
fix: add common derives for integration (#419)
1 parent 0666bb9 commit 33284df

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

mp2-v1/src/query/batching_planner.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use ryhope::{
1010
storage::{updatetree::UpdateTree, WideLineage},
1111
Epoch,
1212
};
13+
use serde::{Deserialize, Serialize};
1314
use verifiable_db::query::{
1415
api::{NodePath, RowInput, TreePathInputs},
1516
computational_hash_ids::ColumnIDs,
@@ -195,8 +196,10 @@ async fn generate_chunks<const CHUNK_SIZE: usize, C: ContextProvider>(
195196
///
196197
/// (2,0) (2,1) (2,2) (2,3) (2,4)
197198
/// ```
198-
#[derive(Clone, Debug, Hash, Eq, PartialEq, Default)]
199-
pub struct UTKey<const ARITY: usize>((usize, usize));
199+
#[derive(
200+
Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash, Serialize, Deserialize,
201+
)]
202+
pub struct UTKey<const ARITY: usize>(pub (usize, usize));
200203

201204
impl<const ARITY: usize> UTKey<ARITY> {
202205
/// Compute the key of the child node of `self` that has `num_left_siblings`
@@ -318,15 +321,13 @@ impl<const ARITY: usize> ProvingTree<ARITY> {
318321
let num_childrens = parent_node.children_keys.len();
319322
let new_child_key = parent_key.children_key(num_childrens);
320323
let child_node = ProvingTreeNode {
321-
parent_key: Some(parent_key.clone()),
324+
parent_key: Some(*parent_key),
322325
children_keys: vec![],
323326
};
324327
// insert new child in the set of children of the parent
325-
parent_node.children_keys.push(new_child_key.clone());
328+
parent_node.children_keys.push(new_child_key);
326329
assert!(
327-
self.nodes
328-
.insert(new_child_key.clone(), child_node)
329-
.is_none(),
330+
self.nodes.insert(new_child_key, child_node).is_none(),
330331
"Node with key {:?} already found in the tree",
331332
new_child_key
332333
);
@@ -339,7 +340,7 @@ impl<const ARITY: usize> ProvingTree<ARITY> {
339340
};
340341
let root_key = UTKey((0, 0));
341342
assert!(
342-
self.nodes.insert(root_key.clone(), root).is_none(),
343+
self.nodes.insert(root_key, root).is_none(),
343344
"Error: root node inserted multiple times"
344345
);
345346
root_key
@@ -412,7 +413,7 @@ impl<const ARITY: usize> ProvingTree<ARITY> {
412413
while node_key.is_some() {
413414
// place node key in the path
414415
let key = node_key.unwrap();
415-
path.push(key.clone());
416+
path.push(*key);
416417
// fetch key of the parent node, if any
417418
node_key = self
418419
.nodes
@@ -449,7 +450,7 @@ impl<const NUM_CHUNKS: usize> UTForChunksBuilder<NUM_CHUNKS> {
449450
let path = tree.compute_path_for_leaf(node_index);
450451
(
451452
(
452-
path.last().unwrap().clone(), // chunk node is always a leaf of the tree, so it is the last node
453+
*path.last().unwrap(), // chunk node is always a leaf of the tree, so it is the last node
453454
// in the path
454455
chunk,
455456
),

mp2-v1/src/query/planner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, C: ContextProvider> NonExistenceInput<'a, C> {
6565
}
6666
}
6767

68-
pub(crate) async fn find_row_node_for_non_existence(
68+
pub async fn find_row_node_for_non_existence(
6969
&self,
7070
primary: BlockPrimaryIndex,
7171
) -> anyhow::Result<RowTreeKey> {

mp2-v1/tests/common/cases/query/aggregated_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub(crate) async fn prove_query(
237237
let proof_key = ProofKey::QueryAggregate((
238238
planner.query.query.clone(),
239239
planner.query.placeholders.placeholder_values(),
240-
k.clone(),
240+
*k,
241241
));
242242
planner.ctx.storage.store_proof(proof_key.clone(), proof)?;
243243
proof_id = Some(proof_key);

verifiable-db/src/query/api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl NodePath {
119119
}
120120
}
121121

122-
#[derive(Clone, Debug)]
122+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
123123
/// Data structure containing the inputs necessary to prove a query for a row
124124
/// of the DB table.
125125
pub struct RowInput {

0 commit comments

Comments
 (0)