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: generate nft protobuf #9747

Merged
merged 21 commits into from
Aug 31, 2021
Merged

Conversation

dreamer-zq
Copy link
Collaborator

@dreamer-zq dreamer-zq commented Jul 22, 2021

Description

Generate nft protobuf, refer #9826.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@dreamer-zq dreamer-zq changed the title Generate nft protobuf feat: generate nft protobuf Jul 22, 2021
Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

Was this intended to be against master?

Let's remove gogoproto annotations because we're migrating to golang v2 protobuf and these don't seem necessary.

proto/cosmos/nft/v1beta1/event.proto Show resolved Hide resolved
proto/cosmos/nft/v1beta1/genesis.proto Outdated Show resolved Hide resolved
@chengwenxi
Copy link
Contributor

chengwenxi commented Jul 23, 2021

Was this intended to be against master?

Yes, we hope that this module is completed when it is merged into master, so that it will not affect the release of new versions based on the master branch.

If this consideration is redundant, we can directly PR to the master.

@robert-zaremba robert-zaremba self-assigned this Jul 28, 2021
@robert-zaremba robert-zaremba added this to the v0.44 milestone Jul 28, 2021
@robert-zaremba robert-zaremba added the C: Proto Proto definition and proto release label Jul 28, 2021
@aaronc
Copy link
Member

aaronc commented Jul 30, 2021

Was this intended to be against master?

Yes, we hope that this module is completed when it is merged into master, so that it will not affect the release of new versions based on the master branch.

If this consideration is redundant, we can directly PR to the master.

Let's please target PRs against master. Thanks 🙏

@chengwenxi chengwenxi changed the base branch from vincent/nft to master July 31, 2021 11:20
@chengwenxi chengwenxi mentioned this pull request Jul 31, 2021
13 tasks
@charleenfei
Copy link
Contributor

Was this intended to be against master?

Yes, we hope that this module is completed when it is merged into master, so that it will not affect the release of new versions based on the master branch.
If this consideration is redundant, we can directly PR to the master.

Let's please target PRs against master. Thanks 🙏

bumping this nft adr review! @okwme @aaronc

Copy link
Collaborator

@robert-zaremba robert-zaremba 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. Pre-approving, but left few comments

string name = 2;
string symbol = 3;
string description = 4;
string uri = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

shall we add: uri_hash - this will be a hash of the document pointed by URI - similar to what we have in bank.proto metadata,

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a comment to the uri_hash

message NFT {
string class_id = 1;
string id = 2;
string uri = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's add uri_hash as well.

string class_id = 1;
string id = 2;
string uri = 3;
google.protobuf.Any data = 10;
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add comment to the data field. Both data and any has almost no meaning.

option (google.api.http).get = "/cosmos/nft/v1beta1/owner/{class_id}/{id}";
}

// Supply queries the number of nft based on the class, same as totalSupply of ERC721
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Supply queries the number of nft based on the class, same as totalSupply of ERC721
// Supply queries the number of NFTs from the given class, same as totalSupply of ERC721.


import "cosmos/nft/v1beta1/nft.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/nft";
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about putting genesis into a subpackage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean that genesis output to github.com/cosmos/cosmos-sdk/x/nft/genesis?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes. What do you think about this idea?

Copy link
Collaborator

@robert-zaremba robert-zaremba Aug 11, 2021

Choose a reason for hiding this comment

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

When thinking more about it - I would propose to split it in the following way:

  • x/nft -- for all things related to RPC
  • x/nft/dal -- for all things related to storage (data access layer)
    This way we have a clear domains.

PS: we think to do the same for eco-credit module

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW: Aaron pointed in a chat, that this will require splitting the proto packages as well:

  • proto/cosmos/nft/v1beta1
  • proto/cosmos/nft/dal/v1beta1

Copy link
Collaborator

@robert-zaremba robert-zaremba Aug 12, 2021

Choose a reason for hiding this comment

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

The main point for breaking down the proto into 2 (or more) packages is to have more freedom to upgrading it in the future:

  • the protobuf service API and related types should be rather stable and we want to avoid any breaking change. We will version it.
  • the storage types can be in an internal package and don't need to be versioned. If "tomorrow" we will find a better storage layout we can update the module without bumping the API version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, got it

Copy link
Member

Choose a reason for hiding this comment

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

Let's please not use the term dal. I would use state instead. I also don't want to delay this PR unnecessarily, and would prefer to do this design in a more general way for the SDK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If so, how can this PR be modified?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Recently, @aaronc pointed that the store proto version is important for merkle proofs. So, we will probably need to discuss more about it.
TL;DR - let's merge this in one package.

Copy link
Collaborator

@robert-zaremba robert-zaremba 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. Let's add a comment to the uri_hash attribute.

string name = 2;
string symbol = 3;
string description = 4;
string uri = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a comment to the uri_hash

@chengwenxi chengwenxi requested a review from aaronc August 20, 2021 09:14
@robert-zaremba
Copy link
Collaborator

Is there anything left for finalizing this PR? We will need a second review. Not sure if @aaronc will have a time (he is starting holidays next week). So maybe @okwme or @alexanderbez ?

Copy link
Member

@aaronc aaronc 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 would really like there to be more documentation comments.

(side note: I am a bit uncomfortable that we disabled COMMENT_FIELD in buf.yaml. can we maybe change this @AmauryM @ryanchristo ?)

@amaury1093
Copy link
Contributor

(side note: I am a bit uncomfortable that we disabled COMMENT_FIELD in buf.yaml. can we maybe change this @AmauryM @ryanchristo ?)

Yeah, I agree. #9978

@codecov
Copy link

codecov bot commented Aug 24, 2021

Codecov Report

Merging #9747 (3747e37) into master (54b0556) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9747   +/-   ##
=======================================
  Coverage   63.56%   63.56%           
=======================================
  Files         572      572           
  Lines       53584    53584           
=======================================
+ Hits        34058    34059    +1     
+ Misses      17583    17582    -1     
  Partials     1943     1943           
Impacted Files Coverage Δ
crypto/keys/internal/ecdsa/privkey.go 84.21% <0.00%> (+1.75%) ⬆️

Copy link
Contributor

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Are we waiting for comments on the message fields before merging?

There are very few descriptions for message fields generated in the proto documentation. I think it would be preferred to address adding the comments within this pull request rather than having to play catch up in #9978 or a followup pull request.

The group module provides a good example of how thorough comments should be:
https://github.com/cosmos/cosmos-sdk/blob/master/proto/cosmos/group/v1beta1/tx.proto

Comment on lines +6927 to +6931
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `class_id` | [string](#string) | | |
| `id` | [string](#string) | | |
| `owner` | [string](#string) | | |
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's an example of the generated protobuf documentation without comments.

@robert-zaremba
Copy link
Collaborator

I believe this is ready for merge - please check if all doc comments are there.

@tac0turtle tac0turtle added the A:automerge Automatically merge PR once all prerequisites pass. label Aug 31, 2021
@mergify mergify bot merged commit 6bddcd5 into cosmos:master Aug 31, 2021
@orijbot
Copy link

orijbot commented Aug 31, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C: Proto Proto definition and proto release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants