From 9cfdea3447fc1a173f4ca99cd2f76c3e247330d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 4 Apr 2024 23:16:34 +0200 Subject: [PATCH] fix: piece: Don't return StartEport in PieceDealInfo.EndEpoch (#11832) --- storage/pipeline/piece/piece_info.go | 2 +- storage/pipeline/precommit_policy_test.go | 35 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/storage/pipeline/piece/piece_info.go b/storage/pipeline/piece/piece_info.go index 7ee8f7029..48e15751a 100644 --- a/storage/pipeline/piece/piece_info.go +++ b/storage/pipeline/piece/piece_info.go @@ -147,7 +147,7 @@ func (ds *PieceDealInfo) EndEpoch() (abi.ChainEpoch, error) { default: // note - when implementing make sure to cache any dynamically computed values // todo do we want a smarter mechanism here - return ds.DealSchedule.StartEpoch, nil + return ds.DealSchedule.EndEpoch, nil } } diff --git a/storage/pipeline/precommit_policy_test.go b/storage/pipeline/precommit_policy_test.go index ec2a61ff2..6329e90d3 100644 --- a/storage/pipeline/precommit_policy_test.go +++ b/storage/pipeline/precommit_policy_test.go @@ -18,6 +18,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -242,3 +243,37 @@ func TestMissingDealIsIgnored(t *testing.T) { assert.Equal(t, 547300, int(exp)) } + +func TestBasicPolicyDDO(t *testing.T) { + cfg := fakeConfigGetter(nil) + pcp := pipeline.NewBasicPreCommitPolicy(&fakeChain{ + h: abi.ChainEpoch(55), + }, cfg, 0) + + pieces := []pipeline.SafeSectorPiece{ + pipeline.SafePiece(api.SectorPiece{ + Piece: abi.PieceInfo{ + Size: abi.PaddedPieceSize(1024), + PieceCID: fakePieceCid(t), + }, + DealInfo: &piece.PieceDealInfo{ + PublishCid: nil, + DealID: abi.DealID(44), + DealSchedule: piece.DealSchedule{ + StartEpoch: abi.ChainEpoch(100_000), + EndEpoch: abi.ChainEpoch(1500_000), + }, + PieceActivationManifest: &miner.PieceActivationManifest{ + Size: 0, + VerifiedAllocationKey: nil, + Notify: nil, + }, + }, + }), + } + + exp, err := pcp.Expiration(context.Background(), pieces...) + require.NoError(t, err) + + assert.Equal(t, abi.ChainEpoch(1500_000), exp) +}