From 9d8c234b27de629cb9649d3bcb6f9f3e9dd4a0d2 Mon Sep 17 00:00:00 2001 From: 0x5459 <0x5459@protonmail.com> Date: Thu, 23 Nov 2023 18:02:33 +0800 Subject: [PATCH] remove command `move-partitions` --- .../internal/util_sealer_sectors.go | 277 +++++++++--------- 1 file changed, 138 insertions(+), 139 deletions(-) diff --git a/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go b/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go index 064cc4964..75a3fdcff 100644 --- a/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go +++ b/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go @@ -40,7 +40,6 @@ import ( specpolicy "github.com/filecoin-project/venus/venus-shared/actors/policy" "github.com/filecoin-project/venus/venus-shared/types" - minerV12 "github.com/filecoin-project/go-state-types/builtin/v12/miner" "github.com/filecoin-project/lotus/api" "github.com/ipfs-force-community/damocles/damocles-manager/core" "github.com/ipfs-force-community/damocles/damocles-manager/modules/policy" @@ -2636,141 +2635,141 @@ var utilSealerSectorsUnsealCmd = &cli.Command{ }, } -var utilSealerSectorsMovePartitionsCmd = &cli.Command{ - Name: "move-partitions", - Usage: "move deadline of specified partitions from one to another", - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "miner", - Usage: "miner address", - Required: true, - }, - &cli.Int64SliceFlag{ - Name: "partition-indices", - Usage: "Indices of partitions to update, separated by comma", - }, - &cli.Uint64Flag{ - Name: "orig-deadline", - Usage: "Deadline to move partition from", - }, - &cli.Uint64Flag{ - Name: "dest-deadline", - Usage: "Deadline to move partition to", - }, - &cli.BoolFlag{ - Name: "really-do-it", - Usage: "Actually send transaction performing the action", - Value: false, - }, - &cli.IntFlag{ - Name: "confidence", - Usage: "Number of epochs to wait for message confidence", - Value: 5, - }, - }, - Action: func(cctx *cli.Context) error { - if !cctx.Bool("really-do-it") { - fmt.Println("Pass --really-do-it to actually execute this action") - return nil - } - - if cctx.Args().Present() { - return fmt.Errorf("please use flags to provide arguments") - } - - maddr, err := ShouldAddress(cctx.String("miner"), false, true) - if err != nil { - return err - } - - fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr)) - - api, ctx, stop, err := extractAPI(cctx) - if err != nil { - return err - } - defer stop() - - minfo, err := api.Chain.StateMinerInfo(ctx, maddr, types.EmptyTSK) - if err != nil { - return err - } - - origDeadline := cctx.Uint64("orig-deadline") - if origDeadline > miner.WPoStPeriodDeadlines { - return fmt.Errorf("orig-deadline %d out of range", origDeadline) - } - destDeadline := cctx.Uint64("dest-deadline") - if destDeadline > miner.WPoStPeriodDeadlines { - return fmt.Errorf("dest-deadline %d out of range", destDeadline) - } - if origDeadline == destDeadline { - return fmt.Errorf("dest-desdline cannot be the same as orig-deadline") - } - - partitions := cctx.Int64Slice("partition-indices") - if len(partitions) == 0 { - return fmt.Errorf("must include at least one partition to move") - } - - curPartitions, err := api.Chain.StateMinerPartitions(ctx, maddr, origDeadline, types.EmptyTSK) - if err != nil { - return fmt.Errorf("getting partitions for deadline %d: %w", origDeadline, err) - } - if len(partitions) > len(curPartitions) { - return fmt.Errorf("partition size(%d) cannot be bigger than current partition size(%d) for deadline %d", len(partitions), len(curPartitions), origDeadline) - } - - fmt.Printf("Moving %d paritions\n", len(partitions)) - - partitionsBf := bitfield.New() - for _, partition := range partitions { - if partition >= int64(len(curPartitions)) { - return fmt.Errorf("partition index(%d) doesn't exist", partition) - } - partitionsBf.Set(uint64(partition)) - } - - params := minerV12.MovePartitionsParams{ - OrigDeadline: origDeadline, - DestDeadline: destDeadline, - Partitions: partitionsBf, - } - - serializedParams, err := actors.SerializeParams(¶ms) - if err != nil { - return fmt.Errorf("serializing params: %w", err) - } - - mid, err := api.Messager.PushMessage(ctx, &types.Message{ - From: minfo.Worker, - To: maddr, - Method: builtin.MethodsMiner.MovePartitions, - Value: big.Zero(), - Params: serializedParams, - }, nil) - if err != nil { - return err - } - - fmt.Printf("MovePartitions Message CID: %s\n", mid) - - // wait for it to get mined into a block - fmt.Printf("waiting for %d epochs for confirmation..\n", uint64(cctx.Int("confidence"))) - - wait, err := api.Messager.WaitMessage(ctx, mid, uint64(cctx.Int("confidence"))) - if err != nil { - return err - } - - // check it executed successfully - if wait.Receipt.ExitCode != 0 { - fmt.Println("Moving partitions failed!") - return err - } - - fmt.Println("Move partition confirmed") - - return nil - }, -} +// var utilSealerSectorsMovePartitionsCmd = &cli.Command{ +// Name: "move-partitions", +// Usage: "move deadline of specified partitions from one to another", +// Flags: []cli.Flag{ +// &cli.StringFlag{ +// Name: "miner", +// Usage: "miner address", +// Required: true, +// }, +// &cli.Int64SliceFlag{ +// Name: "partition-indices", +// Usage: "Indices of partitions to update, separated by comma", +// }, +// &cli.Uint64Flag{ +// Name: "orig-deadline", +// Usage: "Deadline to move partition from", +// }, +// &cli.Uint64Flag{ +// Name: "dest-deadline", +// Usage: "Deadline to move partition to", +// }, +// &cli.BoolFlag{ +// Name: "really-do-it", +// Usage: "Actually send transaction performing the action", +// Value: false, +// }, +// &cli.IntFlag{ +// Name: "confidence", +// Usage: "Number of epochs to wait for message confidence", +// Value: 5, +// }, +// }, +// Action: func(cctx *cli.Context) error { +// if !cctx.Bool("really-do-it") { +// fmt.Println("Pass --really-do-it to actually execute this action") +// return nil +// } + +// if cctx.Args().Present() { +// return fmt.Errorf("please use flags to provide arguments") +// } + +// maddr, err := ShouldAddress(cctx.String("miner"), false, true) +// if err != nil { +// return err +// } + +// fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr)) + +// api, ctx, stop, err := extractAPI(cctx) +// if err != nil { +// return err +// } +// defer stop() + +// minfo, err := api.Chain.StateMinerInfo(ctx, maddr, types.EmptyTSK) +// if err != nil { +// return err +// } + +// origDeadline := cctx.Uint64("orig-deadline") +// if origDeadline > miner.WPoStPeriodDeadlines { +// return fmt.Errorf("orig-deadline %d out of range", origDeadline) +// } +// destDeadline := cctx.Uint64("dest-deadline") +// if destDeadline > miner.WPoStPeriodDeadlines { +// return fmt.Errorf("dest-deadline %d out of range", destDeadline) +// } +// if origDeadline == destDeadline { +// return fmt.Errorf("dest-desdline cannot be the same as orig-deadline") +// } + +// partitions := cctx.Int64Slice("partition-indices") +// if len(partitions) == 0 { +// return fmt.Errorf("must include at least one partition to move") +// } + +// curPartitions, err := api.Chain.StateMinerPartitions(ctx, maddr, origDeadline, types.EmptyTSK) +// if err != nil { +// return fmt.Errorf("getting partitions for deadline %d: %w", origDeadline, err) +// } +// if len(partitions) > len(curPartitions) { +// return fmt.Errorf("partition size(%d) cannot be bigger than current partition size(%d) for deadline %d", len(partitions), len(curPartitions), origDeadline) +// } + +// fmt.Printf("Moving %d paritions\n", len(partitions)) + +// partitionsBf := bitfield.New() +// for _, partition := range partitions { +// if partition >= int64(len(curPartitions)) { +// return fmt.Errorf("partition index(%d) doesn't exist", partition) +// } +// partitionsBf.Set(uint64(partition)) +// } + +// params := minerV12.MovePartitionsParams{ +// OrigDeadline: origDeadline, +// DestDeadline: destDeadline, +// Partitions: partitionsBf, +// } + +// serializedParams, err := actors.SerializeParams(¶ms) +// if err != nil { +// return fmt.Errorf("serializing params: %w", err) +// } + +// mid, err := api.Messager.PushMessage(ctx, &types.Message{ +// From: minfo.Worker, +// To: maddr, +// Method: builtin.MethodsMiner.MovePartitions, +// Value: big.Zero(), +// Params: serializedParams, +// }, nil) +// if err != nil { +// return err +// } + +// fmt.Printf("MovePartitions Message CID: %s\n", mid) + +// // wait for it to get mined into a block +// fmt.Printf("waiting for %d epochs for confirmation..\n", uint64(cctx.Int("confidence"))) + +// wait, err := api.Messager.WaitMessage(ctx, mid, uint64(cctx.Int("confidence"))) +// if err != nil { +// return err +// } + +// // check it executed successfully +// if wait.Receipt.ExitCode != 0 { +// fmt.Println("Moving partitions failed!") +// return err +// } + +// fmt.Println("Move partition confirmed") + +// return nil +// }, +// }