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{}{} miner4.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
miner5.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{}{} miner{{.}}.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
{{else}} {{else}}
miner{{.}}.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} 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}}
{{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) 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 // Split partitions into batches, so as not to exceed the number of sectors
// allowed in a single message // allowed in a single message
partitionBatches, err := s.batchPartitions(partitions) partitionBatches, err := s.batchPartitions(partitions, nv)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -679,7 +684,7 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
return posts, nil 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. // 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 // 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 // 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) 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: // The number of messages will be:
// ceiling(number of partitions / partitions per message) // ceiling(number of partitions / partitions per message)
batchCount := len(partitions) / partitionsPerMsg batchCount := len(partitions) / partitionsPerMsg

View File

@ -5,6 +5,9 @@ import (
"context" "context"
"testing" "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" "github.com/stretchr/testify/require"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -177,13 +180,16 @@ func TestWDPostDoPost(t *testing.T) {
mockStgMinerAPI := newMockStorageMinerAPI() mockStgMinerAPI := newMockStorageMinerAPI()
// Get the number of sectors allowed in a partition for this proof type // 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) require.NoError(t, err)
// 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
require.NoError(t, err) 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 // Enough partitions to fill expectedMsgCount-1 messages
partitionCount := (expectedMsgCount - 1) * partitionsPerMsg partitionCount := (expectedMsgCount - 1) * partitionsPerMsg
@ -219,11 +225,11 @@ func TestWDPostDoPost(t *testing.T) {
} }
di := &dline.Info{ di := &dline.Info{
WPoStPeriodDeadlines: miner2.WPoStPeriodDeadlines, WPoStPeriodDeadlines: miner5.WPoStPeriodDeadlines,
WPoStProvingPeriod: miner2.WPoStProvingPeriod, WPoStProvingPeriod: miner5.WPoStProvingPeriod,
WPoStChallengeWindow: miner2.WPoStChallengeWindow, WPoStChallengeWindow: miner5.WPoStChallengeWindow,
WPoStChallengeLookback: miner2.WPoStChallengeLookback, WPoStChallengeLookback: miner5.WPoStChallengeLookback,
FaultDeclarationCutoff: miner2.FaultDeclarationCutoff, FaultDeclarationCutoff: miner5.FaultDeclarationCutoff,
} }
ts := mockTipSet(t) ts := mockTipSet(t)