From 14c7ed17d6c1e1cd45e17fde8501cb3cdfc0b445 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:28:14 +0800 Subject: [PATCH 1/3] fix: piece size already padded --- cmd/droplet-client/direct-deal.go | 8 ++++++++ cmd/droplet-client/util.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/droplet-client/direct-deal.go b/cmd/droplet-client/direct-deal.go index beffcae3..a6d7ed27 100644 --- a/cmd/droplet-client/direct-deal.go +++ b/cmd/droplet-client/direct-deal.go @@ -108,6 +108,9 @@ var directDealAllocate = &cli.Command{ Name: "start-epoch", Usage: "start epoch by when the deal should be proved by provider on-chain (default: 8 days from now)", }, + &cli.BoolFlag{ + Name: "piece-size-padded", + }, }, Action: func(cctx *cli.Context) error { if cctx.IsSet("piece-info") && cctx.IsSet("manifest") { @@ -302,6 +305,7 @@ func pieceInfosFromCtx(cctx *cli.Context) ([]*pieceInfo, uint64, error) { var pieceInfos []*pieceInfo var rDataCap uint64 pieces := cctx.StringSlice("piece-info") + pieceSizePadded := cctx.Bool("piece-size-padded") for _, p := range pieces { pieceDetail := strings.Split(p, "=") @@ -322,6 +326,10 @@ func pieceInfosFromCtx(cctx *cli.Context) ([]*pieceInfo, uint64, error) { } pieceSize := abi.UnpaddedPieceSize(n).Padded() + if pieceSizePadded { + pieceSize = abi.PaddedPieceSize(n) + } + pieceInfos = append(pieceInfos, &pieceInfo{ pieceSize: pieceSize, pieceCID: pcid, diff --git a/cmd/droplet-client/util.go b/cmd/droplet-client/util.go index a51aa853..901deb52 100644 --- a/cmd/droplet-client/util.go +++ b/cmd/droplet-client/util.go @@ -84,7 +84,7 @@ func loadManifest(path string) ([]*manifest, error) { manifests = append(manifests, &manifest{payloadCID: payloadCID, payloadSize: payloadSize, pieceCID: pieceCID, pieceSize: abi.UnpaddedPieceSize(pieceSize)}) } - } else if len(record) == 6 { + } else if len(record) >= 5 { // payload_cid,filename,piece_cid,payload_size,piece_size,detail payloadCID, err := cid.Parse(record[0]) if err != nil { From 2aa9f56259102807806b3d825bdcce30fcd22afe Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:09:13 +0800 Subject: [PATCH 2/3] fix: piece size already padded --- cmd/droplet-client/direct-deal.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/droplet-client/direct-deal.go b/cmd/droplet-client/direct-deal.go index a6d7ed27..299bae33 100644 --- a/cmd/droplet-client/direct-deal.go +++ b/cmd/droplet-client/direct-deal.go @@ -344,6 +344,7 @@ func pieceInfosFromFile(cctx *cli.Context) ([]*pieceInfo, uint64, error) { var pieceInfos []*pieceInfo var rDataCap uint64 manifest := cctx.String("manifest") + pieceSizePadded := cctx.Bool("piece-size-padded") pieces, err := loadManifest(manifest) if err != nil { @@ -355,6 +356,9 @@ func pieceInfosFromFile(cctx *cli.Context) ([]*pieceInfo, uint64, error) { return nil, 0, fmt.Errorf("invalid piece size: %d", p.pieceSize) } n := p.pieceSize.Padded() + if pieceSizePadded { + n = abi.PaddedPieceSize(p.pieceSize) + } pieceInfos = append(pieceInfos, &pieceInfo{ pieceSize: n, pieceCID: p.pieceCID, From 68b1e041d06ec9159bfe79842ea3f5b68836fb89 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:58:11 +0800 Subject: [PATCH 3/3] fix: output multi miner deal to file --- cmd/droplet-client/direct-deal.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/droplet-client/direct-deal.go b/cmd/droplet-client/direct-deal.go index 299bae33..63ef23b1 100644 --- a/cmd/droplet-client/direct-deal.go +++ b/cmd/droplet-client/direct-deal.go @@ -139,6 +139,7 @@ var directDealAllocate = &cli.Command{ // Get all minerIDs from input maddrs := make(map[abi.ActorID]types.MinerInfo) + mIDs := make(map[abi.ActorID]struct{}) minerIds := cctx.StringSlice("miner") for _, id := range minerIds { maddr, err := address.NewFromString(id) @@ -158,6 +159,7 @@ var directDealAllocate = &cli.Command{ } maddrs[abi.ActorID(mid)] = m + mIDs[abi.ActorID(mid)] = struct{}{} } // Get all pieceCIDs from input @@ -270,7 +272,7 @@ var directDealAllocate = &cli.Command{ return fmt.Errorf("failed to execute the message with error: %s", res.Receipt.ExitCode.Error()) } - newAllocations, err := findNewAllocations(ctx, fapi, walletAddr, oldAllocations) + newAllocations, err := findNewAllocations(ctx, fapi, walletAddr, oldAllocations, mIDs) if err != nil { return fmt.Errorf("failed to find new allocations: %w", err) } @@ -396,7 +398,7 @@ func getAllocationParams(cctx *cli.Context, currentHeight abi.ChainEpoch) (*allo return ¶ms, nil } -func findNewAllocations(ctx context.Context, fapi v1.FullNode, walletAddr address.Address, oldAllocations map[types.AllocationId]types.Allocation) (map[types.AllocationId]types.Allocation, error) { +func findNewAllocations(ctx context.Context, fapi v1.FullNode, walletAddr address.Address, oldAllocations map[types.AllocationId]types.Allocation, mIDs map[abi.ActorID]struct{}) (map[types.AllocationId]types.Allocation, error) { allAllocations, err := fapi.StateGetAllocations(ctx, walletAddr, types.EmptyTSK) if err != nil { return nil, fmt.Errorf("failed to get allocations: %w", err) @@ -405,6 +407,9 @@ func findNewAllocations(ctx context.Context, fapi v1.FullNode, walletAddr addres newAllocations := make(map[types.AllocationId]types.Allocation, len(allAllocations)-len(oldAllocations)) for k, v := range allAllocations { if _, ok := oldAllocations[k]; !ok { + if _, ok := mIDs[v.Provider]; !ok { + continue + } newAllocations[k] = v } }