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

chore: update ci #607

Merged
merged 12 commits into from
May 10, 2024
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
merge_group:
push:
branches:
- main
- osmo**
- release/**
permissions:
contents: read
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- "**.go"
push:
branches:
- main
- release/**
paths:
- "**.go"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "go.sum"
push:
branches:
- main
- osmo**
paths:
- "**/*.go"
- "go.mod"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Lint
on:
push:
branches:
- main
- osmo**
- release/**
pull_request:
merge_group:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
merge_group:
push:
branches:
- osmo**
- release/v0.50.x

permissions:
Expand Down Expand Up @@ -183,12 +184,6 @@ jobs:
with:
name: "${{ github.sha }}-e2e-coverage"
continue-on-error: true
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

liveness-test:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ run:
- server/grpc/gogoreflection/fix_registration.go
- "fix_registration.go"
- "x/bank/migrations/v4/gen_state_test.go"
- "baseapp/abci_utils.go"
- ".*\\.pb\\.go$"
- ".*\\.pb\\.gw\\.go$"
- ".*\\.pulsar\\.go$"
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# test

# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sim \
Expand Down
8 changes: 5 additions & 3 deletions store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ func TestMultiStore_Pruning_SameHeightsTwice(t *testing.T) {
require.Error(t, err, "expected error when loading pruned height: %d", v)
}

for v := int64(numVersions - int64(keepRecent)); v < numVersions; v++ {
for v := numVersions - int64(keepRecent); v < numVersions; v++ {
err := ms.LoadVersion(v)
require.NoError(t, err, "expected no error when loading height: %d", v)
}
Expand Down Expand Up @@ -618,12 +618,14 @@ func TestMultiStore_PruningRestart(t *testing.T) {

// commit one more block and ensure the heights have been pruned
ms.Commit()
time.Sleep(150 * time.Millisecond)
ms.Commit()

actualHeightToPrune = ms.pruningManager.GetPruningHeight(ms.LatestVersion())
require.Equal(t, int64(8), actualHeightToPrune)

// Ensure async pruning is done
time.Sleep(500 * time.Millisecond)
ms.Commit()

for v := int64(1); v <= actualHeightToPrune; v++ {
_, err := ms.CacheMultiStoreWithVersion(v)
require.Error(t, err, "expected error when loading height: %d", v)
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/auth/vesting/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package testutil
import (
"fmt"

"cosmossdk.io/math"
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/suite"

"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec/address"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
Expand Down
15 changes: 7 additions & 8 deletions tests/integration/auth/keeper/vesting_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ import (
"testing"
"time"

"cosmossdk.io/math"
"cosmossdk.io/simapp"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtime "github.com/cometbft/cometbft/types/time"
"github.com/stretchr/testify/require"

"cosmossdk.io/math"
"cosmossdk.io/simapp"

addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/runtime"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

tmtime "github.com/cometbft/cometbft/types/time"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
)

var (
Expand Down Expand Up @@ -216,7 +215,7 @@ func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers i
addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, valTokens)
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
pks := simtestutil.CreateTestPubKeys(1)
cdc := app.AppCodec() //simapp.MakeTestEncodingConfig().Marshaler
cdc := app.AppCodec()

authority := types.NewModuleAddress("gov")
app.StakingKeeper = stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(app.GetKey(stakingtypes.StoreKey)), app.AccountKeeper, app.BankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr))
Expand Down
5 changes: 2 additions & 3 deletions types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"regexp"
"sort"
"strings"

"unicode"

"cosmossdk.io/math"
Expand Down Expand Up @@ -851,11 +850,11 @@ func SetCoinDenomRegex(reFn func() string) {

// ValidateDenom is the default validation function for Coin.Denom.
func ValidateDenom(denom string) error {
if reDnm == nil || reDecCoin == nil { //nolint:gocritic
if reDnm == nil || reDecCoin == nil {
// Convert the string to a byte slice as required by the Ragel-generated function.

// Call the Ragel-generated function.
if !MatchDenom(denom) { //nolint:gocritic
if !MatchDenom(denom) {
return fmt.Errorf("invalid denom: %s", denom)
}
} else if !reDnm.MatchString(denom) { // If reDnm has been initialized, use it for matching.
Expand Down
6 changes: 3 additions & 3 deletions types/dec_coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func (coins DecCoins) Sort() DecCoins {
func ParseDecCoin(coinStr string) (coin DecCoin, err error) {
var amountStr, denomStr string
// if custom parsing has not been set, use default coin regex
if reDecCoin == nil { //nolint:gocritic
if reDecCoin == nil {
amountStr, denomStr, err = ParseDecAmount(coinStr)
if err != nil {
return DecCoin{}, err
Expand Down Expand Up @@ -665,8 +665,8 @@ func ParseDecAmount(coinStr string) (string, string, error) {
parsingAmount := true

for _, r := range strings.TrimSpace(coinStr) {
if parsingAmount { //nolint:gocritic
if unicode.IsDigit(r) || r == '.' { //nolint:gocritic
if parsingAmount {
if unicode.IsDigit(r) || r == '.' {
amountRune = append(amountRune, r)
} else if unicode.IsSpace(r) { // if space is seen, indicates that we have finished parsing amount
parsingAmount = false
Expand Down
3 changes: 1 addition & 2 deletions x/auth/vesting/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"
"time"
Expand Down Expand Up @@ -227,7 +226,7 @@ func NewMsgCreatePeriodicVestingAccountCmd(ac address.Codec) *cobra.Command {
// readScheduleFile reads the file at path and unmarshals it to get the schedule.
// Returns start time, periods, and error.
func readScheduleFile(path string) (int64, []types.Period, error) {
contents, err := ioutil.ReadFile(path)
contents, err := os.ReadFile(path)
if err != nil {
return 0, nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions x/auth/vesting/types/period.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func DisjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (int64,
}

// ConjunctPeriods returns the combination of two period schedules where the result is the minimum of the two schedules.
func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTime int64, endTime int64, merged []Period) {
func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTime, endTime int64, merged []Period) {
timeP := startP
timeQ := startQ
iP := 0
Expand Down Expand Up @@ -246,7 +246,7 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi
}

// consumeBoth processes simultaneous events in P and Q and emits an
// event if the minumum of P and Q changes
// event if the minimum of P and Q changes
consumeBoth := func(nextTime int64) {
amountP = amountP.Add(periodsP[iP].Amount...)
amountQ = amountQ.Add(periodsQ[iQ].Amount...)
Expand Down Expand Up @@ -289,7 +289,7 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi
}

endTime = time
return
return startTime, endTime, merged
}

// AlignSchedules rewrites the first period length to align the two arguments to the same start time,
Expand Down
55 changes: 26 additions & 29 deletions x/auth/vesting/types/vesting_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ import (

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
"gopkg.in/yaml.v3"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
)

Expand Down Expand Up @@ -525,29 +522,31 @@ func (plva PermanentLockedAccount) Validate() error {
return plva.BaseVestingAccount.Validate()
}

type getPK interface {
GetPubKey() cryptotypes.PubKey
}
// type getPK interface {
// GetPubKey() cryptotypes.PubKey
// }

func getPKString(g getPK) string {
if pk := g.GetPubKey(); pk != nil {
return pk.String()
}
return ""
}
// func getPKString(g getPK) string {
// if pk := g.GetPubKey(); pk != nil {
// return pk.String()
// }
// return ""
// }

func marshalYaml(i interface{}) (interface{}, error) {
bz, err := yaml.Marshal(i)
if err != nil {
return nil, err
}
return string(bz), nil
}
// func marshalYaml(i interface{}) (interface{}, error) {
// bz, err := yaml.Marshal(i)
// if err != nil {
// return nil, err
// }
// return string(bz), nil
// }

// Clawback Vesting Account

var _ vestexported.VestingAccount = (*ClawbackVestingAccount)(nil)
var _ authtypes.GenesisAccount = (*ClawbackVestingAccount)(nil)
var (
_ vestexported.VestingAccount = (*ClawbackVestingAccount)(nil)
_ authtypes.GenesisAccount = (*ClawbackVestingAccount)(nil)
)

// NewClawbackVestingAccount returns a new ClawbackVestingAccount
func NewClawbackVestingAccount(
Expand Down Expand Up @@ -631,7 +630,6 @@ func CoinEq(a, b sdk.Coins) bool {
func (va ClawbackVestingAccount) Validate() error {
if va.GetStartTime() >= va.GetEndTime() {
return errors.New("vesting start-time must be before end-time")

}

lockupEnd := va.GetStartTime()
Expand Down Expand Up @@ -683,7 +681,7 @@ func NewClawbackGrantAction(
grantStartTime int64,
grantLockupPeriods, grantVestingPeriods []Period,
grantCoins sdk.Coins,
) exported.AddGrantAction {
) vestexported.AddGrantAction {
return clawbackGrantAction{
funderAddress: funderAddress,
grantStartTime: grantStartTime,
Expand All @@ -693,7 +691,7 @@ func NewClawbackGrantAction(
}
}

func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error {
func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error {
cva, ok := rawAccount.(*ClawbackVestingAccount)
if !ok {
return fmt.Errorf("expected *ClawbackVestingAccount, got %T", rawAccount)
Expand All @@ -707,10 +705,9 @@ func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported
}
cva.addGrant(ctx, cga.grantStartTime, cga.grantLockupPeriods, cga.grantVestingPeriods, cga.grantCoins)
return nil

}

func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action exported.AddGrantAction) error {
func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action vestexported.AddGrantAction) error {
return action.AddToAccount(ctx, va)
}

Expand Down Expand Up @@ -794,7 +791,7 @@ type clawbackAction struct {
bk BankKeeper
}

func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) exported.ClawbackAction {
func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) vestexported.ClawbackAction {
return clawbackAction{
requestor: requestor,
dest: dest,
Expand All @@ -803,7 +800,7 @@ func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk Bank
}
}

func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error {
func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error {
cva, ok := rawAccount.(*ClawbackVestingAccount)
if !ok {
return fmt.Errorf("clawback expects *ClawbackVestingAccount, got %T", rawAccount)
Expand All @@ -814,7 +811,7 @@ func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.Ve
return cva.clawback(ctx, ca.dest, ca.ak, ca.bk)
}

func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action exported.ClawbackAction) error {
func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action vestexported.ClawbackAction) error {
return action.TakeFromAccount(ctx, va)
}

Expand Down
3 changes: 2 additions & 1 deletion x/auth/vesting/types/vesting_account_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"time"

tmtime "github.com/cometbft/cometbft/types/time"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/stretchr/testify/require"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion x/auth/vesting/types/vesting_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,8 @@ func TestGetVestedCoinsClawbackVestingAcc(t *testing.T) {
vestedCoins = va.GetVestedCoins(now.Add(18 * time.Hour))
require.Equal(t,
sdk.Coins{
sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75)}, vestedCoins)
sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75),
}, vestedCoins)

// require 100% of coins vested
vestedCoins = va.GetVestedCoins(now.Add(48 * time.Hour))
Expand Down
Loading
Loading