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

revert: replace all ModuleCdc instances with legacy.Cdc #11680

Merged
merged 7 commits into from
Apr 20, 2022

Conversation

RiccardoM
Copy link
Contributor

Description

Reverts the usage of a singleton legacy.Cdc codec while (de)serializing x/authz messages.

Closes: #11643


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)

@@ -0,0 +1,18 @@
package codec
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've created this new package in order to avoid any possible dependency cycle that might arise if we leave the ModuleCdc definition inside the x/authz/codec.go file. If you think we can keep it inside x/authz/codec.go then I can move it there without any issue

Copy link
Contributor

Choose a reason for hiding this comment

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

to avoid any possible dependency cycle that might arise if we leave the ModuleCdc definition inside the x/authz/codec.go

Which dep cycle do you see happening?

By default, I would say let's keep like all other modules, unless there's a strong reason to do a separate package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I've just tried moving it back to authz/codec.go and the following popped up:

package github.com/cosmos/cosmos-sdk/server
        imports github.com/cosmos/cosmos-sdk/server/rosetta
        imports github.com/cosmos/cosmos-sdk/x/auth/tx
        imports github.com/cosmos/cosmos-sdk/x/auth/middleware
        imports github.com/cosmos/cosmos-sdk/x/auth/types
        imports github.com/cosmos/cosmos-sdk/x/authz
        imports github.com/cosmos/cosmos-sdk/x/auth/types: import cycle not allowed
package github.com/cosmos/cosmos-sdk/server
        imports github.com/cosmos/cosmos-sdk/server/rosetta
        imports github.com/cosmos/cosmos-sdk/x/auth/tx
        imports github.com/cosmos/cosmos-sdk/x/auth/middleware
        imports github.com/cosmos/cosmos-sdk/x/auth/types
        imports github.com/cosmos/cosmos-sdk/x/authz
        imports github.com/cosmos/cosmos-sdk/x/auth/types: import cycle not allowed

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Can we add a comment somewhere saying that authz's codec is in a separate package to avoid dep cycle? Maybe a package godoc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AmauryM @alexanderbez documentation has been added

@RiccardoM
Copy link
Contributor Author

There is one test failing within the gov module due to the v1/v1beta1 versions that I don't know how to fix. Maybe @AmauryM you can help with it? If I recall correctly you were working on this module

x/distribution/types/codec.go Show resolved Hide resolved
x/gov/types/v1/codec.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Apr 19, 2022

Codecov Report

Merging #11680 (7e9dce8) into master (75d4e41) will increase coverage by 0.03%.
The diff coverage is 70.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11680      +/-   ##
==========================================
+ Coverage   65.84%   65.87%   +0.03%     
==========================================
  Files         667      667              
  Lines       70374    70446      +72     
==========================================
+ Hits        46336    46405      +69     
+ Misses      21347    21346       -1     
- Partials     2691     2695       +4     
Impacted Files Coverage Δ
x/auth/vesting/types/msgs.go 0.00% <0.00%> (ø)
x/authz/keeper/msg_server.go 0.00% <0.00%> (ø)
x/authz/simulation/operations.go 66.97% <0.00%> (ø)
x/distribution/types/msg.go 60.00% <0.00%> (ø)
x/evidence/types/msgs.go 36.36% <0.00%> (ø)
x/group/msgs.go 52.41% <0.00%> (ø)
x/staking/types/msg.go 53.50% <0.00%> (ø)
x/upgrade/types/msgs.go 55.55% <0.00%> (ø)
x/authz/authorization_grant.go 65.71% <50.00%> (ø)
x/gov/types/v1/msgs.go 63.69% <50.00%> (ø)
... and 24 more

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

LGTM, pending a small comment. Thanks @RiccardoM for this quick PR!

@amaury1093 amaury1093 requested a review from zmanian April 19, 2022 10:15
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Apr 20, 2022
@mergify mergify bot merged commit 610b2ee into master Apr 20, 2022
@mergify mergify bot deleted the riccardom/revert-global-cdc branch April 20, 2022 09:27
@alexanderbez
Copy link
Contributor

@AmauryM do we need to backport this at all. Is it in 0.46.x?

@amaury1093 amaury1093 added the backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release label Apr 22, 2022
@amaury1093
Copy link
Contributor

@Mergifyio backport release/v0.46.x

mergify bot pushed a commit that referenced this pull request Apr 22, 2022
## Description
Reverts the usage of a singleton `legacy.Cdc` codec while (de)serializing `x/authz` messages.

Closes: #11643

---

### 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)

(cherry picked from commit 610b2ee)

# Conflicts:
#	x/authz/msgs.go
#	x/group/msgs.go
@mergify
Copy link
Contributor

mergify bot commented Apr 22, 2022

backport release/v0.46.x

✅ Backports have been created

p0mvn pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request May 5, 2022
Reverts the usage of a singleton `legacy.Cdc` codec while (de)serializing `x/authz` messages.

Closes: cosmos#11643

---

*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

*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)
p0mvn pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request May 6, 2022
Reverts the usage of a singleton `legacy.Cdc` codec while (de)serializing `x/authz` messages.

Closes: cosmos#11643

---

*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

*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)
ValarDragon pushed a commit to osmosis-labs/cosmos-sdk that referenced this pull request May 19, 2022
* fix: remove time.now check from authz
cosmos#11129

* fix: implement Amino serialization for x/authz and x/feegrant (cosmos#11224)

* fix: Add RegisterLegacyAminoCodec for authz/feegrant

* add module name

* Fix GetSignByes, add tests

* removed module names from registered messages to match other modules

* added interfaces and concrete types registration

* unseal amino instances to allow external grant and authorization registration

* fixed messages tests

* allow to register external types into authz modulecdc

* use legacy.Cdc instead of ModuleCdc inside x/authz

* move the legacy.Cdc initialization outside init function

* added serialization docs

* Update docs/core/encoding.md

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>

* added the Ledger specification

* fixed tests

Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com>

* revert: replace all ModuleCdc instances with legacy.Cdc (cosmos#11680)
Reverts the usage of a singleton `legacy.Cdc` codec while (de)serializing `x/authz` messages.

Closes: cosmos#11643

---

*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

*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)

Co-authored-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Co-authored-by: Amaury M <1293565+amaurym@users.noreply.github.com>
RiccardoM added a commit to desmos-labs/cosmos-sdk that referenced this pull request Jun 20, 2022
RiccardoM added a commit to desmos-labs/cosmos-sdk that referenced this pull request Oct 25, 2022
RiccardoM added a commit to desmos-labs/cosmos-sdk that referenced this pull request Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revert using a global legacy.Cdc for all modules
3 participants