This commit is contained in:
Łukasz Magiera 2024-02-11 14:08:54 +01:00
parent f8183a7122
commit c28bf97922
14 changed files with 269 additions and 68 deletions

View File

@ -5,10 +5,10 @@ import (
"net/http"
"net/url"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"github.com/filecoin-project/go-address"
)
type LotusProvider interface {

View File

@ -9,6 +9,15 @@ import (
"net/url"
"time"
"github.com/google/uuid"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/metrics"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
datatransfer "github.com/filecoin-project/go-data-transfer/v2"
@ -24,6 +33,7 @@ import (
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/go-state-types/proof"
apitypes "github.com/filecoin-project/lotus/api/types"
builtinactors "github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
@ -36,14 +46,6 @@ import (
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"github.com/google/uuid"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/metrics"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"
"golang.org/x/xerrors"
)
var ErrNotSupported = xerrors.New("method not supported")

View File

@ -5,6 +5,11 @@ package v0api
import (
"context"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
datatransfer "github.com/filecoin-project/go-data-transfer/v2"
@ -16,6 +21,7 @@ import (
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/api"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
@ -23,10 +29,6 @@ import (
marketevents "github.com/filecoin-project/lotus/markets/loggers"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo/imports"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"
"golang.org/x/xerrors"
)
var ErrNotSupported = xerrors.New("method not supported")

View File

@ -4,19 +4,22 @@ import (
"bufio"
"encoding/base64"
"fmt"
"net"
"os"
"time"
"github.com/BurntSushi/toml"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/lotus/api"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/cmd/lotus-provider/rpc"
"github.com/gbrlsnchs/jwt/v3"
manet "github.com/multiformats/go-multiaddr/net"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"net"
"os"
"time"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/lotus/api"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/cmd/lotus-provider/rpc"
)
const providerEnvVar = "PROVIDER_API_INFO"

View File

@ -5,19 +5,22 @@ import (
"crypto/rand"
"encoding/base64"
"fmt"
"io"
"github.com/BurntSushi/toml"
"github.com/fatih/color"
"github.com/samber/lo"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/repo"
"github.com/samber/lo"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"io"
)
var configNewCmd = &cli.Command{

View File

@ -5,13 +5,6 @@ import (
"context"
"encoding/base64"
"encoding/json"
"github.com/filecoin-project/lotus/api/client"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"net"
"net/http"
"net/url"
@ -21,6 +14,8 @@ import (
"github.com/gbrlsnchs/jwt/v3"
"github.com/gorilla/mux"
logging "github.com/ipfs/go-log/v2"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"go.opencensus.io/tag"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
@ -30,13 +25,18 @@ import (
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/client"
cliutil "github.com/filecoin-project/lotus/cli/util"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/lib/rpcenc"
"github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/metrics/proxy"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/provider/lpmarket"
"github.com/filecoin-project/lotus/provider/lpweb"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)
var log = logging.Logger("lp/rpc")

View File

@ -3,23 +3,25 @@ package main
import (
"encoding/json"
"fmt"
"github.com/docker/go-units"
"github.com/fatih/color"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/cmd/lotus-provider/rpc"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"github.com/google/uuid"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"math/bits"
"os"
"path/filepath"
"sort"
"strings"
"time"
"github.com/docker/go-units"
"github.com/fatih/color"
"github.com/google/uuid"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/cmd/lotus-provider/rpc"
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)
const metaFile = "sectorstore.json"

View File

@ -4,12 +4,12 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr"
"os"
"strconv"
"github.com/fatih/color"
"github.com/libp2p/go-libp2p/core/peer"
ma "github.com/multiformats/go-multiaddr"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"

View File

@ -4,20 +4,6 @@ import (
"bytes"
"context"
"fmt"
"github.com/fatih/color"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/lib/nullreader"
"github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/provider/lpmarket"
"github.com/filecoin-project/lotus/provider/lpmarket/fakelm"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"github.com/ipfs/go-cid"
"github.com/mitchellh/go-homedir"
manet "github.com/multiformats/go-multiaddr/net"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"io"
"net"
"net/http"
@ -27,6 +13,13 @@ import (
"sync"
"time"
"github.com/fatih/color"
"github.com/ipfs/go-cid"
"github.com/mitchellh/go-homedir"
manet "github.com/multiformats/go-multiaddr/net"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
cborutil "github.com/filecoin-project/go-cbor-util"
commcid "github.com/filecoin-project/go-fil-commcid"
@ -38,9 +31,17 @@ import (
"github.com/filecoin-project/go-state-types/builtin/v9/market"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/lib/must"
"github.com/filecoin-project/lotus/lib/nullreader"
"github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/provider/lpmarket"
"github.com/filecoin-project/lotus/provider/lpmarket/fakelm"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
)
var lpUtilCmd = &cli.Command{

View File

@ -4,6 +4,13 @@
* [Version](#Version)
* [Allocate](#Allocate)
* [AllocatePieceToSector](#AllocatePieceToSector)
* [Storage](#Storage)
* [StorageAddLocal](#StorageAddLocal)
* [StorageDetachLocal](#StorageDetachLocal)
* [StorageInfo](#StorageInfo)
* [StorageList](#StorageList)
* [StorageLocal](#StorageLocal)
* [StorageStat](#StorageStat)
##
@ -93,3 +100,130 @@ Response:
}
```
## Storage
### StorageAddLocal
Perms: admin
Inputs:
```json
[
"string value"
]
```
Response: `{}`
### StorageDetachLocal
Perms: admin
Inputs:
```json
[
"string value"
]
```
Response: `{}`
### StorageInfo
Perms: admin
Inputs:
```json
[
"76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8"
]
```
Response:
```json
{
"ID": "76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8",
"URLs": [
"string value"
],
"Weight": 42,
"MaxStorage": 42,
"CanSeal": true,
"CanStore": true,
"Groups": [
"string value"
],
"AllowTo": [
"string value"
],
"AllowTypes": [
"string value"
],
"DenyTypes": [
"string value"
]
}
```
### StorageList
Perms: admin
Inputs: `null`
Response:
```json
{
"76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8": [
{
"Miner": 1000,
"Number": 100,
"SectorFileType": 2
}
]
}
```
### StorageLocal
Perms: admin
Inputs: `null`
Response:
```json
{
"76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8": "/data/path"
}
```
### StorageStat
Perms: admin
Inputs:
```json
[
"76f1988b-ef30-4d7e-b3ec-9a627f4ba5a8"
]
```
Response:
```json
{
"Capacity": 9,
"Available": 9,
"FSAvailable": 9,
"Reserved": 9,
"Max": 9,
"Used": 9
}
```

View File

@ -10,6 +10,7 @@ VERSION:
1.25.3-dev
COMMANDS:
cli Execute cli commands
run Start a lotus provider process
stop Stop a running lotus provider
config Manage node config by layers. The layer 'base' will always be applied.
@ -37,6 +38,27 @@ GLOBAL OPTIONS:
--version, -v print the version
```
## lotus-provider cli
```
NAME:
lotus-provider cli - Execute cli commands
USAGE:
lotus-provider cli command [command options] [arguments...]
COMMANDS:
storage manage sector storage
help, h Shows a list of commands or help for one command
OPTIONS:
--machine value machine host:port
--help, -h show help
```
### lotus-provider cli storage
```
```
## lotus-provider run
```
NAME:
@ -82,7 +104,9 @@ COMMANDS:
list, ls List config layers you can get.
interpret, view, stacked, stack Interpret stacked config layers by this version of lotus-provider, with system-generated comments.
remove, rm, del, delete Remove a named config layer.
edit edit a config layer
from-miner Express a database config (for lotus-provider) from an existing miner.
new-cluster Create new coniguration for a new cluster
help, h Shows a list of commands or help for one command
OPTIONS:
@ -164,6 +188,23 @@ OPTIONS:
--help, -h show help
```
### lotus-provider config edit
```
NAME:
lotus-provider config edit - edit a config layer
USAGE:
lotus-provider config edit [command options] [layer name]
OPTIONS:
--editor value editor to use (default: "vim") [$EDITOR]
--source value source config layer (default: <edited layer>)
--allow-owerwrite allow overwrite of existing layer if source is a different layer (default: false)
--no-source-diff save the whole config into the layer, not just the diff (default: false)
--no-interpret-source do not interpret source layer (default: true if --source is set)
--help, -h show help
```
### lotus-provider config from-miner
```
NAME:
@ -182,6 +223,18 @@ OPTIONS:
--help, -h show help
```
### lotus-provider config new-cluster
```
NAME:
lotus-provider config new-cluster - Create new coniguration for a new cluster
USAGE:
lotus-provider config new-cluster [command options] [SP actor address...]
OPTIONS:
--help, -h show help
```
## lotus-provider test
```
NAME:

View File

@ -2,7 +2,6 @@ package modules
import (
"context"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"strings"
"go.uber.org/fx"
@ -22,6 +21,7 @@ import (
"github.com/filecoin-project/lotus/provider/lpmarket"
"github.com/filecoin-project/lotus/provider/lpmarket/fakelm"
"github.com/filecoin-project/lotus/storage/paths"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
"github.com/filecoin-project/lotus/storage/sectorblocks"
)

View File

@ -2,6 +2,7 @@ package fakelm
import (
"context"
"github.com/google/uuid"
"github.com/filecoin-project/go-address"

View File

@ -3,23 +3,23 @@ package fakelm
import (
"context"
"encoding/base64"
"github.com/BurntSushi/toml"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
"github.com/filecoin-project/lotus/node/config"
"github.com/gbrlsnchs/jwt/v3"
"net/http"
"net/url"
"github.com/BurntSushi/toml"
"github.com/gbrlsnchs/jwt/v3"
"github.com/google/uuid"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/provider/lpmarket"
"github.com/filecoin-project/lotus/storage/paths"
sealing "github.com/filecoin-project/lotus/storage/pipeline"