Merge pull request #6502 from filecoin-project/fix/max-part-per-post

fix: pick the correct partitions-per-post limit
This commit is contained in:
Aayush Rajasekaran 2021-06-16 20:11:29 -04:00 committed by GitHub
commit f6fb41fce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View File

@ -278,13 +278,13 @@ func GetMaxSectorExpirationExtension() abi.ChainEpoch {
return miner5.MaxSectorExpirationExtension return miner5.MaxSectorExpirationExtension
} }
// TODO: we'll probably need to abstract over this better in the future. func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) {
func GetMaxPoStPartitions(p abi.RegisteredPoStProof) (int, error) {
sectorsPerPart, err := builtin5.PoStProofWindowPoStPartitionSectors(p) sectorsPerPart, err := builtin5.PoStProofWindowPoStPartitionSectors(p)
if err != nil { if err != nil {
return 0, err return 0, err
} }
return int(miner5.AddressedSectorsMax / sectorsPerPart), nil maxSectors := uint64(GetAddressedSectorsMax(nv))
return int(maxSectors / sectorsPerPart), nil
} }
func GetDefaultSectorSize() abi.SectorSize { func GetDefaultSectorSize() abi.SectorSize {

View File

@ -182,13 +182,13 @@ func GetMaxSectorExpirationExtension() abi.ChainEpoch {
return miner{{.latestVersion}}.MaxSectorExpirationExtension return miner{{.latestVersion}}.MaxSectorExpirationExtension
} }
// TODO: we'll probably need to abstract over this better in the future. func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) {
func GetMaxPoStPartitions(p abi.RegisteredPoStProof) (int, error) {
sectorsPerPart, err := builtin{{.latestVersion}}.PoStProofWindowPoStPartitionSectors(p) sectorsPerPart, err := builtin{{.latestVersion}}.PoStProofWindowPoStPartitionSectors(p)
if err != nil { if err != nil {
return 0, err return 0, err
} }
return int(miner{{.latestVersion}}.AddressedSectorsMax / sectorsPerPart), nil maxSectors := uint64(GetAddressedSectorsMax(nv))
return int(maxSectors / sectorsPerPart), nil
} }
func GetDefaultSectorSize() abi.SectorSize { func GetDefaultSectorSize() abi.SectorSize {

View File

@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych" paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
@ -68,3 +69,12 @@ func TestPartitionSizes(t *testing.T) {
require.Equal(t, sizeOld, sizeNew) require.Equal(t, sizeOld, sizeNew)
} }
} }
func TestPoStSize(t *testing.T) {
v12PoStSize, err := GetMaxPoStPartitions(network.Version12, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1)
require.Equal(t, 4, v12PoStSize)
require.NoError(t, err)
v13PoStSize, err := GetMaxPoStPartitions(network.Version13, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1)
require.NoError(t, err)
require.Equal(t, 10, v13PoStSize)
}

View File

@ -732,7 +732,7 @@ func (s *WindowPoStScheduler) batchPartitions(partitions []api.Partition, nv net
// sectors per partition 3: ooo // sectors per partition 3: ooo
// partitions per message 2: oooOOO // partitions per message 2: oooOOO
// <1><2> (3rd doesn't fit) // <1><2> (3rd doesn't fit)
partitionsPerMsg, err := policy.GetMaxPoStPartitions(s.proofType) partitionsPerMsg, err := policy.GetMaxPoStPartitions(nv, s.proofType)
if err != nil { if err != nil {
return nil, xerrors.Errorf("getting sectors per partition: %w", err) return nil, xerrors.Errorf("getting sectors per partition: %w", err)
} }

View File

@ -31,6 +31,7 @@ import (
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner" "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/chain/types"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface" "github.com/filecoin-project/lotus/extern/sector-storage/storiface"
"github.com/filecoin-project/lotus/journal" "github.com/filecoin-project/lotus/journal"
@ -185,8 +186,8 @@ func TestWDPostDoPost(t *testing.T) {
// Work out the number of partitions that can be included in a message // Work out the number of partitions that can be included in a message
// without exceeding the message sector limit // without exceeding the message sector limit
partitionsPerMsg, err := policy.GetMaxPoStPartitions(network.Version13, proofType)
require.NoError(t, err) require.NoError(t, err)
partitionsPerMsg := int(miner5.AddressedSectorsMax / sectorsPerPartition)
if partitionsPerMsg > miner5.AddressedPartitionsMax { if partitionsPerMsg > miner5.AddressedPartitionsMax {
partitionsPerMsg = miner5.AddressedPartitionsMax partitionsPerMsg = miner5.AddressedPartitionsMax
} }