From a5a0bd378e11272cfce01609d7460e253b640445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 25 Oct 2023 21:13:56 +0200 Subject: [PATCH] lpwindow: make gen --- .circleci/config.yml | 2 +- cmd/lotus-provider/run.go | 2 +- node/config/doc_gen.go | 52 +++++++++ provider/address.go | 4 +- provider/builder.go | 4 +- provider/chainsched/chain_sched.go | 10 +- provider/lpwindow/prove_sub.go | 181 ----------------------------- provider/lpwindow/task.go | 24 ++-- provider/lpwindow/task_test.go | 4 +- 9 files changed, 82 insertions(+), 201 deletions(-) delete mode 100644 provider/lpwindow/prove_sub.go diff --git a/.circleci/config.yml b/.circleci/config.yml index 3504381d0..a0d5c4c38 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1028,7 +1028,7 @@ workflows: requires: - build suite: utest-unit-rest - target: "./blockstore/... ./build/... ./chain/... ./conformance/... ./gateway/... ./journal/... ./lib/... ./markets/... ./paychmgr/... ./tools/..." + target: "./blockstore/... ./build/... ./chain/... ./conformance/... ./gateway/... ./journal/... ./lib/... ./markets/... ./paychmgr/... ./provider/... ./tools/..." - test: name: test-unit-storage diff --git a/cmd/lotus-provider/run.go b/cmd/lotus-provider/run.go index 1fe62f72a..24241eab1 100644 --- a/cmd/lotus-provider/run.go +++ b/cmd/lotus-provider/run.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "github.com/filecoin-project/lotus/provider" "net" "net/http" "os" @@ -37,6 +36,7 @@ import ( "github.com/filecoin-project/lotus/node/modules" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/repo" + "github.com/filecoin-project/lotus/provider" "github.com/filecoin-project/lotus/storage/paths" "github.com/filecoin-project/lotus/storage/sealer" "github.com/filecoin-project/lotus/storage/sealer/ffiwrapper" diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index e2e47afc7..14c0325c1 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -29,6 +29,14 @@ var Doc = map[string][]DocField{ Comment: ``, }, }, + "ApisConfig": { + { + Name: "FULLNODE_API_INFO", + Type: "[]string", + + Comment: `FULLNODE_API_INFO is the API endpoint for the Lotus daemon.`, + }, + }, "Backup": { { Name: "DisableMetadataLog", @@ -590,6 +598,14 @@ starts. By default, the cache is rehydrated from previously cached entries store datastore if any is present.`, }, }, + "JournalConfig": { + { + Name: "DisabledEvents", + Type: "string", + + Comment: `Events of the form: "system1:event1,system1:event2[,...]"`, + }, + }, "Libp2p": { { Name: "ListenAddresses", @@ -700,6 +716,12 @@ sent automatically, if control addresses are configured. A control address that doesn't have enough funds will still be chosen over the worker address if this flag is set.`, }, + { + Name: "MinerAddresses", + Type: "[]string", + + Comment: `MinerAddresses are the addresses of the miner actors to use for sending messages`, + }, }, "LotusProviderConfig": { { @@ -724,6 +746,30 @@ over the worker address if this flag is set.`, Name: "Proving", Type: "ProvingConfig", + Comment: ``, + }, + { + Name: "SealingParams", + Type: "SealingConfig", + + Comment: ``, + }, + { + Name: "SealerConfig", + Type: "//", + + Comment: ``, + }, + { + Name: "Journal", + Type: "JournalConfig", + + Comment: ``, + }, + { + Name: "Apis", + Type: "ApisConfig", + Comment: ``, }, }, @@ -922,6 +968,12 @@ This is useful to allow workers to bypass the lotus miner to access sector infor Comment: ``, }, + { + Name: "WindowPostMaxTasks", + Type: "int", + + Comment: ``, + }, { Name: "EnableWinningPost", Type: "bool", diff --git a/provider/address.go b/provider/address.go index e4416c140..f69ca3fac 100644 --- a/provider/address.go +++ b/provider/address.go @@ -1,10 +1,12 @@ package provider import ( + "golang.org/x/xerrors" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/storage/ctladdr" - "golang.org/x/xerrors" ) func AddressSelector(addrConf *config.LotusProviderAddresses) func() (*ctladdr.AddressSelector, error) { diff --git a/provider/builder.go b/provider/builder.go index 50d7ec379..325c175e8 100644 --- a/provider/builder.go +++ b/provider/builder.go @@ -2,6 +2,9 @@ package provider import ( "context" + + logging "github.com/ipfs/go-log/v2" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/journal" "github.com/filecoin-project/lotus/lib/harmony/harmonydb" @@ -12,7 +15,6 @@ import ( "github.com/filecoin-project/lotus/storage/ctladdr" "github.com/filecoin-project/lotus/storage/sealer" "github.com/filecoin-project/lotus/storage/sealer/storiface" - logging "github.com/ipfs/go-log/v2" ) var log = logging.Logger("provider") diff --git a/provider/chainsched/chain_sched.go b/provider/chainsched/chain_sched.go index 5f70103cf..559a0274f 100644 --- a/provider/chainsched/chain_sched.go +++ b/provider/chainsched/chain_sched.go @@ -2,14 +2,16 @@ package chainsched import ( "context" + "time" + + logging "github.com/ipfs/go-log/v2" + "go.opencensus.io/trace" + "golang.org/x/xerrors" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - logging "github.com/ipfs/go-log/v2" - "go.opencensus.io/trace" - "golang.org/x/xerrors" - "time" ) var log = logging.Logger("chainsched") diff --git a/provider/lpwindow/prove_sub.go b/provider/lpwindow/prove_sub.go deleted file mode 100644 index 8994f6a67..000000000 --- a/provider/lpwindow/prove_sub.go +++ /dev/null @@ -1,181 +0,0 @@ -package lpwindow - -/* -import ( - "context" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" - "github.com/filecoin-project/go-state-types/dline" - "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/node/modules/dtypes" - "github.com/filecoin-project/lotus/storage/wdpost" -) - -type changeHandler struct { - api WDPoStAPI - actors []dtypes.MinerAddress - proveHdlr *proveHandler -} - -func newChangeHandler(api WDPoStAPI, actors []dtypes.MinerAddress) *changeHandler { - p := newProver(api) - return &changeHandler{api: api, actors: actors, proveHdlr: p} -} - -func (ch *changeHandler) start() { - go ch.proveHdlr.run() -} - -func (ch *changeHandler) Update(ctx context.Context, revert *types.TipSet, advance *types.TipSet) error { - // Get the current deadline period - di, err := ch.api.StateMinerProvingDeadline(ctx, ch.actor, advance.Key()) - if err != nil { - return err - } - - if !di.PeriodStarted() { - return nil // not proving anything yet - } - - hc := &headChange{ - ctx: ctx, - revert: revert, - advance: advance, - di: di, - } - - select { - case ch.proveHdlr.hcs <- hc: - case <-ch.proveHdlr.shutdownCtx.Done(): - case <-ctx.Done(): - } - - return nil -} - -type proveHandler struct { - api WDPoStAPI - posts *postsCache - - //postResults chan *postResult - hcs chan *headChange - - current *currentPost - - shutdownCtx context.Context - shutdownFn context.CancelFunc -} - -type headChange struct { - ctx context.Context - revert *types.TipSet - advance *types.TipSet - di *dline.Info -} - -type currentPost struct { - di *dline.Info - abort context.CancelFunc -} - -func newProver( - api WDPoStAPI, -) *proveHandler { - ctx, cancel := context.WithCancel(context.Background()) - return &proveHandler{ - api: api, - //postResults: make(chan *postResult), - hcs: make(chan *headChange), - shutdownCtx: ctx, - shutdownFn: cancel, - } -} - -func (p *proveHandler) run() { - // Abort proving on shutdownFn - defer func() { - if p.current != nil { - p.current.abort() - } - }() - - for p.shutdownCtx.Err() == nil { - select { - case <-p.shutdownCtx.Done(): - return - - case hc := <-p.hcs: - // Head changed - p.processHeadChange(hc.ctx, hc.advance, hc.di) - - case res := <-p.postResults: - // Proof generation complete - p.processPostResult(res) - } - } -} - -func (p *proveHandler) processHeadChange(ctx context.Context, newTS *types.TipSet, di *dline.Info) { - // If the post window has expired, abort the current proof - if p.current != nil && newTS.Height() >= p.current.di.Close { - // Cancel the context on the current proof - p.current.abort() - - // Clear out the reference to the proof so that we can immediately - // start generating a new proof, without having to worry about state - // getting clobbered when the abort completes - p.current = nil - } - - // Only generate one proof at a time - if p.current != nil { - return - } - - // If the proof for the current post window has been generated, check the - // next post window - _, complete := p.posts.get(di) - for complete { - di = wdpost.NextDeadline(di) - _, complete = p.posts.get(di) - } - - // Check if the chain is above the Challenge height for the post window - if newTS.Height() < di.Challenge+wdpost.ChallengeConfidence { - return - } - - p.current = ¤tPost{di: di} - curr := p.current - p.current.abort = p.api.startGeneratePoST(ctx, newTS, di, func(posts []miner.SubmitWindowedPoStParams, err error) { - p.postResults <- &postResult{ts: newTS, currPost: curr, posts: posts, err: err} - }) -} - -func (p *proveHandler) processPostResult(res *postResult) { - di := res.currPost.di - if res.err != nil { - // Proving failed so inform the API - p.api.recordPoStFailure(res.err, res.ts, di) - log.Warnf("Aborted window post Proving (Deadline: %+v)", di) - p.api.onAbort(res.ts, di) - - // Check if the current post has already been aborted - if p.current == res.currPost { - // If the current post was not already aborted, setting it to nil - // marks it as complete so that a new post can be started - p.current = nil - } - return - } - - // Completed processing this proving window - p.current = nil - - // Add the proofs to the cache - p.posts.add(di, res.posts) -} - -func (ch *changeHandler) Shutdown() { - ch.proveHdlr.shutdownFn() -} -*/ diff --git a/provider/lpwindow/task.go b/provider/lpwindow/task.go index e1a405268..6bdfa7d70 100644 --- a/provider/lpwindow/task.go +++ b/provider/lpwindow/task.go @@ -2,29 +2,31 @@ package lpwindow import ( "context" - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/policy" - "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/wdpost" - logging "github.com/ipfs/go-log/v2" - "golang.org/x/xerrors" "sort" "time" + logging "github.com/ipfs/go-log/v2" + "github.com/samber/lo" + "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/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" + + "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/harmony/harmonydb" "github.com/filecoin-project/lotus/lib/harmony/harmonytask" "github.com/filecoin-project/lotus/lib/harmony/resources" "github.com/filecoin-project/lotus/lib/harmony/taskhelp" + "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/sealtasks" "github.com/filecoin-project/lotus/storage/sealer/storiface" - "github.com/samber/lo" + "github.com/filecoin-project/lotus/storage/wdpost" ) var log = logging.Logger("lpwindow") diff --git a/provider/lpwindow/task_test.go b/provider/lpwindow/task_test.go index c9a65dbc9..0f7a1335b 100644 --- a/provider/lpwindow/task_test.go +++ b/provider/lpwindow/task_test.go @@ -3,12 +3,14 @@ package lpwindow import ( "testing" + "github.com/stretchr/testify/require" + "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/harmony/harmonydb" "github.com/filecoin-project/lotus/lib/harmony/harmonytask" "github.com/filecoin-project/lotus/node/config" - "github.com/stretchr/testify/require" ) // test to create WDPostTask, invoke AddTask and check if the task is added to the DB