From 9d8d30497101883cfcdadfedfeea49460dca8eca Mon Sep 17 00:00:00 2001 From: Ian Joiner <14581281+iajoiner@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:37:10 -0400 Subject: [PATCH] feat!: add `ProverEvaluate::get_output_length` and rename `get_length` to `get_input_lengths` - add `ProverEvaluate::get_output_length` - rename `get_length` to `get_input_lengths` - move `get_input_lengths` to `ProverEvaluate` - add `get_table_references` --- crates/proof-of-sql/src/base/database/mod.rs | 1 + .../proof-of-sql/src/sql/proof/proof_plan.rs | 37 ++++-- .../proof-of-sql/src/sql/proof/query_proof.rs | 10 +- .../src/sql/proof/query_proof_test.rs | 112 ++++++++++++++---- .../sql/proof/verifiable_query_result_test.rs | 41 +++++-- .../src/sql/proof_plans/dyn_proof_plan.rs | 32 +++-- .../src/sql/proof_plans/filter_exec.rs | 29 ++++- .../filter_exec_test_dishonest_prover.rs | 25 ++++ .../src/sql/proof_plans/group_by_exec.rs | 39 +++++- .../src/sql/proof_plans/projection_exec.rs | 22 +++- 10 files changed, 284 insertions(+), 64 deletions(-) diff --git a/crates/proof-of-sql/src/base/database/mod.rs b/crates/proof-of-sql/src/base/database/mod.rs index a1bb6dd7f..6f3fe3e66 100644 --- a/crates/proof-of-sql/src/base/database/mod.rs +++ b/crates/proof-of-sql/src/base/database/mod.rs @@ -72,6 +72,7 @@ mod test_accessor; #[cfg(any(test, feature = "test"))] pub use test_accessor::TestAccessor; #[cfg(test)] +#[allow(unused_imports)] pub(crate) use test_accessor::UnimplementedTestAccessor; #[cfg(test)] diff --git a/crates/proof-of-sql/src/sql/proof/proof_plan.rs b/crates/proof-of-sql/src/sql/proof/proof_plan.rs index 430485308..dd0ce205f 100644 --- a/crates/proof-of-sql/src/sql/proof/proof_plan.rs +++ b/crates/proof-of-sql/src/sql/proof/proof_plan.rs @@ -3,7 +3,7 @@ use crate::base::{ commitment::Commitment, database::{ Column, ColumnField, ColumnRef, CommitmentAccessor, DataAccessor, MetadataAccessor, - OwnedTable, + OwnedTable, TableRef, }, map::IndexSet, proof::ProofError, @@ -22,17 +22,9 @@ pub trait ProofPlan: Debug + Send + Sync + ProverEvaluate Result<(), ProofError>; - /// The length of the input table - fn get_length(&self, accessor: &dyn MetadataAccessor) -> usize; - /// The offset of the query, that is, how many rows to skip before starting to read the input table fn get_offset(&self, accessor: &dyn MetadataAccessor) -> usize; - /// Check if the input table is empty - fn is_empty(&self, accessor: &dyn MetadataAccessor) -> bool { - self.get_length(accessor) == 0 - } - /// Form components needed to verify and proof store into `VerificationBuilder` fn verifier_evaluate( &self, @@ -44,11 +36,36 @@ pub trait ProofPlan: Debug + Send + Sync + ProverEvaluate Vec; - /// Return all the columns referenced in the Query + /// Return all the columns referenced in the query fn get_column_references(&self) -> IndexSet; + + /// Return all the tables referenced in the query + fn get_table_references(&self) -> IndexSet { + self.get_column_references() + .iter() + .map(ColumnRef::table_ref) + .collect() + } + + /// Check if the input tables are all empty + fn is_empty(&self, accessor: &dyn MetadataAccessor) -> bool { + self.get_table_references() + .iter() + .all(|table_ref| accessor.get_length(*table_ref) == 0) + } } pub trait ProverEvaluate { + /// Get the length of the input tables + fn get_input_lengths<'a>( + &self, + alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> Vec; + + /// Get the length of the output table + fn get_output_length<'a>(&self, alloc: &'a Bump, accessor: &'a dyn DataAccessor) -> usize; + /// Evaluate the query and modify `FirstRoundBuilder` to track the result of the query. fn result_evaluate<'a>( &self, diff --git a/crates/proof-of-sql/src/sql/proof/query_proof.rs b/crates/proof-of-sql/src/sql/proof/query_proof.rs index 62f3ada00..916a4019a 100644 --- a/crates/proof-of-sql/src/sql/proof/query_proof.rs +++ b/crates/proof-of-sql/src/sql/proof/query_proof.rs @@ -47,13 +47,13 @@ impl QueryProof { accessor: &impl DataAccessor, setup: &CP::ProverPublicSetup<'_>, ) -> (Self, ProvableQueryResult) { - let table_length = expr.get_length(accessor); + let alloc = Bump::new(); + // TODO: Modify this to handle multiple tables + let table_length = expr.get_input_lengths(&alloc, accessor)[0]; let num_sumcheck_variables = cmp::max(log2_up(table_length), 1); let generator_offset = expr.get_offset(accessor); assert!(num_sumcheck_variables > 0); - let alloc = Bump::new(); - // Evaluate query result let result_cols = expr.result_evaluate(table_length, &alloc, accessor); let output_length = result_cols.first().map_or(0, Column::len); @@ -150,7 +150,9 @@ impl QueryProof { result: &ProvableQueryResult, setup: &CP::VerifierPublicSetup<'_>, ) -> QueryResult { - let input_length = expr.get_length(accessor); + //TODO: Modify this when we have multiple tables + assert!(expr.get_table_references().len() == 1); + let input_length = accessor.get_length(*expr.get_table_references().first().unwrap()); let output_length = result.table_length(); let generator_offset = expr.get_offset(accessor); let num_sumcheck_variables = cmp::max(log2_up(input_length), 1); diff --git a/crates/proof-of-sql/src/sql/proof/query_proof_test.rs b/crates/proof-of-sql/src/sql/proof/query_proof_test.rs index 684cde01e..9eb68fc42 100644 --- a/crates/proof-of-sql/src/sql/proof/query_proof_test.rs +++ b/crates/proof-of-sql/src/sql/proof/query_proof_test.rs @@ -7,8 +7,7 @@ use crate::{ database::{ owned_table_utility::{bigint, owned_table}, Column, ColumnField, ColumnRef, ColumnType, CommitmentAccessor, DataAccessor, - MetadataAccessor, OwnedTable, OwnedTableTestAccessor, TestAccessor, - UnimplementedTestAccessor, + MetadataAccessor, OwnedTable, OwnedTableTestAccessor, }, map::IndexSet, proof::ProofError, @@ -41,6 +40,16 @@ impl Default for TrivialTestProofPlan { } } impl ProverEvaluate for TrivialTestProofPlan { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + _accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![self.length] + } + fn get_output_length<'a>(&self, _alloc: &'a Bump, _accessor: &'a dyn DataAccessor) -> usize { + self.length + } fn result_evaluate<'a>( &self, _input_length: usize, @@ -80,9 +89,6 @@ impl ProofPlan for TrivialTestProofPlan { builder.count_anchored_mles(self.anchored_mle_count); Ok(()) } - fn get_length(&self, _accessor: &dyn MetadataAccessor) -> usize { - self.length - } fn get_offset(&self, _accessor: &dyn MetadataAccessor) -> usize { self.offset } @@ -107,7 +113,12 @@ impl ProofPlan for TrivialTestProofPlan { vec![ColumnField::new("a1".parse().unwrap(), ColumnType::BigInt)] } fn get_column_references(&self) -> IndexSet { - unimplemented!("no real usage for this function yet") + core::iter::once(ColumnRef::new( + "sxt.test".parse().unwrap(), + "a1".parse().unwrap(), + ColumnType::BigInt, + )) + .collect() } } @@ -117,7 +128,13 @@ fn verify_a_trivial_query_proof_with_given_offset(n: usize, offset_generators: u offset: offset_generators, ..Default::default() }; - let accessor = UnimplementedTestAccessor::new_empty(); + let column: Vec = vec![0_i64; n]; + let accessor = OwnedTableTestAccessor::::new_from_table( + "sxt.test".parse().unwrap(), + owned_table([bigint("a1", column)]), + offset_generators, + (), + ); let (proof, result) = QueryProof::::new(&expr, &accessor, &()); let QueryData { verification_hash, @@ -150,7 +167,12 @@ fn verify_fails_if_the_summation_in_sumcheck_isnt_zero() { column_fill_value: 123, ..Default::default() }; - let accessor = UnimplementedTestAccessor::new_empty(); + let accessor = OwnedTableTestAccessor::::new_from_table( + "sxt.test".parse().unwrap(), + owned_table([bigint("a1", [123_i64; 2])]), + 0, + (), + ); let (proof, result) = QueryProof::::new(&expr, &accessor, &()); assert!(proof.verify(&expr, &accessor, &result, &()).is_err()); } @@ -163,7 +185,12 @@ fn verify_fails_if_the_sumcheck_evaluation_isnt_correct() { evaluation: 123, ..Default::default() }; - let accessor = UnimplementedTestAccessor::new_empty(); + let accessor = OwnedTableTestAccessor::::new_from_table( + "sxt.test".parse().unwrap(), + owned_table([bigint("a1", [0_i64; 2])]), + 0, + (), + ); let (proof, result) = QueryProof::::new(&expr, &accessor, &()); assert!(proof.verify(&expr, &accessor, &result, &()).is_err()); } @@ -176,7 +203,12 @@ fn verify_fails_if_counts_dont_match() { anchored_mle_count: 1, ..Default::default() }; - let accessor = UnimplementedTestAccessor::new_empty(); + let accessor = OwnedTableTestAccessor::::new_from_table( + "sxt.test".parse().unwrap(), + owned_table([bigint("a1", [0_i64; 2])]), + 0, + (), + ); let (proof, result) = QueryProof::::new(&expr, &accessor, &()); assert!(proof.verify(&expr, &accessor, &result, &()).is_err()); } @@ -198,6 +230,16 @@ impl Default for SquareTestProofPlan { } } impl ProverEvaluate for SquareTestProofPlan { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + _accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![2] + } + fn get_output_length<'a>(&self, _alloc: &'a Bump, _accessor: &'a dyn DataAccessor) -> usize { + 2 + } fn result_evaluate<'a>( &self, _table_length: usize, @@ -246,9 +288,6 @@ impl ProofPlan for SquareTestProofPlan { builder.count_anchored_mles(1); Ok(()) } - fn get_length(&self, _accessor: &dyn MetadataAccessor) -> usize { - 2 - } fn get_offset(&self, accessor: &dyn MetadataAccessor) -> usize { accessor.get_offset("sxt.test".parse().unwrap()) } @@ -276,7 +315,12 @@ impl ProofPlan for SquareTestProofPlan { vec![ColumnField::new("a1".parse().unwrap(), ColumnType::BigInt)] } fn get_column_references(&self) -> IndexSet { - unimplemented!("no real usage for this function yet") + core::iter::once(ColumnRef::new( + "sxt.test".parse().unwrap(), + "a1".parse().unwrap(), + ColumnType::BigInt, + )) + .collect() } } @@ -380,6 +424,16 @@ impl Default for DoubleSquareTestProofPlan { } } impl ProverEvaluate for DoubleSquareTestProofPlan { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + _accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![2] + } + fn get_output_length<'a>(&self, _alloc: &'a Bump, _accessor: &'a dyn DataAccessor) -> usize { + 2 + } fn result_evaluate<'a>( &self, _input_length: usize, @@ -441,9 +495,6 @@ impl ProofPlan for DoubleSquareTestProofPlan { builder.count_anchored_mles(1); Ok(()) } - fn get_length(&self, _accessor: &dyn MetadataAccessor) -> usize { - 2 - } fn get_offset(&self, accessor: &dyn MetadataAccessor) -> usize { accessor.get_offset("sxt.test".parse().unwrap()) } @@ -479,7 +530,12 @@ impl ProofPlan for DoubleSquareTestProofPlan { vec![ColumnField::new("a1".parse().unwrap(), ColumnType::BigInt)] } fn get_column_references(&self) -> IndexSet { - unimplemented!("no real usage for this function yet") + core::iter::once(ColumnRef::new( + "sxt.test".parse().unwrap(), + "a1".parse().unwrap(), + ColumnType::BigInt, + )) + .collect() } } @@ -592,6 +648,16 @@ fn verify_fails_the_result_doesnt_satisfy_an_intermediate_equation() { #[derive(Debug, Serialize)] struct ChallengeTestProofPlan {} impl ProverEvaluate for ChallengeTestProofPlan { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + _accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![2] + } + fn get_output_length<'a>(&self, _alloc: &'a Bump, _accessor: &'a dyn DataAccessor) -> usize { + 2 + } fn result_evaluate<'a>( &self, _input_length: usize, @@ -644,9 +710,6 @@ impl ProofPlan for ChallengeTestProofPlan { builder.count_post_result_challenges(2); Ok(()) } - fn get_length(&self, _accessor: &dyn MetadataAccessor) -> usize { - 2 - } fn get_offset(&self, accessor: &dyn MetadataAccessor) -> usize { accessor.get_offset("sxt.test".parse().unwrap()) } @@ -675,7 +738,12 @@ impl ProofPlan for ChallengeTestProofPlan { vec![ColumnField::new("a1".parse().unwrap(), ColumnType::BigInt)] } fn get_column_references(&self) -> IndexSet { - unimplemented!("no real usage for this function yet") + core::iter::once(ColumnRef::new( + "sxt.test".parse().unwrap(), + "a1".parse().unwrap(), + ColumnType::BigInt, + )) + .collect() } } diff --git a/crates/proof-of-sql/src/sql/proof/verifiable_query_result_test.rs b/crates/proof-of-sql/src/sql/proof/verifiable_query_result_test.rs index 5d299e408..cbcc3db9e 100644 --- a/crates/proof-of-sql/src/sql/proof/verifiable_query_result_test.rs +++ b/crates/proof-of-sql/src/sql/proof/verifiable_query_result_test.rs @@ -8,7 +8,7 @@ use crate::{ database::{ owned_table_utility::{bigint, owned_table}, Column, ColumnField, ColumnRef, ColumnType, CommitmentAccessor, DataAccessor, - MetadataAccessor, OwnedTable, TestAccessor, UnimplementedTestAccessor, + MetadataAccessor, OwnedTable, OwnedTableTestAccessor, TableRef, }, map::IndexSet, proof::ProofError, @@ -25,6 +25,16 @@ pub(super) struct EmptyTestQueryExpr { pub(super) columns: usize, } impl ProverEvaluate for EmptyTestQueryExpr { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + _accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![self.length] + } + fn get_output_length<'a>(&self, _alloc: &'a Bump, _accessor: &'a dyn DataAccessor) -> usize { + self.length + } fn result_evaluate<'a>( &self, _input_length: usize, @@ -59,9 +69,6 @@ impl ProofPlan for EmptyTestQueryExpr { builder.count_intermediate_mles(self.columns); Ok(()) } - fn get_length(&self, _accessor: &dyn MetadataAccessor) -> usize { - self.length - } fn get_offset(&self, _accessor: &dyn MetadataAccessor) -> usize { 0 } @@ -86,7 +93,15 @@ impl ProofPlan for EmptyTestQueryExpr { } fn get_column_references(&self) -> IndexSet { - unimplemented!("no real usage for this function yet") + (1..=self.columns) + .map(|i| { + ColumnRef::new( + TableRef::new("sxt.test".parse().unwrap()), + format!("a{i}").parse().unwrap(), + ColumnType::BigInt, + ) + }) + .collect() } } @@ -96,7 +111,13 @@ fn we_can_verify_queries_on_an_empty_table() { columns: 1, ..Default::default() }; - let accessor = UnimplementedTestAccessor::new_empty(); + let column: Vec = vec![0_i64; 0]; + let accessor = OwnedTableTestAccessor::::new_from_table( + "sxt.test".parse().unwrap(), + owned_table([bigint("a1", column)]), + 0, + (), + ); let res = VerifiableQueryResult::::new(&expr, &accessor, &()); let QueryData { verification_hash: _, @@ -112,7 +133,13 @@ fn empty_verification_fails_if_the_result_contains_non_null_members() { columns: 1, ..Default::default() }; - let accessor = UnimplementedTestAccessor::new_empty(); + let column: Vec = vec![0_i64; 0]; + let accessor = OwnedTableTestAccessor::::new_from_table( + "sxt.test".parse().unwrap(), + owned_table([bigint("a1", column)]), + 0, + (), + ); let res = VerifiableQueryResult:: { provable_result: Some(ProvableQueryResult::default()), proof: None, diff --git a/crates/proof-of-sql/src/sql/proof_plans/dyn_proof_plan.rs b/crates/proof-of-sql/src/sql/proof_plans/dyn_proof_plan.rs index c524a2c76..e509a00ed 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/dyn_proof_plan.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/dyn_proof_plan.rs @@ -44,14 +44,6 @@ impl ProofPlan for DynProofPlan { } } - fn get_length(&self, accessor: &dyn crate::base::database::MetadataAccessor) -> usize { - match self { - DynProofPlan::Projection(expr) => expr.get_length(accessor), - DynProofPlan::GroupBy(expr) => expr.get_length(accessor), - DynProofPlan::Filter(expr) => expr.get_length(accessor), - } - } - fn get_offset(&self, accessor: &dyn crate::base::database::MetadataAccessor) -> usize { match self { DynProofPlan::Projection(expr) => expr.get_offset(accessor), @@ -92,6 +84,30 @@ impl ProofPlan for DynProofPlan { } impl ProverEvaluate for DynProofPlan { + fn get_input_lengths<'a>( + &self, + alloc: &'a bumpalo::Bump, + accessor: &'a dyn crate::base::database::DataAccessor, + ) -> Vec { + match self { + DynProofPlan::Projection(expr) => expr.get_input_lengths(alloc, accessor), + DynProofPlan::GroupBy(expr) => expr.get_input_lengths(alloc, accessor), + DynProofPlan::Filter(expr) => expr.get_input_lengths(alloc, accessor), + } + } + + fn get_output_length<'a>( + &self, + alloc: &'a bumpalo::Bump, + accessor: &'a dyn crate::base::database::DataAccessor, + ) -> usize { + match self { + DynProofPlan::Projection(expr) => expr.get_output_length(alloc, accessor), + DynProofPlan::GroupBy(expr) => expr.get_output_length(alloc, accessor), + DynProofPlan::Filter(expr) => expr.get_output_length(alloc, accessor), + } + } + #[tracing::instrument(name = "DynProofPlan::result_evaluate", level = "debug", skip_all)] fn result_evaluate<'a>( &self, diff --git a/crates/proof-of-sql/src/sql/proof_plans/filter_exec.rs b/crates/proof-of-sql/src/sql/proof_plans/filter_exec.rs index 28895df61..0340c5082 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/filter_exec.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/filter_exec.rs @@ -77,10 +77,6 @@ where Ok(()) } - fn get_length(&self, accessor: &dyn MetadataAccessor) -> usize { - accessor.get_length(self.table.table_ref) - } - fn get_offset(&self, accessor: &dyn MetadataAccessor) -> usize { accessor.get_offset(self.table.table_ref) } @@ -145,6 +141,31 @@ where pub type FilterExec = OstensibleFilterExec; impl ProverEvaluate for FilterExec { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![accessor.get_length(self.table.table_ref)] + } + + fn get_output_length<'a>( + &self, + alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> usize { + let input_length = accessor.get_length(self.table.table_ref); + let selection_column: Column<'a, C::Scalar> = + self.where_clause + .result_evaluate(input_length, alloc, accessor); + selection_column + .as_boolean() + .expect("selection is not boolean") + .iter() + .filter(|&&b| b) + .count() + } + #[tracing::instrument(name = "FilterExec::result_evaluate", level = "debug", skip_all)] fn result_evaluate<'a>( &self, diff --git a/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test_dishonest_prover.rs b/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test_dishonest_prover.rs index 4d32bc735..a3fff262e 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test_dishonest_prover.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/filter_exec_test_dishonest_prover.rs @@ -30,6 +30,31 @@ impl ProverHonestyMarker for Dishonest {} type DishonestFilterExec = OstensibleFilterExec; impl ProverEvaluate for DishonestFilterExec { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![accessor.get_length(self.table.table_ref)] + } + + fn get_output_length<'a>( + &self, + alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> usize { + let input_length = accessor.get_length(self.table.table_ref); + let selection_column: Column<'a, Curve25519Scalar> = + self.where_clause + .result_evaluate(input_length, alloc, accessor); + selection_column + .as_boolean() + .expect("selection is not boolean") + .iter() + .filter(|&&b| b) + .count() + } + #[tracing::instrument( name = "DishonestFilterExec::result_evaluate", level = "debug", diff --git a/crates/proof-of-sql/src/sql/proof_plans/group_by_exec.rs b/crates/proof-of-sql/src/sql/proof_plans/group_by_exec.rs index 069aa08d1..c67cbad4f 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/group_by_exec.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/group_by_exec.rs @@ -92,10 +92,6 @@ impl ProofPlan for GroupByExec { Ok(()) } - fn get_length(&self, accessor: &dyn MetadataAccessor) -> usize { - accessor.get_length(self.table.table_ref) - } - fn get_offset(&self, accessor: &dyn MetadataAccessor) -> usize { accessor.get_offset(self.table.table_ref) } @@ -205,6 +201,41 @@ impl ProofPlan for GroupByExec { } impl ProverEvaluate for GroupByExec { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![accessor.get_length(self.table.table_ref)] + } + + fn get_output_length<'a>( + &self, + alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> usize { + let input_length = accessor.get_length(self.table.table_ref); + // 1. selection + let selection_column: Column<'a, C::Scalar> = + self.where_clause + .result_evaluate(input_length, alloc, accessor); + let selection = selection_column + .as_boolean() + .expect("selection is not boolean"); + + // 2. columns + let group_by_columns = self + .group_by_exprs + .iter() + .map(|expr| expr.result_evaluate(input_length, alloc, accessor)) + .collect::>(); + // Compute filtered_columns + let AggregatedColumns { count_column, .. } = + aggregate_columns(alloc, &group_by_columns, &[], &[], &[], selection) + .expect("columns should be aggregatable"); + count_column.len() + } + #[tracing::instrument(name = "GroupByExec::result_evaluate", level = "debug", skip_all)] fn result_evaluate<'a>( &self, diff --git a/crates/proof-of-sql/src/sql/proof_plans/projection_exec.rs b/crates/proof-of-sql/src/sql/proof_plans/projection_exec.rs index fb66bff00..60fcac6d2 100644 --- a/crates/proof-of-sql/src/sql/proof_plans/projection_exec.rs +++ b/crates/proof-of-sql/src/sql/proof_plans/projection_exec.rs @@ -16,7 +16,7 @@ use crate::{ proof_exprs::{AliasedDynProofExpr, ProofExpr, TableExpr}, }, }; -use alloc::vec::Vec; +use alloc::{vec, vec::Vec}; use bumpalo::Bump; use core::iter::repeat_with; use serde::{Deserialize, Serialize}; @@ -54,10 +54,6 @@ impl ProofPlan for ProjectionExec { Ok(()) } - fn get_length(&self, accessor: &dyn MetadataAccessor) -> usize { - accessor.get_length(self.table.table_ref) - } - fn get_offset(&self, accessor: &dyn MetadataAccessor) -> usize { accessor.get_offset(self.table.table_ref) } @@ -95,6 +91,22 @@ impl ProofPlan for ProjectionExec { } impl ProverEvaluate for ProjectionExec { + fn get_input_lengths<'a>( + &self, + _alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> Vec { + vec![accessor.get_length(self.table.table_ref)] + } + + fn get_output_length<'a>( + &self, + _alloc: &'a Bump, + accessor: &'a dyn DataAccessor, + ) -> usize { + accessor.get_length(self.table.table_ref) + } + #[tracing::instrument(name = "ProjectionExec::result_evaluate", level = "debug", skip_all)] fn result_evaluate<'a>( &self,