-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
style!: Refactor codebase to use proper Interface prefixes #13268
style!: Refactor codebase to use proper Interface prefixes #13268
Conversation
@alexanderbez The only thing I did to verify is running |
CHANGELOG.md
Outdated
@@ -37,6 +37,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ | |||
|
|||
## [Unreleased] | |||
|
|||
* (improvement) [#13254](https://github.com/cosmos/cosmos-sdk/pull/13268) Change `I` suffix to prefix in the relevant Golang interfaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move that under the API Breaking Changes
section (l.107)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Note that I was following the instructions in https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pull-requests
and figured someone (in the future) is responsible from moving it from Unreleased
to API Breaking
.
x/auth/README.md
Outdated
* [CLI](#cli) | ||
* [gRPC](#grpc) | ||
* [REST](#rest) | ||
- [`x/auth`](#xauth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's apply the correct .md
formatting here too. (When you use the markdown all in one vscode extension, it unfortunately generates a ToC that does not respect the markdownlint config. You need to ctrl+z and ctrl+k+ctrl+s for reverting the formatting)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, Visual Studio's "Markdown all in one" doesn't play well with "MarkdownLint". I ended up just checking out all of my .md
changes and updating it manually.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #13268 +/- ##
==========================================
- Coverage 55.87% 55.65% -0.23%
==========================================
Files 646 712 +66
Lines 54895 60840 +5945
==========================================
+ Hits 30675 33862 +3187
- Misses 21762 24162 +2400
- Partials 2458 2816 +358
|
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI | ||
NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI | ||
SetAccount(ctx sdk.Context, acc authtypes.AccountI) | ||
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.IAccount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge API breaking change IMO, for all chains. With time I got used to AccountI
. I also don't see a strong need to switch (just because some guy wrote about it in a medium article?)
I'm fine with eventually switching to something consistent, but maybe let's do it in 2 phases:
- Add type aliases, e.g.
AccountI
->IAccount
, so that everything is backwards-compatible. Add deprecation godoc on all old interfaces. - Rip off the old interfaces, but probably not in 0.47
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge API breaking change IMO, for all chains
Agreed.
I also don't see a strong need to switch
Yea, I was conflicted as well so I made sure to double-check if I should proceed before making any changes: #13254 (comment)
(just because some guy wrote about it in a medium article?)
It seems to be the "Go" standard. I can find more references and added them to the PR. Just lmk if I should invest the time
Add type aliases, e.g. AccountI -> IAccount, so that everything is backwards-compatible. Add deprecation godoc on all old interfaces.
Done. See #13279
Here's an example:
Rip off the old interfaces, but probably not in 0.47
Could you leave a comment in #13279 on next steps and timelines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate your efforts here @Olshansk and I know we're not really treating the SDK as 1.0 yet so some breaking changes are okay.
At the same time, I think we really need to measure the value of breaking changes like this. I generally think changing things just because some authority says the style should be different isn't a great reason to force downstream changes on clients...
So my preference would generally for us not to be spending time on these sort of changes (and then forcing our users to spend time on them), if there isn't some larger benefit.
AccountI
, etc. may seem clunky but it also seems like not a big deal...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood.
I confirmed the scope of work before starting in the original tickets, tended to the comments in the PR, documented the future work, tested the changes, and made it backwards compatible with the goal of better code health before the SDK reaches 1.0
If you still believe I should close out the PR and issue without a merge, please lmk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aliases address backwards compatibility. Also if its an issue for downstream users, we don't have to remove them for 1.0
@AmauryM @marbar3778 what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you mean you defined new proto types? Or just aliases? Idk...just seems like such a large diff and tech debt to maintain for a version just to change type names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the approach @AmauryM suggested in the first message in this thread.
Given the long async back and forth, is there a cosmos contributor hour where we can discuss it over a call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AmauryM Could you take a look at the latest changes and see if it aligns with your suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal take is that this PR sees a lot of resistance, and doesn't have a clear motivation from SDK users (i.e. no-one came to us about AccountI vs IAccount).
@Olshansk I really appreciate your work here, but my recommendation would be to simply to close the PR. I'm sorry about this, we should have better discussed this in the issue beforehand.
However, if you feel strongly about this going through, please join the SDK community call this Thursday 6-7pm CEST, and we can quickly discuss this with a wider audience before moving forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
closing this for now but let me know if you'd like to attend the community call to discuss further. |
I would! When is the next one? |
Idiomatic Go interfaces are named by their method set, and are never prefixed or suffixed by
|
@peterbourgon Really appreciate the link & reference (and somewhat embarrassed I didn't find that link myself). Let's close this out. |
Description
Closes: #13254
Per the discussion and examples in #13254, this aims to make the Cosmos SDK more compliant with Golang syntax best practices.
Changes
Specifically, naming interface with either an
I
prefix or anInterface
suffix rather than anI
suffix. The interfaces renamed are:s/ValidatorI/IValidator
s/HasAnimalI/IHasAnimal
s/MsgSubmitEvidenceI/IMsgSubmitEvidence
s/DelegationI/IDelegation
s/FeeAllowanceI/IFeeAllowance
s/ModuleAccountI/IModuleAccount
s/AccountKeeperI/IAccountKeeperI
s/AccountI/IAccount
How Changes were made
type (.*)[a-z]I Interface \{
Find: AccountI([^a-z^A-z]) Replace: IAccount$1
References
Author Checklist
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
!
in the type prefix if API or client breaking change