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: implement nft module msg server #10074

Merged
merged 23 commits into from
Oct 27, 2021

Conversation

dreamer-zq
Copy link
Collaborator

@dreamer-zq dreamer-zq commented Sep 3, 2021

Description

MsgServer implementation and corresponding keeper methods, 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)

@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Merging #10074 (8133e0c) into master (0a3660d) will increase coverage by 0.24%.
The diff coverage is 75.53%.

❗ Current head 8133e0c differs from pull request most recent head e38a1fe. Consider uploading reports for the commit e38a1fe to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10074      +/-   ##
==========================================
+ Coverage   64.19%   64.44%   +0.24%     
==========================================
  Files         575      579       +4     
  Lines       54923    54901      -22     
==========================================
+ Hits        35257    35380     +123     
+ Misses      17663    17509     -154     
- Partials     2003     2012       +9     
Impacted Files Coverage Δ
x/nft/keeper/msg_server.go 0.00% <0.00%> (ø)
x/nft/keeper/class.go 73.33% <73.33%> (ø)
x/nft/keeper/keeper.go 77.77% <77.77%> (ø)
x/nft/keeper/nft.go 80.16% <80.16%> (ø)
x/nft/keeper/genesis.go 85.00% <85.00%> (ø)
simapp/app.go 81.93% <100.00%> (+0.78%) ⬆️
x/nft/keeper/keys.go 100.00% <100.00%> (ø)
x/distribution/simulation/operations.go 80.54% <0.00%> (-9.73%) ⬇️
x/auth/tx/builder.go 76.05% <0.00%> (-2.55%) ⬇️
types/module/module.go 65.04% <0.00%> (-1.96%) ⬇️
... and 16 more

@chengwenxi chengwenxi mentioned this pull request Sep 3, 2021
13 tasks
x/nft/msgs.go Outdated Show resolved Hide resolved
@RiccardoM
Copy link
Contributor

Any updates on this @ryanchristo @clevinson ?

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 move the generated proto code to a separate module. I propose x/nft/proto. The reason is related to the semver discussion for Cosmos SDK, and versioning proto definition is one of the requirements. We will do that work for all other modules right after 0.45 release.
  • let's add integration tests on the proto service level (can be done in a separate PR - we will just need to create a task for it - leaving it to you).
  • we should avoid panics and Must* methods whenever possible.
  • also, I would consider dropping the beta name in the proto versions. This doesn't help with versioning in fact. Once it will be used it should not have beta (let's add it to the issue tracker).

type AccountKeeper interface {
GetModuleAddress(name string) sdk.AccAddress
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

would be good to depend on Query proto services rather than keepers directly, but I think we will firstly need to clean other parts of SDK before requesting that changes (and finalize adr-33).

x/nft/keeper/class.go Outdated Show resolved Hide resolved
x/nft/keeper/class.go Outdated Show resolved Hide resolved
x/nft/keeper/keys.go Outdated Show resolved Hide resolved
x/nft/keeper/keys.go Outdated Show resolved Hide resolved
Id: msg.Id,
Sender: msg.Sender,
Receiver: msg.Receiver,
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

x/nft/keeper/nft.go Outdated Show resolved Hide resolved
x/nft/nft.pb.go Show resolved Hide resolved
@charleenfei
Copy link
Contributor

  • let's move the generated proto code to a separate module. I propose x/nft/proto. The reason is related to the semver discussion for Cosmos SDK, and versioning proto definition is one of the requirements. We will do that work for all other modules right after 0.45 release.

just for clarity: this was decided in the SDK grooming meeting that this change is not necessary for the PR to be merged

@robert-zaremba
Copy link
Collaborator

just for clarity: this was decided in the SDK grooming meeting that this change is not necessary for the PR to be merged

Yes. Definitely not blocking. IMHO it's good to do it though, because we will already separate more stable proto (which external clients will be able to consume) from the functional implementation. And it's very easy to do that split at this stage when no other external app is depending on it.

x/nft/genesis.go Outdated Show resolved Hide resolved
x/nft/genesis.go Show resolved Hide resolved
x/nft/keeper/genesis.go Outdated Show resolved Hide resolved
x/nft/keeper/keys.go Show resolved Hide resolved
Copy link
Contributor

@clevinson clevinson left a comment

Choose a reason for hiding this comment

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

Some comments as I was going through this today. Didn't fully finish, but going OOO so wanted to post what I have so far.

Thanks for this work!

x/nft/genesis.go Show resolved Hide resolved
x/nft/keeper/keeper_test.go Show resolved Hide resolved
x/nft/keeper/keeper_test.go Outdated Show resolved Hide resolved
x/nft/keeper/keeper_test.go Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the C:CLI label Oct 8, 2021
@dreamer-zq
Copy link
Collaborator Author

dreamer-zq commented Oct 8, 2021

Looks good!

  • let's move the generated proto code to a separate module. I propose x/nft/proto. The reason is related to the semver discussion for Cosmos SDK, and versioning proto definition is one of the requirements. We will do that work for all other modules right after 0.45 release.
  • let's add integration tests on the proto service level (can be done in a separate PR - we will just need to create a task for it - leaving it to you).
  • we should avoid panics and Must* methods whenever possible.
  • also, I would consider dropping the beta name in the proto versions. This doesn't help with versioning in fact. Once it will be used it should not have beta (let's add it to the issue tracker).

When I tried to move the generated proto file to the x/nft/proto package, I encountered the following problems:

  1. MsgSend in the msgs.go file implements the sdk.Msg interface, and needs to be moved to the x/nft/proto package (if this is done, in order to avoid circular dependencies, you also need to move errors.go to the x/nft/proto package , It feels inappropriate to do so)
  2. The unexported method in the x/nft/proto package is used in codec.go: _Msg_serviceDesc.

Do you have any good solutions to the above problems?

@catShaark
Copy link
Contributor

Your mint method checks if the class of the minted nft exists, but there's no msg to create new class. So how can user mint new nft ?

@dreamer-zq
Copy link
Collaborator Author

dreamer-zq commented Oct 11, 2021

Your mint method checks if the class of the minted nft exists, but there's no msg to create new class. So how can user mint new nft ?

According to the design of adr-043-nft, this module is the low-level design of nft, which only exposes the methods and storage of nft general implementation. Users need to implement the upper-level logic according to their own business rules, such as the definition of msg (except for nft.MsgSend )

@catShaark
Copy link
Contributor

Your mint method checks if the class of the minted nft exists, but there's no msg to create new class. So how can user mint new nft ?

According to the design of adr-043-nft, this module is the low-level design of nft, which only exposes the methods and storage of nft general implementation. Users need to implement the upper-level logic according to their own business rules, such as the definition of msg (except for nft.MsgSend )

ohh, I get it now, thank u

@robert-zaremba
Copy link
Collaborator

@dreamer-zq , the previous question shows that we should better explain that in the ADR. Could you add a paragraph in the ADR highlighting what client module must provide (at minimum)?

@robert-zaremba
Copy link
Collaborator

We are in fact discussing solutions on the future migration of the core modules. We don't have a plan finalized yet. If you encounter some problems, then you can skip it and we will try to refactor it later.

1. `MsgSend` in the msgs.go file implements the `sdk.Msg` interface, and needs to be moved to the x/nft/proto package (if this is done, in order to avoid circular dependencies, you also need to move errors.go to the x/nft/proto package , It feels inappropriate to do so)

We have few ideas, but non of them is finalized (eg: wrappers, implementer function as an attribute)... you could include the implementation in the proto package... but again - if this will cause some doubts then let's skip it.

2. The unexported method in the x/nft/proto package is used in codec.go: `_Msg_serviceDesc`.

You can add a method in x/nft/proto which will return _Msg_serviceDesc (eg: GetMsgServiceDesc() ).

@aaronc
Copy link
Member

aaronc commented Oct 11, 2021

I advise that we pause refactoring generated proto code into separate go modules here. I think our team should lead doing this refactoring once we've figured out a strategy, and this should be done in a separate PR. We should also use the x/nft/types package for this, not x/nft/proto IMHO. But again, let's just focus on merging the basic msg server functionality here.

@github-actions github-actions bot added the T: ADR An issue or PR relating to an architectural decision record label Oct 13, 2021
@dreamer-zq
Copy link
Collaborator Author

@dreamer-zq , the previous question shows that we should better explain that in the ADR. Could you add a paragraph in the ADR highlighting what client module must provide (at minimum)?

I have added some instructions in adr-33

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.

Left few more comments.

Most importantly, we need to implement UnpackInterfaces for the NFT type.

x/nft/module/module.go Show resolved Hide resolved
x/nft/keeper/class.go Outdated Show resolved Hide resolved
x/nft/validation.go Outdated Show resolved Hide resolved
x/nft/validation.go Outdated Show resolved Hide resolved
x/nft/validation.go Outdated Show resolved Hide resolved
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.

All good! Thanks for the PR!

@aaronc aaronc added A:automerge Automatically merge PR once all prerequisites pass. C:x/nft labels Oct 20, 2021
@aaronc
Copy link
Member

aaronc commented Oct 20, 2021

Happy to merge this. Can someone take a look at the test failures?

@aaronc
Copy link
Member

aaronc commented Oct 27, 2021

What's up with CI? @robert-zaremba @AmauryM ? We really need to fix these issues. Is there anything in CI actually preventing this from being merged? Also is this go module actually getting tested in CI?

@amaury1093
Copy link
Contributor

There's a couple of flaky tests #9010. No-one has found their root cause yet.

The current way we're circumventing this is by re-running the tests, which I just did

@mergify mergify bot merged commit 1d1fcc9 into cosmos:master Oct 27, 2021
@chengwenxi chengwenxi deleted the implement-nft-msgServer branch October 29, 2021 03:24
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

MsgServer implementation and corresponding keeper methods, refer cosmos#9826

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

---

### 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) 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)
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:x/nft T: ADR An issue or PR relating to an architectural decision record
Projects
None yet
Development

Successfully merging this pull request may close these issues.