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

create proofs with post state #384

Merged
merged 4 commits into from
Sep 12, 2023
Merged

create proofs with post state #384

merged 4 commits into from
Sep 12, 2023

Conversation

gballet
Copy link
Member

@gballet gballet commented Aug 30, 2023

Changes the signature of MakeVerkleMultiProof to accept an extra root: if that root isn't nil, it means that the post state of the tree is also added to the proof.

@gballet gballet requested a review from jsign August 31, 2023 08:57
@gballet
Copy link
Member Author

gballet commented Aug 31, 2023

This is missing specific tests, btw

proof_ipa.go Outdated Show resolved Hide resolved
@gballet gballet force-pushed the proofs-with-post-state branch 3 times, most recently from 1eebc7f to f392bd3 Compare September 1, 2023 14:27
proof_ipa.go Show resolved Hide resolved
proof_ipa.go Show resolved Hide resolved
Copy link
Collaborator

@jsign jsign left a comment

Choose a reason for hiding this comment

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

LGTM, but I left some comments for your consideration since maybe some of them require code changes.

proof_ipa.go Outdated Show resolved Hide resolved
proof_ipa.go Show resolved Hide resolved
proof_ipa.go Outdated Show resolved Hide resolved
proof_ipa.go Outdated Show resolved Hide resolved
proof_ipa.go Outdated Show resolved Hide resolved
proof_ipa.go Show resolved Hide resolved
proof_ipa.go Show resolved Hide resolved
proof_ipa.go Outdated Show resolved Hide resolved
proof_test.go Outdated Show resolved Hide resolved
@gballet gballet force-pushed the proofs-with-post-state branch 4 times, most recently from 6764a0c to d220d72 Compare September 5, 2023 12:25
@gballet gballet marked this pull request as ready for review September 5, 2023 12:56
Copy link
Collaborator

@jsign jsign left a comment

Choose a reason for hiding this comment

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

Left some comments for your consideration.

// if a post-state tree is present, merge its proof elements with
// those of the pre-state tree, so that they can be proved together.
if postroot != nil {
pe_post, _, _, err := GetCommitmentsForMultiproof(postroot, keys, resolver)
Copy link
Collaborator

Choose a reason for hiding this comment

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

One question: here keys is the same set of keys used for pre-state and post-state proving.

But if the block execution read 1000 keys but only wrote into 1 key; shouldn't keys in this line only have 1 key instead of the 1000 ones? If that isn't the case, that would probably mean that proof_(c/f/y/z)s will have duplicate cuadruples.

As in, in the post-state VKT, there will be keys in keys that have the same value as in the pre-state VKT (e.g: 999 in this example). So, that means that there will be many repeated openings.

Maybe I'm a bit confused.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well the opening themselves will not be integrated to the proof. But you are correct that they will be computed. This is reusing a function that does too much, and at the end values that are just read will find themselves in the proof. This is not incorrect but it's much more than necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not going to fix it in this PR, created #393 to track it.

proof_ipa.go Outdated
Comment on lines 153 to 154
tr := common.NewTranscript("vt")
mpArg := ipa.CreateMultiProof(tr, cfg.conf, proof_cis, proof_fs, proof_zs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think at some point we should hide this transcript creation from clients.
It's a bit odd, and I don't think there's a use case in which you want to call CreateMultiProof with an existing non-pristine transcript.

If makes sense to you, I can add it to some TODO list I'm keeping.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, add it to the never-ending Todo list 😜

proof_ipa.go Outdated
Comment on lines 451 to 456
// PostStateTreeFromProof uses the pre-state trie and the list of updated values
// to produce the stateless post-state trie.
func PostStateTreeFromProof(preroot VerkleNode, statediff StateDiff) (VerkleNode, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I'd rename this to POstStateTreeFromStateDiff since it doesn't require a proof or similar.

Comment on lines +780 to +782
if len(data.keys) != len(data.values) {
t.Fatalf("incompatible number of keys and values: %d != %d", len(data.keys), len(data.values))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: dunno if you want to add the same check to compare len(data.updatekeys) != len(data.updatevalues).

Comment on lines 438 to 443
if bytes.Equal(k[:31], info[string(p)].stem) {
values[k[31]] = proof.Values[i]
values[k[31]] = proof.PreValues[i]
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still feel this if is a bit strange. We're reconstructing the values to be assigned in the leaf when we'll soon create the LeafNode.

But see what we do in CreatePath(...):

Is the latter needed? Or a noop? Or maybe I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I can't remember why that is, and removing it seems to work. I won't remove it in this PR but I'm making a note of it in #395

@gballet gballet merged commit 354ce60 into master Sep 12, 2023
6 checks passed
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.

2 participants