Skip to content

Commit

Permalink
Replace an OracleFactory error with an Info message (#14950)
Browse files Browse the repository at this point in the history
* Replace an error with an Info message

* Fetch EVM OCR key bundles

* Woopsie

* Add changeset

* Improve info log
  • Loading branch information
DeividasK authored Oct 29, 2024
1 parent 2f2a529 commit 0cd0867
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-clocks-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal OracleFactory error handling change
27 changes: 13 additions & 14 deletions core/services/standardcapabilities/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,28 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) ([]job.Ser
return nil, fmt.Errorf("failed to create relayer set: %w", err)
}

ocrKeyBundles, err := d.ks.OCR2().GetAll()
ocrEvmKeyBundles, err := d.ks.OCR2().GetAllOfType(chaintype.EVM)
if err != nil {
return nil, err
}

if len(ocrKeyBundles) > 1 {
return nil, fmt.Errorf("expected exactly one OCR key bundle, but found: %d", len(ocrKeyBundles))
}

var ocrKeyBundle ocr2key.KeyBundle
if len(ocrKeyBundles) == 0 {
ocrKeyBundle, err = d.ks.OCR2().Create(ctx, chaintype.EVM)
var ocrEvmKeyBundle ocr2key.KeyBundle
if len(ocrEvmKeyBundles) == 0 {
ocrEvmKeyBundle, err = d.ks.OCR2().Create(ctx, chaintype.EVM)
if err != nil {
return nil, errors.Wrap(err, "failed to create OCR key bundle")
}
} else {
ocrKeyBundle = ocrKeyBundles[0]
if len(ocrEvmKeyBundles) > 1 {
log.Infof("found %d EVM OCR key bundles, which may cause unexpected behavior if using the OracleFactory", len(ocrEvmKeyBundles))
}
ocrEvmKeyBundle = ocrEvmKeyBundles[0]
}

ethKeyBundles, err := d.ks.Eth().GetAll(ctx)
if err != nil {
return nil, err
}
if len(ethKeyBundles) > 1 {
return nil, fmt.Errorf("expected exactly one ETH key bundle, but found: %d", len(ethKeyBundles))
}

var ethKeyBundle ethkey.KeyV2
if len(ethKeyBundles) == 0 {
Expand All @@ -148,6 +144,9 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) ([]job.Ser
return nil, errors.Wrap(err, "failed to create ETH key bundle")
}
} else {
if len(ethKeyBundles) > 1 {
log.Infof("found %d ETH key bundles, which may cause unexpected behavior if using the OracleFactory", len(ethKeyBundles))
}
ethKeyBundle = ethKeyBundles[0]
}

Expand All @@ -159,7 +158,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) ([]job.Ser
JobORM: d.jobORM,
JobID: spec.ID,
JobName: spec.Name.ValueOrZero(),
KB: ocrKeyBundle,
KB: ocrEvmKeyBundle,
Config: spec.StandardCapabilitiesSpec.OracleFactory,
PeerWrapper: d.peerWrapper,
RelayerSet: relayerSet,
Expand All @@ -180,7 +179,7 @@ func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) ([]job.Ser
JobORM: d.jobORM,
JobID: spec.ID,
JobName: spec.Name.ValueOrZero(),
KB: ocrKeyBundle,
KB: ocrEvmKeyBundle,
Config: spec.StandardCapabilitiesSpec.OracleFactory,
PeerWrapper: d.peerWrapper,
RelayerSet: relayerSet,
Expand Down

0 comments on commit 0cd0867

Please sign in to comment.