Skip to content

Commit

Permalink
Merge branch 'master' into roman/upstream/snapshot-pruning-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Apr 19, 2022
2 parents 73b75ee + c634dbf commit 986f6ff
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 45 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,13 @@ jobs:
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6.0.1
with:
SUFFIX_FILTER: |
**/**.go
go.mod
go.sum
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
if: env.GIT_DIFF
- name: test-sim-import-export
run: |
make test-sim-import-export
if: env.GIT_DIFF
test-sim-after-import:
runs-on: ubuntu-latest
Expand All @@ -83,23 +73,13 @@ jobs:
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6.0.1
with:
SUFFIX_FILTER: |
**/**.go
go.mod
go.sum
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
if: env.GIT_DIFF
- name: test-sim-after-import
run: |
make test-sim-after-import
if: env.GIT_DIFF
test-sim-multi-seed-short:
runs-on: ubuntu-latest
Expand All @@ -112,20 +92,10 @@ jobs:
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6.0.1
with:
SUFFIX_FILTER: |
**/**.go
go.mod
go.sum
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
if: env.GIT_DIFF
- name: test-sim-multi-seed-short
run: |
make test-sim-multi-seed-short
if: env.GIT_DIFF
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ jobs:
with:
name: "${{ github.sha }}-go-submodules-coverage"
if: env.GIT_DIFF
continue-on-error: true
- run: |
cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
if: env.GIT_DIFF
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (x/auth/vesting) [\#11652](https://github.com/cosmos/cosmos-sdk/pull/11652) Add util functions for `Period(s)`
* [\#11630](https://github.com/cosmos/cosmos-sdk/pull/11630) Add SafeSub method to sdk.Coin.
* [\#11511](https://github.com/cosmos/cosmos-sdk/pull/11511) Add api server flags to start command.
* [\#11484](https://github.com/cosmos/cosmos-sdk/pull/11484) Implement getter for keyring backend option.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
github.com/tendermint/btcd v0.1.1
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
github.com/tendermint/go-amino v0.16.0
github.com/tendermint/tendermint v0.35.3
github.com/tendermint/tendermint v0.35.4
github.com/tendermint/tm-db v0.6.6
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac
Expand Down
8 changes: 5 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,10 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creachadair/atomicfile v0.2.4/go.mod h1:BRq8Une6ckFneYXZQ+kO7p1ZZP3I2fzVzf28JxrIkBc=
github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM=
github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk=
github.com/creachadair/tomledit v0.0.16/go.mod h1:gvtfnSZLa+YNQD28vaPq0Nk12bRxEhmUdBzAWn+EGF4=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
Expand Down Expand Up @@ -1278,8 +1280,8 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/tendermint v0.35.2/go.mod h1:0sVA1nOm5KKaxHar3aIzmMGKH9F/nBMn7T5ruQGZuHg=
github.com/tendermint/tendermint v0.35.3 h1:fulTTA5BIXlipxAdOpt/l0OCJlwhTWASkrvRjfKvXH4=
github.com/tendermint/tendermint v0.35.3/go.mod h1:EaeXmSXy5QSjhV+nK8Rt42PuGFDoz0H74eqc8aWeGsY=
github.com/tendermint/tendermint v0.35.4 h1:ZL9Q+rXBwTEYbONBXy0mWkyG08uvdgQNSuYmoBR1sfE=
github.com/tendermint/tendermint v0.35.4/go.mod h1:+9zS92hqCl6mL7XLK3dg71nzoBLJlkl/aNLx4NXKNP8=
github.com/tendermint/tm-db v0.6.6 h1:EzhaOfR0bdKyATqcd5PNeyeq8r+V4bRPHBfyFdD9kGM=
github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI=
github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0=
Expand Down Expand Up @@ -1330,7 +1332,7 @@ github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+
github.com/valyala/quicktemplate v1.7.0/go.mod h1:sqKJnoaOF88V07vkO+9FL8fb9uZg/VPSJnLYn+LmLk8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/vektra/mockery/v2 v2.10.0/go.mod h1:m/WO2UzWzqgVX3nvqpRQq70I4Z7jbSCRhdmkgtp+Ab4=
github.com/vektra/mockery/v2 v2.10.4/go.mod h1:m/WO2UzWzqgVX3nvqpRQq70I4Z7jbSCRhdmkgtp+Ab4=
github.com/vektra/mockery/v2 v2.10.6/go.mod h1:8vf4KDDUptfkyypzdHLuE7OE2xA7Gdt60WgIS8PgD+U=
github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
Expand Down
2 changes: 1 addition & 1 deletion scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ cd ..
cp -r github.com/cosmos/cosmos-sdk/* ./
rm -rf github.com

go mod tidy
go mod tidy -compat=1.17

./scripts/protocgen2.sh
42 changes: 37 additions & 5 deletions x/auth/vesting/types/period.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,55 @@ package types
import (
"fmt"
"strings"
"time"

"sigs.k8s.io/yaml"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// Periods stores all vesting periods passed as part of a PeriodicVestingAccount
type Periods []Period

// String Period implements stringer interface
// Duration is converts the period Length from seconds to a time.Duration
func (p Period) Duration() time.Duration {
return time.Duration(p.Length) * time.Second
}

// String implements the fmt.Stringer interface
func (p Period) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}

// String Periods implements stringer interface
func (vp Periods) String() string {
periodsListString := make([]string, len(vp))
for _, period := range vp {
// TotalLength return the total length in seconds for a period
func (p Periods) TotalLength() int64 {
var total int64
for _, period := range p {
total += period.Length
}
return total
}

// TotalDuration returns the total duration of the period
func (p Periods) TotalDuration() time.Duration {
len := p.TotalLength()
return time.Duration(len) * time.Second
}

// TotalDuration returns the sum of coins for the period
func (p Periods) TotalAmount() sdk.Coins {
total := sdk.Coins{}
for _, period := range p {
total = total.Add(period.Amount...)
}
return total
}

// String implements the fmt.Stringer interface
func (p Periods) String() string {
periodsListString := make([]string, len(p))
for _, period := range p {
periodsListString = append(periodsListString, period.String())
}

Expand Down
2 changes: 1 addition & 1 deletion x/group/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func GroupTotalWeightInvariantHelper(ctx sdk.Context, key storetypes.StoreKey, g
}
}

groupWeight, err := groupmath.NewPositiveDecFromString(groupInfo.GetTotalWeight())
groupWeight, err := groupmath.NewNonNegativeDecFromString(groupInfo.GetTotalWeight())
if err != nil {
msg += fmt.Sprintf("error while parsing non-nengative decimal for group with ID %d\n%v\n", groupInfo.Id, err)
return msg, broken
Expand Down
2 changes: 1 addition & 1 deletion x/group/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2753,7 +2753,7 @@ func (s *TestSuite) TestLeaveGroup() {
math.NewDecFromInt64(0),
},
{
"valid testcase: decision policy is not present",
"valid testcase: decision policy is not present (and group total weight can be 0)",
&group.MsgLeaveGroup{
GroupId: groupID2,
Address: member1.String(),
Expand Down
6 changes: 3 additions & 3 deletions x/group/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func (k Keeper) CreateGroup(goCtx context.Context, req *group.MsgCreateGroup) (*
func (k Keeper) UpdateGroupMembers(goCtx context.Context, req *group.MsgUpdateGroupMembers) (*group.MsgUpdateGroupMembersResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
action := func(g *group.GroupInfo) error {
totalWeight, err := math.NewPositiveDecFromString(g.TotalWeight)
totalWeight, err := math.NewNonNegativeDecFromString(g.TotalWeight)
if err != nil {
return err
return sdkerrors.Wrap(err, "group total weight")
}
for i := range req.MemberUpdates {
if err := k.assertMetadataLength(req.MemberUpdates[i].Metadata, "group member metadata"); err != nil {
Expand Down Expand Up @@ -800,7 +800,7 @@ func (k Keeper) LeaveGroup(goCtx context.Context, req *group.MsgLeaveGroup) (*gr
return nil, sdkerrors.Wrap(err, "group")
}

groupWeight, err := math.NewPositiveDecFromString(groupInfo.TotalWeight)
groupWeight, err := math.NewNonNegativeDecFromString(groupInfo.TotalWeight)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 986f6ff

Please sign in to comment.