Wdpost run should respect AddressedPartitionsMax
This commit is contained in:
parent
2ab24b358d
commit
85873f6057
@ -497,9 +497,14 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
|
||||
return nil, xerrors.Errorf("getting partitions: %w", err)
|
||||
}
|
||||
|
||||
nv, err := s.api.StateNetworkVersion(ctx, ts.Key())
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting network version: %w", err)
|
||||
}
|
||||
|
||||
// Split partitions into batches, so as not to exceed the number of sectors
|
||||
// allowed in a single message
|
||||
partitionBatches, err := s.batchPartitions(partitions)
|
||||
partitionBatches, err := s.batchPartitions(partitions, nv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -679,7 +684,7 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *WindowPoStScheduler) batchPartitions(partitions []api.Partition) ([][]api.Partition, error) {
|
||||
func (s *WindowPoStScheduler) batchPartitions(partitions []api.Partition, nv network.Version) ([][]api.Partition, error) {
|
||||
// We don't want to exceed the number of sectors allowed in a message.
|
||||
// So given the number of sectors in a partition, work out the number of
|
||||
// partitions that can be in a message without exceeding sectors per
|
||||
@ -695,6 +700,11 @@ func (s *WindowPoStScheduler) batchPartitions(partitions []api.Partition) ([][]a
|
||||
return nil, xerrors.Errorf("getting sectors per partition: %w", err)
|
||||
}
|
||||
|
||||
// Also respect the AddressedPartitionsMax (which is the same as DeclarationsMax (which is all really just MaxPartitionsPerDeadline))
|
||||
if partitionsPerMsg > policy.GetDeclarationsMax(nv) {
|
||||
partitionsPerMsg = policy.GetDeclarationsMax(nv)
|
||||
}
|
||||
|
||||
// The number of messages will be:
|
||||
// ceiling(number of partitions / partitions per message)
|
||||
batchCount := len(partitions) / partitionsPerMsg
|
||||
|
@ -5,6 +5,9 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
|
||||
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -177,13 +180,16 @@ func TestWDPostDoPost(t *testing.T) {
|
||||
mockStgMinerAPI := newMockStorageMinerAPI()
|
||||
|
||||
// Get the number of sectors allowed in a partition for this proof type
|
||||
sectorsPerPartition, err := builtin2.PoStProofWindowPoStPartitionSectors(proofType)
|
||||
sectorsPerPartition, err := builtin5.PoStProofWindowPoStPartitionSectors(proofType)
|
||||
require.NoError(t, err)
|
||||
// Work out the number of partitions that can be included in a message
|
||||
// without exceeding the message sector limit
|
||||
|
||||
require.NoError(t, err)
|
||||
partitionsPerMsg := int(miner2.AddressedSectorsMax / sectorsPerPartition)
|
||||
partitionsPerMsg := int(miner5.AddressedSectorsMax / sectorsPerPartition)
|
||||
if partitionsPerMsg > miner5.AddressedPartitionsMax {
|
||||
partitionsPerMsg = miner5.AddressedPartitionsMax
|
||||
}
|
||||
|
||||
// Enough partitions to fill expectedMsgCount-1 messages
|
||||
partitionCount := (expectedMsgCount - 1) * partitionsPerMsg
|
||||
@ -219,11 +225,11 @@ func TestWDPostDoPost(t *testing.T) {
|
||||
}
|
||||
|
||||
di := &dline.Info{
|
||||
WPoStPeriodDeadlines: miner2.WPoStPeriodDeadlines,
|
||||
WPoStProvingPeriod: miner2.WPoStProvingPeriod,
|
||||
WPoStChallengeWindow: miner2.WPoStChallengeWindow,
|
||||
WPoStChallengeLookback: miner2.WPoStChallengeLookback,
|
||||
FaultDeclarationCutoff: miner2.FaultDeclarationCutoff,
|
||||
WPoStPeriodDeadlines: miner5.WPoStPeriodDeadlines,
|
||||
WPoStProvingPeriod: miner5.WPoStProvingPeriod,
|
||||
WPoStChallengeWindow: miner5.WPoStChallengeWindow,
|
||||
WPoStChallengeLookback: miner5.WPoStChallengeLookback,
|
||||
FaultDeclarationCutoff: miner5.FaultDeclarationCutoff,
|
||||
}
|
||||
ts := mockTipSet(t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user