diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 05520c060ba..82b2960f55f 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -24,7 +24,7 @@ require ( github.com/prometheus/client_golang v1.20.5 github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chainlink-automation v0.8.1 - github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae + github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 github.com/smartcontractkit/chainlink/deployment v0.0.0-00010101000000-000000000000 github.com/smartcontractkit/chainlink/v2 v2.14.0-mercury-20240807.0.20241106193309-5560cd76211a github.com/smartcontractkit/libocr v0.0.0-20241007185508-adbe57025f12 diff --git a/core/scripts/go.sum b/core/scripts/go.sum index 3160b2c6c6c..18b9ec97d91 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -1092,8 +1092,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422 h1:VfH/AW5NtTmroY9zz6OYCPFbFTqpMyJ2ubgT9ahYf3U= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae h1:uqce0bjNVYzFrrVLafXgyn8SVNdfOtZekLfAwQihHiA= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 h1:2k65bPK7j7nnX1sn3PCJ543jtyd5wl4LJl5n41jl1hk= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f/go.mod h1:wHtwSR3F1CQSJJZDQKuqaqFYnvkT+kMyget7dl8Clvo= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e h1:JiETqdNM0bktAUGMc62COwXIaw3rR3M77Me6bBLG0Fg= diff --git a/core/services/chainlink/application.go b/core/services/chainlink/application.go index c65694c7268..70db358c52f 100644 --- a/core/services/chainlink/application.go +++ b/core/services/chainlink/application.go @@ -475,7 +475,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) { srvcs = append(srvcs, workflowRegistrySyncer) delegates[job.Workflow] = workflows.NewDelegate( - globalLogger, + globalLogger.Named("WorkflowRegistrySyncer"), opts.CapabilitiesRegistry, workflowRegistrySyncer, workflowORM, diff --git a/core/services/workflows/syncer/workflow_registry.go b/core/services/workflows/syncer/workflow_registry.go index 281f5d6aed1..b213a9c370f 100644 --- a/core/services/workflows/syncer/workflow_registry.go +++ b/core/services/workflows/syncer/workflow_registry.go @@ -4,6 +4,7 @@ import ( "context" _ "embed" "sync" + "time" "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink-common/pkg/types/core" @@ -39,51 +40,70 @@ type WorkflowRegistry struct { } func (w *WorkflowRegistry) Start(ctx context.Context) error { - w.wg.Add(1) go func() { - w.Logger.Info("starting hardcoded workflow...") - - // HACK: don't load the workflow if we aren't a workflow node. - _, err := w.Registry.Get(ctx, "offchain_reporting@1.0.0") - if err != nil { - w.Logger.Info("not a workflow node, skipping hardcoded workflow") - return - } - - moduleConfig := &host.ModuleConfig{Logger: logger.NullLogger, IsUncompressed: true} - spec, err := host.GetWorkflowSpec(ctx, moduleConfig, workflow, config) - if err != nil { - w.Logger.Errorf("failed to get workflow spec", err) - return - } - - cfg := workflows.Config{ - Lggr: w.Logger, - Workflow: *spec, - WorkflowID: workflowID, - WorkflowOwner: workflowOwner, - WorkflowName: workflowName, - Registry: w.Registry, - Store: w.Store, - Config: config, - Binary: workflow, - SecretsFetcher: w, - } - engine, err := workflows.NewEngine(ctx, cfg) - if err != nil { - w.Logger.Errorf("failed to create engine: %w", err) - return - } - err = engine.Start(ctx) - if err != nil { - w.Logger.Errorf("failed to start hardcoded workflow: %w", err) - return + timeout := time.After(5 * time.Minute) + ticker := time.NewTicker(10 * time.Second) + + for { + select { + case <-timeout: + w.Logger.Info("timed out setting up hardcoded workflow") + return + case <-ticker.C: + success := w.trySetup() + if success { + return + } + } } - w.subServices = []job.ServiceCtx{engine} }() return nil } +func (w *WorkflowRegistry) trySetup() bool { + ctx := context.Background() + w.Logger.Info("starting hardcoded workflow...") + + // HACK: don't load the workflow if we aren't a workflow node. + _, err := w.Registry.Get(ctx, "offchain_reporting@1.0.0") + if err != nil { + w.Logger.Info("not a workflow node, skipping hardcoded workflow") + return true + } + + moduleConfig := &host.ModuleConfig{Logger: logger.NullLogger, IsUncompressed: true} + spec, err := host.GetWorkflowSpec(ctx, moduleConfig, workflow, config) + if err != nil { + w.Logger.Errorf("failed to get workflow spec", err) + return false + } + + cfg := workflows.Config{ + Lggr: w.Logger, + Workflow: *spec, + WorkflowID: workflowID, + WorkflowOwner: workflowOwner, + WorkflowName: workflowName, + Registry: w.Registry, + Store: w.Store, + Config: config, + Binary: workflow, + SecretsFetcher: w, + } + engine, err := workflows.NewEngine(ctx, cfg) + if err != nil { + w.Logger.Errorf("failed to create engine: %w", err) + return false + } + err = engine.Start(ctx) + if err != nil { + w.Logger.Errorf("failed to start hardcoded workflow: %w", err) + return false + } + w.subServices = []job.ServiceCtx{engine} + return true +} + func (w *WorkflowRegistry) Close() error { for _, s := range w.subServices { err := s.Close() diff --git a/go.mod b/go.mod index e31d27ab3d2..f238c87db99 100644 --- a/go.mod +++ b/go.mod @@ -77,7 +77,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.27 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422 - github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae + github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e github.com/smartcontractkit/chainlink-feeds v0.1.1 diff --git a/go.sum b/go.sum index e0adc852492..c503a4f0749 100644 --- a/go.sum +++ b/go.sum @@ -1077,8 +1077,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422 h1:VfH/AW5NtTmroY9zz6OYCPFbFTqpMyJ2ubgT9ahYf3U= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae h1:uqce0bjNVYzFrrVLafXgyn8SVNdfOtZekLfAwQihHiA= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 h1:2k65bPK7j7nnX1sn3PCJ543jtyd5wl4LJl5n41jl1hk= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f/go.mod h1:wHtwSR3F1CQSJJZDQKuqaqFYnvkT+kMyget7dl8Clvo= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e h1:JiETqdNM0bktAUGMc62COwXIaw3rR3M77Me6bBLG0Fg= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index f86b2ee70fa..4aa2114394b 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -36,7 +36,7 @@ require ( github.com/smartcontractkit/chain-selectors v1.0.27 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422 - github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae + github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 github.com/smartcontractkit/chainlink-protos/job-distributor v0.4.0 github.com/smartcontractkit/chainlink-testing-framework/havoc v1.50.2 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.13 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 144d29156e5..42bd89ed566 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -1405,8 +1405,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422 h1:VfH/AW5NtTmroY9zz6OYCPFbFTqpMyJ2ubgT9ahYf3U= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae h1:uqce0bjNVYzFrrVLafXgyn8SVNdfOtZekLfAwQihHiA= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 h1:2k65bPK7j7nnX1sn3PCJ543jtyd5wl4LJl5n41jl1hk= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f/go.mod h1:wHtwSR3F1CQSJJZDQKuqaqFYnvkT+kMyget7dl8Clvo= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e h1:JiETqdNM0bktAUGMc62COwXIaw3rR3M77Me6bBLG0Fg= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index e1c2c4f50a0..ac816b8bfd2 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -17,7 +17,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 github.com/slack-go/slack v0.15.0 - github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae + github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.13 github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.5 github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2 diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index 9ad23c4de4c..961ef3751d6 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -1394,8 +1394,8 @@ github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgB github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422 h1:VfH/AW5NtTmroY9zz6OYCPFbFTqpMyJ2ubgT9ahYf3U= github.com/smartcontractkit/chainlink-ccip v0.0.0-20241106140121-4c9ee21ab422/go.mod h1:4adKaHNaxFsRvV/lYfqtbsWyyvIPUMLR0FdOJN/ljis= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae h1:uqce0bjNVYzFrrVLafXgyn8SVNdfOtZekLfAwQihHiA= -github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106142051-c7bded1c08ae/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4 h1:2k65bPK7j7nnX1sn3PCJ543jtyd5wl4LJl5n41jl1hk= +github.com/smartcontractkit/chainlink-common v0.3.1-0.20241106202532-3b320ad9b7c4/go.mod h1:TQ9/KKXZ9vr8QAlUquqGpSvDCpR+DtABKPXZY4CiRns= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f h1:BwrIaQIx5Iy6eT+DfLhFfK2XqjxRm74mVdlX8gbu4dw= github.com/smartcontractkit/chainlink-cosmos v0.5.2-0.20241017133723-5277829bd53f/go.mod h1:wHtwSR3F1CQSJJZDQKuqaqFYnvkT+kMyget7dl8Clvo= github.com/smartcontractkit/chainlink-data-streams v0.1.1-0.20241018134907-a00ba3729b5e h1:JiETqdNM0bktAUGMc62COwXIaw3rR3M77Me6bBLG0Fg=