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

fix: replace MPT metadata with counter for row_id computation #399

Open
wants to merge 7 commits into
base: generic-extraction-tree-creation
Choose a base branch
from

Conversation

silathdiir
Copy link
Contributor

No description provided.

@silathdiir silathdiir force-pushed the generic-extraction-row-id-update branch from a24cfde to 0836ee3 Compare October 31, 2024 04:04
Copy link
Contributor

@nicholas-mainardi nicholas-mainardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! mostly minor comments


b.register_curve_public_input(values_digest.individual);
b.register_curve_public_input(values_digest.multiplier);
b.register_curve_public_input(metadata_digest.individual);
b.register_curve_public_input(metadata_digest.multiplier);

(cell, child_values_digest, child_metadata_digest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

child_metadata_digest could be removed from the test now, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this child_metadata_digest in commit aa84a07.


// individual_counter = p.individual_counter + is_individual
let individual_cnt = cells_pi.individual_counter()
+ if self.cell.is_individual() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a method F::from_bool if I remember correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix to use F::from_bool in commit 3a686f9.


// multiplier_counter = p.multiplier_counter + not is_individual
let multiplier_cnt = cells_pi.multiplier_counter()
+ if self.cell.is_multiplier() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: method F::from_bool could be used here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix to use F::from_bool in commit 3a686f9.

@@ -184,33 +184,19 @@ impl CircuitInput {
pub fn leaf(
identifier: u64,
value: U256,
mpt_metadata: HashOut<F>,
row_unique_data: HashOut<F>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

row_unique_data should be typed as HashOutput to avoid exposing plonky2 types in external APIs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix to HashOutput type in commit d5c9e24.

Copy link
Collaborator

@nikkolasg nikkolasg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me but with a few question - i think @nicholas-mainardi should be able to answer.

);
// Check individual counter
let multiplier_cnt = F::from_bool(is_multiplier);
assert_eq!(pi.individual_counter(), F::ONE - multiplier_cnt);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this.
We officially only support single table so the multipler columns can be 1 or more, that means this subtraction can underflow.

Then in my mind the total number of columns = individual_counter + multiplier_counter so if we want the individual_columns = total - multiplier_columns , not one...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing a leaf node of a cells tree, so the counter is either 0 or 1, depending on whether the current cell is accumulated as individual or multiplier

Comment on lines +51 to +52
b.connect(digest.multiplier_cnt, min_child.multiplier_counter_target());
b.connect(digest.multiplier_cnt, max_child.multiplier_counter_target());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also check that the individual counter are the same between the children and this node ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The individual counter is not exposed as public input in rows tree nodes, since it's already included in the value digest, to compute row_id_individual. This should already be enforced to be the same in MPT circuits, where we ensure that row_id_individual for each item being extracted is computed using a counter provably bound to the number of columns specified in the metadata digest; therefore, by checking in MPT circuits that the metadata digest is always the same across all the extracted items, we should implicitly check that all counters employed to compute row_id_individual, and so the value digest, are the same for all extracted items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants