chore: deps: bump xerrors / fix lint (#12438)

This commit is contained in:
Peter Rabbitson
2024-09-07 23:43:15 +02:00
committed by GitHub
parent 6b03326888
commit a83d02efba
29 changed files with 84 additions and 70 deletions

View File

@ -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,

View File

@ -4,6 +4,7 @@ import (
"bytes"
"context"
_ "embed"
"errors"
"fmt"
"os"
"runtime"
@ -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")
}
}
@ -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)
}

View File

@ -3,6 +3,7 @@ package exchange
import (
"bufio"
"context"
"errors"
"fmt"
"io"
"math/rand"
@ -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)
}

View File

@ -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)
}

View File

@ -3,6 +3,7 @@ package messagesigner
import (
"bytes"
"context"
"errors"
"sync"
"github.com/google/uuid"
@ -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

View File

@ -3,6 +3,7 @@ package state
import (
"bytes"
"context"
"errors"
"fmt"
"github.com/ipfs/go-cid"
@ -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)
@ -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)

View File

@ -3,6 +3,7 @@ package stmgr
import (
"bytes"
"context"
"errors"
"os"
"github.com/ipfs/go-cid"
@ -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)

View File

@ -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)
}

View File

@ -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)

View File

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"sync"
"time"
@ -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

View File

@ -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() {

View File

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"fmt"
"os"
"time"
@ -11,7 +12,6 @@ import (
"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"
@ -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))
@ -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
@ -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))
@ -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
}
@ -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))

View File

@ -3,6 +3,7 @@ package vm
import (
"bytes"
"context"
"errors"
"fmt"
"sync/atomic"
"time"
@ -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")
@ -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{
@ -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)
}

View File

@ -2,6 +2,7 @@ package wallet
import (
"context"
"errors"
"sort"
"strings"
"sync"
@ -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)
@ -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
}
@ -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)
}
}
@ -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
}
@ -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)
}
@ -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)
}
}

View File

@ -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())

2
go.mod
View File

@ -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
)

4
go.sum
View File

@ -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=

View File

@ -3,6 +3,7 @@ package itests
import (
"context"
"errors"
"strings"
"testing"
"time"
@ -10,7 +11,6 @@ import (
logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
@ -183,7 +183,7 @@ func (ts *apiSuite) testOutOfGasError(t *testing.T) {
_, err = full.GasEstimateMessageGas(ctx, msg, nil, types.EmptyTSK)
require.Error(t, err, "should have failed")
require.True(t, xerrors.Is(err, &lapi.ErrOutOfGas{}))
require.True(t, errors.Is(err, &lapi.ErrOutOfGas{}))
}
func (ts *apiSuite) testLookupNotFoundError(t *testing.T) {
@ -196,7 +196,7 @@ func (ts *apiSuite) testLookupNotFoundError(t *testing.T) {
_, err = full.StateLookupID(ctx, addr, types.EmptyTSK)
require.Error(t, err)
require.True(t, xerrors.Is(err, &lapi.ErrActorNotFound{}))
require.True(t, errors.Is(err, &lapi.ErrActorNotFound{}))
}
func (ts *apiSuite) testMining(t *testing.T) {

View File

@ -3,6 +3,7 @@ package itests
import (
"context"
"errors"
"fmt"
"os"
"regexp"
@ -13,7 +14,6 @@ import (
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
@ -71,7 +71,7 @@ func TestPaymentChannelsBasic(t *testing.T) {
// This makes us wait as much as 10 epochs before giving up and failing
retry := 0
_, err = paymentReceiver.StateLookupID(ctx, chAddr, types.EmptyTSK)
for err != nil && xerrors.Is(err, &api.ErrActorNotFound{}) {
for err != nil && errors.Is(err, &api.ErrActorNotFound{}) {
time.Sleep(blocktime)
_, err = paymentReceiver.StateLookupID(ctx, chAddr, types.EmptyTSK)
retry++

View File

@ -470,7 +470,7 @@ func (a *EthModule) EthGetTransactionCount(ctx context.Context, sender ethtypes.
// First, handle the case where the "sender" is an EVM actor.
if actor, err := a.StateManager.LoadActor(ctx, addr, ts); err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return 0, nil
}
return 0, xerrors.Errorf("failed to lookup contract %s: %w", sender, err)
@ -560,7 +560,7 @@ func (a *EthModule) EthGetCode(ctx context.Context, ethAddr ethtypes.EthAddress,
actor, err := a.StateManager.LoadActor(ctx, to, ts)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return nil, nil
}
return nil, xerrors.Errorf("failed to lookup contract %s: %w", ethAddr, err)
@ -653,7 +653,7 @@ func (a *EthModule) EthGetStorageAt(ctx context.Context, ethAddr ethtypes.EthAdd
actor, err := a.StateManager.LoadActor(ctx, to, ts)
if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return ethtypes.EthBytes(make([]byte, 32)), nil
}
return nil, xerrors.Errorf("failed to lookup contract %s: %w", ethAddr, err)
@ -734,7 +734,7 @@ func (a *EthModule) EthGetBalance(ctx context.Context, address ethtypes.EthAddre
}
actor, err := a.StateManager.LoadActorRaw(ctx, filAddr, st)
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return ethtypes.EthBigIntZero, nil
} else if err != nil {
return ethtypes.EthBigInt{}, err

View File

@ -487,7 +487,7 @@ func (m *StateModule) StateLookupID(ctx context.Context, addr address.Address, t
}
ret, err := m.StateManager.LookupIDAddress(ctx, addr, ts)
if err != nil && xerrors.Is(err, types.ErrActorNotFound) {
if err != nil && errors.Is(err, types.ErrActorNotFound) {
return address.Undef, &api.ErrActorNotFound{}
}
@ -1223,7 +1223,7 @@ func (a *StateAPI) StateListMessages(ctx context.Context, match *api.MessageMatc
_, err := a.StateLookupID(ctx, match.To, tsk)
// if the recipient doesn't exist at the start point, we're not gonna find any matches
if xerrors.Is(err, &api.ErrActorNotFound{}) {
if errors.Is(err, &api.ErrActorNotFound{}) {
return nil, nil
}
@ -1234,7 +1234,7 @@ func (a *StateAPI) StateListMessages(ctx context.Context, match *api.MessageMatc
_, err := a.StateLookupID(ctx, match.From, tsk)
// if the sender doesn't exist at the start point, we're not gonna find any matches
if xerrors.Is(err, &api.ErrActorNotFound{}) {
if errors.Is(err, &api.ErrActorNotFound{}) {
return nil, nil
}

View File

@ -2,6 +2,7 @@ package full
import (
"context"
"errors"
"go.uber.org/fx"
"golang.org/x/xerrors"
@ -28,7 +29,7 @@ type WalletAPI struct {
func (a *WalletAPI) WalletBalance(ctx context.Context, addr address.Address) (types.BigInt, error) {
act, err := a.StateManagerAPI.LoadActorTsk(ctx, addr, types.EmptyTSK)
if xerrors.Is(err, types.ErrActorNotFound) {
if errors.Is(err, types.ErrActorNotFound) {
return big.Zero(), nil
} else if err != nil {
return big.Zero(), err

View File

@ -2,6 +2,7 @@ package lp2p
import (
"crypto/rand"
"errors"
"time"
logging "github.com/ipfs/go-log/v2"
@ -35,7 +36,7 @@ func PrivKey(ks types.KeyStore) (crypto.PrivKey, error) {
if err == nil {
return crypto.UnmarshalPrivateKey(k.PrivateKey)
}
if !xerrors.Is(err, types.ErrKeyInfoNotFound) {
if !errors.Is(err, types.ErrKeyInfoNotFound) {
return nil, err
}
pk, err := genLibp2pKey()

View File

@ -2,12 +2,12 @@
package repo
import (
"errors"
"testing"
"github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/config"
@ -96,7 +96,7 @@ func basicTest(t *testing.T, repo Repo) {
err = kstr.Put("k1", k1)
if assert.Error(t, err, "putting key under the same name should error") {
assert.True(t, xerrors.Is(err, types.ErrKeyExists), "returned error is ErrKeyExists")
assert.True(t, errors.Is(err, types.ErrKeyExists), "returned error is ErrKeyExists")
}
k1prim, err := kstr.Get("k1")
@ -105,7 +105,7 @@ func basicTest(t *testing.T, repo Repo) {
k2prim, err := kstr.Get("k2")
if assert.Error(t, err, "should not be able to get k2") {
assert.True(t, xerrors.Is(err, types.ErrKeyInfoNotFound), "returned error is ErrKeyNotFound")
assert.True(t, errors.Is(err, types.ErrKeyInfoNotFound), "returned error is ErrKeyNotFound")
}
assert.Empty(t, k2prim, "there should be no output for k2")
@ -125,6 +125,6 @@ func basicTest(t *testing.T, repo Repo) {
err = kstr.Delete("k2")
if assert.Error(t, err) {
assert.True(t, xerrors.Is(err, types.ErrKeyInfoNotFound), "returned errror is ErrKeyNotFound")
assert.True(t, errors.Is(err, types.ErrKeyInfoNotFound), "returned errror is ErrKeyNotFound")
}
}

View File

@ -2,6 +2,7 @@ package paychmgr
import (
"context"
"errors"
"fmt"
"github.com/ipfs/go-cid"
@ -148,7 +149,7 @@ func (ca *channelAccessor) createVoucher(ctx context.Context, ch address.Address
// If there are not enough funds in the channel to cover the voucher,
// return a voucher create result with the shortfall
var ife insufficientFundsErr
if xerrors.As(err, &ife) {
if errors.As(err, &ife) {
return &api.VoucherCreateResult{
Shortfall: ife.Shortfall(),
}, nil

View File

@ -3,6 +3,7 @@ package sealing
import (
"bytes"
"context"
"errors"
"net/url"
"github.com/ipfs/go-cid"
@ -62,7 +63,7 @@ func (m *Sealing) checkSectorMeta(ctx context.Context, meta api.RemoteSectorMeta
{
// initial sanity check, doesn't prevent races
_, err := m.GetSectorInfo(meta.Sector.Number)
if err != nil && !xerrors.Is(err, datastore.ErrNotFound) {
if err != nil && !errors.Is(err, datastore.ErrNotFound) {
return SectorInfo{}, err
}
if err == nil {

View File

@ -419,7 +419,7 @@ func (sb *Sealer) pieceCid(spt abi.RegisteredSealProof, in []byte) (cid.Cid, err
func (sb *Sealer) acquireUpdatePath(ctx context.Context, sector storiface.SectorRef) (string, func(), error) {
// copy so that the sector doesn't get removed from a long-term storage path
replicaPath, releaseSector, err := sb.sectors.AcquireSectorCopy(ctx, sector, storiface.FTUpdate, storiface.FTNone, storiface.PathSealing)
if xerrors.Is(err, storiface.ErrSectorNotFound) {
if errors.Is(err, storiface.ErrSectorNotFound) {
return "", releaseSector, nil
} else if err != nil {
return "", releaseSector, xerrors.Errorf("reading updated replica: %w", err)
@ -471,7 +471,7 @@ func (sb *Sealer) acquireSectorKeyOrRegenerate(ctx context.Context, sector stori
paths, done, err := sb.sectors.AcquireSectorCopy(ctx, sector, storiface.FTSealed|storiface.FTCache, storiface.FTNone, storiface.PathSealing)
if err == nil {
return paths, done, err
} else if !xerrors.Is(err, storiface.ErrSectorNotFound) {
} else if !errors.Is(err, storiface.ErrSectorNotFound) {
return paths, done, xerrors.Errorf("reading sector key: %w", err)
}
@ -575,7 +575,7 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector storiface.SectorRef, o
var pf *partialfile.PartialFile
switch {
case xerrors.Is(err, storiface.ErrSectorNotFound):
case errors.Is(err, storiface.ErrSectorNotFound):
// allocate if doesn't exist
unsealedPath, done, err = sb.sectors.AcquireSector(ctx, sector, storiface.FTNone, storiface.FTUnsealed, storiface.PathSealing)
if err != nil {
@ -774,7 +774,7 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector storif
pf, err := partialfile.OpenPartialFile(maxPieceSize, path.Unsealed)
if err != nil {
if xerrors.Is(err, os.ErrNotExist) {
if errors.Is(err, os.ErrNotExist) {
return false, nil
}
@ -1183,7 +1183,7 @@ func (sb *Sealer) ReleaseUnsealed(ctx context.Context, sector storiface.SectorRe
return err
}
} else {
if !xerrors.Is(err, os.ErrNotExist) {
if !errors.Is(err, os.ErrNotExist) {
return xerrors.Errorf("opening partial file: %w", err)
}
}

View File

@ -3,6 +3,7 @@ package sealer
import (
"bufio"
"context"
"errors"
"io"
"sync"
@ -178,7 +179,7 @@ func (p *pieceProvider) ReadPiece(ctx context.Context, sector storiface.SectorRe
r, err := p.tryReadUnsealedPiece(ctx, unsealed, sector, pieceOffset, size)
if xerrors.Is(err, storiface.ErrSectorNotFound) {
if errors.Is(err, storiface.ErrSectorNotFound) {
log.Debugf("no unsealed sector file with unsealed piece, sector=%+v, pieceOffset=%d, size=%d", sector, pieceOffset, size)
err = nil
}

View File

@ -3,6 +3,7 @@ package sealer
import (
"context"
"encoding/json"
"errors"
"io"
"os"
"reflect"
@ -312,7 +313,7 @@ func (l *LocalWorker) asyncCall(ctx context.Context, sector storiface.SectorRef,
func toCallError(err error) *storiface.CallError {
var serr *storiface.CallError
if err != nil && !xerrors.As(err, &serr) {
if err != nil && !errors.As(err, &serr) {
serr = storiface.Err(storiface.ErrUnknown, err)
}