Skip to content

Commit

Permalink
fix: piece: Don't return StartEport in PieceDealInfo.EndEpoch (#11832)
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k authored Apr 4, 2024
1 parent fd64e38 commit 37c24bb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion storage/pipeline/piece/piece_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
35 changes: 35 additions & 0 deletions storage/pipeline/precommit_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

0 comments on commit 37c24bb

Please sign in to comment.