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

Util for miners to extend all v1 sectors #5924

Merged
merged 4 commits into from
Apr 5, 2021
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
1 change: 1 addition & 0 deletions chain/actors/builtin/miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var FaultDeclarationCutoff = miner0.FaultDeclarationCutoff
const MinSectorExpiration = miner0.MinSectorExpiration

// Not used / checked in v0
// TODO: Abstract over network versions
var DeclarationsMax = miner2.DeclarationsMax
var AddressedSectorsMax = miner2.AddressedSectorsMax

Expand Down
37 changes: 36 additions & 1 deletion chain/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func DealProviderCollateralBounds(
case actors.Version3:
return market3.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
default:
panic("unsupported network version")
panic("unsupported actors version")
}
}

Expand Down Expand Up @@ -191,3 +191,38 @@ func GetDefaultSectorSize() abi.SectorSize {

return szs[0]
}

func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) abi.ChainEpoch {
if nwVer <= network.Version10 {
return builtin3.SealProofPoliciesV0[proof].SectorMaxLifetime
}

return builtin3.SealProofPoliciesV11[proof].SectorMaxLifetime
}

func GetAddressedSectorsMax(nwVer network.Version) int {
switch actors.VersionForNetwork(nwVer) {
case actors.Version0:
return miner0.AddressedSectorsMax
case actors.Version2:
return miner2.AddressedSectorsMax
case actors.Version3:
return miner3.AddressedSectorsMax
default:
panic("unsupported network version")
}
}

func GetDeclarationsMax(nwVer network.Version) int {
switch actors.VersionForNetwork(nwVer) {
case actors.Version0:
// TODO: Should we instead panic here since the concept doesn't exist yet?
return miner0.AddressedPartitionsMax
case actors.Version2:
return miner2.DeclarationsMax
case actors.Version3:
return miner3.DeclarationsMax
default:
panic("unsupported network version")
}
}
2 changes: 1 addition & 1 deletion cmd/lotus-storage-miner/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func infoCmdAct(cctx *cli.Context) error {

fmt.Println()

maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
maddr, err := getActorAddress(ctx, cctx)
if err != nil {
return err
}
Expand Down
12 changes: 9 additions & 3 deletions cmd/lotus-storage-miner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,21 @@ func main() {
lcli.RunApp(app)
}

func getActorAddress(ctx context.Context, nodeAPI api.StorageMiner, overrideMaddr string) (maddr address.Address, err error) {
if overrideMaddr != "" {
maddr, err = address.NewFromString(overrideMaddr)
func getActorAddress(ctx context.Context, cctx *cli.Context) (maddr address.Address, err error) {
if cctx.IsSet("actor") {
maddr, err = address.NewFromString(cctx.String("actor"))
if err != nil {
return maddr, err
}
return
}

nodeAPI, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return address.Undef, err
}
defer closer()

maddr, err = nodeAPI.ActorAddress(ctx)
if err != nil {
return maddr, xerrors.Errorf("getting actor address: %w", err)
Expand Down
32 changes: 4 additions & 28 deletions cmd/lotus-storage-miner/proving.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ var provingFaultsCmd = &cli.Command{
Action: func(cctx *cli.Context) error {
color.NoColor = !cctx.Bool("color")

nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()

api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
Expand All @@ -54,7 +48,7 @@ var provingFaultsCmd = &cli.Command{

stor := store.ActorStore(ctx, blockstore.NewAPIBlockstore(api))

maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
maddr, err := getActorAddress(ctx, cctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -98,12 +92,6 @@ var provingInfoCmd = &cli.Command{
Action: func(cctx *cli.Context) error {
color.NoColor = !cctx.Bool("color")

nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()

api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
Expand All @@ -112,7 +100,7 @@ var provingInfoCmd = &cli.Command{

ctx := lcli.ReqContext(cctx)

maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
maddr, err := getActorAddress(ctx, cctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -211,12 +199,6 @@ var provingDeadlinesCmd = &cli.Command{
Action: func(cctx *cli.Context) error {
color.NoColor = !cctx.Bool("color")

nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()

api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
Expand All @@ -225,7 +207,7 @@ var provingDeadlinesCmd = &cli.Command{

ctx := lcli.ReqContext(cctx)

maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
maddr, err := getActorAddress(ctx, cctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -301,12 +283,6 @@ var provingDeadlineInfoCmd = &cli.Command{
return xerrors.Errorf("could not parse deadline index: %w", err)
}

nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil {
return err
}
defer closer()

api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
Expand All @@ -315,7 +291,7 @@ var provingDeadlineInfoCmd = &cli.Command{

ctx := lcli.ReqContext(cctx)

maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
maddr, err := getActorAddress(ctx, cctx)
if err != nil {
return err
}
Expand Down
Loading