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

chore: added new field account-id with uint64 in AccountAddressByID #13780

Merged
merged 32 commits into from
Nov 21, 2022

Conversation

atheeshp
Copy link
Contributor

@atheeshp atheeshp commented Nov 7, 2022

Description

Closes: #13410


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)

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@atheeshp atheeshp changed the title added new field account-id with uint64 in AccountAddressByID chore: added new field account-id with uint64 in AccountAddressByID Nov 7, 2022
x/auth/keeper/grpc_query.go Fixed Show fixed Hide fixed
x/auth/keeper/grpc_query.go Fixed Show fixed Hide fixed
proto/cosmos/auth/v1beta1/query.proto Outdated Show resolved Hide resolved
@@ -197,10 +197,17 @@ message AddressStringToBytesResponse {
//
// Since: cosmos-sdk 0.46.2
message QueryAccountAddressByIDRequest {
// Deprecated, use account_id instead
//
// id is the account number of the address to be queried. This field
// should have been an uint64 (like all account numbers), and will be
// updated to uint64 in a future version of the auth query.
int64 id = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

we can add the proto deprecated annotation here

x/auth/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 10, 2022

Codecov Report

Merging #13780 (3a39765) into main (d8391cb) will increase coverage by 0.00%.
The diff coverage is 55.55%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #13780   +/-   ##
=======================================
  Coverage   56.24%   56.24%           
=======================================
  Files         664      664           
  Lines       56480    56484    +4     
=======================================
+ Hits        31766    31769    +3     
- Misses      22143    22144    +1     
  Partials     2571     2571           
Impacted Files Coverage Δ
x/auth/client/cli/query.go 19.55% <0.00%> (-0.13%) ⬇️
x/auth/keeper/grpc_query.go 57.14% <100.00%> (-1.30%) ⬇️
x/auth/keeper/account.go 71.66% <0.00%> (-5.00%) ⬇️
x/staking/simulation/operations.go 75.91% <0.00%> (+1.37%) ⬆️
crypto/keys/internal/ecdsa/privkey.go 83.01% <0.00%> (+1.88%) ⬆️

x/auth/keeper/grpc_query.go Fixed Show fixed Hide fixed
x/auth/keeper/grpc_query.go Fixed Show fixed Hide fixed
x/auth/keeper/grpc_query.go Fixed Show fixed Hide fixed
x/auth/keeper/grpc_query.go Fixed Show fixed Hide fixed
@atheeshp atheeshp marked this pull request as ready for review November 10, 2022 12:56
@atheeshp atheeshp requested a review from a team as a code owner November 10, 2022 12:56
x/auth/client/cli/query.go Outdated Show resolved Hide resolved

var accId uint64
switch {
case req.AccountId > 0 && req.Id > 0 && req.AccountId != uint64(req.Id):
Copy link
Contributor

Choose a reason for hiding this comment

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

TBH I'm not sure how much value this case adds. IMO we should instead enforce one or the other value is passed. If both are passed, i.e. both are non-zero, then simply error.

Copy link
Contributor Author

@atheeshp atheeshp Nov 12, 2022

Choose a reason for hiding this comment

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

IMO we should instead enforce one or the other value is passed

Unforunately we can't do this since 0 is also a valid case here to query by account-number. and the default values for both int64 & uint64 are 0s

Copy link
Contributor

Choose a reason for hiding this comment

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

We start account numbers at 1?

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'm not sure, but I'm getting the response for 0 too by using the same query.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I see that they start with 0. It' really unfortunate we have to have this sort of case. I would almost prefer to completely omit/ignore the legacy field all together.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also agree with ignoring the legacy field. Maybe we can throw an error if it's not zero? So that users have immediate feedback they need to change something on their side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we are keeping it as deprecated means, may be it should not throw error unitl the field gets removed right? (not sure just a thought)

Copy link
Contributor

Choose a reason for hiding this comment

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

The question really is:

Are we backporting this to < 0.47.x? If not, then just ignore the legacy field and remove this case all together. If we are backporting to 0.46.x and 0.45.x, then we need to handle the use of the legacy field and I suppose this is fine.

Copy link
Contributor

@amaury1093 amaury1093 Nov 16, 2022

Choose a reason for hiding this comment

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

I vote no backport.

Edit: but again, I also don't like to ignore that old field. Imagina a dapp pinging that endpoint, and suddently (after node upgrade) it returns a different response. I propose to error if the legacy field is populated.

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem is a zero/default value 0 is technically valid (the very first account). So there is no notion of "set" vs "unset" unfortunately. Thats why I suggested ignoring it.

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, just a small proposal to have shorter code

x/auth/keeper/grpc_query.go Outdated Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

few nits

x/auth/keeper/grpc_query.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
proto/cosmos/auth/v1beta1/query.proto Outdated Show resolved Hide resolved
atheeshp and others added 8 commits November 17, 2022 18:14
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
x/auth/keeper/grpc_query.go Outdated Show resolved Hide resolved
@atheeshp atheeshp enabled auto-merge (squash) November 21, 2022 11:30
@sonarcloud
Copy link

sonarcloud bot commented Nov 21, 2022

[Cosmos SDK] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

50.0% 50.0% Coverage
0.0% 0.0% Duplication

@atheeshp atheeshp merged commit 42597ee into main Nov 21, 2022
@atheeshp atheeshp deleted the ap/change-acc-id-type branch November 21, 2022 11:50
@julienrbrt
Copy link
Member

@Mergifyio backport release/v0.47.x

@mergify
Copy link
Contributor

mergify bot commented Nov 30, 2022

backport release/v0.47.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 30, 2022
…D` (#13780)

* add changes

* Update CHANGELOG.md

* Update CHANGELOG.md

* review changes

* add test

* fix static check

* fix lint

* fix lint

* fix lint

* review changes

* review changes

* review changes

* review changes

* fix tests

* Update CHANGELOG.md

Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>

* Update proto/cosmos/auth/v1beta1/query.proto

Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>

* review changes

* lint

* review changes

Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
(cherry picked from commit 42597ee)
tac0turtle pushed a commit that referenced this pull request Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Account-id type used as int64 instead of uint64
5 participants