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

feat(proof): create a proto representation of the proof #220

Merged
merged 7 commits into from
Jul 19, 2023

Conversation

vgonkivs
Copy link
Member

@vgonkivs vgonkivs commented Jul 14, 2023

Overview

Added and generated a proto representation of the Proof

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@codecov
Copy link

codecov bot commented Jul 14, 2023

Codecov Report

Merging #220 (4141b50) into master (3693c9a) will decrease coverage by 28.47%.
The diff coverage is 6.20%.

@@             Coverage Diff             @@
##           master     #220       +/-   ##
===========================================
- Coverage   93.67%   65.20%   -28.47%     
===========================================
  Files           5        6        +1     
  Lines         601      891      +290     
===========================================
+ Hits          563      581       +18     
- Misses         21      293      +272     
  Partials       17       17               
Impacted Files Coverage Δ
pb/proof.pb.go 0.72% <0.72%> (ø)
proof.go 89.50% <100.00%> (+1.01%) ⬆️

rootulp
rootulp previously approved these changes Jul 14, 2023
pb/proof.proto Outdated
Comment on lines 5 to 11
message Proof {
int64 start = 1;
int64 end = 2;
repeated bytes nodes = 3;
bytes leafHash = 4;
bool isMaxNamespaceIDIgnored=5;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[optional] doc comments on what each field does would be super helpful. Content from the specs may help https://github.com/celestiaorg/nmt/blob/master/docs/spec/nmt.md#namespace-proof

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @rootulp, thanks for the great suggestion. Added comments here 223b55a

pb/proof.proto Outdated
int64 end = 2;
repeated bytes nodes = 3;
bytes leafHash = 4;
bool isMaxNamespaceIDIgnored=5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

[not blocking] Related: #206 . Once we make this a protobuf field, I wonder if renaming it would be breaking. I think renaming shouldn't block this PR but wanted to call it out. cc: @staheri14

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @rootulp for this suggestion. I also agree that in line with #206, it would be good to change this message field to isMaxNamespaceIgnored. I don't think it has to match the same field in the Proof struct, so it should be fine to use isMaxNamespaceIgnored instead.

rootulp
rootulp previously approved these changes Jul 14, 2023
pb/proof.proto Outdated Show resolved Hide resolved
pb/proof.proto Outdated Show resolved Hide resolved
Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have added some comments.

pb/proof.proto Outdated
int64 end = 2;
repeated bytes nodes = 3;
bytes leafHash = 4;
bool isMaxNamespaceIDIgnored=5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @rootulp for this suggestion. I also agree that in line with #206, it would be good to change this message field to isMaxNamespaceIgnored. I don't think it has to match the same field in the Proof struct, so it should be fine to use isMaxNamespaceIgnored instead.

@@ -453,6 +454,30 @@ func (proof Proof) VerifyInclusion(h hash.Hash, nid namespace.ID, leavesWithoutN
return res
}

// ProtoToProof creates a proof from its proto representation.
func ProtoToProof(protoProof pb.Proof) Proof {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need an encoding counterpart i.e., ProofToProto?

Copy link
Member Author

Choose a reason for hiding this comment

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

The counterpart will look like a creation of a pb struct. I think it could be done in place(but can make a counterpart).

proof.go Show resolved Hide resolved
Co-authored-by: Rootul P <rootulp@gmail.com>
rootulp
rootulp previously approved these changes Jul 17, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM after lint fixes

proof_test.go Outdated Show resolved Hide resolved
proof_test.go Outdated Show resolved Hide resolved
proof_test.go Outdated Show resolved Hide resolved
proof_test.go Outdated Show resolved Hide resolved
@rootulp
Copy link
Collaborator

rootulp commented Jul 17, 2023

@vgonkivs do you mind if we rename the PR title to feat(proof):... so that the squashed commit message conforms to conventional commits?

@rootulp rootulp changed the title proof: create a proto representation of the proof feat(proof): create a proto representation of the proof Jul 17, 2023
@rootulp rootulp removed the request for review from evan-forbes July 17, 2023 13:49
@rootulp rootulp added the enhancement New feature or request label Jul 17, 2023
@vgonkivs
Copy link
Member Author

Yes, please. You can name it whatever fits you.

Co-authored-by: Rootul P <rootulp@gmail.com>
@vgonkivs vgonkivs requested a review from rootulp July 17, 2023 14:38
rootulp
rootulp previously approved these changes Jul 17, 2023
staheri14
staheri14 previously approved these changes Jul 17, 2023
Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

LGTM! I suggested an optional change, but I highly recommended it.

proof_test.go Outdated Show resolved Hide resolved
@vgonkivs vgonkivs dismissed stale reviews from staheri14 and rootulp via 4141b50 July 18, 2023 09:50
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Still LGTM

@staheri14
Copy link
Contributor

staheri14 commented Jul 18, 2023

It looks good to me, thanks for updating the test style @vgonkivs! my only concern is the failing checks in Snyk for which I cannot see the details. @rootulp can you see the details?

@rootulp
Copy link
Collaborator

rootulp commented Jul 18, 2023

Snyk claims this PR introduces 14 new vulnerabilities b/c the go.mod changes. I don't think we should block the PR on it though

@staheri14
Copy link
Contributor

staheri14 commented Jul 18, 2023

Thanks @rootulp for looking into this, I have created the tracking issue, feel free to add a snapshot of the Snyk errors in the issue for the record.

Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

LGTM!

@rootulp rootulp merged commit 9d22de9 into celestiaorg:master Jul 19, 2023
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants