Merge pull request #6047 from filecoin-project/feat/client-collat-bounds

Adjust client deal collateral overestimation to 1.2
This commit is contained in:
Łukasz Magiera 2021-04-15 23:51:32 +02:00 committed by GitHub
commit 35cf83d519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -212,7 +212,13 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor
return res.IDs[dealIdx], nil
}
const clientOverestimation = 2
var clientOverestimation = struct {
numerator int64
denominator int64
}{
numerator: 12,
denominator: 10,
}
func (c *ClientNodeAdapter) DealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, isVerified bool) (abi.TokenAmount, abi.TokenAmount, error) {
bounds, err := c.StateDealProviderCollateralBounds(ctx, size, isVerified, types.EmptyTSK)
@ -220,7 +226,9 @@ func (c *ClientNodeAdapter) DealProviderCollateralBounds(ctx context.Context, si
return abi.TokenAmount{}, abi.TokenAmount{}, err
}
return big.Mul(bounds.Min, big.NewInt(clientOverestimation)), bounds.Max, nil
min := big.Mul(bounds.Min, big.NewInt(clientOverestimation.numerator))
min = big.Div(min, big.NewInt(clientOverestimation.denominator))
return min, bounds.Max, nil
}
// TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer)