Merge pull request #6366 from filecoin-project/asr/post-tests

Fix supported proof type manipulations for v5 actors
This commit is contained in:
Łukasz Magiera 2021-06-01 10:25:26 +02:00 committed by GitHub
commit b149eb8d02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 9 deletions

View File

@ -92,6 +92,13 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
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{}{}
}
}

View File

@ -62,6 +62,13 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
miner{{.}}.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
{{else}}
miner{{.}}.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)
}
miner{{.}}.WindowPoStProofTypes[wpp] = struct{}{}
{{end}}
{{end}}
}

View File

@ -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

View File

@ -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)