diff --git a/schema/appdata/async_test.go b/schema/appdata/async_test.go index 856575f71be1..bd802457d775 100644 --- a/schema/appdata/async_test.go +++ b/schema/appdata/async_test.go @@ -2,7 +2,7 @@ package appdata import ( "context" - "fmt" + "errors" "sync" "testing" ) @@ -78,7 +78,7 @@ func TestAsyncListenerMux(t *testing.T) { calls1 = append(calls1, name) }) listener1.Commit = func(data CommitData) (completionCallback func() error, err error) { - return nil, fmt.Errorf("error") + return nil, errors.New("error") } listener2 := callCollector(2, func(name string, _ int, _ Packet) { calls2 = append(calls2, name) @@ -141,7 +141,7 @@ func TestAsyncListener(t *testing.T) { }) listener.OnKVPair = func(updates KVPairData) error { - return fmt.Errorf("error") + return errors.New("error") } res := AsyncListener(AsyncListenerOptions{BufferSize: 16}, listener) diff --git a/server/v2/stf/util.go b/server/v2/stf/util.go index b69e805d350c..cd2cab2f70e4 100644 --- a/server/v2/stf/util.go +++ b/server/v2/stf/util.go @@ -2,7 +2,7 @@ package stf import ( "context" - "fmt" + "errors" ) // getExecutionCtxFromContext tries to get the execution context from the given go context. @@ -16,5 +16,5 @@ func getExecutionCtxFromContext(ctx context.Context) (*executionContext, error) return value, nil } - return nil, fmt.Errorf("failed to get executionContext from context") + return nil, errors.New("failed to get executionContext from context") } diff --git a/server/v2/store/snapshot.go b/server/v2/store/snapshot.go index 3289d94f5e7d..2c106f85fe69 100644 --- a/server/v2/store/snapshot.go +++ b/server/v2/store/snapshot.go @@ -337,12 +337,12 @@ func (s *StoreComponent[T]) LoadArchiveCmd() *cobra.Command { savedSnapshot := <-quitChan if savedSnapshot == nil { - return fmt.Errorf("failed to save snapshot") + return errors.New("failed to save snapshot") } if !reflect.DeepEqual(&snapshot, savedSnapshot) { _ = snapshotStore.Delete(snapshot.Height, snapshot.Format) - return fmt.Errorf("invalid archive, the saved snapshot is not equal to the original one") + return errors.New("invalid archive, the saved snapshot is not equal to the original one") } return nil diff --git a/store/v2/root/factory.go b/store/v2/root/factory.go index 17e2d39e87eb..b10c87770aee 100644 --- a/store/v2/root/factory.go +++ b/store/v2/root/factory.go @@ -139,9 +139,9 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { case SCTypeIavl: return iavl.NewIavlTree(db.NewPrefixDB(opts.SCRawDB, []byte(key)), opts.Logger, storeOpts.IavlConfig), nil case SCTypeIavlV2: - return nil, fmt.Errorf("iavl v2 not supported") + return nil, errors.New("iavl v2 not supported") default: - return nil, fmt.Errorf("unsupported commitment store type") + return nil, errors.New("unsupported commitment store type") } } } diff --git a/store/v2/root/store.go b/store/v2/root/store.go index 218af42b6f89..c39119a9aaf3 100644 --- a/store/v2/root/store.go +++ b/store/v2/root/store.go @@ -245,7 +245,7 @@ func (s *Store) LoadVersion(version uint64) error { // NOTE: It cannot be called while the store is migrating. func (s *Store) LoadVersionAndUpgrade(version uint64, upgrades *corestore.StoreUpgrades) error { if upgrades == nil { - return fmt.Errorf("upgrades cannot be nil") + return errors.New("upgrades cannot be nil") } if s.telemetry != nil { @@ -253,7 +253,7 @@ func (s *Store) LoadVersionAndUpgrade(version uint64, upgrades *corestore.StoreU } if s.isMigrating { - return fmt.Errorf("cannot upgrade while migrating") + return errors.New("cannot upgrade while migrating") } if err := s.loadVersion(version, upgrades); err != nil { @@ -283,7 +283,7 @@ func (s *Store) loadVersion(v uint64, upgrades *corestore.StoreUpgrades) error { // if upgrades are provided, we need to load the version and apply the upgrades upgradeableStore, ok := s.stateCommitment.(store.UpgradeableStore) if !ok { - return fmt.Errorf("SC store does not support upgrades") + return errors.New("SC store does not support upgrades") } if err := upgradeableStore.LoadVersionAndUpgrade(v, upgrades); err != nil { return fmt.Errorf("failed to load SS version with upgrades %d: %w", v, err) diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index 0c9246e0136a..a533bc21714a 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -2,9 +2,10 @@ package keeper import ( "context" + "errors" "fmt" - "github.com/pkg/errors" + pkgerr "github.com/pkg/errors" "cosmossdk.io/collections" "cosmossdk.io/math" @@ -55,7 +56,7 @@ func (k Keeper) IncrementValidatorPeriod(ctx context.Context, val sdk.ValidatorI // fetch current rewards rewards, err := k.ValidatorCurrentRewards.Get(ctx, valBz) - if err != nil && !errors.Is(err, collections.ErrNotFound) { + if err != nil && !pkgerr.Is(err, collections.ErrNotFound) { return 0, err } @@ -71,7 +72,7 @@ func (k Keeper) IncrementValidatorPeriod(ctx context.Context, val sdk.ValidatorI } outstanding, err := k.ValidatorOutstandingRewards.Get(ctx, valBz) - if err != nil && !errors.Is(err, collections.ErrNotFound) { + if err != nil && !pkgerr.Is(err, collections.ErrNotFound) { return 0, err } @@ -144,7 +145,7 @@ func (k Keeper) decrementReferenceCount(ctx context.Context, valAddr sdk.ValAddr } if historical.ReferenceCount == 0 { - return fmt.Errorf("cannot set negative reference count") + return errors.New("cannot set negative reference count") } historical.ReferenceCount-- if historical.ReferenceCount == 0 { diff --git a/x/genutil/genesis.go b/x/genutil/genesis.go index 2008f28fe19d..386a281659cf 100644 --- a/x/genutil/genesis.go +++ b/x/genutil/genesis.go @@ -2,7 +2,7 @@ package genutil import ( "context" - "fmt" + "errors" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/module" @@ -22,7 +22,7 @@ func InitGenesis( txEncodingConfig client.TxEncodingConfig, ) (validatorUpdates []module.ValidatorUpdate, err error) { if deliverTx == nil { - return nil, fmt.Errorf("deliverTx (genesis.TxHandler) not defined, verify x/genutil wiring") + return nil, errors.New("deliverTx (genesis.TxHandler) not defined, verify x/genutil wiring") } if len(genesisState.GenTxs) > 0 {