Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Support early sector finalization #88

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ Use with caution since might not be compatible in all filesystems.`,
Description: `If bigger than zero, stop bidding if the number of Lotus sealing sectors exceeds this limit.
Zero means no limits`,
},
{
Name: "finalize-early",
DefValue: false,
Description: "Match lotus FinalizeEarly sector state accounting",
},
{
Name: "deal-data-fetch-attempts",
DefValue: 3,
Expand Down Expand Up @@ -364,6 +369,7 @@ var daemonCmd = &cobra.Command{
v.GetString("lotus-market-api-token"),
v.GetInt("lotus-api-conn-retries"),
v.GetBool("fake-mode"),
v.GetBool("finalize-early"),
)
cli.CheckErrf("creating lotus client: %v", err)
fin.Add(lc)
Expand Down
22 changes: 15 additions & 7 deletions service/lotusclient/lotusclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,27 @@ type LotusClient interface {

// Client provides access to Lotus for importing deal data.
type Client struct {
cmin api.StorageMiner
cmkt api.StorageMiner
fakeMode bool
cmin api.StorageMiner
cmkt api.StorageMiner
fakeMode bool
finalizeEarly bool

ctx context.Context
finalizer *finalizer.Finalizer
}

// New returns a new *LotusClient.
func New(maddr string, authToken string, marketMaddr string, marketAuthToken string,
connRetries int, fakeMode bool) (*Client, error) {
connRetries int, fakeMode bool, finalizeEarly bool) (*Client, error) {
fin := finalizer.NewFinalizer()
ctx, cancel := context.WithCancel(context.Background())
fin.Add(finalizer.NewContextCloser(cancel))

lc := &Client{
fakeMode: fakeMode,
ctx: ctx,
finalizer: fin,
fakeMode: fakeMode,
finalizeEarly: finalizeEarly,
ctx: ctx,
finalizer: fin,
}
if lc.fakeMode {
return lc, nil
Expand Down Expand Up @@ -123,6 +125,12 @@ func (c *Client) CurrentSealingSectors() (int, error) {
notSealingStates := []string{"Proving", "Removed", "Removing",
"Terminating", "TerminateWait", "TerminateFinality", "TerminateFailed"}

if c.finalizeEarly {
// some additional states can be mapped to sstProving with the FinalizeEarly option
// https://github.com/filecoin-project/lotus/blob/v1.13.0/extern/storage-sealing/sector_state.go#L115
notSealingStates = append(notSealingStates, "SubmitCommit", "CommitWait", "SubmitCommitAggregate", "CommitAggregateWait", "SubmitReplicaUpdate", "ReplicaUpdateWait")
}

ctx, cancel := context.WithTimeout(c.ctx, requestTimeout)
defer cancel()
start := time.Now()
Expand Down