diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index d927f369f3e..365c1d4e597 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -622,7 +622,13 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e if err != nil { return 0, err } - return int(uint64(maxSectors) / sectorsPerPart), nil + + maxPartitions, err := getPoStedPartitionsMax(nv) + if err != nil { + return 0, err + } + + return min(maxPartitions, int(uint64(maxSectors)/sectorsPerPart)), nil } func GetDefaultAggregationProof() abi.RegisteredAggregationProof { @@ -685,6 +691,66 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { } } +func getPoStedPartitionsMax(nwVer network.Version) (int, error) { + v, err := actorstypes.VersionForNetwork(nwVer) + if err != nil { + return 0, err + } + switch v { + + case actorstypes.Version0: + + return miner0.AddressedPartitionsMax, nil + + case actorstypes.Version2: + + return miner2.AddressedPartitionsMax, nil + + case actorstypes.Version3: + + return miner3.AddressedPartitionsMax, nil + + case actorstypes.Version4: + + return miner4.AddressedPartitionsMax, nil + + case actorstypes.Version5: + + return miner5.AddressedPartitionsMax, nil + + case actorstypes.Version6: + + return miner6.AddressedPartitionsMax, nil + + case actorstypes.Version7: + + return miner7.AddressedPartitionsMax, nil + + case actorstypes.Version8: + + return miner8.AddressedPartitionsMax, nil + + case actorstypes.Version9: + + return miner9.AddressedPartitionsMax, nil + + case actorstypes.Version10: + + return miner10.AddressedPartitionsMax, nil + + case actorstypes.Version11: + + return miner11.AddressedPartitionsMax, nil + + case actorstypes.Version12: + + return miner12.PoStedPartitionsMax, nil + + default: + return 0, xerrors.Errorf("unsupported network version") + } +} + func GetDeclarationsMax(nwVer network.Version) (int, error) { v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { @@ -865,3 +931,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base return big.Zero(), xerrors.Errorf("unsupported network version") } } + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/chain/actors/policy/policy.go.template b/chain/actors/policy/policy.go.template index c3ce4a9d918..54fb4fd8df1 100644 --- a/chain/actors/policy/policy.go.template +++ b/chain/actors/policy/policy.go.template @@ -244,7 +244,7 @@ func GetMinSectorExpiration() abi.ChainEpoch { } func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) { - sectorsPerPart, err := builtin{{.latestVersion}}.PoStProofWindowPoStPartitionSectors(p) + sectorsPerPart, err := builtin12.PoStProofWindowPoStPartitionSectors(p) if err != nil { return 0, err } @@ -252,7 +252,13 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e if err != nil { return 0, err } - return int(uint64(maxSectors) / sectorsPerPart), nil + + maxPartitions, err := getPoStedPartitionsMax(nv) + if err != nil { + return 0, err + } + + return min(maxPartitions, int(uint64(maxSectors) / sectorsPerPart)), nil } func GetDefaultAggregationProof() abi.RegisteredAggregationProof { @@ -282,6 +288,25 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { } } +func getPoStedPartitionsMax(nwVer network.Version) (int, error) { + v, err := actorstypes.VersionForNetwork(nwVer) + if err != nil { + return 0, err + } + switch v { + {{range .versions}} + case actorstypes.Version{{.}}: + {{if (le . 11)}} + return miner{{.}}.AddressedPartitionsMax, nil + {{else}} + return miner{{.}}.PoStedPartitionsMax, nil + {{end}} + {{end}} + default: + return 0, xerrors.Errorf("unsupported network version") + } +} + func GetDeclarationsMax(nwVer network.Version) (int, error) { v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { @@ -341,3 +366,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base return big.Zero(), xerrors.Errorf("unsupported network version") } } + +func min(a, b int) int { + if a < b { + return a + } + return b +} \ No newline at end of file diff --git a/go.mod b/go.mod index 49ca2ff6439..e4d4a8f71ae 100644 --- a/go.mod +++ b/go.mod @@ -338,3 +338,5 @@ require ( replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi replace github.com/filecoin-project/test-vectors => ./extern/test-vectors + +replace github.com/filecoin-project/go-state-types => ../go-state-types \ No newline at end of file diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 5e137bfc4d9..b392083e175 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -934,10 +934,11 @@ func (a *StateAPI) stateComputeDataCIDv1(ctx context.Context, maddr address.Addr return cid.Undef, xerrors.Errorf("computing params for ComputeDataCommitment: %w", err) } ccmt := &types.Message{ - To: market.Address, - From: maddr, - Value: types.NewInt(0), - Method: market.Methods.ComputeDataCommitment, + To: market.Address, + From: maddr, + Value: types.NewInt(0), + // Hard coded, because the method has since been deprecated + Method: 8, Params: ccparams, } r, err := a.StateCall(ctx, ccmt, tsk) @@ -971,10 +972,11 @@ func (a *StateAPI) stateComputeDataCIDv2(ctx context.Context, maddr address.Addr return cid.Undef, xerrors.Errorf("computing params for ComputeDataCommitment: %w", err) } ccmt := &types.Message{ - To: market.Address, - From: maddr, - Value: types.NewInt(0), - Method: market.Methods.ComputeDataCommitment, + To: market.Address, + From: maddr, + Value: types.NewInt(0), + // Hard coded, because the method has since been deprecated + Method: 8, Params: ccparams, } r, err := a.StateCall(ctx, ccmt, tsk)