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: market: upgrade index-provider and related dependencies #8890

Closed
wants to merge 6 commits into from
Closed
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
5 changes: 3 additions & 2 deletions blockstore/autobatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
"golang.org/x/xerrors"
)

Expand Down Expand Up @@ -175,7 +176,7 @@ func (bs *AutobatchBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block,
return blk, nil
}

if err != ErrNotFound {
if !ipld.IsNotFound(err) {
return blk, err
}

Expand Down Expand Up @@ -213,7 +214,7 @@ func (bs *AutobatchBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error)
if err == nil {
return true, nil
}
if err == ErrNotFound {
if ipld.IsNotFound(err) {
return false, nil
}

Expand Down
9 changes: 5 additions & 4 deletions blockstore/badger/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/dgraph-io/badger/v2/pb"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
logger "github.com/ipfs/go-log/v2"
pool "github.com/libp2p/go-buffer-pool"
"github.com/multiformats/go-base32"
Expand Down Expand Up @@ -543,7 +544,7 @@ func (b *Blockstore) View(ctx context.Context, cid cid.Cid, fn func([]byte) erro
case nil:
return item.Value(fn)
case badger.ErrKeyNotFound:
return blockstore.ErrNotFound
return ipld.ErrNotFound{Cid: cid}
default:
return fmt.Errorf("failed to view block from badger blockstore: %w", err)
}
Expand Down Expand Up @@ -583,7 +584,7 @@ func (b *Blockstore) Has(ctx context.Context, cid cid.Cid) (bool, error) {
// Get implements Blockstore.Get.
func (b *Blockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error) {
if !cid.Defined() {
return nil, blockstore.ErrNotFound
return nil, ipld.ErrNotFound{Cid: cid}
}

if err := b.access(); err != nil {
Expand All @@ -606,7 +607,7 @@ func (b *Blockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)
val, err = item.ValueCopy(nil)
return err
case badger.ErrKeyNotFound:
return blockstore.ErrNotFound
return ipld.ErrNotFound{Cid: cid}
default:
return fmt.Errorf("failed to get block from badger blockstore: %w", err)
}
Expand Down Expand Up @@ -638,7 +639,7 @@ func (b *Blockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error) {
case nil:
size = int(item.ValueSize())
case badger.ErrKeyNotFound:
return blockstore.ErrNotFound
return ipld.ErrNotFound{Cid: cid}
default:
return fmt.Errorf("failed to get block size from badger blockstore: %w", err)
}
Expand Down
10 changes: 6 additions & 4 deletions blockstore/badger/blockstore_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
u "github.com/ipfs/go-ipfs-util"
ipld "github.com/ipfs/go-ipld-format"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/lotus/blockstore"
Expand Down Expand Up @@ -55,7 +56,7 @@ func (s *Suite) TestGetWhenKeyNotPresent(t *testing.T) {
c := cid.NewCidV0(u.Hash([]byte("stuff")))
bl, err := bs.Get(ctx, c)
require.Nil(t, bl)
require.Equal(t, blockstore.ErrNotFound, err)
require.Equal(t, ipld.ErrNotFound{Cid: c}, err)
}

func (s *Suite) TestGetWhenKeyIsNil(t *testing.T) {
Expand All @@ -68,7 +69,7 @@ func (s *Suite) TestGetWhenKeyIsNil(t *testing.T) {
}

_, err := bs.Get(ctx, cid.Undef)
require.Equal(t, blockstore.ErrNotFound, err)
require.Equal(t, ipld.ErrNotFound{Cid: cid.Undef}, err)
}

func (s *Suite) TestPutThenGetBlock(t *testing.T) {
Expand Down Expand Up @@ -163,8 +164,9 @@ func (s *Suite) TestPutThenGetSizeBlock(t *testing.T) {
require.NoError(t, err)
require.Zero(t, emptySize)

missingSize, err := bs.GetSize(ctx, missingBlock.Cid())
require.Equal(t, blockstore.ErrNotFound, err)
missingCid := missingBlock.Cid()
missingSize, err := bs.GetSize(ctx, missingCid)
require.Equal(t, ipld.ErrNotFound{Cid: missingCid}, err)
require.Equal(t, -1, missingSize)
}

Expand Down
2 changes: 0 additions & 2 deletions blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (

var log = logging.Logger("blockstore")

var ErrNotFound = blockstore.ErrNotFound

// Blockstore is the blockstore interface used by Lotus. It is the union
// of the basic go-ipfs blockstore, with other capabilities required by Lotus,
// e.g. View or Sync.
Expand Down
7 changes: 4 additions & 3 deletions blockstore/buffered.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
)

// buflog is a logger for the buffered blockstore. It is subscoped from the
Expand Down Expand Up @@ -106,7 +107,7 @@ func (bs *BufferedBlockstore) DeleteMany(ctx context.Context, cids []cid.Cid) er

func (bs *BufferedBlockstore) View(ctx context.Context, c cid.Cid, callback func([]byte) error) error {
// both stores are viewable.
if err := bs.write.View(ctx, c, callback); err == ErrNotFound {
if err := bs.write.View(ctx, c, callback); ipld.IsNotFound(err) {
// not found in write blockstore; fall through.
} else {
return err // propagate errors, or nil, i.e. found.
Expand All @@ -116,7 +117,7 @@ func (bs *BufferedBlockstore) View(ctx context.Context, c cid.Cid, callback func

func (bs *BufferedBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block, error) {
if out, err := bs.write.Get(ctx, c); err != nil {
if err != ErrNotFound {
if !ipld.IsNotFound(err) {
return nil, err
}
} else {
Expand All @@ -128,7 +129,7 @@ func (bs *BufferedBlockstore) Get(ctx context.Context, c cid.Cid) (block.Block,

func (bs *BufferedBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
s, err := bs.read.GetSize(ctx, c)
if err == ErrNotFound || s == 0 {
if ipld.IsNotFound(err) || s == 0 {
return bs.write.GetSize(ctx, c)
}

Expand Down
15 changes: 8 additions & 7 deletions blockstore/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
"golang.org/x/xerrors"
)

Expand Down Expand Up @@ -55,7 +56,7 @@ func (fbs *FallbackStore) getFallback(c cid.Cid) (blocks.Block, error) {

if fbs.missFn == nil {
log.Errorw("fallbackstore: missFn not configured yet")
return nil, ErrNotFound
return nil, ipld.ErrNotFound{Cid: c}
}
}

Expand All @@ -78,10 +79,10 @@ func (fbs *FallbackStore) getFallback(c cid.Cid) (blocks.Block, error) {

func (fbs *FallbackStore) Get(ctx context.Context, c cid.Cid) (blocks.Block, error) {
b, err := fbs.Blockstore.Get(ctx, c)
switch err {
case nil:
switch {
case err == nil:
return b, nil
case ErrNotFound:
case ipld.IsNotFound(err):
return fbs.getFallback(c)
default:
return b, err
Expand All @@ -90,10 +91,10 @@ func (fbs *FallbackStore) Get(ctx context.Context, c cid.Cid) (blocks.Block, err

func (fbs *FallbackStore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
sz, err := fbs.Blockstore.GetSize(ctx, c)
switch err {
case nil:
switch {
case err == nil:
return sz, nil
case ErrNotFound:
case ipld.IsNotFound(err):
b, err := fbs.getFallback(c)
if err != nil {
return 0, err
Expand Down
2 changes: 1 addition & 1 deletion blockstore/ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (i *IPFSBlockstore) Put(ctx context.Context, block blocks.Block) error {

_, err = i.api.Block().Put(ctx, bytes.NewReader(block.RawData()),
options.Block.Hash(mhd.Code, mhd.Length),
options.Block.Format(cid.CodecToStr[block.Cid().Type()]))
options.Block.Format(multihash.Codes[block.Cid().Type()]))
return err
}

Expand Down
7 changes: 4 additions & 3 deletions blockstore/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
)

// NewMemory returns a temporary memory-backed blockstore.
Expand Down Expand Up @@ -35,15 +36,15 @@ func (m MemBlockstore) Has(ctx context.Context, k cid.Cid) (bool, error) {
func (m MemBlockstore) View(ctx context.Context, k cid.Cid, callback func([]byte) error) error {
b, ok := m[k]
if !ok {
return ErrNotFound
return ipld.ErrNotFound{Cid: k}
}
return callback(b.RawData())
}

func (m MemBlockstore) Get(ctx context.Context, k cid.Cid) (blocks.Block, error) {
b, ok := m[k]
if !ok {
return nil, ErrNotFound
return nil, ipld.ErrNotFound{Cid: k}
}
return b, nil
}
Expand All @@ -52,7 +53,7 @@ func (m MemBlockstore) Get(ctx context.Context, k cid.Cid) (blocks.Block, error)
func (m MemBlockstore) GetSize(ctx context.Context, k cid.Cid) (int, error) {
b, ok := m[k]
if !ok {
return 0, ErrNotFound
return 0, ipld.ErrNotFound{Cid: k}
}
return len(b.RawData()), nil
}
Expand Down
20 changes: 9 additions & 11 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
dstore "github.com/ipfs/go-datastore"
ipld "github.com/ipfs/go-ipld-format"
logging "github.com/ipfs/go-log/v2"
"go.opencensus.io/stats"
"go.uber.org/multierr"
Expand Down Expand Up @@ -312,12 +313,12 @@ func (s *SplitStore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)

blk, err := s.hot.Get(ctx, cid)

switch err {
case nil:
switch {
case err == nil:
s.trackTxnRef(cid)
return blk, nil

case bstore.ErrNotFound:
case ipld.IsNotFound(err):
if s.isWarm() {
s.debug.LogReadMiss(cid)
}
Expand Down Expand Up @@ -366,12 +367,12 @@ func (s *SplitStore) GetSize(ctx context.Context, cid cid.Cid) (int, error) {

size, err := s.hot.GetSize(ctx, cid)

switch err {
case nil:
switch {
case err == nil:
s.trackTxnRef(cid)
return size, nil

case bstore.ErrNotFound:
case ipld.IsNotFound(err):
if s.isWarm() {
s.debug.LogReadMiss(cid)
}
Expand Down Expand Up @@ -551,8 +552,7 @@ func (s *SplitStore) View(ctx context.Context, cid cid.Cid, cb func([]byte) erro
defer s.viewDone()

err := s.hot.View(ctx, cid, cb)
switch err {
case bstore.ErrNotFound:
if ipld.IsNotFound(err) {
if s.isWarm() {
s.debug.LogReadMiss(cid)
}
Expand All @@ -566,10 +566,8 @@ func (s *SplitStore) View(ctx context.Context, cid cid.Cid, cb func([]byte) erro
stats.Record(s.ctx, metrics.SplitstoreMiss.M(1))
}
return err

default:
return err
}
return err
}

func (s *SplitStore) isWarm() bool {
Expand Down
23 changes: 10 additions & 13 deletions blockstore/splitstore/splitstore_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
cbg "github.com/whyrusleeping/cbor-gen"
"go.opencensus.io/stats"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-state-types/abi"

bstore "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/metrics"
Expand Down Expand Up @@ -1064,13 +1064,10 @@ func (s *SplitStore) view(c cid.Cid, cb func([]byte) error) error {
}

err := s.hot.View(s.ctx, c, cb)
switch err {
case bstore.ErrNotFound:
if ipld.IsNotFound(err) {
return s.cold.View(s.ctx, c, cb)

default:
return err
}
return err
}

func (s *SplitStore) has(c cid.Cid) (bool, error) {
Expand All @@ -1089,10 +1086,10 @@ func (s *SplitStore) has(c cid.Cid) (bool, error) {

func (s *SplitStore) get(c cid.Cid) (blocks.Block, error) {
blk, err := s.hot.Get(s.ctx, c)
switch err {
case nil:
switch {
case err == nil:
return blk, nil
case bstore.ErrNotFound:
case ipld.IsNotFound(err):
return s.cold.Get(s.ctx, c)
default:
return nil, err
Expand All @@ -1101,10 +1098,10 @@ func (s *SplitStore) get(c cid.Cid) (blocks.Block, error) {

func (s *SplitStore) getSize(c cid.Cid) (int, error) {
sz, err := s.hot.GetSize(s.ctx, c)
switch err {
case nil:
switch {
case err == nil:
return sz, nil
case bstore.ErrNotFound:
case ipld.IsNotFound(err):
return s.cold.GetSize(s.ctx, c)
default:
return 0, err
Expand All @@ -1121,7 +1118,7 @@ func (s *SplitStore) moveColdBlocks(coldr *ColdSetReader) error {

blk, err := s.hot.Get(s.ctx, c)
if err != nil {
if err == bstore.ErrNotFound {
if ipld.IsNotFound(err) {
log.Warnf("hotstore missing block %s", c)
return nil
}
Expand Down
Loading