From 9fd5721de9d87b3eb428960aabf7f85c98ad6f2b Mon Sep 17 00:00:00 2001 From: Phi Date: Fri, 10 Nov 2023 10:25:34 +0100 Subject: [PATCH] Revert move-partitions cmd Revert move-partitions cmd --- cmd/lotus-miner/actor.go | 138 ---------------------------- documentation/en/cli-lotus-miner.md | 17 ---- 2 files changed, 155 deletions(-) diff --git a/cmd/lotus-miner/actor.go b/cmd/lotus-miner/actor.go index 320c4e6de81..6d76cc07fdc 100644 --- a/cmd/lotus-miner/actor.go +++ b/cmd/lotus-miner/actor.go @@ -21,7 +21,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - minerV12 "github.com/filecoin-project/go-state-types/builtin/v12/miner" "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" @@ -50,7 +49,6 @@ var actorCmd = &cli.Command{ actorProposeChangeWorker, actorConfirmChangeWorker, actorCompactAllocatedCmd, - actorMovePartitionsCmd, actorProposeChangeBeneficiary, actorConfirmChangeBeneficiary, }, @@ -1288,142 +1286,6 @@ var actorConfirmChangeBeneficiary = &cli.Command{ }, } -var actorMovePartitionsCmd = &cli.Command{ - Name: "move-partitions", - Usage: "move deadline of specified partitions from one to another", - Flags: []cli.Flag{ - &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, - }, - }, - 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") - } - - ctx := lcli.ReqContext(cctx) - - minerApi, closer, err := lcli.GetStorageMinerAPI(cctx) - if err != nil { - return err - } - defer closer() - - maddr, err := minerApi.ActorAddress(ctx) - if err != nil { - return err - } - - fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr)) - - fullNodeApi, acloser, err := lcli.GetFullNodeAPI(cctx) - if err != nil { - return err - } - defer acloser() - - minfo, err := fullNodeApi.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 := fullNodeApi.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) - } - - smsg, err := fullNodeApi.MpoolPushMessage(ctx, &types.Message{ - From: minfo.Worker, - To: maddr, - Method: builtin.MethodsMiner.MovePartitions, - Value: big.Zero(), - Params: serializedParams, - }, nil) - if err != nil { - return fmt.Errorf("mpool push: %w", err) - } - - fmt.Println("MovePartitions Message CID:", smsg.Cid()) - - // wait for it to get mined into a block - fmt.Println("Waiting for block confirmation...") - wait, err := fullNodeApi.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence) - if err != nil { - return err - } - - // check it executed successfully - if wait.Receipt.ExitCode.IsError() { - fmt.Println("Moving partitions failed!") - return err - } - - fmt.Println("Move partition confirmed") - - return nil - }, -} - var actorCompactAllocatedCmd = &cli.Command{ Name: "compact-allocated", Usage: "compact allocated sectors bitfield", diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 1ee74871487..eddf41d1c80 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -223,7 +223,6 @@ COMMANDS: propose-change-worker Propose a worker address change confirm-change-worker Confirm a worker address change compact-allocated compact allocated sectors bitfield - move-partitions move deadline of specified partitions from one to another propose-change-beneficiary Propose a beneficiary address change confirm-change-beneficiary Confirm a beneficiary address change help, h Shows a list of commands or help for one command @@ -373,22 +372,6 @@ OPTIONS: --help, -h show help ``` -### lotus-miner actor move-partitions -``` -NAME: - lotus-miner actor move-partitions - move deadline of specified partitions from one to another - -USAGE: - lotus-miner actor move-partitions [command options] [arguments...] - -OPTIONS: - --partition-indices value [ --partition-indices value ] Indices of partitions to update, separated by comma - --orig-deadline value Deadline to move partition from (default: 0) - --dest-deadline value Deadline to move partition to (default: 0) - --really-do-it Actually send transaction performing the action (default: false) - --help, -h show help -``` - ### lotus-miner actor propose-change-beneficiary ``` NAME: