From 6c15199683d3b67304e1e862b4b998c0b20330e7 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Wed, 24 Aug 2022 16:17:28 +0200 Subject: [PATCH] refactor: clean up unused vars etc --- api/api.go | 7 +- api/proxy_gen.go | 52 +++++++++++---- build/openrpc/boost.json.gz | Bin 4922 -> 5070 bytes .../remoteblockstore/remoteblockstore.go | 44 +++++------- cmd/booster-bitswap/run.go | 28 +------- cmd/booster-bitswap/server.go | 8 +-- documentation/en/api-v1-methods.md | 63 +++++++++++++++--- go.mod | 1 - go.sum | 1 - node/config/doc_gen.go | 31 +++++++++ node/impl/boost.go | 10 ++- 11 files changed, 160 insertions(+), 85 deletions(-) diff --git a/api/api.go b/api/api.go index cc550f9d2..b86eb0557 100644 --- a/api/api.go +++ b/api/api.go @@ -47,7 +47,12 @@ type Boost interface { BoostDagstoreGC(ctx context.Context) ([]DagstoreShardResult, error) //perm:admin BoostDagstorePiecesContainingMultihash(ctx context.Context, mh multihash.Multihash) ([]cid.Cid, error) //perm:read BoostDagstoreListShards(ctx context.Context) ([]DagstoreShardInfo, error) //perm:read - BoostGetBlock(ctx context.Context, c cid.Cid) ([]byte, error) //perm:read + + // MethodGroup: Blockstore + BlockstoreGet(ctx context.Context, c cid.Cid) ([]byte, error) //perm:read + BlockstoreHas(ctx context.Context, c cid.Cid) (bool, error) //perm:read + BlockstoreGetSize(ctx context.Context, c cid.Cid) (int, error) //perm:read + // RuntimeSubsystems returns the subsystems that are enabled // in this instance. RuntimeSubsystems(ctx context.Context) (lapi.MinerSubsystems, error) //perm:read diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 8b56db2dc..03f23469f 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -38,6 +38,12 @@ type BoostStruct struct { Internal struct { ActorSectorSize func(p0 context.Context, p1 address.Address) (abi.SectorSize, error) `perm:"read"` + BlockstoreGet func(p0 context.Context, p1 cid.Cid) ([]byte, error) `perm:"read"` + + BlockstoreGetSize func(p0 context.Context, p1 cid.Cid) (int, error) `perm:"read"` + + BlockstoreHas func(p0 context.Context, p1 cid.Cid) (bool, error) `perm:"read"` + BoostDagstoreDestroyShard func(p0 context.Context, p1 string) error `perm:"admin"` BoostDagstoreGC func(p0 context.Context) ([]DagstoreShardResult, error) `perm:"admin"` @@ -60,8 +66,6 @@ type BoostStruct struct { BoostDummyDeal func(p0 context.Context, p1 smtypes.DealParams) (*ProviderDealRejectionInfo, error) `perm:"admin"` - BoostGetBlock func(p0 context.Context, p1 cid.Cid) ([]byte, error) `perm:"read"` - BoostIndexerAnnounceAllDeals func(p0 context.Context) error `perm:"admin"` BoostOfflineDealWithData func(p0 context.Context, p1 uuid.UUID, p2 string) (*ProviderDealRejectionInfo, error) `perm:"admin"` @@ -264,6 +268,39 @@ func (s *BoostStub) ActorSectorSize(p0 context.Context, p1 address.Address) (abi return *new(abi.SectorSize), ErrNotSupported } +func (s *BoostStruct) BlockstoreGet(p0 context.Context, p1 cid.Cid) ([]byte, error) { + if s.Internal.BlockstoreGet == nil { + return *new([]byte), ErrNotSupported + } + return s.Internal.BlockstoreGet(p0, p1) +} + +func (s *BoostStub) BlockstoreGet(p0 context.Context, p1 cid.Cid) ([]byte, error) { + return *new([]byte), ErrNotSupported +} + +func (s *BoostStruct) BlockstoreGetSize(p0 context.Context, p1 cid.Cid) (int, error) { + if s.Internal.BlockstoreGetSize == nil { + return 0, ErrNotSupported + } + return s.Internal.BlockstoreGetSize(p0, p1) +} + +func (s *BoostStub) BlockstoreGetSize(p0 context.Context, p1 cid.Cid) (int, error) { + return 0, ErrNotSupported +} + +func (s *BoostStruct) BlockstoreHas(p0 context.Context, p1 cid.Cid) (bool, error) { + if s.Internal.BlockstoreHas == nil { + return false, ErrNotSupported + } + return s.Internal.BlockstoreHas(p0, p1) +} + +func (s *BoostStub) BlockstoreHas(p0 context.Context, p1 cid.Cid) (bool, error) { + return false, ErrNotSupported +} + func (s *BoostStruct) BoostDagstoreDestroyShard(p0 context.Context, p1 string) error { if s.Internal.BoostDagstoreDestroyShard == nil { return ErrNotSupported @@ -385,17 +422,6 @@ func (s *BoostStub) BoostDummyDeal(p0 context.Context, p1 smtypes.DealParams) (* return nil, ErrNotSupported } -func (s *BoostStruct) BoostGetBlock(p0 context.Context, p1 cid.Cid) ([]byte, error) { - if s.Internal.BoostGetBlock == nil { - return *new([]byte), ErrNotSupported - } - return s.Internal.BoostGetBlock(p0, p1) -} - -func (s *BoostStub) BoostGetBlock(p0 context.Context, p1 cid.Cid) ([]byte, error) { - return *new([]byte), ErrNotSupported -} - func (s *BoostStruct) BoostIndexerAnnounceAllDeals(p0 context.Context) error { if s.Internal.BoostIndexerAnnounceAllDeals == nil { return ErrNotSupported diff --git a/build/openrpc/boost.json.gz b/build/openrpc/boost.json.gz index ce1230bc7d4f93fa065dba073523e4a17cbdd835..2124f961d84d7eb34d8b2ce0046e4d9bdb0c2cc6 100644 GIT binary patch literal 5070 zcmV;<6EW-`iwFP!00000|Li?&bJ{q!f5qebrRh*YfRHvb`ynBH;n}pC8`|AxcbmBt zwg7F6>{@afn&H3Sk^F8;wror`rJi^<-qG)%OOTCuk72j>!ZnWcO-Elry0lHApZ@)zW3Xa9 z-yjPbHp1OAgWB#C@_*5HsCRS|62nCf^#OhP@?~Lv#&ZuF+B2d(Keuf{r_}WfdZ1-G zKXZDTVPgvKX?N`Z-_e{S4Vb123F)5s{~u`2zzlWcejN?EuI(OZ51;X8isl;WPB4Wo z238h7?U!FPj4Z$9XX--gxmbIS;kOLTgO2vvbwAj2>N$?>QfRUs8}?7oN&b>&PLJVz z@ELDD<1b&n=pCJSs}*q9`lP z-o%3oTB;3B@Ql5}riLikqi=$>oor}~mohnyZBE_jo! zVXqG70sFmhT$@e$;f%4>;mopUhburRbPs`p4jtFNU;p0%;_kx!pUeKJr*Af$JP)5+ zwsA|S?ZUT^R^#AQR~i2r$n1`hd7wS}`)0PLh5VWVSir45q)J?x#r3K2XfRFXgw5v` zQ*B~GOwk+(hfbv28*_d-iRKjH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P0A*YF~@GFGAcQ1n)jNSn=(17Wiu4Xpr?psUgV?+Zf9a%Y`@na z>ig0GWY}Pbqv&;O7{u|j9Ymu#E(e3c;uquX(+I~K(+Gt!ktNIND1gm*gcUSF2H~C8 z$Z0YK_dQdv5jB^C6Gc4>p(N-B$cCc}>4l+%QYPDbLptJt@#3W?x-gf(cG#(C6D|9K zTC$ZTSnpiQG&zZXV@{$pi#$(=dDS3oqoWz>KgKK$bzHiZIQJI3C6B>W-?vDtLmlz^{Yr=*yjEO5w3fmj!F@P=)pXCg|7Pvu zBg_VUErqj&Dpxt3N(v{5YNK-gX(}h6zWl}d(c|4X>HX?)hNme|-YAOithp@SN3JGN z*8R(wv+HhJ@@3t+UXwP7dm~}~X%a?Cj)i7zvXxfI;|ZS2Drc59r$y>MEwUGO>PbgY zxG4~=mx!_{rBhrb=+Agc#q$^f=t`zzj3K*+|O sTRcT04Y6Sco5j?WbAFjXNiHz5U#!)8Eduxd9{>RV|K=RgbQ0bG06ge@MgRZ+ diff --git a/cmd/booster-bitswap/remoteblockstore/remoteblockstore.go b/cmd/booster-bitswap/remoteblockstore/remoteblockstore.go index 4a1f5eee3..bd9611b08 100644 --- a/cmd/booster-bitswap/remoteblockstore/remoteblockstore.go +++ b/cmd/booster-bitswap/remoteblockstore/remoteblockstore.go @@ -5,7 +5,6 @@ import ( "errors" blocks "github.com/ipfs/go-block-format" - format "github.com/ipfs/go-ipld-format" logging "github.com/ipfs/go-log/v2" "github.com/ipfs/go-cid" @@ -14,23 +13,15 @@ import ( var log = logging.Logger("remote-blockstore") -var ErrBlockNotFound = errors.New("block not found") -var ErrNotFound = errors.New("not found") - var _ blockstore.Blockstore = (*RemoteBlockstore)(nil) -// ErrNoPieceSelected means that the piece selection function rejected all of the given pieces. -var ErrNoPieceSelected = errors.New("no piece selected") - -// PieceSelectorF helps select a piece to fetch a cid from if the given cid is present in multiple pieces. -// It should return `ErrNoPieceSelected` if none of the given piece is selected. -type PieceSelectorF func(c cid.Cid, pieceCids []cid.Cid) (cid.Cid, error) - type RemoteBlockstoreAPI interface { - BoostGetBlock(ctx context.Context, c cid.Cid) ([]byte, error) + BlockstoreGet(ctx context.Context, c cid.Cid) ([]byte, error) + BlockstoreHas(ctx context.Context, c cid.Cid) (bool, error) + BlockstoreGetSize(ctx context.Context, c cid.Cid) (int, error) } -// RemoteBlockstore is a read only blockstore over all cids across all pieces on a provider. +// RemoteBlockstore is a read-only blockstore over all cids across all pieces on a provider. type RemoteBlockstore struct { api RemoteBlockstoreAPI } @@ -42,9 +33,9 @@ func NewRemoteBlockstore(api RemoteBlockstoreAPI) blockstore.Blockstore { } func (ro *RemoteBlockstore) Get(ctx context.Context, c cid.Cid) (b blocks.Block, err error) { - log.Debugw("processing request for block", "cid", c) - data, err := ro.api.BoostGetBlock(ctx, c) - log.Debugw("boost api response for get block", "cid", c, "error", err) + log.Debugw("Get", "cid", c) + data, err := ro.api.BlockstoreGet(ctx, c) + log.Debugw("Get response", "cid", c, "error", err) if err != nil { return nil, err } @@ -52,22 +43,17 @@ func (ro *RemoteBlockstore) Get(ctx context.Context, c cid.Cid) (b blocks.Block, } func (ro *RemoteBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error) { - _, err := ro.api.BoostGetBlock(ctx, c) - if err != nil { - if format.IsNotFound(err) { - return false, nil - } - return false, err - } - return true, nil + log.Debugw("Has", "cid", c) + has, err := ro.api.BlockstoreHas(ctx, c) + log.Debugw("Has response", "cid", c, "has", has, "error", err) + return has, err } func (ro *RemoteBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) { - data, err := ro.api.BoostGetBlock(ctx, c) - if err != nil { - return 0, err - } - return len(data), nil + log.Debugw("GetSize", "cid", c) + size, err := ro.api.BlockstoreGetSize(ctx, c) + log.Debugw("GetSize response", "cid", c, "size", size, "error", err) + return size, err } // --- UNSUPPORTED BLOCKSTORE METHODS ------- diff --git a/cmd/booster-bitswap/run.go b/cmd/booster-bitswap/run.go index a7706364d..f5c43cb36 100644 --- a/cmd/booster-bitswap/run.go +++ b/cmd/booster-bitswap/run.go @@ -2,7 +2,6 @@ package main import ( "context" - "errors" "fmt" "net/http" _ "net/http/pprof" @@ -14,7 +13,6 @@ import ( "github.com/filecoin-project/boost/cmd/booster-bitswap/remoteblockstore" "github.com/filecoin-project/go-jsonrpc" lcli "github.com/filecoin-project/lotus/cli" - "github.com/filecoin-project/lotus/storage/sealer" "github.com/urfave/cli/v2" ) @@ -37,16 +35,6 @@ var runCmd = &cli.Command{ Usage: "the endpoint for the boost API", Required: true, }, - &cli.StringFlag{ - Name: "api-fullnode", - Usage: "the endpoint for the full node API", - Required: true, - }, - &cli.StringFlag{ - Name: "api-sealer", - Usage: "the endpoint for the sealer API", - Required: true, - }, }, Action: func(cctx *cli.Context) error { if cctx.Bool("pprof") { @@ -69,11 +57,11 @@ var runCmd = &cli.Command{ remoteStore := remoteblockstore.NewRemoteBlockstore(bapi) // Create the server API - server := NewBitswapServer(cctx.String("base-path"), cctx.Int("port"), remoteStore) + port := cctx.Int("port") + server := NewBitswapServer(port, remoteStore) // Start the server - log.Infof("Starting booster-http node on port %d with base path '%s'", - cctx.Int("port"), cctx.String("base-path")) + log.Infof("Starting booster-bitswap node on port %d", port) err = server.Start(ctx) if err != nil { return err @@ -96,16 +84,6 @@ var runCmd = &cli.Command{ }, } -func storageAuthWithURL(apiInfo string) (sealer.StorageAuth, error) { - s := strings.Split(apiInfo, ":") - if len(s) != 2 { - return nil, errors.New("unexpected format of `apiInfo`") - } - headers := http.Header{} - headers.Add("Authorization", "Bearer "+s[0]) - return sealer.StorageAuth(headers), nil -} - func getBoostAPI(ctx context.Context, ai string) (api.Boost, jsonrpc.ClientCloser, error) { ai = strings.TrimPrefix(strings.TrimSpace(ai), "BOOST_API_INFO=") info := cliutil.ParseApiInfo(ai) diff --git a/cmd/booster-bitswap/server.go b/cmd/booster-bitswap/server.go index dd95a5eb9..5871a37af 100644 --- a/cmd/booster-bitswap/server.go +++ b/cmd/booster-bitswap/server.go @@ -3,7 +3,6 @@ package main import ( "context" "crypto/rand" - "errors" "fmt" bsnetwork "github.com/ipfs/go-bitswap/network" @@ -19,8 +18,6 @@ import ( "github.com/libp2p/go-libp2p/p2p/transport/tcp" ) -var ErrNotFound = errors.New("not found") - type BitswapServer struct { port int remoteStore blockstore.Blockstore @@ -30,7 +27,7 @@ type BitswapServer struct { server *server.Server } -func NewBitswapServer(path string, port int, remoteStore blockstore.Blockstore) *BitswapServer { +func NewBitswapServer(port int, remoteStore blockstore.Blockstore) *BitswapServer { return &BitswapServer{port: port, remoteStore: remoteStore} } @@ -65,8 +62,7 @@ func (s *BitswapServer) Start(ctx context.Context) error { s.server = server.New(ctx, net, s.remoteStore, bsopts...) net.Start(s.server) - fmt.Printf("bitswap server running on SP, addrs: %s, peerID: %s\n", host.Addrs(), host.ID()) - log.Infow("bitswap server running on SP", "multiaddrs", host.Addrs(), "peerId", host.ID()) + log.Infow("bitswap server running", "multiaddrs", host.Addrs(), "peerId", host.ID()) return nil } diff --git a/documentation/en/api-v1-methods.md b/documentation/en/api-v1-methods.md index 4ed9e1260..2b8be58f1 100644 --- a/documentation/en/api-v1-methods.md +++ b/documentation/en/api-v1-methods.md @@ -4,6 +4,10 @@ * [Auth](#auth) * [AuthNew](#authnew) * [AuthVerify](#authverify) +* [Blockstore](#blockstore) + * [BlockstoreGet](#blockstoreget) + * [BlockstoreGetSize](#blockstoregetsize) + * [BlockstoreHas](#blockstorehas) * [Boost](#boost) * [BoostDagstoreDestroyShard](#boostdagstoredestroyshard) * [BoostDagstoreGC](#boostdagstoregc) @@ -137,6 +141,57 @@ Response: ] ``` +## Blockstore + + +### BlockstoreGet +There are not yet any comments for this method. + +Perms: read + +Inputs: +```json +[ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + } +] +``` + +Response: `"Ynl0ZSBhcnJheQ=="` + +### BlockstoreGetSize + + +Perms: read + +Inputs: +```json +[ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + } +] +``` + +Response: `123` + +### BlockstoreHas + + +Perms: read + +Inputs: +```json +[ + { + "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" + } +] +``` + +Response: `true` + ## Boost @@ -1303,11 +1358,7 @@ Inputs: Response: ```json { - "Dynamic": true, "Memory": 9, - "MemoryFraction": 12.3, - "MinMemory": 9, - "MaxMemory": 9, "Streams": 123, "StreamsInbound": 123, "StreamsOutbound": 123, @@ -1473,11 +1524,7 @@ Inputs: [ "string value", { - "Dynamic": true, "Memory": 9, - "MemoryFraction": 12.3, - "MinMemory": 9, - "MaxMemory": 9, "Streams": 123, "StreamsInbound": 123, "StreamsOutbound": 123, diff --git a/go.mod b/go.mod index 116ceef67..2f0625eb4 100644 --- a/go.mod +++ b/go.mod @@ -75,7 +75,6 @@ require ( github.com/libp2p/go-eventbus v0.2.1 github.com/libp2p/go-libp2p v0.21.0 github.com/libp2p/go-libp2p-core v0.19.1 - github.com/libp2p/go-libp2p-crypto v0.1.0 github.com/libp2p/go-libp2p-gostream v0.4.1-0.20220720161416-e1952aede109 github.com/libp2p/go-libp2p-http v0.2.1 github.com/libp2p/go-libp2p-kad-dht v0.17.0 diff --git a/go.sum b/go.sum index 8b03c7090..285c3c10b 100644 --- a/go.sum +++ b/go.sum @@ -1271,7 +1271,6 @@ github.com/libp2p/go-libp2p-core v0.19.1 h1:zaZQQCeCrFMtxFa1wHy6AhsVynyNmZAvwgWq github.com/libp2p/go-libp2p-core v0.19.1/go.mod h1:2uLhmmqDiFY+dw+70KkBLeKvvsJHGWUINRDdeV1ip7k= github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= github.com/libp2p/go-libp2p-crypto v0.0.2/go.mod h1:eETI5OUfBnvARGOHrJz2eWNyTUxEGZnBxMcbUjfIj4I= -github.com/libp2p/go-libp2p-crypto v0.1.0 h1:k9MFy+o2zGDNGsaoZl0MA3iZ75qXxr9OOoAZF+sD5OQ= github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI= github.com/libp2p/go-libp2p-daemon v0.2.2/go.mod h1:kyrpsLB2JeNYR2rvXSVWyY0iZuRIMhqzWR3im9BV6NQ= github.com/libp2p/go-libp2p-discovery v0.0.5/go.mod h1:YtF20GUxjgoKZ4zmXj8j3Nb2TUSBHFlOCetzYdbZL5I= diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 8a29b89df..30f54ebf2 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -1188,6 +1188,13 @@ This parameter is ONLY applicable if the retrieval pricing policy strategy has b Comment: ``, }, + { + Name: "LocalWorkerName", + Type: "string", + + Comment: `LocalWorkerName specifies a custom name for the builtin worker. +If set to an empty string (default) os hostname will be used`, + }, { Name: "Assigner", Type: "string", @@ -1443,6 +1450,30 @@ the compaction boundary; default is 0.`, A value of 0 disables, while a value 1 will do full GC in every compaction. Default is 20 (about once a week).`, }, + { + Name: "EnableColdStoreAutoPrune", + Type: "bool", + + Comment: `EnableColdStoreAutoPrune turns on compaction of the cold store i.e. pruning +where hotstore compaction occurs every finality epochs pruning happens every 3 finalities +Default is false`, + }, + { + Name: "ColdStoreFullGCFrequency", + Type: "uint64", + + Comment: `ColdStoreFullGCFrequency specifies how often to performa a full (moving) GC on the coldstore. +Only applies if auto prune is enabled. A value of 0 disables while a value of 1 will do +full GC in every prune. +Default is 7 (about once every a week)`, + }, + { + Name: "ColdStoreRetention", + Type: "int64", + + Comment: `ColdStoreRetention specifies the retention policy for data reachable from the chain, in +finalities beyond the compaction boundary, default is 0, -1 retains everything`, + }, }, "lotus_config.StorageMiner": []DocField{ { diff --git a/node/impl/boost.go b/node/impl/boost.go index 1fcd4150f..487e8caa5 100644 --- a/node/impl/boost.go +++ b/node/impl/boost.go @@ -475,10 +475,18 @@ func (sm *BoostAPI) BoostDagstoreDestroyShard(ctx context.Context, key string) e return nil } -func (sm *BoostAPI) BoostGetBlock(ctx context.Context, c cid.Cid) ([]byte, error) { +func (sm *BoostAPI) BlockstoreGet(ctx context.Context, c cid.Cid) ([]byte, error) { blk, err := sm.IndexBackedBlockstore.Get(ctx, c) if err != nil { return nil, err } return blk.RawData(), nil } + +func (sm *BoostAPI) BlockstoreHas(ctx context.Context, c cid.Cid) (bool, error) { + return sm.IndexBackedBlockstore.Has(ctx, c) +} + +func (sm *BoostAPI) BlockstoreGetSize(ctx context.Context, c cid.Cid) (int, error) { + return sm.IndexBackedBlockstore.GetSize(ctx, c) +}