Skip to content

Commit

Permalink
fix: pick the correct partitions-per-post limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jun 16, 2021
1 parent ae26e50 commit 526674c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions chain/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ func GetMaxSectorExpirationExtension() abi.ChainEpoch {
return miner5.MaxSectorExpirationExtension
}

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

func GetDefaultSectorSize() abi.SectorSize {
Expand Down
6 changes: 3 additions & 3 deletions chain/actors/policy/policy.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ func GetMaxSectorExpirationExtension() abi.ChainEpoch {
return miner{{.latestVersion}}.MaxSectorExpirationExtension
}

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

func GetDefaultSectorSize() abi.SectorSize {
Expand Down
10 changes: 10 additions & 0 deletions chain/actors/policy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/require"

"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"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
Expand Down Expand Up @@ -68,3 +69,12 @@ func TestPartitionSizes(t *testing.T) {
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)
}
2 changes: 1 addition & 1 deletion storage/wdpost_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func (s *WindowPoStScheduler) batchPartitions(partitions []api.Partition, nv net
// sectors per partition 3: ooo
// partitions per message 2: oooOOO
// <1><2> (3rd doesn't fit)
partitionsPerMsg, err := policy.GetMaxPoStPartitions(s.proofType)
partitionsPerMsg, err := policy.GetMaxPoStPartitions(nv, s.proofType)
if err != nil {
return nil, xerrors.Errorf("getting sectors per partition: %w", err)
}
Expand Down
3 changes: 2 additions & 1 deletion storage/wdpost_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"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/extern/sector-storage/storiface"
"github.com/filecoin-project/lotus/journal"
Expand Down Expand Up @@ -185,8 +186,8 @@ func TestWDPostDoPost(t *testing.T) {
// Work out the number of partitions that can be included in a message
// without exceeding the message sector limit

partitionsPerMsg, err := policy.GetMaxPoStPartitions(network.Version13, proofType)
require.NoError(t, err)
partitionsPerMsg := int(miner5.AddressedSectorsMax / sectorsPerPartition)
if partitionsPerMsg > miner5.AddressedPartitionsMax {
partitionsPerMsg = miner5.AddressedPartitionsMax
}
Expand Down

0 comments on commit 526674c

Please sign in to comment.