@@ -422,6 +422,7 @@ func (tm *TestUnmanagedMiner) SnapDealWithRealProofs(ctx context.Context, proofT
422
422
snapProof , err := ffi .SectorUpdate .GenerateUpdateProofWithVanilla (updateProofType , tm .sealedCids [sectorNumber ],
423
423
newSealed , newUnsealed , vp )
424
424
require .NoError (tm .t , err )
425
+ tm .waitForMutableDeadline (ctx , sectorNumber )
425
426
426
427
// submit proof
427
428
var manifest []miner14.PieceActivationManifest
@@ -453,12 +454,41 @@ func (tm *TestUnmanagedMiner) SnapDealWithRealProofs(ctx context.Context, proofT
453
454
RequireActivationSuccess : true ,
454
455
RequireNotificationSuccess : false ,
455
456
}
456
-
457
457
r , err := tm .submitMessage (ctx , params , 1 , builtin .MethodsMiner .ProveReplicaUpdates3 )
458
458
require .NoError (tm .t , err )
459
459
require .True (tm .t , r .Receipt .ExitCode .IsSuccess ())
460
460
}
461
461
462
+ func (tm * TestUnmanagedMiner ) waitForMutableDeadline (ctx context.Context , sectorNum abi.SectorNumber ) {
463
+ ts , err := tm .FullNode .ChainHead (ctx )
464
+ require .NoError (tm .t , err )
465
+
466
+ sl , err := tm .FullNode .StateSectorPartition (ctx , tm .ActorAddr , sectorNum , ts .Key ())
467
+ require .NoError (tm .t , err )
468
+
469
+ dlinfo , err := tm .FullNode .StateMinerProvingDeadline (ctx , tm .ActorAddr , ts .Key ())
470
+ require .NoError (tm .t , err )
471
+
472
+ sectorDeadlineOpen := sl .Deadline == dlinfo .Index
473
+ sectorDeadlineNext := (dlinfo .Index + 1 )% dlinfo .WPoStPeriodDeadlines == sl .Deadline
474
+ immutable := sectorDeadlineOpen || sectorDeadlineNext
475
+
476
+ // Sleep for immutable epochs
477
+ if immutable {
478
+ dlineEpochsRemaining := dlinfo .NextOpen () - ts .Height ()
479
+ var targetEpoch abi.ChainEpoch
480
+ if sectorDeadlineOpen {
481
+ // sleep for remainder of deadline
482
+ targetEpoch = ts .Height () + dlineEpochsRemaining
483
+ } else {
484
+ // sleep for remainder of deadline and next one
485
+ targetEpoch = ts .Height () + dlineEpochsRemaining + dlinfo .WPoStChallengeWindow
486
+ }
487
+ _ , err := tm .FullNode .WaitTillChainOrError (ctx , HeightAtLeast (targetEpoch + 5 ))
488
+ require .NoError (tm .t , err )
489
+ }
490
+ }
491
+
462
492
func (tm * TestUnmanagedMiner ) OnboardCCSectorWithMockProofs (ctx context.Context , proofType abi.RegisteredSealProof ) (abi.SectorNumber , chan WindowPostResp ,
463
493
context.CancelFunc ) {
464
494
req := require .New (tm .t )
0 commit comments