Skip to content

Commit 4255ab1

Browse files
authored
Export non existence query logic (#403)
1 parent 83a12f6 commit 4255ab1

14 files changed

+511
-366
lines changed

mp2-v1/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ serde.workspace = true
2222
mp2_common = { path = "../mp2-common" }
2323
recursion_framework = { path = "../recursion-framework" }
2424
ryhope = { path = "../ryhope" }
25+
parsil = { path = "../parsil" }
2526
verifiable-db = { path = "../verifiable-db" }
2627
derive_more = "0.99.18"
2728
hex.workspace = true
2829
serde_json.workspace = true
30+
bb8 = "0.8.5"
31+
bb8-postgres = "0.8.1"
32+
tokio-postgres = "0.7.12"
33+
futures = "0.3.30"
2934

3035
[dev-dependencies]
3136
alloy.workspace = true

mp2-v1/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//! Circuits for v1 of Lagrange Proof Network (LPN)
2-
2+
#![allow(incomplete_features)]
33
// Add this to allow generic const expressions, e.g. `PAD_LEN(NODE_LEN)`.
44
#![feature(generic_const_exprs)]
55
// Add this so we don't need to always specify const generic in generic
66
// parameters (i.e. use "_")
77
#![feature(generic_arg_infer)]
8+
// stylistic feature
9+
#![feature(async_closure)]
810
use mp2_common::mpt_sequential::PAD_LEN;
911

1012
pub const MAX_BRANCH_NODE_LEN: usize = 532;
@@ -21,4 +23,5 @@ pub mod contract_extraction;
2123
pub mod final_extraction;
2224
pub mod indexing;
2325
pub mod length_extraction;
26+
pub mod query;
2427
pub mod values_extraction;

mp2-v1/src/query/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod planner;

mp2-v1/src/query/planner.rs

+436
Large diffs are not rendered by default.

mp2-v1/tests/common/block_extraction.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
use alloy::primitives::U256;
22
use anyhow::Result;
33
use mp2_common::{
4-
eth::{left_pad_generic, BlockUtil},
4+
eth::BlockUtil,
55
proof::deserialize_proof,
6-
u256,
76
utils::{Endianness, Packer, ToFields},
87
C, D, F,
98
};
109
use mp2_v1::{api, block_extraction, indexing::block::BlockPrimaryIndex};
1110

1211
use super::TestContext;
1312

14-
pub(crate) fn block_number_to_u256_limbs(number: u64) -> Vec<F> {
15-
const NUM_LIMBS: usize = u256::NUM_LIMBS;
16-
let block_number_buff = number.to_be_bytes();
17-
left_pad_generic::<u32, NUM_LIMBS>(&block_number_buff.pack(Endianness::Big)).to_fields()
18-
}
19-
2013
impl TestContext {
2114
pub(crate) async fn prove_block_extraction(&self, bn: BlockPrimaryIndex) -> Result<Vec<u8>> {
2215
let block = self

mp2-v1/tests/common/cases/indexing.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ pub(crate) const MAPPING_VALUE_COLUMN: &str = "map_value";
6969
pub(crate) const MAPPING_KEY_COLUMN: &str = "map_key";
7070

7171
impl TableIndexing {
72-
pub fn table(&self) -> &Table {
73-
&self.table
74-
}
7572
pub(crate) async fn merge_table_test_case(
7673
ctx: &mut TestContext,
7774
) -> Result<(Self, Vec<TableRowUpdate<BlockPrimaryIndex>>)> {
@@ -429,7 +426,7 @@ impl TableIndexing {
429426
updates: Vec<TableRowUpdate<BlockPrimaryIndex>>,
430427
expected_metadata_hash: &HashOutput,
431428
) -> Result<()> {
432-
let current_block = ctx.block_number().await;
429+
let current_block = ctx.block_number().await as BlockPrimaryIndex;
433430
// apply the new cells to the trees
434431
// NOTE ONLY the rest of the cells, not including the secondary one !
435432
let mut rows_update = Vec::new();
@@ -462,7 +459,7 @@ impl TableIndexing {
462459
let row_payload = ctx
463460
.prove_cells_tree(
464461
&self.table,
465-
current_block as usize,
462+
current_block,
466463
previous_row,
467464
new_cell_collection,
468465
tree_update,
@@ -495,7 +492,7 @@ impl TableIndexing {
495492
let row_payload = ctx
496493
.prove_cells_tree(
497494
&self.table,
498-
current_block as usize,
495+
current_block,
499496
Row {
500497
k: new_cells.previous_row_key.clone(),
501498
payload: old_row,

mp2-v1/tests/common/cases/planner.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl TreeInfo<RowTreeKey, RowPayload<BlockPrimaryIndex>>
121121
planner: &mut QueryPlanner<'a>,
122122
primary: BlockPrimaryIndex,
123123
k: &RowTreeKey,
124-
v: &RowPayload<BlockPrimaryIndex>,
124+
_v: &RowPayload<BlockPrimaryIndex>,
125125
) -> Result<Option<Vec<u8>>> {
126126
// TODO export that in single function
127127
Ok(if self.is_satisfying_query(k) {
@@ -274,7 +274,7 @@ impl TreeInfo<BlockPrimaryIndex, IndexNode<BlockPrimaryIndex>>
274274
&self,
275275
ctx: &mut TestContext,
276276
query_id: &QueryID,
277-
primary: BlockPrimaryIndex,
277+
_primary: BlockPrimaryIndex,
278278
key: &BlockPrimaryIndex,
279279
placeholder_values: PlaceholderValues,
280280
proof: Vec<u8>,
@@ -345,7 +345,7 @@ impl<'b> TreeInfo<BlockPrimaryIndex, IndexNode<BlockPrimaryIndex>> for IndexInfo
345345
&self,
346346
ctx: &mut TestContext,
347347
query_id: &QueryID,
348-
primary: BlockPrimaryIndex,
348+
_primary: BlockPrimaryIndex,
349349
key: &BlockPrimaryIndex,
350350
placeholder_values: PlaceholderValues,
351351
proof: Vec<u8>,

0 commit comments

Comments
 (0)