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

fix: Fix group simulations #11347

Merged
merged 5 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x/group/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func GroupTotalWeightInvariantHelper(ctx sdk.Context, key storetypes.StoreKey, g
msg += fmt.Sprintf("error while returning group member iterator for group with ID %d\n%v\n", groupInfo.Id, err)
return msg, broken
}
defer memIt.Close()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this didn't seem to be related to broken sims but fixed it anyway


for {
_, err = memIt.LoadNext(&groupMember)
Expand All @@ -184,7 +185,6 @@ func GroupTotalWeightInvariantHelper(ctx sdk.Context, key storetypes.StoreKey, g
return msg, broken
}
}
memIt.Close()

groupWeight, err := groupmath.NewNonNegativeDecFromString(groupInfo.GetTotalWeight())
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions x/group/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (
WeightMsgSubmitProposal = 90
WeightMsgVote = 90
WeightMsgExec = 90
WeightMsgLeaveGroup = 20
WeightMsgLeaveGroup = 5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just considering MsgLeaveGroup as any other group updates

WeightMsgUpdateGroupMetadata = 5
WeightMsgUpdateGroupAdmin = 5
WeightMsgUpdateGroupMembers = 5
Expand Down Expand Up @@ -188,10 +188,6 @@ func WeightedOperations(
weightMsgCreateGroupPolicy,
SimulateMsgCreateGroupPolicy(ak, bk, k),
),
simulation.NewWeightedOperation(
weightMsgLeaveGroup,
SimulateMsgLeaveGroup(k, ak, bk),
),
simulation.NewWeightedOperation(
weightMsgCreateGroupWithPolicy,
SimulateMsgCreateGroupWithPolicy(ak, bk),
Expand Down Expand Up @@ -235,6 +231,10 @@ func WeightedOperations(
weightMsgUpdateGroupPolicyMetadata,
SimulateMsgUpdateGroupPolicyMetadata(ak, bk, k),
),
simulation.NewWeightedOperation(
weightMsgLeaveGroup,
SimulateMsgLeaveGroup(k, ak, bk),
),
}

return append(wPreCreateProposalOps, append(createProposalOps, wPostCreateProposalOps...)...)
Expand Down
2 changes: 1 addition & 1 deletion x/group/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (suite *SimTestSuite) TestWeightedOperations() {
}{
{simulation.WeightMsgCreateGroup, group.MsgCreateGroup{}.Route(), simulation.TypeMsgCreateGroup},
{simulation.WeightMsgCreateGroupPolicy, group.MsgCreateGroupPolicy{}.Route(), simulation.TypeMsgCreateGroupPolicy},
{simulation.WeightMsgLeaveGroup, group.MsgLeaveGroup{}.Route(), simulation.TypeMsgLeaveGroup},
{simulation.WeightMsgCreateGroupWithPolicy, group.MsgCreateGroupWithPolicy{}.Route(), simulation.TypeMsgCreateGroupWithPolicy},
{simulation.WeightMsgSubmitProposal, group.MsgSubmitProposal{}.Route(), simulation.TypeMsgSubmitProposal},
{simulation.WeightMsgSubmitProposal, group.MsgSubmitProposal{}.Route(), simulation.TypeMsgSubmitProposal},
Expand All @@ -66,6 +65,7 @@ func (suite *SimTestSuite) TestWeightedOperations() {
{simulation.WeightMsgUpdateGroupPolicyAdmin, group.MsgUpdateGroupPolicyAdmin{}.Route(), simulation.TypeMsgUpdateGroupPolicyAdmin},
{simulation.WeightMsgUpdateGroupPolicyDecisionPolicy, group.MsgUpdateGroupPolicyDecisionPolicy{}.Route(), simulation.TypeMsgUpdateGroupPolicyDecisionPolicy},
{simulation.WeightMsgUpdateGroupPolicyMetadata, group.MsgUpdateGroupPolicyMetadata{}.Route(), simulation.TypeMsgUpdateGroupPolicyMetadata},
{simulation.WeightMsgLeaveGroup, group.MsgLeaveGroup{}.Route(), simulation.TypeMsgLeaveGroup},
}

for i, w := range weightedOps {
Expand Down