lotus/chain/actors/policy/policy.go

777 lines
23 KiB
Go
Raw Normal View History

package policy
import (
2021-08-10 17:07:30 +00:00
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/abi"
2022-11-08 05:53:13 +00:00
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/big"
builtin10 "github.com/filecoin-project/go-state-types/builtin"
builtin11 "github.com/filecoin-project/go-state-types/builtin"
2022-11-08 05:53:13 +00:00
builtin8 "github.com/filecoin-project/go-state-types/builtin"
builtin9 "github.com/filecoin-project/go-state-types/builtin"
market10 "github.com/filecoin-project/go-state-types/builtin/v10/market"
miner10 "github.com/filecoin-project/go-state-types/builtin/v10/miner"
verifreg10 "github.com/filecoin-project/go-state-types/builtin/v10/verifreg"
market11 "github.com/filecoin-project/go-state-types/builtin/v11/market"
miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner"
paych11 "github.com/filecoin-project/go-state-types/builtin/v11/paych"
verifreg11 "github.com/filecoin-project/go-state-types/builtin/v11/verifreg"
2022-11-08 05:53:13 +00:00
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg"
market9 "github.com/filecoin-project/go-state-types/builtin/v9/market"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
2020-09-30 20:30:24 +00:00
"github.com/filecoin-project/go-state-types/network"
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
2022-11-08 04:55:56 +00:00
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
2022-11-08 05:53:13 +00:00
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
2022-04-07 18:46:23 +00:00
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
2020-09-30 20:30:24 +00:00
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
2020-09-29 00:28:16 +00:00
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
2022-04-07 18:46:23 +00:00
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
2021-01-21 18:44:13 +00:00
market3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/market"
miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner"
verifreg3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/verifreg"
2022-04-07 18:46:23 +00:00
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market"
miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner"
verifreg4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/verifreg"
2022-04-07 18:46:23 +00:00
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
2021-05-06 05:44:11 +00:00
market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
verifreg5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/verifreg"
2022-04-07 18:46:23 +00:00
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
2021-09-15 15:22:25 +00:00
market6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/market"
miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner"
verifreg6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/verifreg"
2022-04-07 18:46:23 +00:00
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
2021-11-04 15:59:29 +00:00
market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
2020-09-29 00:28:16 +00:00
)
const (
ChainFinality = miner11.ChainFinality
2021-04-27 07:34:12 +00:00
SealRandomnessLookback = ChainFinality
PaychSettleDelay = paych11.SettleDelay
MaxPreCommitRandomnessLookback = builtin11.EpochsInDay + SealRandomnessLookback
)
// SetSupportedProofTypes sets supported proof types, across all actor versions.
// This should only be used for testing.
func SetSupportedProofTypes(types ...abi.RegisteredSealProof) {
2022-04-07 18:46:23 +00:00
miner0.SupportedProofTypes = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner2.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner2.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2)
miner2.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner3.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner3.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2)
miner3.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner4.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner4.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2)
miner4.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner5.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner6.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
miner7.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
AddSupportedProofTypes(types...)
}
// AddSupportedProofTypes sets supported proof types, across all actor versions.
// This should only be used for testing.
func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
for _, t := range types {
if t >= abi.RegisteredSealProof_StackedDrg2KiBV1_1 {
panic("must specify v1 proof types only")
}
2020-09-25 21:33:25 +00:00
// Set for all miner versions.
2022-04-07 18:46:23 +00:00
miner0.SupportedProofTypes[t] = struct{}{}
miner2.PreCommitSealProofTypesV0[t] = struct{}{}
miner2.PreCommitSealProofTypesV7[t] = struct{}{}
miner2.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
miner2.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
miner3.PreCommitSealProofTypesV0[t] = struct{}{}
miner3.PreCommitSealProofTypesV7[t] = struct{}{}
miner3.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
miner3.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
miner4.PreCommitSealProofTypesV0[t] = struct{}{}
miner4.PreCommitSealProofTypesV7[t] = struct{}{}
miner4.PreCommitSealProofTypesV7[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
miner4.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
miner5.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
wpp, err := t.RegisteredWindowPoStProof()
if err != nil {
// Fine to panic, this is a test-only method
panic(err)
}
miner5.WindowPoStProofTypes[wpp] = struct{}{}
miner6.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
wpp, err = t.RegisteredWindowPoStProof()
if err != nil {
// Fine to panic, this is a test-only method
panic(err)
}
miner6.WindowPoStProofTypes[wpp] = struct{}{}
miner7.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
wpp, err = t.RegisteredWindowPoStProof()
if err != nil {
// Fine to panic, this is a test-only method
panic(err)
}
miner7.WindowPoStProofTypes[wpp] = struct{}{}
}
}
// SetPreCommitChallengeDelay sets the pre-commit challenge delay across all
// actors versions. Use for testing.
func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
// Set for all miner versions.
2022-04-07 18:46:23 +00:00
miner0.PreCommitChallengeDelay = delay
miner2.PreCommitChallengeDelay = delay
miner3.PreCommitChallengeDelay = delay
miner4.PreCommitChallengeDelay = delay
miner5.PreCommitChallengeDelay = delay
miner6.PreCommitChallengeDelay = delay
miner7.PreCommitChallengeDelay = delay
miner8.PreCommitChallengeDelay = delay
2022-09-06 15:49:29 +00:00
miner9.PreCommitChallengeDelay = delay
2022-11-08 04:55:56 +00:00
miner10.PreCommitChallengeDelay = delay
miner11.PreCommitChallengeDelay = delay
}
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
func GetPreCommitChallengeDelay() abi.ChainEpoch {
return miner11.PreCommitChallengeDelay
}
// SetConsensusMinerMinPower sets the minimum power of an individual miner must
// meet for leader election, across all actor versions. This should only be used
// for testing.
func SetConsensusMinerMinPower(p abi.StoragePower) {
2022-04-07 18:46:23 +00:00
power0.ConsensusMinerMinPower = p
for _, policy := range builtin2.SealProofPolicies {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin3.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin4.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin5.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin6.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin7.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin8.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
2022-09-06 15:49:29 +00:00
for _, policy := range builtin9.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
2022-11-08 04:55:56 +00:00
for _, policy := range builtin10.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
for _, policy := range builtin11.PoStProofPolicies {
policy.ConsensusMinerMinPower = p
}
}
// SetMinVerifiedDealSize sets the minimum size of a verified deal. This should
// only be used for testing.
func SetMinVerifiedDealSize(size abi.StoragePower) {
2022-04-07 18:46:23 +00:00
verifreg0.MinVerifiedDealSize = size
verifreg2.MinVerifiedDealSize = size
verifreg3.MinVerifiedDealSize = size
verifreg4.MinVerifiedDealSize = size
verifreg5.MinVerifiedDealSize = size
verifreg6.MinVerifiedDealSize = size
verifreg7.MinVerifiedDealSize = size
verifreg8.MinVerifiedDealSize = size
2022-09-06 15:49:29 +00:00
verifreg9.MinVerifiedDealSize = size
2022-11-08 04:55:56 +00:00
verifreg10.MinVerifiedDealSize = size
verifreg11.MinVerifiedDealSize = size
2020-09-29 00:28:16 +00:00
}
2022-09-06 15:49:29 +00:00
func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) {
2020-09-29 00:28:16 +00:00
switch ver {
2022-04-07 18:46:23 +00:00
2022-09-06 15:49:29 +00:00
case actorstypes.Version0:
2022-04-07 18:46:23 +00:00
return miner0.MaxSealDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version2:
2022-04-07 18:46:23 +00:00
return miner2.MaxProveCommitDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version3:
2022-04-07 18:46:23 +00:00
return miner3.MaxProveCommitDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version4:
2022-04-07 18:46:23 +00:00
return miner4.MaxProveCommitDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version5:
2022-04-07 18:46:23 +00:00
return miner5.MaxProveCommitDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version6:
2022-04-07 18:46:23 +00:00
return miner6.MaxProveCommitDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version7:
2022-04-07 18:46:23 +00:00
return miner7.MaxProveCommitDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version8:
2022-04-07 18:46:23 +00:00
return miner8.MaxProveCommitDuration[t], nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version9:
return miner9.MaxProveCommitDuration[t], nil
2022-11-08 04:55:56 +00:00
case actorstypes.Version10:
return miner10.MaxProveCommitDuration[t], nil
case actorstypes.Version11:
return miner11.MaxProveCommitDuration[t], nil
2020-09-29 00:28:16 +00:00
default:
2021-08-10 17:07:30 +00:00
return 0, xerrors.Errorf("unsupported actors version")
2020-09-29 00:28:16 +00:00
}
}
2020-09-30 20:30:24 +00:00
// SetProviderCollateralSupplyTarget sets the percentage of normalized circulating
// supply that must be covered by provider collateral in a deal. This should
// only be used for testing.
func SetProviderCollateralSupplyTarget(num, denom big.Int) {
market2.ProviderCollateralSupplyTarget = builtin2.BigFrac{
Numerator: num,
Denominator: denom,
}
market3.ProviderCollateralSupplyTarget = builtin3.BigFrac{
Numerator: num,
Denominator: denom,
}
market4.ProviderCollateralSupplyTarget = builtin4.BigFrac{
Numerator: num,
Denominator: denom,
}
market5.ProviderCollateralSupplyTarget = builtin5.BigFrac{
Numerator: num,
Denominator: denom,
}
2021-09-15 15:22:25 +00:00
market6.ProviderCollateralSupplyTarget = builtin6.BigFrac{
Numerator: num,
Denominator: denom,
}
2021-11-04 15:59:29 +00:00
market7.ProviderCollateralSupplyTarget = builtin7.BigFrac{
Numerator: num,
Denominator: denom,
}
2022-03-01 03:57:40 +00:00
market8.ProviderCollateralSupplyTarget = builtin8.BigFrac{
Numerator: num,
Denominator: denom,
}
2022-09-06 15:49:29 +00:00
market9.ProviderCollateralSupplyTarget = builtin9.BigFrac{
Numerator: num,
Denominator: denom,
}
2022-11-08 04:55:56 +00:00
market10.ProviderCollateralSupplyTarget = builtin10.BigFrac{
Numerator: num,
Denominator: denom,
}
market11.ProviderCollateralSupplyTarget = builtin11.BigFrac{
Numerator: num,
Denominator: denom,
}
}
2020-09-30 20:30:24 +00:00
func DealProviderCollateralBounds(
size abi.PaddedPieceSize, verified bool,
rawBytePower, qaPower, baselinePower abi.StoragePower,
circulatingFil abi.TokenAmount, nwVer network.Version,
2021-08-10 17:07:30 +00:00
) (min, max abi.TokenAmount, err error) {
2022-09-06 15:49:29 +00:00
v, err := actorstypes.VersionForNetwork(nwVer)
2021-08-10 17:07:30 +00:00
if err != nil {
return big.Zero(), big.Zero(), err
}
switch v {
2022-04-07 18:46:23 +00:00
2022-09-06 15:49:29 +00:00
case actorstypes.Version0:
2022-04-07 18:46:23 +00:00
min, max := market0.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version2:
2022-04-07 18:46:23 +00:00
min, max := market2.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version3:
2022-04-07 18:46:23 +00:00
min, max := market3.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version4:
2022-04-07 18:46:23 +00:00
min, max := market4.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version5:
2022-04-07 18:46:23 +00:00
min, max := market5.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version6:
2022-04-07 18:46:23 +00:00
min, max := market6.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version7:
2022-04-07 18:46:23 +00:00
min, max := market7.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version8:
2022-04-07 18:46:23 +00:00
min, max := market8.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version9:
min, max := market9.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2022-11-08 04:55:56 +00:00
case actorstypes.Version10:
min, max := market10.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
case actorstypes.Version11:
min, max := market11.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
return min, max, nil
2020-09-30 20:30:24 +00:00
default:
2021-08-10 17:07:30 +00:00
return big.Zero(), big.Zero(), xerrors.Errorf("unsupported actors version")
2020-09-30 20:30:24 +00:00
}
}
2020-12-30 08:02:53 +00:00
func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) {
return market11.DealDurationBounds(pieceSize)
2020-12-30 08:02:53 +00:00
}
// Sets the challenge window and scales the proving period to match (such that
// there are always 48 challenge windows in a proving period).
func SetWPoStChallengeWindow(period abi.ChainEpoch) {
2022-04-07 18:46:23 +00:00
miner0.WPoStChallengeWindow = period
miner0.WPoStProvingPeriod = period * abi.ChainEpoch(miner0.WPoStPeriodDeadlines)
miner2.WPoStChallengeWindow = period
miner2.WPoStProvingPeriod = period * abi.ChainEpoch(miner2.WPoStPeriodDeadlines)
miner3.WPoStChallengeWindow = period
miner3.WPoStProvingPeriod = period * abi.ChainEpoch(miner3.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner3.WPoStDisputeWindow = period * 30
miner4.WPoStChallengeWindow = period
miner4.WPoStProvingPeriod = period * abi.ChainEpoch(miner4.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner4.WPoStDisputeWindow = period * 30
miner5.WPoStChallengeWindow = period
miner5.WPoStProvingPeriod = period * abi.ChainEpoch(miner5.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner5.WPoStDisputeWindow = period * 30
miner6.WPoStChallengeWindow = period
miner6.WPoStProvingPeriod = period * abi.ChainEpoch(miner6.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner6.WPoStDisputeWindow = period * 30
miner7.WPoStChallengeWindow = period
miner7.WPoStProvingPeriod = period * abi.ChainEpoch(miner7.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner7.WPoStDisputeWindow = period * 30
miner8.WPoStChallengeWindow = period
miner8.WPoStProvingPeriod = period * abi.ChainEpoch(miner8.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner8.WPoStDisputeWindow = period * 30
2022-09-06 15:49:29 +00:00
miner9.WPoStChallengeWindow = period
miner9.WPoStProvingPeriod = period * abi.ChainEpoch(miner9.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner9.WPoStDisputeWindow = period * 30
2022-11-08 04:55:56 +00:00
miner10.WPoStChallengeWindow = period
miner10.WPoStProvingPeriod = period * abi.ChainEpoch(miner10.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner10.WPoStDisputeWindow = period * 30
miner11.WPoStChallengeWindow = period
miner11.WPoStProvingPeriod = period * abi.ChainEpoch(miner11.WPoStPeriodDeadlines)
// by default, this is 2x finality which is 30 periods.
// scale it if we're scaling the challenge period.
miner11.WPoStDisputeWindow = period * 30
}
func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch {
if nwVer <= network.Version3 {
return 10
}
// NOTE: if this ever changes, adjust it in a (*Miner).mineOne() logline as well
return ChainFinality
}
2020-10-08 01:09:33 +00:00
func GetMaxSectorExpirationExtension() abi.ChainEpoch {
return miner11.MaxSectorExpirationExtension
2020-10-08 01:09:33 +00:00
}
func GetDefaultSectorExpirationExtension() abi.ChainEpoch {
// Keep default at the previous max of 1.5 years rather than the current 3.5 years.
// This way extension and pledge defaults do not subvert existing expectations.
return miner10.MaxSectorExpirationExtension
}
func GetMinSectorExpiration() abi.ChainEpoch {
return miner11.MinSectorExpiration
}
func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) {
sectorsPerPart, err := builtin11.PoStProofWindowPoStPartitionSectors(p)
2020-10-08 01:09:33 +00:00
if err != nil {
return 0, err
}
2021-08-10 17:07:30 +00:00
maxSectors, err := GetAddressedSectorsMax(nv)
if err != nil {
return 0, err
}
return int(uint64(maxSectors) / sectorsPerPart), nil
2020-10-08 01:09:33 +00:00
}
2021-05-17 18:47:41 +00:00
func GetDefaultAggregationProof() abi.RegisteredAggregationProof {
return abi.RegisteredAggregationProof_SnarkPackV1
}
func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) abi.ChainEpoch {
if nwVer <= network.Version10 {
2021-05-27 19:54:31 +00:00
return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime
}
return builtin11.SealProofPoliciesV11[proof].SectorMaxLifetime
}
2021-08-10 17:07:30 +00:00
func GetAddressedSectorsMax(nwVer network.Version) (int, error) {
2022-09-06 15:49:29 +00:00
v, err := actorstypes.VersionForNetwork(nwVer)
2021-08-10 17:07:30 +00:00
if err != nil {
return 0, err
}
switch v {
2022-04-07 18:46:23 +00:00
2022-09-06 15:49:29 +00:00
case actorstypes.Version0:
2022-04-07 18:46:23 +00:00
return miner0.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version2:
2022-04-07 18:46:23 +00:00
return miner2.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version3:
2022-04-07 18:46:23 +00:00
return miner3.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version4:
2022-04-07 18:46:23 +00:00
return miner4.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version5:
2022-04-07 18:46:23 +00:00
return miner5.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version6:
2022-04-07 18:46:23 +00:00
return miner6.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version7:
2022-04-07 18:46:23 +00:00
return miner7.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version8:
2022-04-07 18:46:23 +00:00
return miner8.AddressedSectorsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version9:
return miner9.AddressedSectorsMax, nil
2022-11-08 04:55:56 +00:00
case actorstypes.Version10:
return miner10.AddressedSectorsMax, nil
case actorstypes.Version11:
return miner11.AddressedSectorsMax, nil
default:
2021-08-10 17:07:30 +00:00
return 0, xerrors.Errorf("unsupported network version")
}
}
2021-08-10 17:07:30 +00:00
func GetDeclarationsMax(nwVer network.Version) (int, error) {
2022-09-06 15:49:29 +00:00
v, err := actorstypes.VersionForNetwork(nwVer)
2021-08-10 17:07:30 +00:00
if err != nil {
return 0, err
}
switch v {
2022-04-07 18:46:23 +00:00
2022-09-06 15:49:29 +00:00
case actorstypes.Version0:
2022-04-07 18:46:23 +00:00
// TODO: Should we instead error here since the concept doesn't exist yet?
return miner0.AddressedPartitionsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version2:
2022-04-07 18:46:23 +00:00
return miner2.DeclarationsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version3:
2022-04-07 18:46:23 +00:00
return miner3.DeclarationsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version4:
2022-04-07 18:46:23 +00:00
return miner4.DeclarationsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version5:
2022-04-07 18:46:23 +00:00
return miner5.DeclarationsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version6:
2022-04-07 18:46:23 +00:00
return miner6.DeclarationsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version7:
2022-04-07 18:46:23 +00:00
return miner7.DeclarationsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version8:
2022-04-07 18:46:23 +00:00
return miner8.DeclarationsMax, nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version9:
return miner9.DeclarationsMax, nil
2022-11-08 04:55:56 +00:00
case actorstypes.Version10:
return miner10.DeclarationsMax, nil
case actorstypes.Version11:
return miner11.DeclarationsMax, nil
default:
2021-08-10 17:32:00 +00:00
return 0, xerrors.Errorf("unsupported network version")
}
}
2021-10-01 14:23:21 +00:00
func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) {
2022-09-06 15:49:29 +00:00
v, err := actorstypes.VersionForNetwork(nwVer)
2021-08-10 17:07:30 +00:00
if err != nil {
return big.Zero(), err
}
switch v {
2022-04-07 18:46:23 +00:00
2022-09-06 15:49:29 +00:00
case actorstypes.Version0:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version2:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version3:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version4:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version5:
2022-04-07 18:46:23 +00:00
return miner5.AggregateNetworkFee(aggregateSize, baseFee), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version6:
2022-04-07 18:46:23 +00:00
return miner6.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version7:
2022-04-07 18:46:23 +00:00
return miner7.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version8:
2022-04-07 18:46:23 +00:00
return miner8.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version9:
return miner9.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
2022-11-08 04:55:56 +00:00
case actorstypes.Version10:
return miner10.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
case actorstypes.Version11:
return miner11.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
2021-10-01 14:23:21 +00:00
default:
return big.Zero(), xerrors.Errorf("unsupported network version")
}
}
func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) {
2022-09-06 15:49:29 +00:00
v, err := actorstypes.VersionForNetwork(nwVer)
2021-10-01 14:23:21 +00:00
if err != nil {
return big.Zero(), err
}
switch v {
2022-04-07 18:46:23 +00:00
2022-09-06 15:49:29 +00:00
case actorstypes.Version0:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version2:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version3:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version4:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version5:
2022-04-07 18:46:23 +00:00
return big.Zero(), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version6:
2022-04-07 18:46:23 +00:00
return miner6.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version7:
2022-04-07 18:46:23 +00:00
return miner7.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version8:
2022-04-07 18:46:23 +00:00
return miner8.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
2022-09-06 15:49:29 +00:00
case actorstypes.Version9:
return miner9.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
2022-11-08 04:55:56 +00:00
case actorstypes.Version10:
return miner10.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
case actorstypes.Version11:
return miner11.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
default:
2021-08-10 17:07:30 +00:00
return big.Zero(), xerrors.Errorf("unsupported network version")
}
}