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

Add Group module #154

Merged
merged 136 commits into from
Jan 29, 2021
Merged

Add Group module #154

merged 136 commits into from
Jan 29, 2021

Conversation

blushi
Copy link
Member

@blushi blushi commented Nov 5, 2020

Closes #136
Closes #145
Closes #198
Closes regen-network/cosmos-modules#69
Closes regen-network/cosmos-modules#72

Proposed Changes

Follow-ups

Feel free to submit a Draft Pull Request as soon as you start working on something. Before you mark your PR as Ready For Review, make sure you've checked off the following boxes or indicated N/A (not applicable):

  • linked to a relevant issue or have written a clear description of the issue in the PR
  • wrote or updated tests
  • wrote or updated documentation
  • added an appropriate entry in CHANGELOG.md following https://keepachangelog.com

Thanks!

@blushi blushi requested a review from aaronc November 10, 2020 10:49
Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

Looks like a lot of stuff in testdata, maybe unnecessarily?

testutil/testdata/group/codec.go Outdated Show resolved Hide resolved
x/group/conditions.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 12, 2020

Codecov Report

Merging #154 (933d055) into master (4afc5cd) will decrease coverage by 50.32%.
The diff coverage is 30.51%.

@@             Coverage Diff             @@
##           master     #154       +/-   ##
===========================================
- Coverage   65.68%   15.35%   -50.33%     
===========================================
  Files          30       48       +18     
  Lines        1457    11388     +9931     
===========================================
+ Hits          957     1749      +792     
- Misses        406     9429     +9023     
- Partials       94      210      +116     

@blushi
Copy link
Member Author

blushi commented Jan 27, 2021

@aaronc @robert-zaremba @anilcse could you have another look? Thanks.

Copy link
Contributor

@anilcse anilcse left a comment

Choose a reason for hiding this comment

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

lgtm

proto/regen/group/v1alpha1/tx.proto Outdated Show resolved Hide resolved
proto/regen/group/v1alpha1/types.proto Outdated Show resolved Hide resolved
x/group/server/msg_server.go Outdated Show resolved Hide resolved
x/group/server/msg_server.go Outdated Show resolved Hide resolved
x/group/server/msg_server.go Outdated Show resolved Hide resolved
x/group/server/msg_server.go Outdated Show resolved Hide resolved
Comment on lines +91 to +97
groupMember := group.GroupMember{GroupId: req.GroupId,
Member: &group.Member{
Address: req.MemberUpdates[i].Address,
Weight: req.MemberUpdates[i].Weight,
Metadata: req.MemberUpdates[i].Metadata,
},
}
Copy link
Member

Choose a reason for hiding this comment

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

let's move this to handle add + update

Copy link
Member Author

Choose a reason for hiding this comment

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

we need it before in "handle delete" or did you mean something else?

Copy link
Member

Choose a reason for hiding this comment

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

just it seems like it's initialized too early in the code

x/group/server/msg_server.go Outdated Show resolved Hide resolved
x/group/server/msg_server.go Show resolved Hide resolved
@blushi blushi requested a review from aaronc January 29, 2021 09:45
if newMemberWeight.Cmp(apd.New(0, 0)) == 0 {
// Handle delete for members with zero weight.
if newMemberWeight.IsZero() {
// We can't delete a group member that doesn't already exist.
if !found {
return sdkerrors.Wrap(orm.ErrNotFound, "unknown member")
Copy link
Member

Choose a reason for hiding this comment

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

There's no harm in ignoring this case right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah I guess groupMemberTable.Delete below would just fail in this case, but that would be an unnecessary access to the store given that we already know that it should fail, wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

We just wouldn't even execute this block... but maybe let's keep it as is because we would need to adjust tests and I don't want to further churn on this PR.

Co-authored-by: Aaron Craelius <aaron@regen.network>
Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

ACK 🎉

I left a few minor doc suggestions that I'll just go ahead and commit.

There's also a few comments that can be dealt with in follow-ups if needed.

But otherwise, ready to merge this!

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. I would remove methods we don't need to not "pollute" the blockchain

rpc GroupMembers(QueryGroupMembersRequest) returns (QueryGroupMembersResponse);

// GroupsByAdmin queries groups by admin address.
rpc GroupsByAdmin(QueryGroupsByAdminRequest) returns (QueryGroupsByAdminResponse);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seams we are trying to implement relational DB - this queries should be handled by an off-chain indexer, or only added later when needed for state machine operations.

Copy link
Member

@aaronc aaronc Jan 29, 2021

Choose a reason for hiding this comment

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

That's a bigger design issue. This decision was made a long time ago

rpc GroupsByAdmin(QueryGroupsByAdminRequest) returns (QueryGroupsByAdminResponse);

// GroupAccountsByGroup queries group accounts by group id.
rpc GroupAccountsByGroup(QueryGroupAccountsByGroupRequest) returns (QueryGroupAccountsByGroupResponse);
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMHO, would be better to remove Group prefix to avoid name clashes:

groupClient.GroupAccountsByGroup

Copy link
Member

Choose a reason for hiding this comment

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

we can deal with that later... can you open an issue or PR if you think there's something that can be improved

Copy link
Collaborator

Choose a reason for hiding this comment

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

@blushi - do you have an opinion about naming? If you also find that we could improve naming then I'm happy to create a PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

@robert-zaremba you mean having AccountsByGroup instead for instance? I don't have a strong preference, although I think keeping the Group prefix makes it more explicit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think keeping the Group prefix makes it more explicit.

This context is already provided by a client / server object, right?

groupClient.AccountsByGroup
vs
groupClient.GroupAccountsByGroup   // we mention group 3 times, and it also sounds that we are grouping by (like in SQL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants