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

Change how profiles are stored #385

Merged
merged 15 commits into from
Apr 15, 2021
Merged

Change how profiles are stored #385

merged 15 commits into from
Apr 15, 2021

Conversation

RiccardoM
Copy link
Contributor

@RiccardoM RiccardoM commented Mar 15, 2021

Description

This PR changes how the profiles are implemented, making them implement the authtypes.AccountI interface and allowing them to be stored inside the x/auth keeper.

Closes #261

Notes

Currently, the only unit test failing should be TestCmdQueryProfile/existing_profile_is_returned_properly. This is due to the fact that right now the Cosmos SDK does not allow to specify custom accounts inside the in-memory network that is used when testing the CLI commands. I've opened cosmos/cosmos-sdk#8936 to fix this, so we will have to wait until that is merged and put inside a release to make this test work properly.

Also, currently the simulation tests fail because it appear that the RandomGenesisAccount method that is present inside the sim package does not initialize accounts with a public key. This leads to a bug that makes it impossible to sign message with any of those accounts. I've written this also inside the #v0.41-stargate Discord channel. I hope to get a PR accepted and merged the next week to fix this as well.

Update 16/03/2021
I've opened a PR for the second error as well: cosmos/cosmos-sdk#8957

Update 14/04/2021
I've forked the Cosmos SDK v0.42.4 code and added some commits that allow to fix the above problems. The code is available here and it includes the changes from the following PRs:

Checklist

  • Targeted PR against correct branch.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit tests.
  • Wrote integration tests (simulation & CLI).
  • Updated the documentation.
  • Added an entry to the CHANGELOG.md file.
  • Re-reviewed Files changed in the Github PR explorer.

Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
@codecov
Copy link

codecov bot commented Mar 15, 2021

Codecov Report

Merging #385 (8445bc1) into master (b589a95) will decrease coverage by 0.99%.
The diff coverage is 58.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #385      +/-   ##
==========================================
- Coverage   71.50%   70.50%   -1.00%     
==========================================
  Files          89       90       +1     
  Lines        3636     3696      +60     
==========================================
+ Hits         2600     2606       +6     
- Misses        972     1005      +33     
- Partials       64       85      +21     
Impacted Files Coverage Δ
x/profiles/legacy/v0.15.0/types.go 100.00% <ø> (ø)
x/profiles/types/models.go 96.42% <0.00%> (-3.58%) ⬇️
x/profiles/types/query.go 0.00% <0.00%> (ø)
x/profiles/types/codec.go 45.00% <33.33%> (-2.06%) ⬇️
x/profiles/types/account.go 45.16% <45.16%> (ø)
x/profiles/keeper/msgs_server.go 78.61% <50.00%> (-14.09%) ⬇️
x/profiles/keeper/querier.go 68.75% <50.00%> (-2.99%) ⬇️
x/profiles/keeper/grpc_query.go 80.64% <60.00%> (+80.64%) ⬆️
x/profiles/keeper/genesis.go 73.33% <66.66%> (+73.33%) ⬆️
x/profiles/keeper/keeper.go 94.28% <86.48%> (-4.02%) ⬇️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b589a95...8445bc1. Read the comment docs.

Changed how the profiles are implemented, by including an *Any inside the Profile object, and making it implement the AccountI interface

Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
…thod execute faster

Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
…profiles-changes

� Conflicts:
�	Makefile
�	go.mod
�	go.sum
�	x/profiles/keeper/types.pb.go
�	x/profiles/types/models.pb.go
Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
# Conflicts:
#	app/app.go
#	app/sim_test.go
#	proto/desmos/profiles/v1beta1/models.proto
#	x/profiles/keeper/msgs_server_test.go
#	x/profiles/types/models.pb.go
#	x/staging/fees/ante/ante_test.go
#	x/staging/fees/ante/common_test.go
#	x/staging/fees/simulation/genesis.go
#	x/staging/reports/types/models.go
…ests type

Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
@RiccardoM RiccardoM marked this pull request as ready for review April 14, 2021 07:17
expProfile *types.Profile
}{
{
name: "DoNotModify and empty fields do not update original values",
Copy link
Contributor

Choose a reason for hiding this comment

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

why empty fields don't update the original values here? A test below say a different thing. Can we remove it?

Suggested change
name: "DoNotModify and empty fields do not update original values",
name: "DoNotModify do not update original values",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I've cleared up the test name and also the test making sure that empty values effectively update the original ones

@leobragaz
Copy link
Contributor

Also, it looks like there's an error inside profiles CLI tests

Signed-off-by: riccardo.montagnin <riccardo.montagnin@gmail.com>
Copy link
Contributor

@leobragaz leobragaz left a comment

Choose a reason for hiding this comment

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

Ready to ship! 🚀

@RiccardoM RiccardoM merged commit d7319ab into master Apr 15, 2021
@RiccardoM RiccardoM deleted the riccardo/profiles-changes branch April 15, 2021 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change how profile data are stored
2 participants