Merge branch 'master' into slashfilter
This commit is contained in:
commit
e3c796c848
2
Makefile
2
Makefile
@ -355,7 +355,7 @@ fiximports:
|
||||
./scripts/fiximports
|
||||
|
||||
gen: actors-code-gen type-gen cfgdoc-gen docsgen api-gen circleci fiximports
|
||||
@echo ">>> IF YOU'VE MODIFIED THE CLI OR CONFIG, REMEMBER TO ALSO MAKE docsgen-cli"
|
||||
@echo ">>> IF YOU'VE MODIFIED THE CLI OR CONFIG, REMEMBER TO ALSO RUN 'make docsgen-cli'"
|
||||
.PHONY: gen
|
||||
|
||||
jen: gen
|
||||
|
@ -37,7 +37,17 @@ var dbDefs = []string{
|
||||
)`,
|
||||
`INSERT OR IGNORE INTO _meta (version) VALUES (1)`,
|
||||
}
|
||||
var dbPragmas = []string{}
|
||||
|
||||
var dbPragmas = []string{
|
||||
"PRAGMA synchronous = normal",
|
||||
"PRAGMA temp_store = memory",
|
||||
"PRAGMA mmap_size = 30000000000",
|
||||
"PRAGMA page_size = 32768",
|
||||
"PRAGMA auto_vacuum = NONE",
|
||||
"PRAGMA automatic_index = OFF",
|
||||
"PRAGMA journal_mode = WAL",
|
||||
"PRAGMA read_uncommitted = ON",
|
||||
}
|
||||
|
||||
const (
|
||||
// prepared stmts
|
||||
|
@ -98,9 +98,10 @@ func main() {
|
||||
log.Info("Starting lotus-bench")
|
||||
|
||||
app := &cli.App{
|
||||
Name: "lotus-bench",
|
||||
Usage: "Benchmark performance of lotus on your hardware",
|
||||
Version: build.UserVersion(),
|
||||
Name: "lotus-bench",
|
||||
Usage: "Benchmark performance of lotus on your hardware",
|
||||
Version: build.UserVersion(),
|
||||
DisableSliceFlagSeparator: true,
|
||||
Commands: []*cli.Command{
|
||||
proveCmd,
|
||||
sealBenchCmd,
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
)
|
||||
|
||||
@ -23,6 +24,7 @@ var ethCmd = &cli.Command{
|
||||
},
|
||||
Subcommands: []*cli.Command{
|
||||
checkTipsetsCmd,
|
||||
computeEthHashCmd,
|
||||
},
|
||||
}
|
||||
|
||||
@ -70,3 +72,36 @@ var checkTipsetsCmd = &cli.Command{
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var computeEthHashCmd = &cli.Command{
|
||||
Name: "compute-eth-hash",
|
||||
Usage: "Compute the eth hash for a given message CID",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if cctx.NArg() != 1 {
|
||||
return lcli.IncorrectNumArgs(cctx)
|
||||
}
|
||||
|
||||
msg, err := messageFromString(cctx, cctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *types.SignedMessage:
|
||||
tx, err := ethtypes.EthTxFromSignedEthMessage(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to convert from signed message: %w", err)
|
||||
}
|
||||
|
||||
tx.Hash, err = tx.TxHash()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to call TxHash: %w", err)
|
||||
}
|
||||
fmt.Println(tx.Hash)
|
||||
default:
|
||||
return fmt.Errorf("not a signed message")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
337
cmd/lotus-shed/indexes.go
Normal file
337
cmd/lotus-shed/indexes.go
Normal file
@ -0,0 +1,337 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
)
|
||||
|
||||
func withCategory(cat string, cmd *cli.Command) *cli.Command {
|
||||
cmd.Category = strings.ToUpper(cat)
|
||||
return cmd
|
||||
}
|
||||
|
||||
var indexesCmd = &cli.Command{
|
||||
Name: "indexes",
|
||||
Usage: "Commands related to managing sqlite indexes",
|
||||
HideHelpCommand: true,
|
||||
Subcommands: []*cli.Command{
|
||||
withCategory("msgindex", backfillMsgIndexCmd),
|
||||
withCategory("msgindex", pruneMsgIndexCmd),
|
||||
withCategory("txhash", backfillTxHashCmd),
|
||||
},
|
||||
}
|
||||
|
||||
var backfillMsgIndexCmd = &cli.Command{
|
||||
Name: "backfill-msgindex",
|
||||
Usage: "Backfill the msgindex.db for a number of epochs starting from a specified height",
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
Name: "from",
|
||||
Value: 0,
|
||||
Usage: "height to start the backfill; uses the current head if omitted",
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "epochs",
|
||||
Value: 1800,
|
||||
Usage: "number of epochs to backfill; defaults to 1800 (2 finalities)",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
curTs, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
startHeight := int64(cctx.Int("from"))
|
||||
if startHeight == 0 {
|
||||
startHeight = int64(curTs.Height()) - 1
|
||||
}
|
||||
epochs := cctx.Int("epochs")
|
||||
|
||||
basePath, err := homedir.Expand(cctx.String("repo"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbPath := path.Join(basePath, "sqlite", "msgindex.db")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: closing db: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
insertStmt, err := db.Prepare("INSERT OR IGNORE INTO messages (cid, tipset_cid, epoch) VALUES (?, ?, ?)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var nrRowsAffected int64
|
||||
for i := 0; i < epochs; i++ {
|
||||
epoch := abi.ChainEpoch(startHeight - int64(i))
|
||||
|
||||
if i%100 == 0 {
|
||||
log.Infof("%d/%d processing epoch:%d, nrRowsAffected:%d", i, epochs, epoch, nrRowsAffected)
|
||||
}
|
||||
|
||||
ts, err := api.ChainGetTipSetByHeight(ctx, epoch, curTs.Key())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get tipset at epoch %d: %w", epoch, err)
|
||||
}
|
||||
|
||||
tsCid, err := ts.Key().Cid()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get tipset cid at epoch %d: %w", epoch, err)
|
||||
}
|
||||
|
||||
msgs, err := api.ChainGetMessagesInTipset(ctx, ts.Key())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get messages in tipset at epoch %d: %w", epoch, err)
|
||||
}
|
||||
|
||||
for _, msg := range msgs {
|
||||
key := msg.Cid.String()
|
||||
tskey := tsCid.String()
|
||||
res, err := insertStmt.Exec(key, tskey, int64(epoch))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to insert message cid %s in tipset %s at epoch %d: %w", key, tskey, epoch, err)
|
||||
}
|
||||
rowsAffected, err := res.RowsAffected()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get rows affected for message cid %s in tipset %s at epoch %d: %w", key, tskey, epoch, err)
|
||||
}
|
||||
nrRowsAffected += rowsAffected
|
||||
}
|
||||
}
|
||||
|
||||
log.Infof("Done backfilling, nrRowsAffected:%d", nrRowsAffected)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var pruneMsgIndexCmd = &cli.Command{
|
||||
Name: "prune-msgindex",
|
||||
Usage: "Prune the msgindex.db for messages included before a given epoch",
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
Name: "from",
|
||||
Usage: "height to start the prune; if negative it indicates epochs from current head",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
startHeight := int64(cctx.Int("from"))
|
||||
if startHeight < 0 {
|
||||
curTs, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
startHeight += int64(curTs.Height())
|
||||
|
||||
if startHeight < 0 {
|
||||
return xerrors.Errorf("bogus start height %d", startHeight)
|
||||
}
|
||||
}
|
||||
|
||||
basePath, err := homedir.Expand(cctx.String("repo"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbPath := path.Join(basePath, "sqlite", "msgindex.db")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: closing db: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := tx.Exec("DELETE FROM messages WHERE epoch < ?", startHeight); err != nil {
|
||||
if err := tx.Rollback(); err != nil {
|
||||
fmt.Printf("ERROR: rollback: %s", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var backfillTxHashCmd = &cli.Command{
|
||||
Name: "backfill-txhash",
|
||||
Usage: "Backfills the txhash.db for a number of epochs starting from a specified height",
|
||||
Flags: []cli.Flag{
|
||||
&cli.UintFlag{
|
||||
Name: "from",
|
||||
Value: 0,
|
||||
Usage: "the tipset height to start backfilling from (0 is head of chain)",
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "epochs",
|
||||
Value: 2000,
|
||||
Usage: "the number of epochs to backfill",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
curTs, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
startHeight := int64(cctx.Int("from"))
|
||||
if startHeight == 0 {
|
||||
startHeight = int64(curTs.Height()) - 1
|
||||
}
|
||||
|
||||
epochs := cctx.Int("epochs")
|
||||
|
||||
basePath, err := homedir.Expand(cctx.String("repo"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbPath := filepath.Join(basePath, "sqlite", "txhash.db")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: closing db: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
insertStmt, err := db.Prepare("INSERT OR IGNORE INTO eth_tx_hashes(hash, cid) VALUES(?, ?)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var totalRowsAffected int64 = 0
|
||||
for i := 0; i < epochs; i++ {
|
||||
epoch := abi.ChainEpoch(startHeight - int64(i))
|
||||
|
||||
select {
|
||||
case <-cctx.Done():
|
||||
fmt.Println("request cancelled")
|
||||
return nil
|
||||
default:
|
||||
}
|
||||
|
||||
curTsk := curTs.Parents()
|
||||
execTs, err := api.ChainGetTipSet(ctx, curTsk)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to call ChainGetTipSet for %s: %w", curTsk, err)
|
||||
}
|
||||
|
||||
if i%100 == 0 {
|
||||
log.Infof("%d/%d processing epoch:%d", i, epochs, epoch)
|
||||
}
|
||||
|
||||
for _, blockheader := range execTs.Blocks() {
|
||||
blkMsgs, err := api.ChainGetBlockMessages(ctx, blockheader.Cid())
|
||||
if err != nil {
|
||||
log.Infof("Could not get block messages at epoch: %d, stopping walking up the chain", epoch)
|
||||
epochs = i
|
||||
break
|
||||
}
|
||||
|
||||
for _, smsg := range blkMsgs.SecpkMessages {
|
||||
if smsg.Signature.Type != crypto.SigTypeDelegated {
|
||||
continue
|
||||
}
|
||||
|
||||
tx, err := ethtypes.EthTxFromSignedEthMessage(smsg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to convert from signed message: %w at epoch: %d", err, epoch)
|
||||
}
|
||||
|
||||
tx.Hash, err = tx.TxHash()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to calculate hash for ethTx: %w at epoch: %d", err, epoch)
|
||||
}
|
||||
|
||||
res, err := insertStmt.Exec(tx.Hash.String(), smsg.Cid().String())
|
||||
if err != nil {
|
||||
return fmt.Errorf("error inserting tx mapping to db: %s at epoch: %d", err, epoch)
|
||||
}
|
||||
|
||||
rowsAffected, err := res.RowsAffected()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting rows affected: %s at epoch: %d", err, epoch)
|
||||
}
|
||||
|
||||
if rowsAffected > 0 {
|
||||
log.Debugf("Inserted txhash %s, cid: %s at epoch: %d", tx.Hash.String(), smsg.Cid().String(), epoch)
|
||||
}
|
||||
|
||||
totalRowsAffected += rowsAffected
|
||||
}
|
||||
}
|
||||
|
||||
curTs = execTs
|
||||
}
|
||||
|
||||
log.Infof("Done, inserted %d missing txhashes", totalRowsAffected)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
@ -86,7 +86,7 @@ func main() {
|
||||
invariantsCmd,
|
||||
gasTraceCmd,
|
||||
replayOfflineCmd,
|
||||
msgindexCmd,
|
||||
indexesCmd,
|
||||
FevmAnalyticsCmd,
|
||||
mismatchesCmd,
|
||||
}
|
||||
|
@ -1,221 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
)
|
||||
|
||||
var msgindexCmd = &cli.Command{
|
||||
Name: "msgindex",
|
||||
Usage: "Tools for managing the message index",
|
||||
Subcommands: []*cli.Command{
|
||||
msgindexBackfillCmd,
|
||||
msgindexPruneCmd,
|
||||
},
|
||||
}
|
||||
|
||||
var msgindexBackfillCmd = &cli.Command{
|
||||
Name: "backfill",
|
||||
Usage: "Backfill the message index for a number of epochs starting from a specified height",
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
Name: "from",
|
||||
Value: 0,
|
||||
Usage: "height to start the backfill; uses the current head if omitted",
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "epochs",
|
||||
Value: 1800,
|
||||
Usage: "number of epochs to backfill; defaults to 1800 (2 finalities)",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "repo",
|
||||
Value: "~/.lotus",
|
||||
Usage: "path to the repo",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
curTs, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
startHeight := int64(cctx.Int("from"))
|
||||
if startHeight == 0 {
|
||||
startHeight = int64(curTs.Height()) - 1
|
||||
}
|
||||
epochs := cctx.Int("epochs")
|
||||
|
||||
basePath, err := homedir.Expand(cctx.String("repo"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbPath := path.Join(basePath, "sqlite", "msgindex.db")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: closing db: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
insertStmt, err := tx.Prepare("INSERT INTO messages VALUES (?, ?, ?)")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
insertMsg := func(cid, tsCid cid.Cid, epoch abi.ChainEpoch) error {
|
||||
key := cid.String()
|
||||
tskey := tsCid.String()
|
||||
if _, err := insertStmt.Exec(key, tskey, int64(epoch)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
rollback := func() {
|
||||
if err := tx.Rollback(); err != nil {
|
||||
fmt.Printf("ERROR: rollback: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < epochs; i++ {
|
||||
epoch := abi.ChainEpoch(startHeight - int64(i))
|
||||
|
||||
ts, err := api.ChainGetTipSetByHeight(ctx, epoch, curTs.Key())
|
||||
if err != nil {
|
||||
rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
tsCid, err := ts.Key().Cid()
|
||||
if err != nil {
|
||||
rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
msgs, err := api.ChainGetMessagesInTipset(ctx, ts.Key())
|
||||
if err != nil {
|
||||
rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
for _, msg := range msgs {
|
||||
if err := insertMsg(msg.Cid, tsCid, epoch); err != nil {
|
||||
rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var msgindexPruneCmd = &cli.Command{
|
||||
Name: "prune",
|
||||
Usage: "Prune the message index for messages included before a given epoch",
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
Name: "from",
|
||||
Usage: "height to start the prune; if negative it indicates epochs from current head",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "repo",
|
||||
Value: "~/.lotus",
|
||||
Usage: "path to the repo",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
startHeight := int64(cctx.Int("from"))
|
||||
if startHeight < 0 {
|
||||
curTs, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
startHeight += int64(curTs.Height())
|
||||
|
||||
if startHeight < 0 {
|
||||
return xerrors.Errorf("bogus start height %d", startHeight)
|
||||
}
|
||||
}
|
||||
|
||||
basePath, err := homedir.Expand(cctx.String("repo"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbPath := path.Join(basePath, "sqlite", "msgindex.db")
|
||||
db, err := sql.Open("sqlite3", dbPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := db.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: closing db: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := tx.Exec("DELETE FROM messages WHERE epoch < ?", startHeight); err != nil {
|
||||
if err := tx.Rollback(); err != nil {
|
||||
fmt.Printf("ERROR: rollback: %s", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -19,12 +19,11 @@ COMMANDS:
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
GLOBAL OPTIONS:
|
||||
--enable-gpu-proving enable use of GPU for mining operations (default: true) [$LOTUS_WORKER_ENABLE_GPU_PROVING]
|
||||
--help, -h show help (default: false)
|
||||
--miner-repo value, --storagerepo value Specify miner repo path. flag storagerepo and env LOTUS_STORAGE_PATH are DEPRECATION, will REMOVE SOON (default: "~/.lotusminer") [$LOTUS_MINER_PATH, $LOTUS_STORAGE_PATH]
|
||||
--version, -v print the version (default: false)
|
||||
--worker-repo value, --workerrepo value Specify worker repo path. flag workerrepo and env WORKER_PATH are DEPRECATION, will REMOVE SOON (default: "~/.lotusworker") [$LOTUS_WORKER_PATH, $WORKER_PATH]
|
||||
|
||||
--miner-repo value, --storagerepo value Specify miner repo path. flag storagerepo and env LOTUS_STORAGE_PATH are DEPRECATION, will REMOVE SOON (default: "~/.lotusminer") [$LOTUS_MINER_PATH, $LOTUS_STORAGE_PATH]
|
||||
--enable-gpu-proving enable use of GPU for mining operations (default: true) [$LOTUS_WORKER_ENABLE_GPU_PROVING]
|
||||
--help, -h show help
|
||||
--version, -v print the version
|
||||
```
|
||||
|
||||
## lotus-worker run
|
||||
@ -36,29 +35,29 @@ USAGE:
|
||||
lotus-worker run [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--addpiece enable addpiece (default: true) [$LOTUS_WORKER_ADDPIECE]
|
||||
--commit enable commit (default: true) [$LOTUS_WORKER_COMMIT]
|
||||
--data-cid Run the data-cid task. true|false (default: inherits --addpiece)
|
||||
--http-server-timeout value (default: "30s")
|
||||
--listen value host address and port the worker api will listen on (default: "0.0.0.0:3456") [$LOTUS_WORKER_LISTEN]
|
||||
--name value custom worker name (default: hostname) [$LOTUS_WORKER_NAME]
|
||||
--no-default disable all default compute tasks, use the worker for storage/fetching only (default: false) [$LOTUS_WORKER_NO_DEFAULT]
|
||||
--no-local-storage don't use storageminer repo for sector storage (default: false) [$LOTUS_WORKER_NO_LOCAL_STORAGE]
|
||||
--no-swap don't use swap (default: false) [$LOTUS_WORKER_NO_SWAP]
|
||||
--name value custom worker name (default: hostname) [$LOTUS_WORKER_NAME]
|
||||
--addpiece enable addpiece (default: true) [$LOTUS_WORKER_ADDPIECE]
|
||||
--precommit1 enable precommit1 (default: true) [$LOTUS_WORKER_PRECOMMIT1]
|
||||
--unseal enable unsealing (default: true) [$LOTUS_WORKER_UNSEAL]
|
||||
--precommit2 enable precommit2 (default: true) [$LOTUS_WORKER_PRECOMMIT2]
|
||||
--commit enable commit (default: true) [$LOTUS_WORKER_COMMIT]
|
||||
--replica-update enable replica update (default: true) [$LOTUS_WORKER_REPLICA_UPDATE]
|
||||
--prove-replica-update2 enable prove replica update 2 (default: true) [$LOTUS_WORKER_PROVE_REPLICA_UPDATE2]
|
||||
--regen-sector-key enable regen sector key (default: true) [$LOTUS_WORKER_REGEN_SECTOR_KEY]
|
||||
--sector-download enable external sector data download (default: false) [$LOTUS_WORKER_SECTOR_DOWNLOAD]
|
||||
--windowpost enable window post (default: false) [$LOTUS_WORKER_WINDOWPOST]
|
||||
--winningpost enable winning post (default: false) [$LOTUS_WORKER_WINNINGPOST]
|
||||
--no-default disable all default compute tasks, use the worker for storage/fetching only (default: false) [$LOTUS_WORKER_NO_DEFAULT]
|
||||
--parallel-fetch-limit value maximum fetch operations to run in parallel (default: 5) [$LOTUS_WORKER_PARALLEL_FETCH_LIMIT]
|
||||
--post-parallel-reads value maximum number of parallel challenge reads (0 = no limit) (default: 32) [$LOTUS_WORKER_POST_PARALLEL_READS]
|
||||
--post-read-timeout value time limit for reading PoSt challenges (0 = no limit) (default: 0s) [$LOTUS_WORKER_POST_READ_TIMEOUT]
|
||||
--precommit1 enable precommit1 (default: true) [$LOTUS_WORKER_PRECOMMIT1]
|
||||
--precommit2 enable precommit2 (default: true) [$LOTUS_WORKER_PRECOMMIT2]
|
||||
--prove-replica-update2 enable prove replica update 2 (default: true) [$LOTUS_WORKER_PROVE_REPLICA_UPDATE2]
|
||||
--regen-sector-key enable regen sector key (default: true) [$LOTUS_WORKER_REGEN_SECTOR_KEY]
|
||||
--replica-update enable replica update (default: true) [$LOTUS_WORKER_REPLICA_UPDATE]
|
||||
--sector-download enable external sector data download (default: false) [$LOTUS_WORKER_SECTOR_DOWNLOAD]
|
||||
--timeout value used when 'listen' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function (default: "30m") [$LOTUS_WORKER_TIMEOUT]
|
||||
--unseal enable unsealing (default: true) [$LOTUS_WORKER_UNSEAL]
|
||||
--windowpost enable window post (default: false) [$LOTUS_WORKER_WINDOWPOST]
|
||||
--winningpost enable winning post (default: false) [$LOTUS_WORKER_WINNINGPOST]
|
||||
|
||||
--http-server-timeout value (default: "30s")
|
||||
--data-cid Run the data-cid task. true|false (default: inherits --addpiece)
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
## lotus-worker stop
|
||||
@ -70,8 +69,7 @@ USAGE:
|
||||
lotus-worker stop [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--help, -h show help (default: false)
|
||||
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
## lotus-worker info
|
||||
@ -83,8 +81,7 @@ USAGE:
|
||||
lotus-worker info [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--help, -h show help (default: false)
|
||||
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
## lotus-worker storage
|
||||
@ -96,14 +93,13 @@ USAGE:
|
||||
lotus-worker storage command [command options] [arguments...]
|
||||
|
||||
COMMANDS:
|
||||
attach attach local storage path
|
||||
detach detach local storage path
|
||||
redeclare redeclare sectors in a local storage path
|
||||
help, h Shows a list of commands or help for one command
|
||||
attach attach local storage path
|
||||
detach detach local storage path
|
||||
redeclare redeclare sectors in a local storage path
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
OPTIONS:
|
||||
--help, -h show help (default: false)
|
||||
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
### lotus-worker storage attach
|
||||
@ -115,14 +111,14 @@ USAGE:
|
||||
lotus-worker storage attach [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--allow-to value [ --allow-to value ] path groups allowed to pull data from this path (allow all if not specified)
|
||||
--groups value [ --groups value ] path group names
|
||||
--init initialize the path first (default: false)
|
||||
--max-storage value (for init) limit storage space for sectors (expensive for very large paths!)
|
||||
--weight value (for init) path weight (default: 10)
|
||||
--seal (for init) use path for sealing (default: false)
|
||||
--store (for init) use path for long-term storage (default: false)
|
||||
--weight value (for init) path weight (default: 10)
|
||||
|
||||
--max-storage value (for init) limit storage space for sectors (expensive for very large paths!)
|
||||
--groups value [ --groups value ] path group names
|
||||
--allow-to value [ --allow-to value ] path groups allowed to pull data from this path (allow all if not specified)
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
### lotus-worker storage detach
|
||||
@ -135,7 +131,7 @@ USAGE:
|
||||
|
||||
OPTIONS:
|
||||
--really-do-it (default: false)
|
||||
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
### lotus-worker storage redeclare
|
||||
@ -147,10 +143,10 @@ USAGE:
|
||||
lotus-worker storage redeclare [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--id value storage path ID
|
||||
--all redeclare all storage paths (default: false)
|
||||
--drop-missing Drop index entries with missing files (default: true)
|
||||
--id value storage path ID
|
||||
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
## lotus-worker resources
|
||||
@ -162,9 +158,9 @@ USAGE:
|
||||
lotus-worker resources [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--all print all resource envvars (default: false)
|
||||
--default print default resource envvars (default: false)
|
||||
|
||||
--all print all resource envvars (default: false)
|
||||
--default print default resource envvars (default: false)
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
## lotus-worker tasks
|
||||
@ -176,13 +172,12 @@ USAGE:
|
||||
lotus-worker tasks command [command options] [arguments...]
|
||||
|
||||
COMMANDS:
|
||||
enable Enable a task type
|
||||
disable Disable a task type
|
||||
help, h Shows a list of commands or help for one command
|
||||
enable Enable a task type
|
||||
disable Disable a task type
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
OPTIONS:
|
||||
--help, -h show help (default: false)
|
||||
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
### lotus-worker tasks enable
|
||||
@ -194,8 +189,8 @@ USAGE:
|
||||
lotus-worker tasks enable [command options] --all | [UNS|C2|PC2|PC1|PR2|RU|AP|DC|GSK]
|
||||
|
||||
OPTIONS:
|
||||
--all Enable all task types (default: false)
|
||||
|
||||
--all Enable all task types (default: false)
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
### lotus-worker tasks disable
|
||||
@ -207,6 +202,6 @@ USAGE:
|
||||
lotus-worker tasks disable [command options] --all | [UNS|C2|PC2|PC1|PR2|RU|AP|DC|GSK]
|
||||
|
||||
OPTIONS:
|
||||
--all Disable all task types (default: false)
|
||||
|
||||
--all Disable all task types (default: false)
|
||||
--help, -h show help
|
||||
```
|
||||
|
File diff suppressed because it is too large
Load Diff
4
go.mod
4
go.mod
@ -116,7 +116,7 @@ require (
|
||||
github.com/kelseyhightower/envconfig v1.4.0
|
||||
github.com/koalacxr/quantile v0.0.1
|
||||
github.com/libp2p/go-buffer-pool v0.1.0
|
||||
github.com/libp2p/go-libp2p v0.27.3
|
||||
github.com/libp2p/go-libp2p v0.27.5
|
||||
github.com/libp2p/go-libp2p-consensus v0.0.1
|
||||
github.com/libp2p/go-libp2p-gorpc v0.5.0
|
||||
github.com/libp2p/go-libp2p-kad-dht v0.21.1
|
||||
@ -144,7 +144,7 @@ require (
|
||||
github.com/raulk/go-watchdog v1.3.0
|
||||
github.com/stretchr/testify v1.8.2
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
|
||||
github.com/urfave/cli/v2 v2.16.3
|
||||
github.com/urfave/cli/v2 v2.25.5
|
||||
github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa
|
||||
github.com/whyrusleeping/ledger-filecoin-go v0.9.1-0.20201010031517-c3dcc1bddce4
|
||||
|
8
go.sum
8
go.sum
@ -1005,8 +1005,8 @@ github.com/libp2p/go-libp2p v0.7.0/go.mod h1:hZJf8txWeCduQRDC/WSqBGMxaTHCOYHt2xS
|
||||
github.com/libp2p/go-libp2p v0.7.4/go.mod h1:oXsBlTLF1q7pxr+9w6lqzS1ILpyHsaBPniVO7zIHGMw=
|
||||
github.com/libp2p/go-libp2p v0.8.1/go.mod h1:QRNH9pwdbEBpx5DTJYg+qxcVaDMAz3Ee/qDKwXujH5o=
|
||||
github.com/libp2p/go-libp2p v0.14.3/go.mod h1:d12V4PdKbpL0T1/gsUNN8DfgMuRPDX8bS2QxCZlwRH0=
|
||||
github.com/libp2p/go-libp2p v0.27.3 h1:tkV/zm3KCZ4R5er9Xcs2pt0YNB4JH0iBfGAtHJdLHRs=
|
||||
github.com/libp2p/go-libp2p v0.27.3/go.mod h1:FAvvfQa/YOShUYdiSS03IR9OXzkcJXwcNA2FUCh9ImE=
|
||||
github.com/libp2p/go-libp2p v0.27.5 h1:KwA7pXKXpz8hG6Cr1fMA7UkgleogcwQj0sxl5qquWRg=
|
||||
github.com/libp2p/go-libp2p v0.27.5/go.mod h1:oMfQGTb9CHnrOuSM6yMmyK2lXz3qIhnkn2+oK3B1Y2g=
|
||||
github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s=
|
||||
github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w=
|
||||
github.com/libp2p/go-libp2p-autonat v0.1.0/go.mod h1:1tLf2yXxiE/oKGtDwPYWTSYG3PtvYlJmg7NeVtPRqH8=
|
||||
@ -1630,8 +1630,8 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
|
||||
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.0.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/urfave/cli/v2 v2.16.3 h1:gHoFIwpPjoyIMbJp/VFd+/vuD0dAgFK4B6DpEMFJfQk=
|
||||
github.com/urfave/cli/v2 v2.16.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI=
|
||||
github.com/urfave/cli/v2 v2.25.5 h1:d0NIAyhh5shGscroL7ek/Ya9QYQE0KNabJgiUinIQkc=
|
||||
github.com/urfave/cli/v2 v2.25.5/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8=
|
||||
|
@ -89,6 +89,7 @@ const (
|
||||
|
||||
// health checks
|
||||
CheckFDLimit
|
||||
CheckFvmConcurrency
|
||||
LegacyMarketsEOL
|
||||
|
||||
// libp2p
|
||||
@ -165,6 +166,7 @@ func defaults() []Option {
|
||||
Override(new(dtypes.NodeStartTime), FromVal(dtypes.NodeStartTime(time.Now()))),
|
||||
|
||||
Override(CheckFDLimit, modules.CheckFdLimit(build.DefaultFDLimit)),
|
||||
Override(CheckFvmConcurrency, modules.CheckFvmConcurrency()),
|
||||
|
||||
Override(new(system.MemoryConstraints), modules.MemoryConstraints),
|
||||
Override(InitMemoryWatchdog, modules.MemoryWatchdog),
|
||||
|
@ -1,6 +1,9 @@
|
||||
package modules
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/filecoin-project/lotus/journal/alerting"
|
||||
"github.com/filecoin-project/lotus/lib/ulimit"
|
||||
)
|
||||
@ -42,6 +45,35 @@ func LegacyMarketsEOL(al *alerting.Alerting) {
|
||||
})
|
||||
}
|
||||
|
||||
func CheckFvmConcurrency() func(al *alerting.Alerting) {
|
||||
return func(al *alerting.Alerting) {
|
||||
fvmConcurrency, ok := os.LookupEnv("LOTUS_FVM_CONCURRENCY")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
fvmConcurrencyVal, err := strconv.Atoi(fvmConcurrency)
|
||||
if err != nil {
|
||||
alert := al.AddAlertType("process", "fvm-concurrency")
|
||||
al.Raise(alert, map[string]string{
|
||||
"message": "LOTUS_FVM_CONCURRENCY is not an integer",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Raise alert if LOTUS_FVM_CONCURRENCY is set to a high value
|
||||
if fvmConcurrencyVal > 24 {
|
||||
alert := al.AddAlertType("process", "fvm-concurrency")
|
||||
al.Raise(alert, map[string]interface{}{
|
||||
"message": "LOTUS_FVM_CONCURRENCY is set to a high value that can cause chain sync panics on network migrations/upgrades",
|
||||
"set_value": fvmConcurrencyVal,
|
||||
"recommended": "24 or less during network upgrades",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: More things:
|
||||
// * Space in repo dirs (taking into account mounts)
|
||||
// * Miner
|
||||
|
@ -4,9 +4,12 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"go.uber.org/fx"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/ethhashlookup"
|
||||
"github.com/filecoin-project/lotus/chain/events"
|
||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
||||
@ -54,6 +57,17 @@ func EthModuleAPI(cfg config.FevmConfig) func(helpers.MetricsCtx, repo.LockedRep
|
||||
}
|
||||
}
|
||||
|
||||
// prefill the whole skiplist cache maintained internally by the GetTipsetByHeight
|
||||
go func() {
|
||||
start := time.Now()
|
||||
log.Infoln("Start prefilling GetTipsetByHeight cache")
|
||||
_, err := cs.GetTipsetByHeight(mctx, abi.ChainEpoch(0), cs.GetHeaviestTipSet(), false)
|
||||
if err != nil {
|
||||
log.Warnf("error when prefilling GetTipsetByHeight cache: %w", err)
|
||||
}
|
||||
log.Infof("Prefilling GetTipsetByHeight done in %s", time.Since(start))
|
||||
}()
|
||||
|
||||
ctx := helpers.LifecycleCtx(mctx, lc)
|
||||
lc.Append(fx.Hook{
|
||||
OnStart: func(context.Context) error {
|
||||
|
Loading…
Reference in New Issue
Block a user