Skip to content

Commit

Permalink
chore: deps: bump xerrors / fix lint (filecoin-project#12438)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribasushi authored Sep 7, 2024
1 parent 6b03326 commit a83d02e
Show file tree
Hide file tree
Showing 29 changed files with 84 additions and 70 deletions.
2 changes: 1 addition & 1 deletion chain/actors/aerrors/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func HandleExternalError(err error, msg string) ActorError {
}
}

if xerrors.Is(err, &cbor.SerializationError{}) {
if errors.Is(err, &cbor.SerializationError{}) {
return &actorError{
fatal: false,
retCode: 253,
Expand Down
5 changes: 3 additions & 2 deletions chain/consensus/filcns/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
_ "embed"
"errors"
"fmt"
"os"
"runtime"
Expand Down Expand Up @@ -455,7 +456,7 @@ func UpgradeFaucetBurnRecovery(ctx context.Context, sm *stmgr.StateManager, _ st
err = tree.ForEach(func(addr address.Address, act *types.Actor) error {
lbact, err := lbtree.GetActor(addr)
if err != nil {
if !xerrors.Is(err, types.ErrActorNotFound) {
if !errors.Is(err, types.ErrActorNotFound) {
return xerrors.Errorf("failed to get actor in lookback state")
}
}
Expand Down Expand Up @@ -1020,7 +1021,7 @@ func UpgradeActorsV3(ctx context.Context, sm *stmgr.StateManager, cache stmgr.Mi

if buildconstants.BuildType == buildconstants.BuildMainnet {
err := stmgr.TerminateActor(ctx, tree, buildconstants.ZeroAddress, cb, epoch, ts)
if err != nil && !xerrors.Is(err, types.ErrActorNotFound) {
if err != nil && !errors.Is(err, types.ErrActorNotFound) {
return cid.Undef, xerrors.Errorf("deleting zero bls actor: %w", err)
}

Expand Down
3 changes: 2 additions & 1 deletion chain/exchange/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package exchange
import (
"bufio"
"context"
"errors"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -119,7 +120,7 @@ func (c *client) doRequest(
// Send request, read response.
res, err := c.sendRequestToPeer(ctx, peer, req)
if err != nil {
if !xerrors.Is(err, network.ErrNoConn) {
if !errors.Is(err, network.ErrNoConn) {
log.Warnf("could not send request to peer %s: %s",
peer.String(), err)
}
Expand Down
2 changes: 1 addition & 1 deletion chain/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ func (mp *MessagePool) loadLocal(ctx context.Context) error {
}

if err := mp.addLoaded(ctx, &sm); err != nil {
if xerrors.Is(err, ErrNonceTooLow) {
if errors.Is(err, ErrNonceTooLow) {
continue // todo: drop the message from local cache (if above certain confidence threshold)
}

Expand Down
3 changes: 2 additions & 1 deletion chain/messagesigner/messagesigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package messagesigner
import (
"bytes"
"context"
"errors"
"sync"

"github.com/google/uuid"
Expand Down Expand Up @@ -141,7 +142,7 @@ func (ms *MessageSigner) NextNonce(ctx context.Context, addr address.Address) (u
dsNonceBytes, err := ms.ds.Get(ctx, addrNonceKey)

switch {
case xerrors.Is(err, datastore.ErrNotFound):
case errors.Is(err, datastore.ErrNotFound):
// If a nonce for this address hasn't yet been created in the
// datastore, just use the nonce from the mempool
return nonce, nil
Expand Down
5 changes: 3 additions & 2 deletions chain/state/statetree.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package state
import (
"bytes"
"context"
"errors"
"fmt"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -368,7 +369,7 @@ func (st *StateTree) GetActor(addr address.Address) (*types.Actor, error) {
// Transform `addr` to its ID format.
iaddr, err := st.LookupIDAddress(addr)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return nil, xerrors.Errorf("resolution lookup failed (%s): %w", addr, err)
}
return nil, xerrors.Errorf("address resolution: %w", err)
Expand Down Expand Up @@ -413,7 +414,7 @@ func (st *StateTree) DeleteActor(addr address.Address) error {

iaddr, err := st.LookupIDAddress(addr)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return xerrors.Errorf("resolution lookup failed (%s): %w", addr, err)
}
return xerrors.Errorf("address resolution: %w", err)
Expand Down
3 changes: 2 additions & 1 deletion chain/stmgr/actors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package stmgr
import (
"bytes"
"context"
"errors"
"os"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -333,7 +334,7 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule
}

act, err := sm.LoadActorRaw(ctx, maddr, lbst)
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
_, err := sm.LoadActor(ctx, maddr, ts)
if err != nil {
return nil, xerrors.Errorf("loading miner in current state: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion chain/stmgr/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (sm *StateManager) Replay(ctx context.Context, ts *types.TipSet, mcid cid.C
finder.mcid = mcid

_, _, err := sm.tsExec.ExecuteTipSet(ctx, sm, ts, &finder, true)
if err != nil && !xerrors.Is(err, errHaltExecution) {
if err != nil && !errors.Is(err, errHaltExecution) {
return nil, nil, xerrors.Errorf("unexpected error during execution: %w", err)
}

Expand Down
2 changes: 1 addition & 1 deletion chain/stmgr/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func DoTransfer(tree types.StateTree, from, to address.Address, amt abi.TokenAmo

func TerminateActor(ctx context.Context, tree *state.StateTree, addr address.Address, em ExecMonitor, epoch abi.ChainEpoch, ts *types.TipSet) error {
a, err := tree.GetActor(addr)
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return types.ErrActorNotFound
} else if err != nil {
return xerrors.Errorf("failed to get actor to delete: %w", err)
Expand Down
23 changes: 12 additions & 11 deletions chain/sub/incoming.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"sync"
"time"

Expand Down Expand Up @@ -354,28 +355,28 @@ func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubs
recordFailure(ctx, metrics.MessageValidationFailure, "add")
switch {

case xerrors.Is(err, messagepool.ErrSoftValidationFailure):
case errors.Is(err, messagepool.ErrSoftValidationFailure):
fallthrough
case xerrors.Is(err, messagepool.ErrRBFTooLowPremium):
case errors.Is(err, messagepool.ErrRBFTooLowPremium):
fallthrough
case xerrors.Is(err, messagepool.ErrTooManyPendingMessages):
case errors.Is(err, messagepool.ErrTooManyPendingMessages):
fallthrough
case xerrors.Is(err, messagepool.ErrNonceGap):
case errors.Is(err, messagepool.ErrNonceGap):
fallthrough
case xerrors.Is(err, messagepool.ErrGasFeeCapTooLow):
case errors.Is(err, messagepool.ErrGasFeeCapTooLow):
fallthrough
case xerrors.Is(err, messagepool.ErrNonceTooLow):
case errors.Is(err, messagepool.ErrNonceTooLow):
fallthrough
case xerrors.Is(err, messagepool.ErrNotEnoughFunds):
case errors.Is(err, messagepool.ErrNotEnoughFunds):
fallthrough
case xerrors.Is(err, messagepool.ErrExistingNonce):
case errors.Is(err, messagepool.ErrExistingNonce):
return pubsub.ValidationIgnore

case xerrors.Is(err, messagepool.ErrMessageTooBig):
case errors.Is(err, messagepool.ErrMessageTooBig):
fallthrough
case xerrors.Is(err, messagepool.ErrMessageValueTooHigh):
case errors.Is(err, messagepool.ErrMessageValueTooHigh):
fallthrough
case xerrors.Is(err, messagepool.ErrInvalidToAddr):
case errors.Is(err, messagepool.ErrInvalidToAddr):
fallthrough
default:
return pubsub.ValidationReject
Expand Down
2 changes: 1 addition & 1 deletion chain/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ loop:
log.Warnf("(fork detected) synced header chain (%s - %d) does not link to our best block (%s - %d)", incoming.Cids(), incoming.Height(), known.Cids(), known.Height())
fork, err := syncer.syncFork(ctx, base, known, ignoreCheckpoint)
if err != nil {
if xerrors.Is(err, ErrForkTooLong) || xerrors.Is(err, ErrForkCheckpoint) {
if errors.Is(err, ErrForkTooLong) || errors.Is(err, ErrForkCheckpoint) {
// TODO: we're marking this block bad in the same way that we mark invalid blocks bad. Maybe distinguish?
log.Warn("adding forked chain to our bad tipset cache")
for _, b := range incoming.Blocks() {
Expand Down
14 changes: 7 additions & 7 deletions chain/vm/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"fmt"
"os"
"time"

"github.com/ipfs/go-cid"
ipldcbor "github.com/ipfs/go-ipld-cbor"
"go.opencensus.io/trace"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
Expand Down Expand Up @@ -113,7 +113,7 @@ func (rt *Runtime) TotalFilCircSupply() abi.TokenAmount {
func (rt *Runtime) ResolveAddress(addr address.Address) (ret address.Address, ok bool) {
r, err := rt.state.LookupIDAddress(addr)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return address.Undef, false
}
panic(aerrors.Fatalf("failed to resolve address %s: %s", addr, err))
Expand All @@ -128,8 +128,8 @@ type notFoundErr interface {
func (rt *Runtime) StoreGet(c cid.Cid, o cbor.Unmarshaler) bool {
if err := rt.cst.Get(context.TODO(), c, o); err != nil {
var nfe notFoundErr
if xerrors.As(err, &nfe) && nfe.IsNotFound() {
if xerrors.As(err, new(ipldcbor.SerializationError)) {
if errors.As(err, &nfe) && nfe.IsNotFound() {
if errors.As(err, new(ipldcbor.SerializationError)) {
panic(aerrors.Newf(exitcode.ErrSerialization, "failed to unmarshal cbor object %s", err))
}
return false
Expand All @@ -143,7 +143,7 @@ func (rt *Runtime) StoreGet(c cid.Cid, o cbor.Unmarshaler) bool {
func (rt *Runtime) StorePut(x cbor.Marshaler) cid.Cid {
c, err := rt.cst.Put(context.TODO(), x)
if err != nil {
if xerrors.As(err, new(ipldcbor.SerializationError)) {
if errors.As(err, new(ipldcbor.SerializationError)) {
panic(aerrors.Newf(exitcode.ErrSerialization, "failed to marshal cbor object %s", err))
}
panic(aerrors.Fatalf("failed to put cbor object: %s", err))
Expand Down Expand Up @@ -219,7 +219,7 @@ func (rt *Runtime) CurrentBalance() abi.TokenAmount {
func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) {
act, err := rt.state.GetActor(addr)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return cid.Undef, false
}

Expand Down Expand Up @@ -314,7 +314,7 @@ func (rt *Runtime) DeleteActor(beneficiary address.Address) {
rt.chargeGas(rt.Pricelist().OnDeleteActor())
act, err := rt.state.GetActor(rt.Receiver())
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
rt.Abortf(exitcode.SysErrorIllegalActor, "failed to load actor in delete actor: %s", err)
}
panic(aerrors.Fatalf("failed to get actor: %s", err))
Expand Down
7 changes: 4 additions & 3 deletions chain/vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package vm
import (
"bytes"
"context"
"errors"
"fmt"
"sync/atomic"
"time"
Expand Down Expand Up @@ -331,7 +332,7 @@ func (vm *LegacyVM) send(ctx context.Context, msg *types.Message, parent *Runtim
_ = rt.chargeGasSafe(newGasCharge("OnGetActor", 0, 0))
toActor, err := st.GetActor(msg.To)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
a, aid, err := TryCreateAccountActor(rt, msg.To)
if err != nil {
return nil, aerrors.Wrapf(err, "could not create account")
Expand Down Expand Up @@ -473,7 +474,7 @@ func (vm *LegacyVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*App
fromActor, err := st.GetActor(msg.From)
// this should never happen, but is currently still exercised by some tests
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
gasOutputs := ZeroGasOutputs()
gasOutputs.MinerPenalty = minerPenaltyAmount
return &ApplyRet{
Expand Down Expand Up @@ -647,7 +648,7 @@ func (vm *LegacyVM) ShouldBurn(ctx context.Context, st *state.StateTree, msg *ty
// the trace, but I'm not sure if that's safe?
if toActor, err := st.GetActor(msg.To); err != nil {
// If the actor wasn't found, we probably deleted it or something. Move on.
if !xerrors.Is(err, types.ErrActorNotFound) {
if !errors.Is(err, types.ErrActorNotFound) {
// Otherwise, this should never fail and something is very wrong.
return false, xerrors.Errorf("failed to lookup target actor: %w", err)
}
Expand Down
13 changes: 7 additions & 6 deletions chain/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package wallet

import (
"context"
"errors"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (w *LocalWallet) findKey(addr address.Address) (*key.Key, error) {

ki, err := w.tryFind(addr)
if err != nil {
if xerrors.Is(err, types.ErrKeyInfoNotFound) {
if errors.Is(err, types.ErrKeyInfoNotFound) {
return nil, nil
}
return nil, xerrors.Errorf("getting from keystore: %w", err)
Expand All @@ -108,7 +109,7 @@ func (w *LocalWallet) tryFind(addr address.Address) (types.KeyInfo, error) {
return ki, err
}

if !xerrors.Is(err, types.ErrKeyInfoNotFound) {
if !errors.Is(err, types.ErrKeyInfoNotFound) {
return types.KeyInfo{}, err
}

Expand Down Expand Up @@ -223,7 +224,7 @@ func (w *LocalWallet) SetDefault(a address.Address) error {
}

if err := w.keystore.Delete(KDefault); err != nil {
if !xerrors.Is(err, types.ErrKeyInfoNotFound) {
if !errors.Is(err, types.ErrKeyInfoNotFound) {
log.Warnf("failed to unregister current default key: %s", err)
}
}
Expand Down Expand Up @@ -251,7 +252,7 @@ func (w *LocalWallet) WalletNew(ctx context.Context, typ types.KeyType) (address

_, err = w.keystore.Get(KDefault)
if err != nil {
if !xerrors.Is(err, types.ErrKeyInfoNotFound) {
if !errors.Is(err, types.ErrKeyInfoNotFound) {
return address.Undef, err
}

Expand Down Expand Up @@ -284,7 +285,7 @@ func (w *LocalWallet) walletDelete(ctx context.Context, addr address.Address) er
w.lk.Lock()
defer w.lk.Unlock()

if err := w.keystore.Delete(KTrashPrefix + k.Address.String()); err != nil && !xerrors.Is(err, types.ErrKeyInfoNotFound) {
if err := w.keystore.Delete(KTrashPrefix + k.Address.String()); err != nil && !errors.Is(err, types.ErrKeyInfoNotFound) {
return xerrors.Errorf("failed to purge trashed key %s: %w", addr, err)
}

Expand Down Expand Up @@ -313,7 +314,7 @@ func (w *LocalWallet) deleteDefault() {
w.lk.Lock()
defer w.lk.Unlock()
if err := w.keystore.Delete(KDefault); err != nil {
if !xerrors.Is(err, types.ErrKeyInfoNotFound) {
if !errors.Is(err, types.ErrKeyInfoNotFound) {
log.Warnf("failed to unregister current default key: %s", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/sending_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func InteractiveSend(ctx context.Context, cctx *cli.Context, srv ServicesAPI,

msg, checks, err := srv.PublishMessage(ctx, proto, cctx.Bool("force") || cctx.Bool("force-send"))
printer := cctx.App.Writer
if xerrors.Is(err, ErrCheckFailed) {
if errors.Is(err, ErrCheckFailed) {
if !cctx.Bool("interactive") {
_, _ = fmt.Fprintf(printer, "Following checks have failed:\n")
printChecks(printer, checks, proto.Message.Cid())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ require (
golang.org/x/term v0.24.0
golang.org/x/time v0.6.0
golang.org/x/tools v0.24.0
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
gopkg.in/cheggaaa/pb.v1 v1.0.28
gotest.tools v2.2.0+incompatible
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1757,8 +1757,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ=
gonum.org/v1/gonum v0.15.0/go.mod h1:xzZVBJBtS+Mz4q0Yl2LJTk+OxOg4jiXZ7qBoM0uISGo=
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
Expand Down
Loading

0 comments on commit a83d02e

Please sign in to comment.