Skip to content

Commit

Permalink
refactor!: remove accessor from ProofPlan::count (#347)
Browse files Browse the repository at this point in the history
Please be sure to look over the pull request guidelines here:
https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md#submit-pr.

# Please go through the following checklist
- [x] The PR title and commit messages adhere to guidelines here:
https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md.
In particular `!` is used if and only if at least one breaking change
has been introduced.
- [x] I have run the ci check script with `source
scripts/run_ci_checks.sh`.

# Rationale for this change
We want to remove the arg since it has never been used and because it
benefits `ProofPlan` composition.
<!--
Why are you proposing this change? If this is already explained clearly
in the linked issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.

 Example:
 Add `NestedLoopJoinExec`.
 Closes #345.

Since we added `HashJoinExec` in #323 it has been possible to do
provable inner joins. However performance is not satisfactory in some
cases. Hence we need to fix the problem by implement
`NestedLoopJoinExec` and speed up the code
 for `HashJoinExec`.
-->

# What changes are included in this PR?
See title.
<!--
There is no need to duplicate the description in the ticket here but it
is sometimes worth providing a summary of the individual changes in this
PR.

Example:
- Add `NestedLoopJoinExec`.
- Speed up `HashJoinExec`.
- Route joins to `NestedLoopJoinExec` if the outer input is sufficiently
small.
-->

# Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?

Example:
Yes.
-->
Existing tests should pass
  • Loading branch information
iajoiner authored Nov 8, 2024
2 parents bb46fcb + 1efb520 commit 107fa10
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 51 deletions.
6 changes: 1 addition & 5 deletions crates/proof-of-sql/src/sql/proof/proof_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ use core::fmt::Debug;
#[enum_dispatch::enum_dispatch(DynProofPlan)]
pub trait ProofPlan: Debug + Send + Sync + ProverEvaluate {
/// Count terms used within the Query's proof
fn count(
&self,
builder: &mut CountBuilder,
accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError>;
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError>;

/// The length of the input table
fn get_length(&self, accessor: &dyn MetadataAccessor) -> usize;
Expand Down
2 changes: 1 addition & 1 deletion crates/proof-of-sql/src/sql/proof/query_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<CP: CommitmentEvaluationProof> QueryProof<CP> {
// count terms
let counts = {
let mut builder = CountBuilder::new(&self.bit_distributions);
expr.count(&mut builder, accessor)?;
expr.count(&mut builder)?;
builder.counts()
}?;

Expand Down
24 changes: 4 additions & 20 deletions crates/proof-of-sql/src/sql/proof/query_proof_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ impl ProverEvaluate for TrivialTestProofPlan {
}
}
impl ProofPlan for TrivialTestProofPlan {
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
builder.count_degree(2);
builder.count_intermediate_mles(1);
builder.count_subpolynomials(1);
Expand Down Expand Up @@ -238,11 +234,7 @@ impl ProverEvaluate for SquareTestProofPlan {
}
}
impl ProofPlan for SquareTestProofPlan {
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
builder.count_degree(3);
builder.count_intermediate_mles(1);
builder.count_subpolynomials(1);
Expand Down Expand Up @@ -436,11 +428,7 @@ impl ProverEvaluate for DoubleSquareTestProofPlan {
}
}
impl ProofPlan for DoubleSquareTestProofPlan {
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
builder.count_degree(3);
builder.count_intermediate_mles(2);
builder.count_subpolynomials(2);
Expand Down Expand Up @@ -641,11 +629,7 @@ impl ProverEvaluate for ChallengeTestProofPlan {
}
}
impl ProofPlan for ChallengeTestProofPlan {
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
builder.count_degree(3);
builder.count_intermediate_mles(1);
builder.count_subpolynomials(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ impl ProverEvaluate for EmptyTestQueryExpr {
}
}
impl ProofPlan for EmptyTestQueryExpr {
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
builder.count_intermediate_mles(self.columns);
Ok(())
}
Expand Down
6 changes: 1 addition & 5 deletions crates/proof-of-sql/src/sql/proof_plans/empty_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ impl EmptyExec {
}

impl ProofPlan for EmptyExec {
fn count(
&self,
_builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, _builder: &mut CountBuilder) -> Result<(), ProofError> {
Ok(())
}

Expand Down
6 changes: 1 addition & 5 deletions crates/proof-of-sql/src/sql/proof_plans/filter_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ impl<H: ProverHonestyMarker> ProofPlan for OstensibleFilterExec<H>
where
OstensibleFilterExec<H>: ProverEvaluate,
{
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
self.where_clause.count(builder)?;
for aliased_expr in &self.aliased_results {
aliased_expr.expr.count(builder)?;
Expand Down
6 changes: 1 addition & 5 deletions crates/proof-of-sql/src/sql/proof_plans/group_by_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ impl GroupByExec {
}

impl ProofPlan for GroupByExec {
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
self.where_clause.count(builder)?;
for expr in &self.group_by_exprs {
expr.count(builder)?;
Expand Down
6 changes: 1 addition & 5 deletions crates/proof-of-sql/src/sql/proof_plans/projection_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ impl ProjectionExec {
}

impl ProofPlan for ProjectionExec {
fn count(
&self,
builder: &mut CountBuilder,
_accessor: &dyn MetadataAccessor,
) -> Result<(), ProofError> {
fn count(&self, builder: &mut CountBuilder) -> Result<(), ProofError> {
for aliased_expr in &self.aliased_results {
aliased_expr.expr.count(builder)?;
builder.count_intermediate_mles(1);
Expand Down

0 comments on commit 107fa10

Please sign in to comment.