Skip to content

Commit

Permalink
Try #4893:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] committed Aug 22, 2023
2 parents 264e589 + 4142049 commit 7eded6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 1 addition & 5 deletions activation/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,8 @@ func (b *Builder) poetRoundStart(epoch types.EpochID) time.Time {

func (b *Builder) createAtx(ctx context.Context, challenge *types.NIPostChallenge) (*types.ActivationTx, error) {
pubEpoch := challenge.PublishEpoch
nextPoetRoundStart := b.poetRoundStart(pubEpoch)

// NiPoST must be ready before start of the next poet round.
buildingNipostCtx, cancel := context.WithDeadline(ctx, nextPoetRoundStart)
defer cancel()
nipost, postDuration, err := b.nipostBuilder.BuildNIPost(buildingNipostCtx, challenge)
nipost, postDuration, err := b.nipostBuilder.BuildNIPost(ctx, challenge)
if err != nil {
return nil, fmt.Errorf("build NIPost: %w", err)
}
Expand Down
16 changes: 10 additions & 6 deletions activation/nipost.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,12 @@ func (nb *NIPostBuilder) BuildNIPost(ctx context.Context, challenge *types.NIPos
defer cancel()
poetRequests := nb.submitPoetChallenges(submitCtx, prefix, challengeHash.Bytes(), signature, nb.signer.NodeID())
if len(poetRequests) == 0 {
return nil, 0, &PoetSvcUnstableError{msg: "failed to submit challenge to any PoET", source: ctx.Err()}
return nil, 0, &PoetSvcUnstableError{msg: "failed to submit challenge to any PoET", source: submitCtx.Err()}
}

nb.state.Challenge = challengeHash
nb.state.PoetRequests = poetRequests
nb.persistState()
if err := ctx.Err(); err != nil {
return nil, 0, fmt.Errorf("submitting challenges: %w", err)
}
}

// Phase 1: query PoET services for proofs
Expand All @@ -264,11 +261,18 @@ func (nb *NIPostBuilder) BuildNIPost(ctx context.Context, challenge *types.NIPos
// Phase 2: Post execution.
var postGenDuration time.Duration = 0
if nb.state.NIPost.Post == nil {
publishDeadline := nb.layerClock.LayerToTime(challenge.TargetEpoch().FirstLayer())
if poetProofDeadline.Before(now) {
return nil, 0, fmt.Errorf("%w: deadline to publish ATX for pub epoch %d exceeded (deadline: %s, now: %s)", ErrATXChallengeExpired, challenge.PublishEpoch, publishDeadline, now)
}
publishCtx, cancel := context.WithDeadline(ctx, publishDeadline)
defer cancel()

nb.log.With().Info("starting post execution", log.Binary("challenge", nb.state.PoetProofRef[:]))
startTime := time.Now()
events.EmitPostStart(nb.state.PoetProofRef[:])

proof, proofMetadata, err := nb.postSetupProvider.GenerateProof(ctx, nb.state.PoetProofRef[:], proving.WithPowCreator(nb.nodeID.Bytes()))
proof, proofMetadata, err := nb.postSetupProvider.GenerateProof(publishCtx, nb.state.PoetProofRef[:], proving.WithPowCreator(nb.nodeID.Bytes()))
if err != nil {
events.EmitPostFailure()
return nil, 0, fmt.Errorf("failed to generate Post: %w", err)
Expand All @@ -278,7 +282,7 @@ func (nb *NIPostBuilder) BuildNIPost(ctx context.Context, challenge *types.NIPos
return nil, 0, fmt.Errorf("failed to get commitment ATX: %w", err)
}
if err := nb.validator.Post(
ctx,
publishCtx,
challenge.PublishEpoch,
nb.nodeID,
commitmentAtxId,
Expand Down

0 comments on commit 7eded6a

Please sign in to comment.