Skip to content

Commit

Permalink
Update configs through JSONConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Apr 22, 2024
1 parent 3fec5d0 commit 7910a77
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
16 changes: 16 additions & 0 deletions core/services/job/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,22 @@ func (r JSONConfig) MercuryCredentialName() (string, error) {
return name, nil
}

func (relayConfig JSONConfig) ApplyDefaultsOCR2(cfg ocr2Config) {

Check failure on line 330 in core/services/job/models.go

View workflow job for this annotation

GitHub Actions / lint

receiver-naming: receiver name relayConfig should be consistent with previous receiver name r for JSONConfig (revive)
_, ok := relayConfig["defaultTransactionQueueDepth"]
if !ok {
relayConfig["defaultTransactionQueueDepth"] = cfg.DefaultTransactionQueueDepth()
}
_, ok = relayConfig["simulateTransactions"]
if !ok {
relayConfig["simulateTransactions"] = cfg.SimulateTransactions()
}
}

type ocr2Config interface {
DefaultTransactionQueueDepth() uint32
SimulateTransactions() bool
}

var ForwardersSupportedPlugins = []types.OCR2PluginType{types.Median, types.DKG, types.OCR2VRF, types.OCR2Keeper, types.Functions}

// OCR2OracleSpec defines the job spec for OCR2 jobs.
Expand Down
13 changes: 1 addition & 12 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, jb job.Job) ([]job.Servi
}
}
spec.RelayConfig["effectiveTransmitterID"] = effectiveTransmitterID
d.relayConfigsWithDefaults(spec.RelayConfig)
spec.RelayConfig.ApplyDefaultsOCR2(d.cfg.OCR2())

ocrDB := NewDB(d.db, spec.ID, 0, lggr, d.cfg.Database())
if d.peerWrapper == nil {
Expand Down Expand Up @@ -1695,17 +1695,6 @@ func (d *Delegate) newServicesOCR2Functions(
return append([]job.ServiceCtx{functionsProvider, thresholdProvider, s4Provider}, functionsServices...), nil
}

func (d *Delegate) relayConfigsWithDefaults(relayConfig job.JSONConfig) {
_, ok := relayConfig["defaultTransactionQueueDepth"]
if !ok {
relayConfig["defaultTransactionQueueDepth"] = d.cfg.OCR2().DefaultTransactionQueueDepth()
}
_, ok = relayConfig["simulateTransactions"]
if !ok {
relayConfig["simulateTransactions"] = d.cfg.OCR2().SimulateTransactions()
}
}

// errorLog implements [loop.ErrorLog]
type errorLog struct {
jobID int32
Expand Down
13 changes: 1 addition & 12 deletions core/services/ocrbootstrap/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, jb job.Job) (services []
if spec.FeedID != nil {
spec.RelayConfig["feedID"] = *spec.FeedID
}
d.relayConfigsWithDefaults(spec.RelayConfig)
spec.RelayConfig.ApplyDefaultsOCR2(d.ocr2Cfg)

ctxVals := loop.ContextValues{
JobID: jb.ID,
Expand Down Expand Up @@ -193,14 +193,3 @@ func (d *Delegate) BeforeJobDeleted(spec job.Job) {}
func (d *Delegate) OnDeleteJob(context.Context, job.Job) error {
return nil
}

func (d *Delegate) relayConfigsWithDefaults(relayConfig job.JSONConfig) {
_, ok := relayConfig["defaultTransactionQueueDepth"]
if !ok {
relayConfig["defaultTransactionQueueDepth"] = d.ocr2Cfg.DefaultTransactionQueueDepth()
}
_, ok = relayConfig["simulateTransactions"]
if !ok {
relayConfig["simulateTransactions"] = d.ocr2Cfg.SimulateTransactions()
}
}

0 comments on commit 7910a77

Please sign in to comment.