Skip to content

Commit

Permalink
fix: market: use expiry-activation for deal weight calculation
Browse files Browse the repository at this point in the history
Ref: #237
  • Loading branch information
firesWu authored and rvagg committed Jul 22, 2024
1 parent 345ace6 commit 4e45acf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion builtin/v13/market/market_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func validateAndComputeDealWeight(proposals *DealArray, dealIDs []abi.DealID, mi

// Compute deal weight
totalDealSpace += uint64(proposal.PieceSize)
dealSpaceTime := DealWeight(proposal)
dealSpaceTime := DealWeight(proposal, sectorExpiry, sectorActivation)
if proposal.VerifiedDeal {
totalVerifiedSpaceTime = big.Add(totalVerifiedSpaceTime, dealSpaceTime)
} else {
Expand Down
4 changes: 2 additions & 2 deletions builtin/v13/market/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func DealClientCollateralBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min ab
}

// Computes the weight for a deal proposal, which is a function of its size and duration.
func DealWeight(proposal *DealProposal) abi.DealWeight {
dealDuration := big.NewInt(int64(proposal.Duration()))
func DealWeight(proposal *DealProposal, sectorExpiry abi.ChainEpoch, sectorActivation abi.ChainEpoch) abi.DealWeight {
dealDuration := big.NewInt(int64(sectorExpiry - sectorActivation))
dealSize := big.NewIntUnsigned(uint64(proposal.PieceSize))
dealSpaceTime := big.Mul(dealDuration, dealSize)
return dealSpaceTime
Expand Down
2 changes: 1 addition & 1 deletion builtin/v14/market/market_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func validateAndComputeDealWeight(proposals *DealArray, dealIDs []abi.DealID, mi

// Compute deal weight
totalDealSpace += uint64(proposal.PieceSize)
dealSpaceTime := DealWeight(proposal)
dealSpaceTime := DealWeight(proposal, sectorExpiry, sectorActivation)
if proposal.VerifiedDeal {
totalVerifiedSpaceTime = big.Add(totalVerifiedSpaceTime, dealSpaceTime)
} else {
Expand Down
4 changes: 2 additions & 2 deletions builtin/v14/market/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func DealClientCollateralBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min ab
}

// Computes the weight for a deal proposal, which is a function of its size and duration.
func DealWeight(proposal *DealProposal) abi.DealWeight {
dealDuration := big.NewInt(int64(proposal.Duration()))
func DealWeight(proposal *DealProposal, sectorExpiry abi.ChainEpoch, sectorActivation abi.ChainEpoch) abi.DealWeight {
dealDuration := big.NewInt(int64(sectorExpiry - sectorActivation))
dealSize := big.NewIntUnsigned(uint64(proposal.PieceSize))
dealSpaceTime := big.Mul(dealDuration, dealSize)
return dealSpaceTime
Expand Down

0 comments on commit 4e45acf

Please sign in to comment.