diff --git a/blockstore/ipfs.go b/blockstore/ipfs.go deleted file mode 100644 index f0606519f..000000000 --- a/blockstore/ipfs.go +++ /dev/null @@ -1,154 +0,0 @@ -package blockstore - -import ( - "bytes" - "context" - "io" - - "github.com/ipfs/boxo/path" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" - "github.com/multiformats/go-multiaddr" - "github.com/multiformats/go-multihash" - "golang.org/x/xerrors" - - rpc "github.com/filecoin-project/kubo-api-client" - iface "github.com/filecoin-project/kubo-api-client/coreiface" - "github.com/filecoin-project/kubo-api-client/coreiface/options" -) - -type IPFSBlockstore struct { - ctx context.Context - api, offlineAPI iface.CoreAPI -} - -var _ BasicBlockstore = (*IPFSBlockstore)(nil) - -func NewLocalIPFSBlockstore(ctx context.Context, onlineMode bool) (Blockstore, error) { - localApi, err := rpc.NewLocalApi() - if err != nil { - return nil, xerrors.Errorf("getting local ipfs api: %w", err) - } - api, err := localApi.WithOptions(options.Api.Offline(!onlineMode)) - if err != nil { - return nil, xerrors.Errorf("setting offline mode: %s", err) - } - - offlineAPI := api - if onlineMode { - offlineAPI, err = localApi.WithOptions(options.Api.Offline(true)) - if err != nil { - return nil, xerrors.Errorf("applying offline mode: %s", err) - } - } - - bs := &IPFSBlockstore{ - ctx: ctx, - api: api, - offlineAPI: offlineAPI, - } - - return Adapt(bs), nil -} - -func NewRemoteIPFSBlockstore(ctx context.Context, maddr multiaddr.Multiaddr, onlineMode bool) (Blockstore, error) { - httpApi, err := rpc.NewApi(maddr) - if err != nil { - return nil, xerrors.Errorf("setting remote ipfs api: %w", err) - } - api, err := httpApi.WithOptions(options.Api.Offline(!onlineMode)) - if err != nil { - return nil, xerrors.Errorf("applying offline mode: %s", err) - } - - offlineAPI := api - if onlineMode { - offlineAPI, err = httpApi.WithOptions(options.Api.Offline(true)) - if err != nil { - return nil, xerrors.Errorf("applying offline mode: %s", err) - } - } - - bs := &IPFSBlockstore{ - ctx: ctx, - api: api, - offlineAPI: offlineAPI, - } - - return Adapt(bs), nil -} - -func (i *IPFSBlockstore) DeleteBlock(ctx context.Context, cid cid.Cid) error { - return xerrors.Errorf("not supported") -} - -func (i *IPFSBlockstore) Has(ctx context.Context, cid cid.Cid) (bool, error) { - _, err := i.offlineAPI.Block().Stat(ctx, path.FromCid(cid)) - if err != nil { - // The underlying client is running in Offline mode. - // Stat() will fail with an err if the block isn't in the - // blockstore. If that's the case, return false without - // an error since that's the original intention of this method. - if err.Error() == "blockservice: key not found" { - return false, nil - } - return false, xerrors.Errorf("getting ipfs block: %w", err) - } - - return true, nil -} - -func (i *IPFSBlockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error) { - rd, err := i.api.Block().Get(ctx, path.FromCid(cid)) - if err != nil { - return nil, xerrors.Errorf("getting ipfs block: %w", err) - } - - data, err := io.ReadAll(rd) - if err != nil { - return nil, err - } - - return blocks.NewBlockWithCid(data, cid) -} - -func (i *IPFSBlockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error) { - st, err := i.api.Block().Stat(ctx, path.FromCid(cid)) - if err != nil { - return 0, xerrors.Errorf("getting ipfs block: %w", err) - } - - return st.Size(), nil -} - -func (i *IPFSBlockstore) Put(ctx context.Context, block blocks.Block) error { - mhd, err := multihash.Decode(block.Cid().Hash()) - if err != nil { - return err - } - - _, err = i.api.Block().Put(ctx, bytes.NewReader(block.RawData()), - options.Block.Hash(mhd.Code, mhd.Length), - options.Block.Format(multihash.Codes[block.Cid().Type()])) - return err -} - -func (i *IPFSBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error { - // TODO: could be done in parallel - - for _, block := range blocks { - if err := i.Put(ctx, block); err != nil { - return err - } - } - - return nil -} - -func (i *IPFSBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) { - return nil, xerrors.Errorf("not supported") -} - -func (i *IPFSBlockstore) HashOnRead(enabled bool) { - return // TODO: We could technically support this, but.. -} diff --git a/documentation/en/default-lotus-config.toml b/documentation/en/default-lotus-config.toml index 85ce178ce..8d3c6a427 100644 --- a/documentation/en/default-lotus-config.toml +++ b/documentation/en/default-lotus-config.toml @@ -129,22 +129,6 @@ [Client] - # type: bool - # env var: LOTUS_CLIENT_USEIPFS - #UseIpfs = false - - # type: bool - # env var: LOTUS_CLIENT_IPFSONLINEMODE - #IpfsOnlineMode = false - - # type: string - # env var: LOTUS_CLIENT_IPFSMADDR - #IpfsMAddr = "" - - # type: bool - # env var: LOTUS_CLIENT_IPFSUSEFORRETRIEVAL - #IpfsUseForRetrieval = false - # The maximum number of simultaneous data transfers between the client # and storage providers for storage deals # diff --git a/go.mod b/go.mod index 6fe41e67f..bb1b33aef 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,6 @@ require ( github.com/filecoin-project/go-statemachine v1.0.3 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-storedcounter v0.1.0 - github.com/filecoin-project/kubo-api-client v0.27.0 github.com/filecoin-project/pubsub v1.0.0 github.com/filecoin-project/specs-actors v0.9.15 github.com/filecoin-project/specs-actors/v2 v2.3.6 @@ -184,7 +183,6 @@ require ( github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bep/debounce v1.2.1 // indirect - github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cilium/ebpf v0.9.1 // indirect @@ -233,7 +231,6 @@ require ( github.com/ipfs/go-bitfield v1.1.0 // indirect github.com/ipfs/go-blockservice v0.5.1 // indirect github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect - github.com/ipfs/go-ipfs-cmds v0.10.0 // indirect github.com/ipfs/go-ipfs-delay v0.0.1 // indirect github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect @@ -302,7 +299,6 @@ require ( github.com/quic-go/quic-go v0.42.0 // indirect github.com/quic-go/webtransport-go v0.6.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect - github.com/rs/cors v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil v2.18.12+incompatible // indirect github.com/sirupsen/logrus v1.9.2 // indirect @@ -311,7 +307,6 @@ require ( github.com/twmb/murmur3 v1.1.6 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.0.1 // indirect - github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect diff --git a/go.sum b/go.sum index 228c83a78..0107afce8 100644 --- a/go.sum +++ b/go.sum @@ -122,8 +122,6 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= -github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= @@ -363,8 +361,6 @@ github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNd github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo= github.com/filecoin-project/go-storedcounter v0.1.0 h1:Mui6wSUBC+cQGHbDUBcO7rfh5zQkWJM/CpAZa/uOuus= github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8= -github.com/filecoin-project/kubo-api-client v0.27.0 h1:rQNbReJCCQ8L107VIQR0qjAlEqdDQRYOhDKYcKGcnPI= -github.com/filecoin-project/kubo-api-client v0.27.0/go.mod h1:1+geFlaV8oJRJ4IlVTqL3QC3T1f5N0aGSptErrtcMQs= github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM= github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg= github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= @@ -748,8 +744,6 @@ github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtL github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw= github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7NapWLY8= github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8= -github.com/ipfs/go-ipfs-cmds v0.10.0 h1:ZB4+RgYaH4UARfJY0uLKl5UXgApqnRjKbuCiJVcErYk= -github.com/ipfs/go-ipfs-cmds v0.10.0/go.mod h1:sX5d7jkCft9XLPnkgEfXY0z2UBOB5g6fh/obBS0enJE= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ= github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= @@ -1510,8 +1504,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= -github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.21.0/go.mod h1:ZPhntP/xmq1nnND05hhpAh2QMhSsA4UN3MGZ6O2J3hM= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -1664,8 +1656,6 @@ github.com/weaveworks/common v0.0.0-20230531151736-e2613bee6b73 h1:CMM9+/AgM77va github.com/weaveworks/common v0.0.0-20230531151736-e2613bee6b73/go.mod h1:rgbeLfJUtEr+G74cwFPR1k/4N0kDeaeSv/qhUNE4hm8= github.com/weaveworks/promrus v1.2.0 h1:jOLf6pe6/vss4qGHjXmGz4oDJQA+AOCqEL3FvvZGz7M= github.com/weaveworks/promrus v1.2.0/go.mod h1:SaE82+OJ91yqjrE1rsvBWVzNZKcHYFtMUyS1+Ogs/KA= -github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboadS0DvysUuJXZ4lWVv5Bh5i7+tbIyi+ck4= -github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM= github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba h1:X4n8JG2e2biEZZXdBKt9HX7DN3bYGFUqljqqy0DqgnY= github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba/go.mod h1:CHQnYnQUEPydYCwuy8lmTHfGmdw9TKrhWV0xLx8l0oM= github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 h1:5HZfQkwe0mIfyDmc1Em5GqlNRzcdtlv4HTNmdpt7XH0= diff --git a/node/builder_chain.go b/node/builder_chain.go index 73c9cfb18..0b40e4530 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -183,7 +183,6 @@ func ConfigFullNode(c interface{}) Option { enableLibp2pNode := true // always enable libp2p for full nodes - ipfsMaddr := cfg.Client.IpfsMAddr return Options( ConfigCommon(&cfg.Common, enableLibp2pNode), @@ -229,13 +228,6 @@ func ConfigFullNode(c interface{}) Option { Override(new(dtypes.ClientBlockstore), modules.ClientBlockstore), - If(cfg.Client.UseIpfs, - Override(new(dtypes.ClientBlockstore), modules.IpfsClientBlockstore(ipfsMaddr, cfg.Client.IpfsOnlineMode)), - Override(new(storagemarket.BlockstoreAccessor), modules.IpfsStorageBlockstoreAccessor), - If(cfg.Client.IpfsUseForRetrieval, - Override(new(retrievalmarket.BlockstoreAccessor), modules.IpfsRetrievalBlockstoreAccessor), - ), - ), Override(new(dtypes.Graphsync), modules.Graphsync(cfg.Client.SimultaneousTransfersForStorage, cfg.Client.SimultaneousTransfersForRetrieval)), Override(new(retrievalmarket.RetrievalClient), modules.RetrievalClient(cfg.Client.OffChainRetrieval)), diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 9a4b91c4a..e9bfb6fba 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -86,30 +86,6 @@ your node if metadata log is disabled`, }, }, "Client": { - { - Name: "UseIpfs", - Type: "bool", - - Comment: ``, - }, - { - Name: "IpfsOnlineMode", - Type: "bool", - - Comment: ``, - }, - { - Name: "IpfsMAddr", - Type: "string", - - Comment: ``, - }, - { - Name: "IpfsUseForRetrieval", - Type: "bool", - - Comment: ``, - }, { Name: "SimultaneousTransfersForStorage", Type: "uint64", diff --git a/node/config/types.go b/node/config/types.go index 6d782fba4..d133fcadd 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -940,10 +940,6 @@ type Splitstore struct { // // Full Node type Client struct { - UseIpfs bool - IpfsOnlineMode bool - IpfsMAddr string - IpfsUseForRetrieval bool // The maximum number of simultaneous data transfers between the client // and storage providers for storage deals SimultaneousTransfersForStorage uint64 diff --git a/node/modules/ipfs.go b/node/modules/ipfs.go deleted file mode 100644 index cb9deb6fd..000000000 --- a/node/modules/ipfs.go +++ /dev/null @@ -1,50 +0,0 @@ -package modules - -import ( - bstore "github.com/ipfs/boxo/blockstore" - "github.com/multiformats/go-multiaddr" - "go.uber.org/fx" - "golang.org/x/xerrors" - - "github.com/filecoin-project/go-fil-markets/retrievalmarket" - "github.com/filecoin-project/go-fil-markets/storagemarket" - - "github.com/filecoin-project/lotus/blockstore" - "github.com/filecoin-project/lotus/markets/retrievaladapter" - "github.com/filecoin-project/lotus/markets/storageadapter" - "github.com/filecoin-project/lotus/node/modules/dtypes" - "github.com/filecoin-project/lotus/node/modules/helpers" -) - -func IpfsStorageBlockstoreAccessor(ipfsBlockstore dtypes.ClientBlockstore) storagemarket.BlockstoreAccessor { - return storageadapter.NewFixedBlockstoreAccessor(bstore.Blockstore(ipfsBlockstore)) -} - -func IpfsRetrievalBlockstoreAccessor(ipfsBlockstore dtypes.ClientBlockstore) retrievalmarket.BlockstoreAccessor { - return retrievaladapter.NewFixedBlockstoreAccessor(bstore.Blockstore(ipfsBlockstore)) -} - -// IpfsClientBlockstore returns a ClientBlockstore implementation backed by an IPFS node. -// If ipfsMaddr is empty, a local IPFS node is assumed considering IPFS_PATH configuration. -// If ipfsMaddr is not empty, it will connect to the remote IPFS node with the provided multiaddress. -// The flag useForRetrieval indicates if the IPFS node will also be used for storing retrieving deals. -func IpfsClientBlockstore(ipfsMaddr string, onlineMode bool) func(helpers.MetricsCtx, fx.Lifecycle, dtypes.ClientImportMgr) (dtypes.ClientBlockstore, error) { - return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, localStore dtypes.ClientImportMgr) (dtypes.ClientBlockstore, error) { - var err error - var ipfsbs blockstore.BasicBlockstore - if ipfsMaddr != "" { - var ma multiaddr.Multiaddr - ma, err = multiaddr.NewMultiaddr(ipfsMaddr) - if err != nil { - return nil, xerrors.Errorf("parsing ipfs multiaddr: %w", err) - } - ipfsbs, err = blockstore.NewRemoteIPFSBlockstore(helpers.LifecycleCtx(mctx, lc), ma, onlineMode) - } else { - ipfsbs, err = blockstore.NewLocalIPFSBlockstore(helpers.LifecycleCtx(mctx, lc), onlineMode) - } - if err != nil { - return nil, xerrors.Errorf("constructing ipfs blockstore: %w", err) - } - return blockstore.WrapIDStore(ipfsbs), nil - } -} diff --git a/node/repo/repo_test.go b/node/repo/repo_test.go index c78afa9db..6390fe7d2 100644 --- a/node/repo/repo_test.go +++ b/node/repo/repo_test.go @@ -56,7 +56,7 @@ func basicTest(t *testing.T, repo Repo) { // mutate config and persist back to repo err = lrepo.SetConfig(func(c interface{}) { cfg := c.(*config.FullNode) - cfg.Client.IpfsMAddr = "duvall" + cfg.FaultReporter.ConsensusFaultReporterAddress = "duvall" }) assert.NoError(t, err) @@ -64,7 +64,7 @@ func basicTest(t *testing.T, repo Repo) { c2, err := lrepo.Config() require.NoError(t, err) cfg2 := c2.(*config.FullNode) - require.Equal(t, cfg2.Client.IpfsMAddr, "duvall") + require.Equal(t, cfg2.FaultReporter.ConsensusFaultReporterAddress, "duvall") err = lrepo.Close() assert.NoError(t, err, "should be able to close")