Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add common derives for integration #419

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions mp2-v1/src/query/batching_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ryhope::{
storage::{updatetree::UpdateTree, WideLineage},
Epoch,
};
use serde::{Deserialize, Serialize};
use verifiable_db::query::{
api::{NodePath, RowInput, TreePathInputs},
computational_hash_ids::ColumnIDs,
Expand Down Expand Up @@ -195,8 +196,10 @@ async fn generate_chunks<const CHUNK_SIZE: usize, C: ContextProvider>(
///
/// (2,0) (2,1) (2,2) (2,3) (2,4)
/// ```
#[derive(Clone, Debug, Hash, Eq, PartialEq, Default)]
pub struct UTKey<const ARITY: usize>((usize, usize));
#[derive(
Clone, Copy, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash, Serialize, Deserialize,
)]
pub struct UTKey<const ARITY: usize>(pub (usize, usize));

impl<const ARITY: usize> UTKey<ARITY> {
/// Compute the key of the child node of `self` that has `num_left_siblings`
Expand Down Expand Up @@ -318,15 +321,13 @@ impl<const ARITY: usize> ProvingTree<ARITY> {
let num_childrens = parent_node.children_keys.len();
let new_child_key = parent_key.children_key(num_childrens);
let child_node = ProvingTreeNode {
parent_key: Some(parent_key.clone()),
parent_key: Some(*parent_key),
children_keys: vec![],
};
// insert new child in the set of children of the parent
parent_node.children_keys.push(new_child_key.clone());
parent_node.children_keys.push(new_child_key);
assert!(
self.nodes
.insert(new_child_key.clone(), child_node)
.is_none(),
self.nodes.insert(new_child_key, child_node).is_none(),
"Node with key {:?} already found in the tree",
new_child_key
);
Expand All @@ -339,7 +340,7 @@ impl<const ARITY: usize> ProvingTree<ARITY> {
};
let root_key = UTKey((0, 0));
assert!(
self.nodes.insert(root_key.clone(), root).is_none(),
self.nodes.insert(root_key, root).is_none(),
"Error: root node inserted multiple times"
);
root_key
Expand Down Expand Up @@ -412,7 +413,7 @@ impl<const ARITY: usize> ProvingTree<ARITY> {
while node_key.is_some() {
// place node key in the path
let key = node_key.unwrap();
path.push(key.clone());
path.push(*key);
// fetch key of the parent node, if any
node_key = self
.nodes
Expand Down Expand Up @@ -449,7 +450,7 @@ impl<const NUM_CHUNKS: usize> UTForChunksBuilder<NUM_CHUNKS> {
let path = tree.compute_path_for_leaf(node_index);
(
(
path.last().unwrap().clone(), // chunk node is always a leaf of the tree, so it is the last node
*path.last().unwrap(), // chunk node is always a leaf of the tree, so it is the last node
// in the path
chunk,
),
Expand Down
2 changes: 1 addition & 1 deletion mp2-v1/src/query/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a, C: ContextProvider> NonExistenceInput<'a, C> {
}
}

pub(crate) async fn find_row_node_for_non_existence(
pub async fn find_row_node_for_non_existence(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why do you need to make this function public to use it in DQ? In my mind everything needed for DQ should be provided by generate_chunks_and_update_tree method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, let me check (seems it's used for a old DQ function for rows-tree proving), thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to check the DQ code, it's also called when creating the rows inputs here.

&self,
primary: BlockPrimaryIndex,
) -> anyhow::Result<RowTreeKey> {
Expand Down
2 changes: 1 addition & 1 deletion mp2-v1/tests/common/cases/query/aggregated_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub(crate) async fn prove_query(
let proof_key = ProofKey::QueryAggregate((
planner.query.query.clone(),
planner.query.placeholders.placeholder_values(),
k.clone(),
*k,
));
planner.ctx.storage.store_proof(proof_key.clone(), proof)?;
proof_id = Some(proof_key);
Expand Down
2 changes: 1 addition & 1 deletion verifiable-db/src/query/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl NodePath {
}
}

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