Skip to content

Commit

Permalink
Fetch EVM OCR key bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
DeividasK committed Oct 25, 2024
1 parent f4ad88a commit b9f9efa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions core/services/standardcapabilities/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +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
}

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 {
if len(ocrKeyBundles) > 1 {
log.Infof("found %d OCR key bundles, which may cause unexpected behavior if using the OracleFactory", len(ocrKeyBundles))
if len(ocrEvmKeyBundles) > 1 {
log.Infof("found %d OCR key bundles, which may cause unexpected behavior if using the OracleFactory", len(ocrEvmKeyBundles))
}
ocrKeyBundle = ocrKeyBundles[0]
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 @@ -147,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 @@ -158,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 Down

0 comments on commit b9f9efa

Please sign in to comment.