lotus-provider: review comments
This commit is contained in:
parent
cb3655149c
commit
ca4282d149
2
Makefile
2
Makefile
@ -119,7 +119,7 @@ lotus-gateway: $(BUILD_DEPS)
|
|||||||
.PHONY: lotus-gateway
|
.PHONY: lotus-gateway
|
||||||
BINS+=lotus-gateway
|
BINS+=lotus-gateway
|
||||||
|
|
||||||
build: lotus lotus-miner lotus-worker lotus-provider
|
build: lotus lotus-miner lotus-worker
|
||||||
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
|
@[[ $$(type -P "lotus") ]] && echo "Caution: you have \
|
||||||
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true
|
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ func main() {
|
|||||||
Name: "repo",
|
Name: "repo",
|
||||||
EnvVars: []string{"LOTUS_PATH"},
|
EnvVars: []string{"LOTUS_PATH"},
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
|
Value: "~/.lotus",
|
||||||
},
|
},
|
||||||
cliutil.FlagVeryVerbose,
|
cliutil.FlagVeryVerbose,
|
||||||
},
|
},
|
||||||
|
@ -8,11 +8,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.opencensus.io/stats"
|
"go.opencensus.io/stats"
|
||||||
@ -40,45 +37,45 @@ var runCmd = &cli.Command{
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "provider-api",
|
Name: "provider-api",
|
||||||
Usage: "2345",
|
Usage: "Port (default 12300)",
|
||||||
},
|
|
||||||
&cli.BoolFlag{
|
|
||||||
Name: "enable-gpu-proving",
|
|
||||||
Usage: "enable use of GPU for mining operations",
|
|
||||||
Value: true,
|
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "nosync",
|
Name: "nosync",
|
||||||
Usage: "don't check full-node sync status",
|
Usage: "don't check full-node sync status",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "halt-after-init",
|
||||||
|
Usage: "only run init, then return",
|
||||||
|
Hidden: true,
|
||||||
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "manage-fdlimit",
|
Name: "manage-fdlimit",
|
||||||
Usage: "manage open file limit",
|
Usage: "manage open file limit",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "db_host",
|
Name: "db-host",
|
||||||
EnvVars: []string{"LOTUS_DB_HOST"},
|
EnvVars: []string{"LOTUS_DB_HOST"},
|
||||||
Usage: "Command separated list of hostnames for yugabyte cluster",
|
Usage: "Command separated list of hostnames for yugabyte cluster",
|
||||||
Value: "yugabyte",
|
Value: "yugabyte",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "db_name",
|
Name: "db-name",
|
||||||
EnvVars: []string{"LOTUS_DB_NAME"},
|
EnvVars: []string{"LOTUS_DB_NAME"},
|
||||||
Value: "yugabyte",
|
Value: "yugabyte",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "db_user",
|
Name: "db-user",
|
||||||
EnvVars: []string{"LOTUS_DB_USER"},
|
EnvVars: []string{"LOTUS_DB_USER"},
|
||||||
Value: "yugabyte",
|
Value: "yugabyte",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "db_password",
|
Name: "db-password",
|
||||||
EnvVars: []string{"LOTUS_DB_PASSWORD"},
|
EnvVars: []string{"LOTUS_DB_PASSWORD"},
|
||||||
Value: "yugabyte",
|
Value: "yugabyte",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "db_port",
|
Name: "db-port",
|
||||||
EnvVars: []string{"LOTUS_DB_PORT"},
|
EnvVars: []string{"LOTUS_DB_PORT"},
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
Value: "5433",
|
Value: "5433",
|
||||||
@ -138,26 +135,6 @@ var runCmd = &cli.Command{
|
|||||||
|
|
||||||
var localPaths []storiface.LocalPath
|
var localPaths []storiface.LocalPath
|
||||||
|
|
||||||
if !cctx.Bool("no-local-storage") {
|
|
||||||
b, err := json.MarshalIndent(&storiface.LocalStorageMeta{
|
|
||||||
ID: storiface.ID(uuid.New().String()),
|
|
||||||
Weight: 10,
|
|
||||||
CanSeal: true,
|
|
||||||
CanStore: false,
|
|
||||||
}, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("marshaling storage config: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(lr.Path(), "sectorstore.json"), b, 0644); err != nil {
|
|
||||||
return xerrors.Errorf("persisting storage metadata (%s): %w", filepath.Join(lr.Path(), "sectorstore.json"), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
localPaths = append(localPaths, storiface.LocalPath{
|
|
||||||
Path: lr.Path(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
|
if err := lr.SetStorage(func(sc *storiface.StorageConfig) {
|
||||||
sc.StoragePaths = append(sc.StoragePaths, localPaths...)
|
sc.StoragePaths = append(sc.StoragePaths, localPaths...)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -197,7 +174,6 @@ var runCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// TODO add harmonytask
|
// TODO add harmonytask
|
||||||
_ = db
|
|
||||||
|
|
||||||
shutdownChan := make(chan struct{})
|
shutdownChan := make(chan struct{})
|
||||||
|
|
||||||
@ -214,11 +190,7 @@ var runCmd = &cli.Command{
|
|||||||
addressSlice := strings.Split(address, ":")
|
addressSlice := strings.Split(address, ":")
|
||||||
if ip := net.ParseIP(addressSlice[0]); ip != nil {
|
if ip := net.ParseIP(addressSlice[0]); ip != nil {
|
||||||
if ip.String() == unspecifiedAddress {
|
if ip.String() == unspecifiedAddress {
|
||||||
timeout, err := time.ParseDuration(cctx.String("timeout"))
|
rip, err := db.GetRoutableIP()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
rip, err := extractRoutableIP(timeout)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -273,12 +245,3 @@ var runCmd = &cli.Command{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractRoutableIP(timeout time.Duration) (string, error) {
|
|
||||||
conn, err := net.DialTimeout("udp", "8.8.8.8:80", timeout)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer conn.Close()
|
|
||||||
return conn.LocalAddr().(*net.UDPAddr).IP.String(), nil
|
|
||||||
}
|
|
||||||
|
@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
"github.com/jackc/pgx/v5/pgconn"
|
"github.com/jackc/pgx/v5/pgconn"
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
"github.com/kr/pretty"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
)
|
)
|
||||||
@ -146,7 +145,7 @@ func (db *DB) GetRoutableIP() (string, error) {
|
|||||||
local := tx.Conn().PgConn().Conn().LocalAddr()
|
local := tx.Conn().PgConn().Conn().LocalAddr()
|
||||||
addr, ok := local.(*net.TCPAddr)
|
addr, ok := local.(*net.TCPAddr)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", errors.New("could not get local addr from " + pretty.Sprint(addr))
|
return "", fmt.Errorf("could not get local addr from %v", addr)
|
||||||
}
|
}
|
||||||
return addr.IP.String(), nil
|
return addr.IP.String(), nil
|
||||||
}
|
}
|
||||||
|
@ -358,15 +358,6 @@ func Provider(r repo.Repo) Option {
|
|||||||
Error(errors.New("the Base() option must be set before Config option")),
|
Error(errors.New("the Base() option must be set before Config option")),
|
||||||
),
|
),
|
||||||
Override(new(repo.LockedRepo), modules.LockedRepo(lr)), // module handles closing
|
Override(new(repo.LockedRepo), modules.LockedRepo(lr)), // module handles closing
|
||||||
|
|
||||||
Override(new(ci.PrivKey), lp2p.PrivKey),
|
|
||||||
Override(new(ci.PubKey), ci.PrivKey.GetPublic),
|
|
||||||
Override(new(peer.ID), peer.IDFromPublicKey),
|
|
||||||
|
|
||||||
Override(new(types.KeyStore), modules.KeyStore),
|
|
||||||
|
|
||||||
Override(new(*dtypes.APIAlg), modules.APISecret),
|
|
||||||
|
|
||||||
//ApplyIf(IsType(repo.WdPost), ConfigWdPost(c)),
|
//ApplyIf(IsType(repo.WdPost), ConfigWdPost(c)),
|
||||||
//ApplyIf(IsType(repo.WinPost), ConfigWinPost(c)),
|
//ApplyIf(IsType(repo.WinPost), ConfigWinPost(c)),
|
||||||
)(settings)
|
)(settings)
|
||||||
|
@ -2,12 +2,11 @@
|
|||||||
Description=Lotus Provider
|
Description=Lotus Provider
|
||||||
After=network.target
|
After=network.target
|
||||||
After=lotus-daemon.service
|
After=lotus-daemon.service
|
||||||
Wants=lotus-daemon.service
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/local/bin/lotus-provider run
|
ExecStart=/usr/local/bin/lotus-provider run
|
||||||
Environment=GOLOG_FILE="/var/log/lotus/provider.log"
|
Environment=GOLOG_FILE="/var/log/lotus/provider.log"
|
||||||
Environment=GOLOG_LOG_FMT="json"
|
Environment=GOLOG_LOG_FMT="json"
|
||||||
|
LimitNOFILE=1000000
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Loading…
Reference in New Issue
Block a user