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

Merge Table #362

Merged
merged 60 commits into from
Oct 30, 2024
Merged

Merge Table #362

merged 60 commits into from
Oct 30, 2024

Conversation

nikkolasg
Copy link
Collaborator

No description provided.

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.

First set of comments, not yet looked at all the changes

mp2-v1/src/values_extraction/merge.rs Outdated Show resolved Hide resolved
verifiable-db/src/block_tree/mod.rs Outdated Show resolved Hide resolved
mp2-v1/src/values_extraction/merge.rs Outdated Show resolved Hide resolved
mp2-v1/src/values_extraction/merge.rs Outdated Show resolved Hide resolved
verifiable-db/src/row_tree/leaf.rs Outdated Show resolved Hide resolved
@nikkolasg nikkolasg marked this pull request as draft September 17, 2024 20:33
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.

First set of comments, still to have a look at verifiable db changes

mp2-common/src/digest.rs Outdated Show resolved Hide resolved
}
}

pub fn cond_combine_to_row_digest(&self) -> Digest {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does cond_ stand for? The naming convention is a bit unclear to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

conditional. Any other preferences ?

mp2-v1/src/final_extraction/base_circuit.rs Outdated Show resolved Hide resolved
mp2-v1/src/final_extraction/merge.rs Outdated Show resolved Hide resolved
@@ -285,6 +354,6 @@ mod tests {
.unwrap(),
)
.unwrap();
proof_pis.check_proof_public_inputs(proof.proof(), true, Some(len_dm));
proof_pis.check_proof_public_inputs(proof.proof(), TableDimension::Compound, Some(len_dm));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add also a test for proof generation employing the API for merge circuit?

verifiable-db/src/block_tree/mod.rs Outdated Show resolved Hide resolved
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.

Further comments on verifiable db changes. Mostly minor comments, main issue for now I think it's related to unit tests, which seem to be missing for the new cases introduced by merged tables.

verifiable-db/src/cells_tree/mod.rs Outdated Show resolved Hide resolved
verifiable-db/src/cells_tree/leaf.rs Outdated Show resolved Hide resolved
/// Create a circuit input for proving a leaf node whose value is considered as a multiplier
/// depending on the boolean value.
/// i.e. it means it's one of the repeated value amongst all the rows
pub fn leaf_multiplier(identifier: u64, value: U256, is_multiplier: bool) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have leaf and leaf_multiplier methods, I would expect to call the former for cells where is_multiplier = false and the latter for cells where is_multiplier = true. In other words, wouldn't it be clearer from API perspective if this method doesn't have is_multiplier flag as input? Or you designed the API in this way because you want to always use leaf for tables not mixing multiple variable types and leaf_multiplier for mixed tables?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

my initial thought was more on keeping the previous API the same and it ended up as you said

the API in this way because you want to always use leaf for tables not mixing multiple variable types and leaf_multiplier for mixed tables

If if i set leaf to set multiplier = false directly then we would not use the individual keyword that i've been trying to instill in the rest of the codebase.
So maybe leaf_merge is better name ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The renaming would make sense if we want to keep the usage of leaf_merge only for merged tables. But for instance in the integration test it seems to me you are using this method for all tests cases, isn't it? So I am wondering if might be always convenient to just have a single method with the multiplier flag rather than having 2 distinct methods

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hackaugusto what do you prefer ? :D Any opinion ? I was more on the side of letting things backward compatible and adding new endpoint, it doesn't "surprise" me more than that but dont really have an strong opinion.

verifiable-db/src/cells_tree/api.rs Outdated Show resolved Hide resolved
verifiable-db/src/cells_tree/api.rs Outdated Show resolved Hide resolved
mp2-common/src/group_hashing/mod.rs Show resolved Hide resolved
// final_digest = HashToInt(mul_digest) * D(ind_digest)
// NOTE This additional digest is necessary since the individual digest is supposed to be a
// full row, that is how it is extracted from MPT
let final_digest = split_digest.cond_combine_to_row_digest(b);
Copy link
Contributor

Choose a reason for hiding this comment

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

In the row circuits I think that instead of having to check whether multiplier ==NEUTRAL, it could be a bit cheaper to have an input flag that tells whether there is not a multiplier to be added. We can call this input flag something like is_combined_table, so that its semantic is clear. This will allow to remove the need to have curve_eq operation, which might require a couple of additional rows. Though I see it's not a dramatic improvement, so if you think it would make the APIs too complex we could also avoid it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mhhh it doesn't make the API complex if i still rely on the check point == neutral but outside of circuit, wdyt ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that would make sense. Though I suppose you should also take into account the multiplier flag for the current row? Like, if point == neutral for all the other cells but multiplier = true for the secondary index, then the scalar multiplication would still need to be performed, right?

pub fn leaf_multiplier(
identifier: u64,
value: U256,
is_multiplier: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as for cells tree API: I would expect this function doesn't have an is_multiplier flag as input, but will instead be called only when is_multiplier = true

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.

Reviewed also integration test. Mostly minor comments about it.

mp2-v1/tests/common/rowtree.rs Show resolved Hide resolved
mp2-v1/tests/common/mod.rs Outdated Show resolved Hide resolved
mp2-v1/tests/common/cases/table_source.rs Show resolved Hide resolved
mp2-v1/tests/common/cases/table_source.rs Outdated Show resolved Hide resolved
mp2-v1/tests/common/cases/table_source.rs Outdated Show resolved Hide resolved
mp2-v1/tests/integrated_tests.rs Outdated Show resolved Hide resolved
Comment on lines +954 to +958
if payload.min() != value {
// the value of successor is different from `value`, so we don't return the
// successor node
return None;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Confused because in the comment you say

if the successor exists in the row tree and it stores the same value of the input node (i.e., value); returns None

And yet here the value is different so i would have expected returning something. Same for the other while loop below.

Copy link
Contributor

Choose a reason for hiding this comment

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

We return a node if we find the successor and it has the same value of the input node, that was the intended meaning of the comment; in this case, we found a successor but its value is different from the input node, so we don't return any node. Feel free to modify comments as you wish to clairfy

@nikkolasg nikkolasg merged commit 0959914 into main Oct 30, 2024
3 of 4 checks passed
@nikkolasg nikkolasg deleted the feat/merge_table branch October 30, 2024 11:52
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