lotus-provider: review comments

This commit is contained in:
Andrew Jackson (Ajax) 2023-08-25 18:17:31 -05:00
parent cb3655149c
commit ca4282d149
6 changed files with 16 additions and 64 deletions

View File

@ -119,7 +119,7 @@ lotus-gateway: $(BUILD_DEPS)
.PHONY: 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 \
an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true

View File

@ -90,7 +90,7 @@ func main() {
Name: "repo",
EnvVars: []string{"LOTUS_PATH"},
Hidden: true,
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
Value: "~/.lotus",
},
cliutil.FlagVeryVerbose,
},

View File

@ -8,11 +8,8 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"path/filepath"
"strings"
"time"
"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/urfave/cli/v2"
"go.opencensus.io/stats"
@ -40,45 +37,45 @@ var runCmd = &cli.Command{
Flags: []cli.Flag{
&cli.StringFlag{
Name: "provider-api",
Usage: "2345",
},
&cli.BoolFlag{
Name: "enable-gpu-proving",
Usage: "enable use of GPU for mining operations",
Value: true,
Usage: "Port (default 12300)",
},
&cli.BoolFlag{
Name: "nosync",
Usage: "don't check full-node sync status",
},
&cli.BoolFlag{
Name: "halt-after-init",
Usage: "only run init, then return",
Hidden: true,
},
&cli.BoolFlag{
Name: "manage-fdlimit",
Usage: "manage open file limit",
Value: true,
},
&cli.StringFlag{
Name: "db_host",
Name: "db-host",
EnvVars: []string{"LOTUS_DB_HOST"},
Usage: "Command separated list of hostnames for yugabyte cluster",
Value: "yugabyte",
},
&cli.StringFlag{
Name: "db_name",
Name: "db-name",
EnvVars: []string{"LOTUS_DB_NAME"},
Value: "yugabyte",
},
&cli.StringFlag{
Name: "db_user",
Name: "db-user",
EnvVars: []string{"LOTUS_DB_USER"},
Value: "yugabyte",
},
&cli.StringFlag{
Name: "db_password",
Name: "db-password",
EnvVars: []string{"LOTUS_DB_PASSWORD"},
Value: "yugabyte",
},
&cli.StringFlag{
Name: "db_port",
Name: "db-port",
EnvVars: []string{"LOTUS_DB_PORT"},
Hidden: true,
Value: "5433",
@ -138,26 +135,6 @@ var runCmd = &cli.Command{
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) {
sc.StoragePaths = append(sc.StoragePaths, localPaths...)
}); err != nil {
@ -197,7 +174,6 @@ var runCmd = &cli.Command{
return err
}
// TODO add harmonytask
_ = db
shutdownChan := make(chan struct{})
@ -214,11 +190,7 @@ var runCmd = &cli.Command{
addressSlice := strings.Split(address, ":")
if ip := net.ParseIP(addressSlice[0]); ip != nil {
if ip.String() == unspecifiedAddress {
timeout, err := time.ParseDuration(cctx.String("timeout"))
if err != nil {
return err
}
rip, err := extractRoutableIP(timeout)
rip, err := db.GetRoutableIP()
if err != nil {
return err
}
@ -273,12 +245,3 @@ var runCmd = &cli.Command{
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
}

View File

@ -17,7 +17,6 @@ import (
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/kr/pretty"
"github.com/filecoin-project/lotus/node/config"
)
@ -146,7 +145,7 @@ func (db *DB) GetRoutableIP() (string, error) {
local := tx.Conn().PgConn().Conn().LocalAddr()
addr, ok := local.(*net.TCPAddr)
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
}

View File

@ -358,15 +358,6 @@ func Provider(r repo.Repo) 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(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.WinPost), ConfigWinPost(c)),
)(settings)

View File

@ -2,12 +2,11 @@
Description=Lotus Provider
After=network.target
After=lotus-daemon.service
Wants=lotus-daemon.service
[Service]
ExecStart=/usr/local/bin/lotus-provider run
Environment=GOLOG_FILE="/var/log/lotus/provider.log"
Environment=GOLOG_LOG_FMT="json"
LimitNOFILE=1000000
[Install]
WantedBy=multi-user.target