-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for lotus-provider, and conveniences #11419
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
793b078
fixes: mk instl, cfg defaults, cli tester
snadrus 2ffe9f8
Merge branch 'feat/sturdypost' into fix-sturdy-tests
snadrus 91cf04a
test fix
snadrus 8fe8977
fixes
snadrus 7ec9eb0
essential fixes for scheduling
snadrus 4b8aa53
lints and non parallel
snadrus f80a5bc
resource cleanup on milliseconds
snadrus ac2306b
unit test and code comments
snadrus 25f9eb4
pg weird interval syntax
snadrus 1dc2810
test-window-post
snadrus 1ae7bc7
lp test fixes
snadrus ec43903
lp: test cli, titled sql
snadrus 31ed5cc
Merge branch 'feat/sturdypost' into fix-sturdy-tests
snadrus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWNwAkUtWuLtKCyyFP2vBzmpTHSrQao7KQx7Xfa8YvSg1N | ||
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWPn8BDeNcctAcAGuxxiic8uMw2pAi3G5vgdFtfgRs5zBu | ||
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWRaoPgwJuZdPSN4A2iTeh8xzkZGCEBxan9vMkidHisUgn | ||
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWMjLCZeEf3VzSWvQYuhe9VzCcrN6RENX9FgmQqiJfQDWs |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/urfave/cli/v2" | ||
"golang.org/x/xerrors" | ||
|
||
"github.com/filecoin-project/go-address" | ||
"github.com/filecoin-project/go-state-types/dline" | ||
|
||
"github.com/filecoin-project/lotus/lib/harmony/harmonydb" | ||
"github.com/filecoin-project/lotus/provider" | ||
) | ||
|
||
var provingCmd = &cli.Command{ | ||
Name: "proving", | ||
Usage: "Utility functions for proving sectors", | ||
Subcommands: []*cli.Command{ | ||
//provingInfoCmd, | ||
provingCompute, | ||
}, | ||
} | ||
|
||
var provingCompute = &cli.Command{ | ||
Name: "compute", | ||
Usage: "Compute a proof-of-spacetime for a sector (requires the sector to be pre-sealed)", | ||
Subcommands: []*cli.Command{ | ||
provingComputeWindowPoStCmd, | ||
scheduleWindowPostCmd, | ||
}, | ||
} | ||
|
||
var scheduleWindowPostCmd = &cli.Command{ | ||
Name: "test-window-post", | ||
Usage: "FOR TESTING: a way to test the windowpost scheduler. Use with 1 lotus-provider running only", | ||
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "i_have_set_LOTUS_PROVDER_NO_SEND_to_true", | ||
}, | ||
&cli.Uint64Flag{ | ||
Name: "deadline", | ||
Usage: "deadline to compute WindowPoSt for ", | ||
Value: 0, | ||
}, | ||
&cli.StringSliceFlag{ | ||
Name: "layers", | ||
Usage: "list of layers to be interpreted (atop defaults). Default: base", | ||
Value: cli.NewStringSlice("base"), | ||
}, | ||
}, | ||
Action: func(cctx *cli.Context) error { | ||
ctx := context.Background() | ||
|
||
if !cctx.Bool("i_have_set_LOTUS_PROVDER_NO_SEND_to_true") { | ||
log.Info("This command is for testing only. It will not send any messages to the chain. If you want to run it, set LOTUS_PROVDER_NO_SEND=true on the lotus-provider environment.") | ||
return nil | ||
} | ||
deps, err := getDeps(ctx, cctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ts, err := deps.full.ChainHead(ctx) | ||
if err != nil { | ||
return xerrors.Errorf("cannot get chainhead %w", err) | ||
} | ||
ht := ts.Height() | ||
|
||
addr, err := address.NewFromString(deps.cfg.Addresses.MinerAddresses[0]) | ||
if err != nil { | ||
return xerrors.Errorf("cannot get miner address %w", err) | ||
} | ||
maddr, err := address.IDFromAddress(addr) | ||
if err != nil { | ||
return xerrors.Errorf("cannot get miner id %w", err) | ||
} | ||
did, err := deps.db.BeginTransaction(ctx, func(tx *harmonydb.Tx) (commit bool, err error) { | ||
_, err = tx.Exec(`INSERT INTO harmony_task (name, posted_time, added_by) VALUES ('WdPost', CURRENT_TIMESTAMP, 123)`) | ||
if err != nil { | ||
log.Error("inserting harmony_task: ", err) | ||
return false, xerrors.Errorf("inserting harmony_task: %w", err) | ||
} | ||
var id int64 | ||
if err = tx.QueryRow(`SELECT id FROM harmony_task ORDER BY update_time DESC LIMIT 1`).Scan(&id); err != nil { | ||
log.Error("getting inserted id: ", err) | ||
return false, xerrors.Errorf("getting inserted id: %w", err) | ||
} | ||
_, err = tx.Exec(`INSERT INTO wdpost_partition_tasks | ||
(task_id, sp_id, proving_period_start, deadline_index, partition_index) VALUES ($1, $2, $3, $4, $5)`, | ||
id, maddr, ht, cctx.Uint64("deadline"), 0) | ||
if err != nil { | ||
log.Error("inserting wdpost_partition_tasks: ", err) | ||
return false, xerrors.Errorf("inserting wdpost_partition_tasks: %w", err) | ||
} | ||
return true, nil | ||
}) | ||
if err != nil { | ||
return xerrors.Errorf("writing SQL transaction: %w", err) | ||
} | ||
log.Infof("Inserted task %v", did) | ||
return nil | ||
}, | ||
} | ||
|
||
var provingComputeWindowPoStCmd = &cli.Command{ | ||
Name: "windowed-post", | ||
Aliases: []string{"window-post"}, | ||
Usage: "Compute WindowPoSt for performance and configuration testing.", | ||
Description: `Note: This command is intended to be used to verify PoSt compute performance. | ||
It will not send any messages to the chain. Since it can compute any deadline, output may be incorrectly timed for the chain.`, | ||
ArgsUsage: "[deadline index]", | ||
Flags: []cli.Flag{ | ||
&cli.Uint64Flag{ | ||
Name: "deadline", | ||
Usage: "deadline to compute WindowPoSt for ", | ||
Value: 0, | ||
}, | ||
&cli.StringSliceFlag{ | ||
Name: "layers", | ||
Usage: "list of layers to be interpreted (atop defaults). Default: base", | ||
Value: cli.NewStringSlice("base"), | ||
}, | ||
&cli.StringFlag{ | ||
Name: "storage-json", | ||
Usage: "path to json file containing storage config", | ||
Value: "~/.lotus-provider/storage.json", | ||
}, | ||
&cli.Uint64Flag{ | ||
Name: "partition", | ||
Usage: "partition to compute WindowPoSt for", | ||
Value: 0, | ||
}, | ||
}, | ||
Action: func(cctx *cli.Context) error { | ||
|
||
ctx := context.Background() | ||
deps, err := getDeps(ctx, cctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
wdPostTask, wdPoStSubmitTask, derlareRecoverTask, err := provider.WindowPostScheduler(ctx, deps.cfg.Fees, deps.cfg.Proving, deps.full, deps.verif, deps.lw, | ||
deps.as, deps.maddrs, deps.db, deps.stor, deps.si, deps.cfg.Subsystems.WindowPostMaxTasks) | ||
if err != nil { | ||
return err | ||
} | ||
_, _ = wdPoStSubmitTask, derlareRecoverTask | ||
|
||
if len(deps.maddrs) == 0 { | ||
return errors.New("no miners to compute WindowPoSt for") | ||
} | ||
head, err := deps.full.ChainHead(ctx) | ||
if err != nil { | ||
return xerrors.Errorf("failed to get chain head: %w", err) | ||
} | ||
|
||
di := dline.NewInfo(head.Height(), cctx.Uint64("deadline"), 0, 0, 0, 10 /*challenge window*/, 0, 0) | ||
|
||
for _, maddr := range deps.maddrs { | ||
out, err := wdPostTask.DoPartition(ctx, head, address.Address(maddr), di, cctx.Uint64("partition")) | ||
if err != nil { | ||
fmt.Println("Error computing WindowPoSt for miner", maddr, err) | ||
continue | ||
} | ||
fmt.Println("Computed WindowPoSt for miner", maddr, ":") | ||
err = json.NewEncoder(os.Stdout).Encode(out) | ||
if err != nil { | ||
fmt.Println("Could not encode WindowPoSt output for miner", maddr, err) | ||
continue | ||
} | ||
} | ||
|
||
return nil | ||
}, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to have a way to submit a mock-compute task to the database, so the computation isn't done in the local cli, but on the real workers (which imo is what SPs will expect in most cases - running check tasks on the cluster with proper scheduling, but no submitting things to the chain)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense. Would you want it to do that with live updates, or just direct them to logs and database to evaluate the success?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have either this or a separate command poll for success