lpwindow: make gen
This commit is contained in:
parent
ad9c05e30b
commit
a5a0bd378e
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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",
|
||||
|
@ -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) {
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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()
|
||||
}
|
||||
*/
|
@ -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")
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user