-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: implement provably extract LIMIT/OFFSET circuits (Part2) #300
base: feat/provably-extract-limit-offset
Are you sure you want to change the base?
feat: implement provably extract LIMIT/OFFSET circuits (Part2) #300
Conversation
438f966
to
cb09bb0
Compare
1c424f7
to
04aacfb
Compare
04aacfb
to
7999666
Compare
child_proof2.max_counter_target(), | ||
subtree_proof.max_counter_target(), | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we missing the constraints to enforce that offset_range_min
and offset_range_max
are the same across all the proofs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also the ones that all index_ids
are the same?
b: &mut CBuilder, | ||
subtree_proof: &PublicInputs<Target>, | ||
included_chid_proof: &PublicInputs<Target>, | ||
excluded_child_proof: &PublicInputs<Target>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should correspond to Publicinputs
of the results tree construction circuits
subtree_proof.accumulator_target(), | ||
included_chid_proof.accumulator_target(), | ||
]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as full node: equality constrains on index_ids, offset_range_min
and offset_range_max
seems to be missing
} | ||
|
||
/// Subtree proof number = 1, child proof number = 2 | ||
pub(crate) const NUM_VERIFIED_PROOFS: usize = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 2, since the excluded_child
proof does not refer to a circuit of this set, but instead to the results tree construction set. Might be better to actually implement this trait in the APIs PR
b: &mut CBuilder, | ||
subtree_proof: &PublicInputs<Target>, | ||
included_chid_proof: &PublicInputs<Target>, | ||
sibling_proof: &PublicInputs<Target>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here subtree_proof
and sibling_proof
should refer to the results tree construction circuits
} | ||
|
||
/// Subtree proof number = 1, child proof number = 2 | ||
pub(crate) const NUM_VERIFIED_PROOFS: usize = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 1, but as for partial node circuit, might be better to implement this in the APIs PR
); | ||
// assert max_left + 1 == p.min_counter | ||
let left_plus_one = b.add(max_left, one); | ||
b.connect(left_plus_one, subtree_proof.min_counter_target()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be more efficient to do b.connect(max_left, min_minus_one)
?
// range specified by the query | ||
// max_left < p.offset_range_max | ||
let is_less = less_than(b, max_left, subtree_proof.offset_range_min_target(), 32); | ||
b.connect(is_less.target, ttrue.target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_less
should be true only if left_child_exists
is true, I will also update the specs
// range specified by the query | ||
// min_right > p.offset_range_min | ||
let is_greater = greater_than(b, min_right, subtree_proof.offset_range_max_target(), 32); | ||
b.connect(is_greater.target, ttrue.target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly as above, is_greater
should be true only if right_child_exists
is true; will update the specs too
&zero_u256.to_targets(), | ||
&zero_u256.to_targets(), | ||
&zero_u256.to_targets(), | ||
&[one; 2], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these correspond to index_ids? So we might need to add those as witness inputs to the circuit
Address issue #181
Refer to the results extraction circuits spec.
This PR should be merged after #288