Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPCORE-863]: fix(service): start multiple feeds managers #14197

Merged
merged 7 commits into from
Aug 29, 2024
5 changes: 5 additions & 0 deletions .changeset/gorgeous-lobsters-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#changed Connect to multiple feeds managers on app start instead of just one (default to first)
2 changes: 2 additions & 0 deletions core/config/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type AppConfig interface {
Threshold() Threshold
WebServer() WebServer
Tracing() Tracing

FeatureMultiFeedsManagers() bool
}

type DatabaseBackupMode string
Expand Down
2 changes: 2 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LogPoller = false # Default
UICSAKeys = false # Default
# CCIP enables the CCIP service.
CCIP = true # Default
# MultiFeedsManagers enables support for multiple feeds manager connections.
MultiFeedsManagers = false # Default

[Database]
# DefaultIdleInTxSessionTimeout is the maximum time allowed for a transaction to be open and idle before timing out. See Postgres `idle_in_transaction_session_timeout` for more details.
Expand Down
1 change: 1 addition & 0 deletions core/config/feature_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ type Feature interface {
FeedsManager() bool
UICSAKeys() bool
LogPoller() bool
MultiFeedsManagers() bool
}
12 changes: 8 additions & 4 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,11 @@ func (p *PrometheusSecrets) validateMerge(f *PrometheusSecrets) (err error) {
}

type Feature struct {
FeedsManager *bool
LogPoller *bool
UICSAKeys *bool
CCIP *bool
FeedsManager *bool
LogPoller *bool
UICSAKeys *bool
CCIP *bool
MultiFeedsManagers *bool
}

func (f *Feature) setFrom(f2 *Feature) {
Expand All @@ -319,6 +320,9 @@ func (f *Feature) setFrom(f2 *Feature) {
if v := f2.CCIP; v != nil {
f.CCIP = v
}
if v := f2.MultiFeedsManagers; v != nil {
f.MultiFeedsManagers = v
}
}

type Database struct {
Expand Down
4 changes: 4 additions & 0 deletions core/services/chainlink/config_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ func (f *featureConfig) LogPoller() bool {
func (f *featureConfig) UICSAKeys() bool {
return *f.c.UICSAKeys
}

func (f *featureConfig) MultiFeedsManagers() bool {
return *f.c.MultiFeedsManagers
}
1 change: 1 addition & 0 deletions core/services/chainlink/config_feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ func TestFeatureConfig(t *testing.T) {
assert.True(t, f.LogPoller())
assert.True(t, f.FeedsManager())
assert.True(t, f.UICSAKeys())
assert.True(t, f.MultiFeedsManagers())
}
4 changes: 4 additions & 0 deletions core/services/chainlink/config_general.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ func (g *generalConfig) FeatureFeedsManager() bool {
return *g.c.Feature.FeedsManager
}

func (g *generalConfig) FeatureMultiFeedsManagers() bool {
return *g.c.Feature.MultiFeedsManagers
}

func (g *generalConfig) OCR() config.OCR {
return &ocrConfig{c: g.c.OCR}
}
Expand Down
10 changes: 6 additions & 4 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,11 @@ func TestConfig_Marshal(t *testing.T) {
}

full.Feature = toml.Feature{
FeedsManager: ptr(true),
LogPoller: ptr(true),
UICSAKeys: ptr(true),
CCIP: ptr(true),
FeedsManager: ptr(true),
LogPoller: ptr(true),
UICSAKeys: ptr(true),
CCIP: ptr(true),
MultiFeedsManagers: ptr(true),
}
full.Database = toml.Database{
DefaultIdleInTxSessionTimeout: commoncfg.MustNewDuration(time.Minute),
Expand Down Expand Up @@ -774,6 +775,7 @@ FeedsManager = true
LogPoller = true
UICSAKeys = true
CCIP = true
MultiFeedsManagers = true
`},
{"Database", Config{Core: toml.Core{Database: full.Database}}, `[Database]
DefaultIdleInTxSessionTimeout = '1m0s'
Expand Down
45 changes: 45 additions & 0 deletions core/services/chainlink/mocks/general_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FeedsManager = true
LogPoller = false
UICSAKeys = false
CCIP = true
MultiFeedsManagers = false

[Database]
DefaultIdleInTxSessionTimeout = '1h0m0s'
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FeedsManager = true
LogPoller = true
UICSAKeys = true
CCIP = true
MultiFeedsManagers = true

[Database]
DefaultIdleInTxSessionTimeout = '1m0s'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FeedsManager = true
LogPoller = false
UICSAKeys = false
CCIP = true
MultiFeedsManagers = false

[Database]
DefaultIdleInTxSessionTimeout = '1h0m0s'
Expand Down
1 change: 1 addition & 0 deletions core/services/feeds/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type GeneralConfig interface {
OCR() coreconfig.OCR
Insecure() coreconfig.Insecure
FeatureMultiFeedsManagers() bool
}

type JobConfig interface {
Expand Down
58 changes: 0 additions & 58 deletions core/services/feeds/mocks/orm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 0 additions & 58 deletions core/services/feeds/mocks/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions core/services/feeds/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type ORM interface {
DeleteProposal(ctx context.Context, id int64) error
GetJobProposal(ctx context.Context, id int64) (*JobProposal, error)
GetJobProposalByRemoteUUID(ctx context.Context, uuid uuid.UUID) (*JobProposal, error)
ListJobProposals(ctx context.Context) (jps []JobProposal, err error)
ListJobProposalsByManagersIDs(ctx context.Context, ids []int64) ([]JobProposal, error)
UpdateJobProposalStatus(ctx context.Context, id int64, status JobProposalStatus) error // NEEDED?
UpsertJobProposal(ctx context.Context, jp *JobProposal) (int64, error)
Expand Down Expand Up @@ -373,17 +372,6 @@ AND status <> $2;
return jp, errors.Wrap(err, "GetJobProposalByRemoteUUID failed")
}

// ListJobProposals lists all job proposals.
func (o *orm) ListJobProposals(ctx context.Context) (jps []JobProposal, err error) {
stmt := `
SELECT *
FROM job_proposals;
`

err = o.ds.SelectContext(ctx, &jps, stmt)
return jps, errors.Wrap(err, "ListJobProposals failed")
}

// ListJobProposalsByManagersIDs gets job proposals by feeds managers IDs.
func (o *orm) ListJobProposalsByManagersIDs(ctx context.Context, ids []int64) ([]JobProposal, error) {
stmt := `
Expand Down
33 changes: 0 additions & 33 deletions core/services/feeds/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,39 +555,6 @@ func Test_ORM_GetJobProposal(t *testing.T) {
})
}

func Test_ORM_ListJobProposals(t *testing.T) {
t.Parallel()
ctx := testutils.Context(t)

orm := setupORM(t)
fmID := createFeedsManager(t, orm)
uuid := uuid.New()
name := null.StringFrom("jp1")

jp := &feeds.JobProposal{
Name: name,
RemoteUUID: uuid,
Status: feeds.JobProposalStatusPending,
FeedsManagerID: fmID,
}

id, err := orm.CreateJobProposal(ctx, jp)
require.NoError(t, err)

jps, err := orm.ListJobProposals(ctx)
require.NoError(t, err)
require.Len(t, jps, 1)

actual := jps[0]
assert.Equal(t, id, actual.ID)
assert.Equal(t, name, actual.Name)
assert.Equal(t, uuid, actual.RemoteUUID)
assert.Equal(t, jp.Status, actual.Status)
assert.False(t, actual.ExternalJobID.Valid)
assert.False(t, actual.PendingUpdate)
assert.Equal(t, jp.FeedsManagerID, actual.FeedsManagerID)
}

func Test_ORM_CountJobProposalsByStatus(t *testing.T) {
t.Parallel()

Expand Down
Loading
Loading