Merge pull request #5764 from filecoin-project/fix/wait-for-proof
fix: wait a bit before starting to compute window post proofs
This commit is contained in:
commit
4abb333611
@ -13,7 +13,10 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const SubmitConfidence = 4
|
const (
|
||||||
|
SubmitConfidence = 4
|
||||||
|
ChallengeConfidence = 10
|
||||||
|
)
|
||||||
|
|
||||||
type CompleteGeneratePoSTCb func(posts []miner.SubmitWindowedPoStParams, err error)
|
type CompleteGeneratePoSTCb func(posts []miner.SubmitWindowedPoStParams, err error)
|
||||||
type CompleteSubmitPoSTCb func(err error)
|
type CompleteSubmitPoSTCb func(err error)
|
||||||
@ -230,7 +233,7 @@ func (p *proveHandler) processHeadChange(ctx context.Context, newTS *types.TipSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the chain is above the Challenge height for the post window
|
// Check if the chain is above the Challenge height for the post window
|
||||||
if newTS.Height() < di.Challenge {
|
if newTS.Height() < di.Challenge+ChallengeConfidence {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ func TestChangeHandlerStartProvingNextDeadline(t *testing.T) {
|
|||||||
|
|
||||||
// Trigger a head change
|
// Trigger a head change
|
||||||
currentEpoch := abi.ChainEpoch(1)
|
currentEpoch := abi.ChainEpoch(1)
|
||||||
go triggerHeadAdvance(t, s, currentEpoch)
|
go triggerHeadAdvance(t, s, currentEpoch+ChallengeConfidence)
|
||||||
|
|
||||||
// Should start proving
|
// Should start proving
|
||||||
<-s.ch.proveHdlr.processedHeadChanges
|
<-s.ch.proveHdlr.processedHeadChanges
|
||||||
@ -405,7 +405,7 @@ func TestChangeHandlerStartProvingNextDeadline(t *testing.T) {
|
|||||||
// Trigger a head change that advances the chain beyond the submit
|
// Trigger a head change that advances the chain beyond the submit
|
||||||
// confidence
|
// confidence
|
||||||
currentEpoch = 1 + SubmitConfidence
|
currentEpoch = 1 + SubmitConfidence
|
||||||
go triggerHeadAdvance(t, s, currentEpoch)
|
go triggerHeadAdvance(t, s, currentEpoch+ChallengeConfidence)
|
||||||
|
|
||||||
// Should be no change to state yet
|
// Should be no change to state yet
|
||||||
<-s.ch.proveHdlr.processedHeadChanges
|
<-s.ch.proveHdlr.processedHeadChanges
|
||||||
@ -424,7 +424,7 @@ func TestChangeHandlerStartProvingNextDeadline(t *testing.T) {
|
|||||||
// the next deadline
|
// the next deadline
|
||||||
go func() {
|
go func() {
|
||||||
di = nextDeadline(di)
|
di = nextDeadline(di)
|
||||||
currentEpoch = di.Challenge
|
currentEpoch = di.Challenge + ChallengeConfidence
|
||||||
triggerHeadAdvance(t, s, currentEpoch)
|
triggerHeadAdvance(t, s, currentEpoch)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ func TestChangeHandlerProvingRounds(t *testing.T) {
|
|||||||
for currentEpoch := abi.ChainEpoch(1); currentEpoch < miner.WPoStChallengeWindow*5; currentEpoch++ {
|
for currentEpoch := abi.ChainEpoch(1); currentEpoch < miner.WPoStChallengeWindow*5; currentEpoch++ {
|
||||||
// Trigger a head change
|
// Trigger a head change
|
||||||
di := mock.getDeadline(currentEpoch)
|
di := mock.getDeadline(currentEpoch)
|
||||||
go triggerHeadAdvance(t, s, currentEpoch)
|
go triggerHeadAdvance(t, s, currentEpoch+ChallengeConfidence)
|
||||||
|
|
||||||
// Wait for prover to process head change
|
// Wait for prover to process head change
|
||||||
<-s.ch.proveHdlr.processedHeadChanges
|
<-s.ch.proveHdlr.processedHeadChanges
|
||||||
@ -913,7 +913,7 @@ func TestChangeHandlerSubmitRevertTwoEpochs(t *testing.T) {
|
|||||||
|
|
||||||
// Move to the challenge epoch for the next deadline
|
// Move to the challenge epoch for the next deadline
|
||||||
diE2 := nextDeadline(diE1)
|
diE2 := nextDeadline(diE1)
|
||||||
currentEpoch = diE2.Challenge
|
currentEpoch = diE2.Challenge + ChallengeConfidence
|
||||||
go triggerHeadAdvance(t, s, currentEpoch)
|
go triggerHeadAdvance(t, s, currentEpoch)
|
||||||
|
|
||||||
// Should move to submitting state for epoch 1
|
// Should move to submitting state for epoch 1
|
||||||
@ -1014,7 +1014,7 @@ func TestChangeHandlerSubmitRevertAdvanceLess(t *testing.T) {
|
|||||||
|
|
||||||
// Move to the challenge epoch for the next deadline
|
// Move to the challenge epoch for the next deadline
|
||||||
diE2 := nextDeadline(diE1)
|
diE2 := nextDeadline(diE1)
|
||||||
currentEpoch = diE2.Challenge
|
currentEpoch = diE2.Challenge + ChallengeConfidence
|
||||||
go triggerHeadAdvance(t, s, currentEpoch)
|
go triggerHeadAdvance(t, s, currentEpoch)
|
||||||
|
|
||||||
// Should move to submitting state for epoch 1
|
// Should move to submitting state for epoch 1
|
||||||
|
@ -600,9 +600,23 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
|
|||||||
return nil, xerrors.Errorf("received no proofs back from generate window post")
|
return nil, xerrors.Errorf("received no proofs back from generate window post")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
headTs, err := s.api.ChainHead(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("getting current head: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRand, err := s.api.ChainGetRandomnessFromBeacon(ctx, headTs.Key(), crypto.DomainSeparationTag_WindowedPoStChallengeSeed, di.Challenge, buf.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed to get chain randomness from beacon for window post (ts=%d; deadline=%d): %w", ts.Height(), di, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !bytes.Equal(checkRand, rand) {
|
||||||
|
log.Warnw("windowpost randomness changed", "old", rand, "new", checkRand, "ts-height", ts.Height(), "challenge-height", di.Challenge, "tsk", ts.Key())
|
||||||
|
}
|
||||||
|
|
||||||
// If we generated an incorrect proof, try again.
|
// If we generated an incorrect proof, try again.
|
||||||
if correct, err := s.verifier.VerifyWindowPoSt(ctx, proof.WindowPoStVerifyInfo{
|
if correct, err := s.verifier.VerifyWindowPoSt(ctx, proof.WindowPoStVerifyInfo{
|
||||||
Randomness: abi.PoStRandomness(rand),
|
Randomness: abi.PoStRandomness(checkRand),
|
||||||
Proofs: postOut,
|
Proofs: postOut,
|
||||||
ChallengedSectors: sinfos,
|
ChallengedSectors: sinfos,
|
||||||
Prover: abi.ActorID(mid),
|
Prover: abi.ActorID(mid),
|
||||||
|
@ -350,7 +350,7 @@ func (m *mockStorageMinerAPI) GasEstimateMessageGas(ctx context.Context, message
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockStorageMinerAPI) ChainHead(ctx context.Context) (*types.TipSet, error) {
|
func (m *mockStorageMinerAPI) ChainHead(ctx context.Context) (*types.TipSet, error) {
|
||||||
panic("implement me")
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockStorageMinerAPI) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
|
func (m *mockStorageMinerAPI) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user