diff --git a/cmd/lotus-provider/run.go b/cmd/lotus-provider/run.go index ca5d9e9d1..16683c50e 100644 --- a/cmd/lotus-provider/run.go +++ b/cmd/lotus-provider/run.go @@ -9,21 +9,21 @@ import ( "strings" "time" - "github.com/filecoin-project/go-statestore" "github.com/gbrlsnchs/jwt/v3" - ds "github.com/ipfs/go-datastore" - dssync "github.com/ipfs/go-datastore/sync" - "golang.org/x/xerrors" - "github.com/gin-contrib/pprof" "github.com/gin-gonic/gin" + ds "github.com/ipfs/go-datastore" + dssync "github.com/ipfs/go-datastore/sync" "github.com/pkg/errors" "github.com/urfave/cli/v2" "go.opencensus.io/stats" "go.opencensus.io/tag" + "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-jsonrpc/auth" + "github.com/filecoin-project/go-statestore" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" lcli "github.com/filecoin-project/lotus/cli" diff --git a/lib/harmony/harmonydb/sql/20230719.sql b/lib/harmony/harmonydb/sql/20230719.sql index d4eb58326..e7b1795c5 100644 --- a/lib/harmony/harmonydb/sql/20230719.sql +++ b/lib/harmony/harmonydb/sql/20230719.sql @@ -6,8 +6,7 @@ CREATE TABLE harmony_machines ( host_and_port varchar(300) NOT NULL, cpu INTEGER NOT NULL, ram BIGINT NOT NULL, - gpu FLOAT NOT NULL, - gpuram BIGINT NOT NULL + gpu FLOAT NOT NULL ); CREATE TABLE harmony_task ( diff --git a/lib/harmony/resources/resources.go b/lib/harmony/resources/resources.go index 140fa3e04..109863173 100644 --- a/lib/harmony/resources/resources.go +++ b/lib/harmony/resources/resources.go @@ -3,6 +3,7 @@ package resources import ( "bytes" "context" + "golang.org/x/xerrors" "os/exec" "regexp" "runtime" @@ -42,7 +43,7 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) { } ctx := context.Background() { // Learn our owner_id while updating harmony_machines - var ownerID int + var ownerID *int // Upsert query with last_contact update, fetch the machine ID // (note this isn't a simple insert .. on conflict because host_and_port isn't unique) @@ -54,7 +55,7 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) { RETURNING id ), inserted AS ( - INSERT INTO harmony_machines (host_and_port, cpu, ram, gpu, gpuram, last_contact) + INSERT INTO harmony_machines (host_and_port, cpu, ram, gpu, last_contact) SELECT $1, $2, $3, $4, CURRENT_TIMESTAMP WHERE NOT EXISTS (SELECT id FROM upsert) RETURNING id @@ -64,10 +65,13 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) { SELECT id FROM inserted; `, hostnameAndPort, reg.Cpu, reg.Ram, reg.Gpu).Scan(&ownerID) if err != nil { - return nil, err + return nil, xerrors.Errorf("inserting machine entry: %w", err) + } + if ownerID == nil { + return nil, xerrors.Errorf("no owner id") } - reg.MachineID = ownerID + reg.MachineID = *ownerID cleaned := CleanupMachines(context.Background(), db) logger.Infow("Cleaned up machines", "count", cleaned) @@ -87,9 +91,10 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) { return ®, nil } + func CleanupMachines(ctx context.Context, db *harmonydb.DB) int { ct, err := db.Exec(ctx, `DELETE FROM harmony_machines WHERE last_contact < $1`, - time.Now().Add(-1*LOOKS_DEAD_TIMEOUT)) + time.Now().Add(-1*LOOKS_DEAD_TIMEOUT).UTC()) if err != nil { logger.Warn("unable to delete old machines: ", err) } diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index 14c0325c1..ecc95ddea 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -36,6 +36,14 @@ var Doc = map[string][]DocField{ Comment: `FULLNODE_API_INFO is the API endpoint for the Lotus daemon.`, }, + { + Name: "StorageRPCSecret", + Type: "string", + + Comment: `RPC Secret for the storage subsystem. +If integrating with lotus-miner this must match the value from +cat ~/.lotusminer/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU | jq -r .PrivateKey`, + }, }, "Backup": { { @@ -748,18 +756,6 @@ over the worker address if this flag is set.`, Comment: ``, }, - { - Name: "SealingParams", - Type: "SealingConfig", - - Comment: ``, - }, - { - Name: "SealerConfig", - Type: "//", - - Comment: ``, - }, { Name: "Journal", Type: "JournalConfig", diff --git a/provider/builder.go b/provider/builder.go index 352c533d6..37b4afae9 100644 --- a/provider/builder.go +++ b/provider/builder.go @@ -2,12 +2,8 @@ package provider import ( "context" - "github.com/filecoin-project/lotus/provider/lpmessage" "time" - "github.com/filecoin-project/lotus/storage/paths" - "github.com/filecoin-project/lotus/storage/sealer" - logging "github.com/ipfs/go-log/v2" "github.com/filecoin-project/lotus/api" @@ -15,8 +11,11 @@ import ( "github.com/filecoin-project/lotus/node/config" dtypes "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/provider/chainsched" + "github.com/filecoin-project/lotus/provider/lpmessage" "github.com/filecoin-project/lotus/provider/lpwindow" "github.com/filecoin-project/lotus/storage/ctladdr" + "github.com/filecoin-project/lotus/storage/paths" + "github.com/filecoin-project/lotus/storage/sealer" "github.com/filecoin-project/lotus/storage/sealer/storiface" ) diff --git a/provider/lpmessage/sender.go b/provider/lpmessage/sender.go index 012499f45..b839f8003 100644 --- a/provider/lpmessage/sender.go +++ b/provider/lpmessage/sender.go @@ -2,15 +2,18 @@ package lpmessage import ( "context" - "github.com/filecoin-project/go-address" - "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/google/uuid" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "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" ) var log = logging.Logger("lpmessage") diff --git a/provider/lpwindow/compute_do.go b/provider/lpwindow/compute_do.go index ffcccc628..1b4d440a0 100644 --- a/provider/lpwindow/compute_do.go +++ b/provider/lpwindow/compute_do.go @@ -3,6 +3,14 @@ package lpwindow import ( "bytes" "context" + "sort" + "sync" + "time" + + "github.com/ipfs/go-cid" + "go.uber.org/multierr" + "golang.org/x/xerrors" + ffi "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" @@ -12,16 +20,11 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/proof" + proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + "github.com/filecoin-project/lotus/build" types "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/storage/sealer/storiface" - proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" - "github.com/ipfs/go-cid" - "go.uber.org/multierr" - "golang.org/x/xerrors" - "sort" - "sync" - "time" ) const disablePreChecks = false // todo config diff --git a/provider/lpwindow/compute_task.go b/provider/lpwindow/compute_task.go index 5a805df07..a5baeb20a 100644 --- a/provider/lpwindow/compute_task.go +++ b/provider/lpwindow/compute_task.go @@ -4,10 +4,6 @@ import ( "bytes" "context" "fmt" - "github.com/filecoin-project/go-bitfield" - "github.com/filecoin-project/go-state-types/crypto" - "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/storage/sealer" "sort" "strings" @@ -16,9 +12,12 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin/v9/miner" + "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" @@ -29,6 +28,7 @@ import ( "github.com/filecoin-project/lotus/lib/promise" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/provider/chainsched" + "github.com/filecoin-project/lotus/storage/sealer" "github.com/filecoin-project/lotus/storage/sealer/sealtasks" "github.com/filecoin-project/lotus/storage/sealer/storiface" "github.com/filecoin-project/lotus/storage/wdpost" diff --git a/provider/lpwindow/faults_simple.go b/provider/lpwindow/faults_simple.go index b79a7dcf7..d43e8ee19 100644 --- a/provider/lpwindow/faults_simple.go +++ b/provider/lpwindow/faults_simple.go @@ -4,13 +4,16 @@ import ( "context" "crypto/rand" "fmt" - ffi "github.com/filecoin-project/filecoin-ffi" - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/storage/paths" - "github.com/filecoin-project/lotus/storage/sealer/storiface" - "golang.org/x/xerrors" "sync" "time" + + "golang.org/x/xerrors" + + ffi "github.com/filecoin-project/filecoin-ffi" + "github.com/filecoin-project/go-state-types/abi" + + "github.com/filecoin-project/lotus/storage/paths" + "github.com/filecoin-project/lotus/storage/sealer/storiface" ) type SimpleFaultTracker struct { diff --git a/provider/lpwindow/submit_task.go b/provider/lpwindow/submit_task.go index 4cb019a5a..dad7ca2f7 100644 --- a/provider/lpwindow/submit_task.go +++ b/provider/lpwindow/submit_task.go @@ -3,11 +3,15 @@ package lpwindow import ( "bytes" "context" + + "golang.org/x/xerrors" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/builtin/v9/miner" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/harmony/harmonydb" @@ -17,7 +21,6 @@ import ( "github.com/filecoin-project/lotus/provider/chainsched" "github.com/filecoin-project/lotus/provider/lpmessage" "github.com/filecoin-project/lotus/storage/ctladdr" - "golang.org/x/xerrors" ) type WdPoStSubmitTaskApi interface {