Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into align_query_height
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jul 21, 2024
2 parents 3f1b2dd + 6f1592d commit f2d145f
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* [#20939](https://github.com/cosmos/cosmos-sdk/pull/20939) Fix collection reverse iterator to include `pagination.key` in the result.
* (client/grpc) [#20969](https://github.com/cosmos/cosmos-sdk/pull/20969) Fix `node.NewQueryServer` method not setting `cfg`.
* (baseapp) [#21003](https://github.com/cosmos/cosmos-sdk/pull/21003) Align block header when query with latest height.
* (testutil/integration) [#21006](https://github.com/cosmos/cosmos-sdk/pull/21006) Fix `NewIntegrationApp` method not writing default genesis to state

### API Breaking Changes

Expand Down
4 changes: 2 additions & 2 deletions testutil/integration/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ func NewIntegrationApp(
bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseapp.SetChainID(appName))
bApp.MountKVStores(keys)

bApp.SetInitChainer(func(ctx sdk.Context, _ *cmtabcitypes.InitChainRequest) (*cmtabcitypes.InitChainResponse, error) {
bApp.SetInitChainer(func(_ sdk.Context, _ *cmtabcitypes.InitChainRequest) (*cmtabcitypes.InitChainResponse, error) {
for _, mod := range modules {
if m, ok := mod.(module.HasGenesis); ok {
if err := m.InitGenesis(ctx, m.DefaultGenesis()); err != nil {
if err := m.InitGenesis(sdkCtx, m.DefaultGenesis()); err != nil {
return nil, err
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/params/types/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func validateUnbondingTime(i interface{}) error {
}

if v < (24 * time.Hour) {
return fmt.Errorf("unbonding time must be at least one day")
return errors.New("unbonding time must be at least one day")
}

return nil
Expand Down
22 changes: 11 additions & 11 deletions x/protocolpool/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package types

import (
"fmt"
"errors"

"cosmossdk.io/errors"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -40,41 +40,41 @@ func ValidateGenesis(gs *GenesisState) error {

func validateBudget(bp Budget) error {
if bp.RecipientAddress == "" {
return fmt.Errorf("recipient cannot be empty")
return errors.New("recipient cannot be empty")
}

// Validate BudgetPerTranche
if bp.BudgetPerTranche == nil || bp.BudgetPerTranche.IsZero() {
return fmt.Errorf("budget per tranche cannot be zero")
return errors.New("budget per tranche cannot be zero")
}
if err := bp.BudgetPerTranche.Validate(); err != nil {
return errors.Wrap(sdkerrors.ErrInvalidCoins, bp.BudgetPerTranche.String())
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, bp.BudgetPerTranche.String())
}

if bp.TranchesLeft == 0 {
return fmt.Errorf("invalid budget proposal: tranches must be greater than zero")
return errors.New("invalid budget proposal: tranches must be greater than zero")
}

if bp.Period == nil || *bp.Period == 0 {
return fmt.Errorf("invalid budget proposal: period length should be greater than zero")
return errors.New("invalid budget proposal: period length should be greater than zero")
}
return nil
}

func validateContinuousFund(cf ContinuousFund) error {
if cf.Recipient == "" {
return fmt.Errorf("recipient cannot be empty")
return errors.New("recipient cannot be empty")
}

// Validate percentage
if cf.Percentage.IsNil() || cf.Percentage.IsZero() {
return fmt.Errorf("percentage cannot be zero or empty")
return errors.New("percentage cannot be zero or empty")
}
if cf.Percentage.IsNegative() {
return fmt.Errorf("percentage cannot be negative")
return errors.New("percentage cannot be negative")
}
if cf.Percentage.GT(math.LegacyOneDec()) {
return fmt.Errorf("percentage cannot be greater than one")
return errors.New("percentage cannot be greater than one")
}
return nil
}
3 changes: 2 additions & 1 deletion x/simulation/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -113,7 +114,7 @@ func SimulateFromSeedX(
// At least 2 accounts must be added here, otherwise when executing SimulateMsgSend
// two accounts will be selected to meet the conditions from != to and it will fall into an infinite loop.
if len(accs) <= 1 {
return params, fmt.Errorf("at least two genesis accounts are required")
return params, errors.New("at least two genesis accounts are required")
}

config.ChainID = chainID
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ func (k Keeper) Delegate(
// all non bonded
if subtractAccount {
if tokenSrc == types.Bonded {
return math.LegacyZeroDec(), fmt.Errorf("delegation token source cannot be bonded; expected Unbonded or Unbonding, got Bonded")
return math.LegacyZeroDec(), errors.New("delegation token source cannot be bonded; expected Unbonded or Unbonding, got Bonded")
}

var sendName string
Expand Down
4 changes: 2 additions & 2 deletions x/staking/keeper/slash.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (k Keeper) Slash(ctx context.Context, consAddr sdk.ConsAddress, infractionH
return math.NewInt(0), err
}
default:
return math.NewInt(0), fmt.Errorf("invalid validator status")
return math.NewInt(0), errors.New("invalid validator status")
}

k.Logger.Info(
Expand Down Expand Up @@ -415,7 +415,7 @@ func (k Keeper) SlashRedelegation(ctx context.Context, srcValidator types.Valida
case dstValidator.IsUnbonded() || dstValidator.IsUnbonding():
notBondedBurnedAmount = notBondedBurnedAmount.Add(tokensToBurn)
default:
return math.ZeroInt(), fmt.Errorf("unknown validator status")
return math.ZeroInt(), errors.New("unknown validator status")
}
}

Expand Down
5 changes: 3 additions & 2 deletions x/staking/keeper/val_state_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"bytes"
"context"
"errors"
"fmt"
"sort"

Expand Down Expand Up @@ -172,7 +173,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) ([]appmod
}

if validator.Jailed {
return nil, fmt.Errorf("should never retrieve a jailed validator from the power store")
return nil, errors.New("should never retrieve a jailed validator from the power store")
}

// if we get to a zero-power validator (which we don't bond),
Expand All @@ -198,7 +199,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx context.Context) ([]appmod
case validator.IsBonded():
// no state change
default:
return nil, fmt.Errorf("unexpected validator status")
return nil, errors.New("unexpected validator status")
}

// fetch the old power bytes
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func (k Keeper) unbondMatureValidators(
}

if !val.IsUnbonding() {
return fmt.Errorf("unexpected validator in unbonding queue; status was not unbonding")
return errors.New("unexpected validator in unbonding queue; status was not unbonding")
}

// if the ref count is not zero, early exit.
Expand Down
2 changes: 1 addition & 1 deletion x/staking/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func ValidatePowerReduction(i interface{}) error {
}

if v.LT(math.NewInt(1)) {
return fmt.Errorf("power reduction cannot be lower than 1")
return errors.New("power reduction cannot be lower than 1")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (k Keeper) HasHandler(name string) bool {
func (k Keeper) ApplyUpgrade(ctx context.Context, plan types.Plan) error {
handler := k.upgradeHandlers[plan.Name]
if handler == nil {
return fmt.Errorf("ApplyUpgrade should never be called without first checking HasHandler")
return errors.New("ApplyUpgrade should never be called without first checking HasHandler")
}

vm, err := k.GetModuleVersionMap(ctx)
Expand Down
3 changes: 2 additions & 1 deletion x/upgrade/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"
"encoding/binary"
"errors"
"fmt"

storetypes "cosmossdk.io/core/store"
Expand Down Expand Up @@ -63,7 +64,7 @@ func (m Migrator) Migrate2to3(ctx context.Context) error {

func migrateAppVersion(ctx context.Context, keeper *Keeper) error {
if keeper.versionModifier == nil {
return fmt.Errorf("version modifier is not set")
return errors.New("version modifier is not set")
}

store := keeper.KVStoreService.OpenKVStore(ctx)
Expand Down

0 comments on commit f2d145f

Please sign in to comment.