Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix supported proof type manipulations for v5 actors #6366

Merged
merged 2 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions chain/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}

}
}
Expand Down
7 changes: 7 additions & 0 deletions chain/actors/policy/policy.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
}
Expand Down
14 changes: 12 additions & 2 deletions storage/wdpost_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 13 additions & 7 deletions storage/wdpost_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down