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

update common repo; apply patch of e9e903bf4b34099f8b274eb1e0f013b4ab… #684

Closed
wants to merge 8 commits into from
5 changes: 5 additions & 0 deletions .changeset/large-flowers-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Update keyvalue store to be compatible with the interface required in chainlink common
5 changes: 5 additions & 0 deletions .changeset/rude-falcons-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Calculate blockRate and logLimit defaults in the log provider based on chain ID
6 changes: 4 additions & 2 deletions core/internal/cltest/factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (

"github.com/jmoiron/sqlx"

"github.com/smartcontractkit/chainlink-common/pkg/utils/jsonserializable"

txmgrcommon "github.com/smartcontractkit/chainlink/v2/common/txmgr"
txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types"
"github.com/smartcontractkit/chainlink/v2/core/auth"
Expand Down Expand Up @@ -454,14 +456,14 @@ func MustInsertPipelineRun(t *testing.T, db *sqlx.DB) (run pipeline.Run) {

func MustInsertPipelineRunWithStatus(t *testing.T, db *sqlx.DB, pipelineSpecID int32, status pipeline.RunStatus) (run pipeline.Run) {
var finishedAt *time.Time
var outputs pipeline.JSONSerializable
var outputs jsonserializable.JSONSerializable
var allErrors pipeline.RunErrors
var fatalErrors pipeline.RunErrors
now := time.Now()
switch status {
case pipeline.RunStatusCompleted:
finishedAt = &now
outputs = pipeline.JSONSerializable{
outputs = jsonserializable.JSONSerializable{
Val: "foo",
Valid: true,
}
Expand Down
8 changes: 4 additions & 4 deletions core/internal/features/ocr2/features_ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ typeABI = '''
'''
`
}
ocrJob, err := validate.ValidatedOracleSpecToml(apps[i].Config.OCR2(), apps[i].Config.Insecure(), fmt.Sprintf(`
ocrJob, err := validate.ValidatedOracleSpecToml(testutils.Context(t), apps[i].Config.OCR2(), apps[i].Config.Insecure(), fmt.Sprintf(`
type = "offchainreporting2"
relay = "evm"
schemaVersion = 1
Expand Down Expand Up @@ -488,7 +488,7 @@ juelsPerFeeCoinSource = """
answer1 [type=median index=0];
"""
juelsPerFeeCoinCacheDuration = "1m"
`, ocrContractAddress, kbs[i].ID(), transmitters[i], fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i, blockBeforeConfig.Number().Int64(), chainReaderSpec, fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i))
`, ocrContractAddress, kbs[i].ID(), transmitters[i], fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i, blockBeforeConfig.Number().Int64(), chainReaderSpec, fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i), nil)
require.NoError(t, err)
err = apps[i].AddJobV2(testutils.Context(t), &ocrJob)
require.NoError(t, err)
Expand Down Expand Up @@ -793,7 +793,7 @@ chainID = 1337
URL: models.WebURL(*u),
}))

ocrJob, err := validate.ValidatedOracleSpecToml(apps[i].Config.OCR2(), apps[i].Config.Insecure(), fmt.Sprintf(`
ocrJob, err := validate.ValidatedOracleSpecToml(testutils.Context(t), apps[i].Config.OCR2(), apps[i].Config.Insecure(), fmt.Sprintf(`
type = "offchainreporting2"
relay = "evm"
schemaVersion = 1
Expand Down Expand Up @@ -841,7 +841,7 @@ juelsPerFeeCoinSource = """
answer1 [type=median index=0];
"""
juelsPerFeeCoinCacheDuration = "1m"
`, ocrContractAddress, kbs[i].ID(), transmitters[i], fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i, fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i))
`, ocrContractAddress, kbs[i].ID(), transmitters[i], fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i, fmt.Sprintf("bridge%d", i), i, slowServers[i].URL, i), nil)
require.NoError(t, err)
err = apps[i].AddJobV2(testutils.Context(t), &ocrJob)
require.NoError(t, err)
Expand Down
30 changes: 26 additions & 4 deletions core/internal/mocks/application.go

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

4 changes: 2 additions & 2 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chain-selectors v1.0.13
github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240311111125-22812a072c35
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240326183122-8012c0f08116
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240404151628-2fb437ef3814
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240229181116-bfb2432a7a66
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1168,8 +1168,8 @@ github.com/smartcontractkit/chain-selectors v1.0.13 h1:vHMbh7Wu+W+/DSD88feiwMMSX
github.com/smartcontractkit/chain-selectors v1.0.13/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240311111125-22812a072c35 h1:GNhRKD3izyzAoGMXDvVUAwEuzz4Atdj3U3RH7eak5Is=
github.com/smartcontractkit/chainlink-automation v1.0.2-0.20240311111125-22812a072c35/go.mod h1:2I0dWdYdK6jHPnSYYy7Y7Xp7L0YTnJ3KZtkhLQflsTU=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240326183122-8012c0f08116 h1:+ncHpL0jLpdCXXOm4JanT1NJVXimysKhyQbK4X22A9g=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240326183122-8012c0f08116/go.mod h1://xWphjmC6GWJtT8l86J2VpnG21xNwFCb0thzz4ItEk=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240404151628-2fb437ef3814 h1:8whef64m7tpUtT6Bm59f1ZVN/xtpV04ay1LwkVJ69iM=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240404151628-2fb437ef3814/go.mod h1:kstYjAGqBswdZpl7YkSPeXBDVwaY1VaR6tUMPWl8ykA=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8 h1:I326nw5GwHQHsLKHwtu5Sb9EBLylC8CfUd7BFAS0jtg=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240213120401-01a23955f9f8/go.mod h1:a65NtrK4xZb01mf0dDNghPkN2wXgcqFQ55ADthVBgMc=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
Expand All @@ -1186,8 +1186,8 @@ github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0=
github.com/smartcontractkit/libocr v0.0.0-20240229181116-bfb2432a7a66 h1:xsU00JB9GJxEiN6tDbqgN+fT98ySdxkUwTw6CfBXscw=
github.com/smartcontractkit/libocr v0.0.0-20240229181116-bfb2432a7a66/go.mod h1:SJEZCHgMCAzzBvo9vMV2DQ9onfEcIJCYSViyP4JI6c4=
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052 h1:1WFjrrVrWoQ9UpVMh7Mx4jDpzhmo1h8hFUKd9awIhIU=
github.com/smartcontractkit/libocr v0.0.0-20240326191951-2bbe9382d052/go.mod h1:SJEZCHgMCAzzBvo9vMV2DQ9onfEcIJCYSViyP4JI6c4=
github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1 h1:yiKnypAqP8l0OX0P3klzZ7SCcBUxy5KqTAKZmQOvSQE=
github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20230906073235-9e478e5e19f1/go.mod h1:q6f4fe39oZPdsh1i57WznEZgxd8siidMaSFq3wdPmVg=
github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20230906073235-9e478e5e19f1 h1:Dai1bn+Q5cpeGMQwRdjOdVjG8mmFFROVkSKuUgBErRQ=
Expand Down
17 changes: 13 additions & 4 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/loop"
commonservices "github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-common/pkg/utils/jsonserializable"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"
"github.com/smartcontractkit/chainlink/v2/core/capabilities"
"github.com/smartcontractkit/chainlink/v2/core/static"
Expand Down Expand Up @@ -84,6 +85,7 @@ type Application interface {
GetExternalInitiatorManager() webhook.ExternalInitiatorManager
GetRelayers() RelayerChainInteroperators
GetLoopRegistry() *plugins.LoopRegistry
GetLoopRegistrarConfig() plugins.RegistrarConfig

// V2 Jobs (TOML specified)
JobSpawner() job.Spawner
Expand All @@ -96,7 +98,7 @@ type Application interface {
TxmStorageService() txmgr.EvmTxStore
AddJobV2(ctx context.Context, job *job.Job) error
DeleteJob(ctx context.Context, jobID int32) error
RunWebhookJobV2(ctx context.Context, jobUUID uuid.UUID, requestBody string, meta pipeline.JSONSerializable) (int64, error)
RunWebhookJobV2(ctx context.Context, jobUUID uuid.UUID, requestBody string, meta jsonserializable.JSONSerializable) (int64, error)
ResumeJobV2(ctx context.Context, taskID uuid.UUID, result pipeline.Result) error
// Testing only
RunJobV2(ctx context.Context, jobID int32, meta map[string]interface{}) (int64, error)
Expand Down Expand Up @@ -144,6 +146,7 @@ type ChainlinkApplication struct {
secretGenerator SecretGenerator
profiler *pyroscope.Profiler
loopRegistry *plugins.LoopRegistry
loopRegistrarConfig plugins.RegistrarConfig

started bool
startStopMu sync.Mutex
Expand Down Expand Up @@ -407,10 +410,11 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
} else {
globalLogger.Debug("Off-chain reporting disabled")
}

loopRegistrarConfig := plugins.NewRegistrarConfig(opts.GRPCOpts, opts.LoopRegistry.Register, opts.LoopRegistry.Unregister)
if cfg.OCR2().Enabled() {
globalLogger.Debug("Off-chain reporting v2 enabled")
registrarConfig := plugins.NewRegistrarConfig(opts.GRPCOpts, opts.LoopRegistry.Register)
ocr2DelegateConfig := ocr2.NewDelegateConfig(cfg.OCR2(), cfg.Mercury(), cfg.Threshold(), cfg.Insecure(), cfg.JobPipeline(), cfg.Database(), registrarConfig)
ocr2DelegateConfig := ocr2.NewDelegateConfig(cfg.OCR2(), cfg.Mercury(), cfg.Threshold(), cfg.Insecure(), cfg.JobPipeline(), cfg.Database(), loopRegistrarConfig)
delegates[job.OffchainReporting2] = ocr2.NewDelegate(
db,
jobORM,
Expand Down Expand Up @@ -478,6 +482,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
legacyEVMChains,
globalLogger,
opts.Version,
loopRegistrarConfig,
)
} else {
feedsService = &feeds.NullService{}
Expand Down Expand Up @@ -516,6 +521,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
secretGenerator: opts.SecretGenerator,
profiler: profiler,
loopRegistry: loopRegistry,
loopRegistrarConfig: loopRegistrarConfig,

sqlxDB: opts.SqlxDB,

Expand Down Expand Up @@ -585,6 +591,9 @@ func (app *ChainlinkApplication) StopIfStarted() error {
func (app *ChainlinkApplication) GetLoopRegistry() *plugins.LoopRegistry {
return app.loopRegistry
}
func (app *ChainlinkApplication) GetLoopRegistrarConfig() plugins.RegistrarConfig {
return app.loopRegistrarConfig
}

// Stop allows the application to exit by halting schedules, closing
// logs, and closing the DB connection.
Expand Down Expand Up @@ -724,7 +733,7 @@ func (app *ChainlinkApplication) DeleteJob(ctx context.Context, jobID int32) err
return app.jobSpawner.DeleteJob(jobID, pg.WithParentCtx(ctx))
}

func (app *ChainlinkApplication) RunWebhookJobV2(ctx context.Context, jobUUID uuid.UUID, requestBody string, meta pipeline.JSONSerializable) (int64, error) {
func (app *ChainlinkApplication) RunWebhookJobV2(ctx context.Context, jobUUID uuid.UUID, requestBody string, meta jsonserializable.JSONSerializable) (int64, error) {
return app.webhookJobRunner.RunJob(ctx, jobUUID, requestBody, meta)
}

Expand Down
80 changes: 42 additions & 38 deletions core/services/feeds/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocrbootstrap"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/utils/crypto"
"github.com/smartcontractkit/chainlink/v2/plugins"
)

//go:generate mockery --quiet --name Service --output ./mocks/ --case=underscore
Expand Down Expand Up @@ -102,22 +103,23 @@ type Service interface {
type service struct {
services.StateMachine

orm ORM
jobORM job.ORM
q pg.Q
csaKeyStore keystore.CSA
p2pKeyStore keystore.P2P
ocr1KeyStore keystore.OCR
ocr2KeyStore keystore.OCR2
jobSpawner job.Spawner
insecureCfg InsecureConfig
jobCfg JobConfig
ocrCfg OCRConfig
ocr2cfg OCR2Config
connMgr ConnectionsManager
legacyChains legacyevm.LegacyChainContainer
lggr logger.Logger
version string
orm ORM
jobORM job.ORM
q pg.Q
csaKeyStore keystore.CSA
p2pKeyStore keystore.P2P
ocr1KeyStore keystore.OCR
ocr2KeyStore keystore.OCR2
jobSpawner job.Spawner
insecureCfg InsecureConfig
jobCfg JobConfig
ocrCfg OCRConfig
ocr2cfg OCR2Config
connMgr ConnectionsManager
legacyChains legacyevm.LegacyChainContainer
lggr logger.Logger
version string
loopRegistrarConfig plugins.RegistrarConfig
}

// NewService constructs a new feeds service
Expand All @@ -135,25 +137,27 @@ func NewService(
legacyChains legacyevm.LegacyChainContainer,
lggr logger.Logger,
version string,
rc plugins.RegistrarConfig,
) *service {
lggr = lggr.Named("Feeds")
svc := &service{
orm: orm,
jobORM: jobORM,
q: pg.NewQ(db, lggr, dbCfg),
jobSpawner: jobSpawner,
p2pKeyStore: keyStore.P2P(),
csaKeyStore: keyStore.CSA(),
ocr1KeyStore: keyStore.OCR(),
ocr2KeyStore: keyStore.OCR2(),
insecureCfg: insecureCfg,
jobCfg: jobCfg,
ocrCfg: ocrCfg,
ocr2cfg: ocr2Cfg,
connMgr: newConnectionsManager(lggr),
legacyChains: legacyChains,
lggr: lggr,
version: version,
orm: orm,
jobORM: jobORM,
q: pg.NewQ(db, lggr, dbCfg),
jobSpawner: jobSpawner,
p2pKeyStore: keyStore.P2P(),
csaKeyStore: keyStore.CSA(),
ocr1KeyStore: keyStore.OCR(),
ocr2KeyStore: keyStore.OCR2(),
insecureCfg: insecureCfg,
jobCfg: jobCfg,
ocrCfg: ocrCfg,
ocr2cfg: ocr2Cfg,
connMgr: newConnectionsManager(lggr),
legacyChains: legacyChains,
lggr: lggr,
version: version,
loopRegistrarConfig: rc,
}

return svc
Expand Down Expand Up @@ -534,7 +538,7 @@ type ProposeJobArgs struct {
// belonging to another feeds manager, we do not update it.
func (s *service) ProposeJob(ctx context.Context, args *ProposeJobArgs) (int64, error) {
// Validate the args
if err := s.validateProposeJobArgs(*args); err != nil {
if err := s.validateProposeJobArgs(ctx, *args); err != nil {
return 0, err
}

Expand Down Expand Up @@ -717,7 +721,7 @@ func (s *service) ApproveSpec(ctx context.Context, id int64, force bool) error {
return errors.Wrap(err, "fms rpc client")
}

j, err := s.generateJob(spec.Definition)
j, err := s.generateJob(ctx, spec.Definition)
if err != nil {
return errors.Wrap(err, "could not generate job from spec")
}
Expand Down Expand Up @@ -1121,7 +1125,7 @@ func (s *service) findExistingJobForOCRFlux(j *job.Job, qopts pg.QOpt) (int32, e
}

// generateJob validates and generates a job from a spec.
func (s *service) generateJob(spec string) (*job.Job, error) {
func (s *service) generateJob(ctx context.Context, spec string) (*job.Job, error) {
jobType, err := job.ValidateSpec(spec)
if err != nil {
return nil, errors.Wrap(err, "failed to parse job spec TOML")
Expand All @@ -1138,7 +1142,7 @@ func (s *service) generateJob(spec string) (*job.Job, error) {
if !s.ocr2cfg.Enabled() {
return nil, ErrOCR2Disabled
}
js, err = ocr2.ValidatedOracleSpecToml(s.ocr2cfg, s.insecureCfg, spec)
js, err = ocr2.ValidatedOracleSpecToml(ctx, s.ocr2cfg, s.insecureCfg, spec, s.loopRegistrarConfig)
case job.Bootstrap:
if !s.ocr2cfg.Enabled() {
return nil, ErrOCR2Disabled
Expand Down Expand Up @@ -1297,9 +1301,9 @@ func (s *service) newOCR2ConfigMsg(cfg OCR2ConfigModel) (*pb.OCR2Config, error)
return msg, nil
}

func (s *service) validateProposeJobArgs(args ProposeJobArgs) error {
func (s *service) validateProposeJobArgs(ctx context.Context, args ProposeJobArgs) error {
// Validate the job spec
j, err := s.generateJob(args.Spec)
j, err := s.generateJob(ctx, args.Spec)
if err != nil {
return errors.Wrap(err, "failed to generate a job based on spec")
}
Expand Down