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

Export non existence query logic #403

Merged
merged 5 commits into from
Nov 7, 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
5 changes: 5 additions & 0 deletions mp2-v1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ serde.workspace = true
mp2_common = { path = "../mp2-common" }
recursion_framework = { path = "../recursion-framework" }
ryhope = { path = "../ryhope" }
parsil = { path = "../parsil" }
verifiable-db = { path = "../verifiable-db" }
derive_more = "0.99.18"
hex.workspace = true
serde_json.workspace = true
bb8 = "0.8.5"
bb8-postgres = "0.8.1"
tokio-postgres = "0.7.12"
futures = "0.3.30"

[dev-dependencies]
alloy.workspace = true
Expand Down
5 changes: 4 additions & 1 deletion mp2-v1/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Circuits for v1 of Lagrange Proof Network (LPN)

#![allow(incomplete_features)]
// Add this to allow generic const expressions, e.g. `PAD_LEN(NODE_LEN)`.
#![feature(generic_const_exprs)]
// Add this so we don't need to always specify const generic in generic
// parameters (i.e. use "_")
#![feature(generic_arg_infer)]
// stylistic feature
#![feature(async_closure)]
use mp2_common::mpt_sequential::PAD_LEN;

pub const MAX_BRANCH_NODE_LEN: usize = 532;
Expand All @@ -21,4 +23,5 @@ pub mod contract_extraction;
pub mod final_extraction;
pub mod indexing;
pub mod length_extraction;
pub mod query;
pub mod values_extraction;
1 change: 1 addition & 0 deletions mp2-v1/src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod planner;
436 changes: 436 additions & 0 deletions mp2-v1/src/query/planner.rs

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions mp2-v1/tests/common/block_extraction.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
use alloy::primitives::U256;
use anyhow::Result;
use mp2_common::{
eth::{left_pad_generic, BlockUtil},
eth::BlockUtil,
proof::deserialize_proof,
u256,
utils::{Endianness, Packer, ToFields},
C, D, F,
};
use mp2_v1::{api, block_extraction, indexing::block::BlockPrimaryIndex};

use super::TestContext;

pub(crate) fn block_number_to_u256_limbs(number: u64) -> Vec<F> {
const NUM_LIMBS: usize = u256::NUM_LIMBS;
let block_number_buff = number.to_be_bytes();
left_pad_generic::<u32, NUM_LIMBS>(&block_number_buff.pack(Endianness::Big)).to_fields()
}

impl TestContext {
pub(crate) async fn prove_block_extraction(&self, bn: BlockPrimaryIndex) -> Result<Vec<u8>> {
let block = self
Expand Down
9 changes: 3 additions & 6 deletions mp2-v1/tests/common/cases/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ pub(crate) const MAPPING_VALUE_COLUMN: &str = "map_value";
pub(crate) const MAPPING_KEY_COLUMN: &str = "map_key";

impl TableIndexing {
pub fn table(&self) -> &Table {
&self.table
}
pub(crate) async fn merge_table_test_case(
ctx: &mut TestContext,
) -> Result<(Self, Vec<TableRowUpdate<BlockPrimaryIndex>>)> {
Expand Down Expand Up @@ -429,7 +426,7 @@ impl TableIndexing {
updates: Vec<TableRowUpdate<BlockPrimaryIndex>>,
expected_metadata_hash: &HashOutput,
) -> Result<()> {
let current_block = ctx.block_number().await;
let current_block = ctx.block_number().await as BlockPrimaryIndex;
// apply the new cells to the trees
// NOTE ONLY the rest of the cells, not including the secondary one !
let mut rows_update = Vec::new();
Expand Down Expand Up @@ -462,7 +459,7 @@ impl TableIndexing {
let row_payload = ctx
.prove_cells_tree(
&self.table,
current_block as usize,
current_block,
previous_row,
new_cell_collection,
tree_update,
Expand Down Expand Up @@ -495,7 +492,7 @@ impl TableIndexing {
let row_payload = ctx
.prove_cells_tree(
&self.table,
current_block as usize,
current_block,
Row {
k: new_cells.previous_row_key.clone(),
payload: old_row,
Expand Down
6 changes: 3 additions & 3 deletions mp2-v1/tests/common/cases/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl TreeInfo<RowTreeKey, RowPayload<BlockPrimaryIndex>>
planner: &mut QueryPlanner<'a>,
primary: BlockPrimaryIndex,
k: &RowTreeKey,
v: &RowPayload<BlockPrimaryIndex>,
_v: &RowPayload<BlockPrimaryIndex>,
) -> Result<Option<Vec<u8>>> {
// TODO export that in single function
Ok(if self.is_satisfying_query(k) {
Expand Down Expand Up @@ -274,7 +274,7 @@ impl TreeInfo<BlockPrimaryIndex, IndexNode<BlockPrimaryIndex>>
&self,
ctx: &mut TestContext,
query_id: &QueryID,
primary: BlockPrimaryIndex,
_primary: BlockPrimaryIndex,
key: &BlockPrimaryIndex,
placeholder_values: PlaceholderValues,
proof: Vec<u8>,
Expand Down Expand Up @@ -345,7 +345,7 @@ impl<'b> TreeInfo<BlockPrimaryIndex, IndexNode<BlockPrimaryIndex>> for IndexInfo
&self,
ctx: &mut TestContext,
query_id: &QueryID,
primary: BlockPrimaryIndex,
_primary: BlockPrimaryIndex,
key: &BlockPrimaryIndex,
placeholder_values: PlaceholderValues,
proof: Vec<u8>,
Expand Down
Loading
Loading