Can now specify a range of partitions to make a bad proof for

This commit is contained in:
Geoff Stuart 2022-05-16 14:14:43 -04:00
parent e49a9b790b
commit ca21235a4f

View File

@ -370,12 +370,16 @@ var sendInvalidWindowPoStCmd = &cli.Command{
Usage: "Actually send transaction performing the action", Usage: "Actually send transaction performing the action",
Value: false, Value: false,
}, },
&cli.Int64SliceFlag{
Name: "partitions",
Usage: "list of partitions to compact sectors in",
Required: true,
},
&cli.StringFlag{ &cli.StringFlag{
Name: "actor", Name: "actor",
Usage: "TODO", Usage: "TODO",
}, },
}, },
ArgsUsage: "",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if !cctx.Bool("really-do-it") { if !cctx.Bool("really-do-it") {
fmt.Println("Pass --really-do-it to actually execute this action") fmt.Println("Pass --really-do-it to actually execute this action")
@ -402,10 +406,10 @@ var sendInvalidWindowPoStCmd = &cli.Command{
deadline, err := api.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK) deadline, err := api.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
//buf := new(bytes.Buffer) partitionIndices := cctx.Int64Slice("partitions")
//if err := maddr.MarshalCBOR(buf); err != nil { if len(partitionIndices) <= 0 {
// return xerrors.Errorf("failed to marshal address to cbor: %w", err) return fmt.Errorf("must include at least one partition to compact")
//} }
chainHead, err := api.ChainHead(ctx) chainHead, err := api.ChainHead(ctx)
if err != nil { if err != nil {
@ -419,15 +423,26 @@ var sendInvalidWindowPoStCmd = &cli.Command{
return xerrors.Errorf("getting proof size: %w", err) return xerrors.Errorf("getting proof size: %w", err)
} }
params := miner.SubmitWindowedPoStParams{ var partitions []miner.PoStPartition
Deadline: deadline.Index, var proofs []proof.PoStProof
Partitions: []miner.PoStPartition{{
Index: 0, emptyProof := proof.PoStProof{
PoStProof: minfo.WindowPoStProofType,
ProofBytes: make([]byte, 0, proofSize)}
for _, partition := range partitionIndices {
newPartition := miner.PoStPartition{
Index: uint64(partition),
Skipped: bitfield.New(), Skipped: bitfield.New(),
}}, }
Proofs: []proof.PoStProof{{ partitions = append(partitions, newPartition)
PoStProof: minfo.WindowPoStProofType, proofs = append(proofs, emptyProof)
ProofBytes: make([]byte, 0, proofSize)}}, }
params := miner.SubmitWindowedPoStParams{
Deadline: deadline.Index,
Partitions: partitions,
Proofs: proofs,
ChainCommitEpoch: deadline.Challenge, ChainCommitEpoch: deadline.Challenge,
ChainCommitRand: checkRand, ChainCommitRand: checkRand,
} }
@ -437,6 +452,7 @@ var sendInvalidWindowPoStCmd = &cli.Command{
return xerrors.Errorf("serializing params: %w", err) return xerrors.Errorf("serializing params: %w", err)
} }
fmt.Printf("submitting bad PoST for %d paritions\n", len(partitionIndices))
smsg, err := api.MpoolPushMessage(ctx, &types.Message{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{
From: minfo.Worker, From: minfo.Worker,
To: maddr, To: maddr,