diff --git a/activation/activation.go b/activation/activation.go index 3695ad06e7..d2a07efe2c 100644 --- a/activation/activation.go +++ b/activation/activation.go @@ -93,7 +93,6 @@ type Builder struct { layerClock layerClock syncer syncer logger *zap.Logger - parentCtx context.Context poets []PoetService poetCfg PoetConfig poetRetryInterval time.Duration @@ -139,14 +138,6 @@ func WithPoetRetryInterval(interval time.Duration) BuilderOption { } } -// WithContext modifies parent context for background job. -func WithContext(ctx context.Context) BuilderOption { - return func(b *Builder) { - // TODO(mafa): fix this - b.parentCtx = ctx // nolint:fatcontext - } -} - // WithPoetConfig sets the poet config. func WithPoetConfig(c PoetConfig) BuilderOption { return func(b *Builder) { @@ -192,7 +183,6 @@ func NewBuilder( opts ...BuilderOption, ) *Builder { b := &Builder{ - parentCtx: context.Background(), signers: make(map[types.NodeID]*signing.EdSigner), conf: conf, db: db, @@ -228,7 +218,13 @@ func (b *Builder) Register(sig *signing.EdSigner) { b.postStates.Set(sig.NodeID(), types.PostStateIdle) if b.stop != nil { - b.startID(b.parentCtx, sig) + ctx, stop := context.WithCancel(context.Background()) + prevStop := b.stop + b.stop = func() { + prevStop() + stop() + } + b.startID(ctx, sig) } } @@ -268,9 +264,8 @@ func (b *Builder) StartSmeshing(coinbase types.Address) error { } b.coinbaseAccount = coinbase - ctx, stop := context.WithCancel(b.parentCtx) + ctx, stop := context.WithCancel(context.Background()) b.stop = stop - for _, sig := range b.signers { b.startID(ctx, sig) } diff --git a/activation/poet.go b/activation/poet.go index 4d8530f5d2..9d6541eb3e 100644 --- a/activation/poet.go +++ b/activation/poet.go @@ -462,7 +462,10 @@ func NewPoetServiceWithClient( opt(service) } - err := service.verifyPhaseShiftConfiguration(context.Background()) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) + defer cancel() + + err := service.verifyPhaseShiftConfiguration(ctx) switch { case errors.Is(err, errIncompatiblePhaseShift): logger.Fatal("failed to create poet service", zap.String("poet", client.Address())) diff --git a/node/node.go b/node/node.go index 3148485542..59a3045417 100644 --- a/node/node.go +++ b/node/node.go @@ -1126,7 +1126,6 @@ func (app *App) initServices(ctx context.Context) error { app.clock, syncer, app.addLogger(ATXBuilderLogger, lg).Zap(), - activation.WithContext(ctx), activation.WithPoetConfig(app.Config.POET), // TODO(dshulyak) makes no sense. how we ended using it? activation.WithPoetRetryInterval(app.Config.HARE3.PreroundDelay),