diff --git a/storage/wdpost_run.go b/storage/wdpost_run.go index 64f5690298a..93598c988e7 100644 --- a/storage/wdpost_run.go +++ b/storage/wdpost_run.go @@ -473,6 +473,19 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty posts[i].ChainCommitRand = commRand } + // Compute randomness after generating proofs so as to reduce the impact + // of chain reorgs (which change randomness) + commEpoch := di.Open + commRand, err := s.api.ChainGetRandomnessFromTickets(ctx, ts.Key(), crypto.DomainSeparationTag_PoStChainCommit, commEpoch, nil) + if err != nil { + return nil, xerrors.Errorf("failed to get chain randomness for windowPost (ts=%d; deadline=%d): %w", ts.Height(), di, err) + } + + for i := range posts { + posts[i].ChainCommitEpoch = commEpoch + posts[i].ChainCommitRand = commRand + } + return posts, nil } diff --git a/storage/wdpost_run_test.go b/storage/wdpost_run_test.go index 47972fe7fd7..7b76bff62f8 100644 --- a/storage/wdpost_run_test.go +++ b/storage/wdpost_run_test.go @@ -19,6 +19,8 @@ import ( "github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/filecoin-project/specs-actors/actors/runtime/proof" + "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/crypto" tutils "github.com/filecoin-project/specs-actors/support/testing" @@ -154,7 +156,7 @@ func TestWDPostDoPost(t *testing.T) { worker: workerAct, } - di := &miner.DeadlineInfo{} + di := &dline.Info{} ts := mockTipSet(t) scheduler.doPost(ctx, di, ts) @@ -218,7 +220,7 @@ func (m *mockStorageMinerAPI) StateSectorPartition(ctx context.Context, maddr ad panic("implement me") } -func (m *mockStorageMinerAPI) StateMinerProvingDeadline(ctx context.Context, address address.Address, key types.TipSetKey) (*miner.DeadlineInfo, error) { +func (m *mockStorageMinerAPI) StateMinerProvingDeadline(ctx context.Context, address address.Address, key types.TipSetKey) (*dline.Info, error) { panic("implement me") }