Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f88c60
docs: add ApplicationQueryService release notes (#13587)
robert-zaremba Oct 21, 2022
f538e09
feat(cli): add module-account cli cmd and grpc get api (backport #136…
mergify[bot] Oct 24, 2022
afdf06a
fix(x/auth): allow multiple = signs in `GetTxsEvent` (backport #12474…
mergify[bot] Oct 24, 2022
ec09eae
fix: app-hash mismatch if upgrade migration commit is interrupted (ba…
mergify[bot] Oct 25, 2022
a653798
feat(cli): Add iavl-disable-fastnode cmd flag with proper description…
mergify[bot] Oct 26, 2022
4eed46e
build(deps): Bump github.com/cosmos/iavl from 0.19.3 to 0.19.4 (#13680)
julienrbrt Oct 28, 2022
9d7028d
feat: emit cached context events (backport #13063) (#13702)
mergify[bot] Oct 31, 2022
eb1e3eb
chore: prepare 0.46.4 changelog (#13716)
julienrbrt Nov 1, 2022
68ee142
ci: notify for 0.46.x releases (#13719)
julienrbrt Nov 1, 2022
c7a9435
docs: fix algolia on 0.46 (#13730)
julienrbrt Nov 2, 2022
ba49bff
ci: modifying docs in 0.46 should not redeploy docs (#13732)
julienrbrt Nov 2, 2022
e4ae994
fix: propagate msg events correctly in x/gov (backport #13728) (#13748)
mergify[bot] Nov 3, 2022
2899dcf
refactor: add error log when iavl set failed (backport #13803) (#13804)
mergify[bot] Nov 9, 2022
0d1ed1a
chore: bump tendermint to `0.34.23` (#13814)
julienrbrt Nov 9, 2022
2bd2cf1
fix: propagate events in x/group through sdk.Results (backport #13808…
mergify[bot] Nov 9, 2022
3a809e2
docs: update algolia index (#13823)
julienrbrt Nov 10, 2022
62443b8
fix: bank store migration (backport #13821) (#13829)
mergify[bot] Nov 10, 2022
68e54fa
feat(types): set custom GasConfig on Context for GasKVStore (backport…
mergify[bot] Nov 11, 2022
2114ec4
chore: prepare 0.46.5 release (#13816)
julienrbrt Nov 14, 2022
2d515e0
fix: Allow underscores in EventRegex (backport #13861) (#13864)
mergify[bot] Nov 15, 2022
0b81939
fix(group): add group members weight checks (backport #13869) (#13880)
mergify[bot] Nov 16, 2022
6b633ef
fix(group)!: Fix group min execution period (backport #13876) (#13885)
mergify[bot] Nov 16, 2022
29cf4bc
feat(bank): Add helper for v0.46 denom migration (#13891)
amaury1093 Nov 16, 2022
e5fef13
chore: impove 0.46.5 release notes (#13898)
julienrbrt Nov 17, 2022
c80177e
refactor: State Streaming Docs + Explicit Config Support (backport #1…
mergify[bot] Nov 17, 2022
b88f086
chore: remove typo (#13914) (#13917)
mergify[bot] Nov 18, 2022
2f55513
fix: correctly propagate msg errors in gov (backport #13918) (#13928)
mergify[bot] Nov 18, 2022
8cce748
feat(bank): enable 0.46.5 bank migration fix through migrator keeper …
robert-zaremba Nov 18, 2022
1d9c475
Merge tag 'v0.46.6' into prov/dwedul/46.6-bump
SpicyLemon Nov 21, 2022
1b0bfe6
Update changelog for version bump.
SpicyLemon Nov 21, 2022
f85c0b8
Bring in Cosmos-SDK PR 13651 that overhauls/cleans up the GetConfig f…
SpicyLemon Nov 21, 2022
42bc817
Fix the pruning command to use the existing viper instance (that has …
SpicyLemon Nov 21, 2022
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
Prev Previous commit
Next Next commit
fix(group): add group members weight checks (backport cosmos#13869) (c…
…osmos#13880)

* fix(group): add group members weight checks (cosmos#13869)

(cherry picked from commit 3423442)

# Conflicts:
#	CHANGELOG.md
#	api/cosmos/tx/v1beta1/service.pulsar.go
#	types/tx/service.pb.go
#	x/group/keeper/keeper.go

* fix conflicts

* updates

* updates

Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
mergify[bot] and julienrbrt authored Nov 16, 2022
commit 0b8193916ac6fc549c317d6e928fbe6782387ac2
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (x/group) [#13869](https://github.com/cosmos/cosmos-sdk/pull/13869) Group members weight must be positive and a finite number.
* (x/bank) [#13821](https://github.com/cosmos/cosmos-sdk/pull/13821) Fix bank store migration of coin metadata.
* (x/group) [#13808](https://github.com/cosmos/cosmos-sdk/pull/13808) Fix propagation of message events to the current context in `EndBlocker`.
* (x/gov) [#13728](https://github.com/cosmos/cosmos-sdk/pull/13728) Fix propagation of message events to the current context in `EndBlocker`.
Expand Down
13 changes: 12 additions & 1 deletion x/group/internal/math/dec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package math provides helper functions for doing mathematical calculations and parsing for the ecocredit module.
// Package math provides helper functions for doing mathematical calculations and parsing for the group module.
package math

import (
Expand Down Expand Up @@ -46,11 +46,22 @@ func (x Dec) IsPositive() bool {
return !x.dec.Negative && !x.dec.IsZero()
}

func (x Dec) IsFinite() bool {
return x.dec.Form != apd.Finite
}

// NewDecFromString returns a new Dec from a string
// It only support finite numbers, not NaN, +Inf, -Inf
func NewDecFromString(s string) (Dec, error) {
d, _, err := apd.NewFromString(s)
if err != nil {
return Dec{}, errors.ErrInvalidDecString.Wrap(err.Error())
}

if d.Form != apd.Finite {
return Dec{}, errors.ErrInvalidDecString.Wrapf("expected a finite decimal, got %s", s)
}

return Dec{*d}, nil
}

Expand Down
8 changes: 8 additions & 0 deletions x/group/internal/math/dec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func TestDec(t *testing.T) {
require.NoError(t, err)
minusFivePointZero, err := NewDecFromString("-5.0")
require.NoError(t, err)
_, err = NewDecFromString("inf")
require.Error(t, err)
_, err = NewDecFromString("Infinite")
require.Error(t, err)
_, err = NewDecFromString("foo")
require.Error(t, err)
_, err = NewDecFromString("NaN")
require.Error(t, err)

res, err := two.Add(zero)
require.NoError(t, err)
Expand Down
5 changes: 3 additions & 2 deletions x/group/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ func (k Keeper) TallyProposalsAtVPEnd(ctx sdk.Context) error {
if err != nil {
return nil
}

//nolint:gosec // implicit memory aliasing in for loop
for _, proposal := range proposals {
policyInfo, err := k.getGroupPolicyInfo(ctx, proposal.GroupPolicyAddress)
if err != nil {
Expand All @@ -400,8 +402,7 @@ func (k Keeper) TallyProposalsAtVPEnd(ctx sdk.Context) error {
return err
}
} else {
err = k.doTallyAndUpdate(ctx, &proposal, electorate, policyInfo) //nolint:gosec // implicit memory aliasing in for loop
if err != nil {
if err := k.doTallyAndUpdate(ctx, &proposal, electorate, policyInfo); err != nil {
return sdkerrors.Wrap(err, "doTallyAndUpdate")
}

Expand Down
20 changes: 20 additions & 0 deletions x/group/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ func (s *TestSuite) TestCreateGroup() {
},
expErr: true,
},
"invalid member weight - Inf": {
req: &group.MsgCreateGroup{
Admin: addr1.String(),
Members: []group.MemberRequest{{
Address: addr3.String(),
Weight: "inf",
}},
},
expErr: true,
},
"invalid member weight - NaN": {
req: &group.MsgCreateGroup{
Admin: addr1.String(),
Members: []group.MemberRequest{{
Address: addr3.String(),
Weight: "NaN",
}},
},
expErr: true,
},
}

var seq uint32 = 1
Expand Down
12 changes: 5 additions & 7 deletions x/group/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,15 +687,13 @@ func (k Keeper) doTallyAndUpdate(ctx sdk.Context, p *group.Proposal, electorate

sinceSubmission := ctx.BlockTime().Sub(p.SubmitTime) // duration passed since proposal submission.
result, err := policy.Allow(tallyResult, electorate.TotalWeight, sinceSubmission)
// If the result was final (i.e. enough votes to pass) or if the voting
// period ended, then we consider the proposal as final.
isFinal := result.Final || ctx.BlockTime().After(p.VotingPeriodEnd)

switch {
case err != nil:
if err != nil {
return sdkerrors.Wrap(err, "policy allow")
}

case isFinal:
// If the result was final (i.e. enough votes to pass) or if the voting
// period ended, then we consider the proposal as final.
if isFinal := result.Final || ctx.BlockTime().After(p.VotingPeriodEnd); isFinal {
if err := k.pruneVotes(ctx, p.Id); err != nil {
return err
}
Expand Down
6 changes: 1 addition & 5 deletions x/group/module/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
if err := k.TallyProposalsAtVPEnd(ctx); err != nil {
panic(err)
}
pruneProposals(ctx, k)
}

func pruneProposals(ctx sdk.Context, k keeper.Keeper) {
err := k.PruneProposals(ctx)
if err != nil {
if err := k.PruneProposals(ctx); err != nil {
panic(err)
}
}
5 changes: 1 addition & 4 deletions x/group/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ func (m MsgCreateGroupPolicy) GetSignBytes() []byte {

// GetSigners returns the expected signers for a MsgCreateGroupPolicy.
func (m MsgCreateGroupPolicy) GetSigners() []sdk.AccAddress {
admin, err := sdk.AccAddressFromBech32(m.Admin)
if err != nil {
panic(err)
}
admin := sdk.MustAccAddressFromBech32(m.Admin)
return []sdk.AccAddress{admin}
}

Expand Down