Skip to content
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

add start-epoch-head-offset #1223

Merged
merged 3 commits into from
Feb 27, 2023
Merged
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
37 changes: 24 additions & 13 deletions cmd/boost/deal_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -54,9 +55,12 @@ var dealFlags = []cli.Flag{
Required: true,
},
&cli.IntFlag{
Name: "start-epoch",
Usage: "start epoch by when the deal should be proved by provider on-chain",
DefaultText: "current chain head + 2 days",
Name: "start-epoch-head-offset",
Usage: "start epoch by when the deal should be proved by provider on-chain after current chain head",
},
&cli.IntFlag{
Name: "start-epoch",
Usage: "start epoch by when the deal should be proved by provider on-chain",
},
&cli.IntFlag{
Name: "duration",
Expand Down Expand Up @@ -233,19 +237,26 @@ func dealCmdAction(cctx *cli.Context, isOnline bool) error {
providerCollateral = big.Div(big.Mul(bounds.Min, big.NewInt(6)), big.NewInt(5)) // add 20%
}

var startEpoch abi.ChainEpoch
if cctx.IsSet("start-epoch") {
startEpoch = abi.ChainEpoch(cctx.Int("start-epoch"))
} else {
tipset, err := api.ChainHead(ctx)
if err != nil {
return fmt.Errorf("getting chain head: %w", err)
}
tipset, err := api.ChainHead(ctx)
if err != nil {
return fmt.Errorf("cannot get chain head: %w", err)
}

head := tipset.Height()
head := tipset.Height()
log.Debugw("current block height", "number", head)

log.Debugw("current block height", "number", head)
if cctx.IsSet("start-epoch") && cctx.IsSet("start-epoch-head-offset") {
return errors.New("only one flag from `start-epoch-head-offset' or `start-epoch` can be specified")
}

var startEpoch abi.ChainEpoch

if cctx.IsSet("start-epoch-head-offset") {
startEpoch = head + abi.ChainEpoch(cctx.Int("start-epoch-head-offset"))
} else if cctx.IsSet("start-epoch") {
startEpoch = abi.ChainEpoch(cctx.Int("start-epoch"))
} else {
// default
startEpoch = head + abi.ChainEpoch(5760) // head + 2 days
}

Expand Down