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

[BCF-2365] Consolidate *Provider Constructors into One #10475

Merged
merged 4 commits into from
Sep 8, 2023

Conversation

cedric-cordenier
Copy link
Contributor

@cedric-cordenier cedric-cordenier commented Sep 4, 2023

  • Adapt the MercuryProvider so that it strictly extends the PluginProvider type. The additional functions in the MercuryTransmitter have moved to a separate MercuryServerFetcher component.
  • Introduce a wrapper relayerServerAdapter type which contains similar logic to the GRPC relayerServer, whose NewPluginProvider function returns a different provider type depending on the passed in ProviderType.
  • Replace uses of New{Mercury|Median|Functions}Provider with calls to NewPluginProvider with the correct ProviderType passed in.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch 2 times, most recently from fb677fa to b2813d7 Compare September 4, 2023 16:49
@cedric-cordenier cedric-cordenier marked this pull request as ready for review September 5, 2023 09:01
@cedric-cordenier cedric-cordenier changed the title Bcf 2365 combine providers [BCF-2365] Consolidate *Provider Constructors into One Sep 5, 2023
@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch from b2813d7 to 368154b Compare September 5, 2023 09:38
go.mod Outdated
@@ -66,7 +66,7 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20230831132059-42af68994512
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20230901143551-bf6bd84d6938
github.com/smartcontractkit/chainlink-relay v0.1.7-0.20230904152856-39e4d6f4a24b
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx,
types.RelayArgs{
ExternalJobID: jobSpec.ExternalJobID,
JobID: spec.ID,
ContractID: spec.ContractID,
RelayConfig: spec.RelayConfig.Bytes(),
New: d.isNewlyCreatedJob,
ProviderType: types.ProviderTypeFunctions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not 100% sure that I understand this new types.ProviderType*. Where will the mapping from plugin type to provider type exist long-term? Core cannot continue to make this associate explicit in the delegate like this. To be product agnostic, it would have to just pass along information from the job spec. It seems like we either need to add this new field to the jobspec, or infer/derive from the plugin type inside the relayer instead of here in core.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we don't want to lock in plugin type and provider type as 1-1, but we also have to balance that against node op UX simplicity, so I would favor hiding this difference for now.

Copy link
Contributor Author

@cedric-cordenier cedric-cordenier Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you're talking about the mapping from the ProviderType value to the ProviderType type, then this mapping should live either in the RelayerServerAdapter (which shouldn't really live in the core node tbh) or in the RelayerServer.

This field should live in the pluginConfig of the jobspec long-term (such as for generic plugin job types). However, based on our discussion the other day where we said that some parts of the codebase will still need to be provider aware, I just added them statically in those places for now (my reasoning being that there is no difference between a call to say, NewMedianProvider or a call to NewPluginProvider with providerType = "median"). That's the case for this block of code here, which has to do with router proxies, which is a functions only feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a similar reaction.

It seems like the job spec is the string that ties all the services together and so the provider type should be coming from there.

how does core know which services to start today for say, mercury vs functions? is something in the jobspec or is it inferred from something else?

my real question is: if we add the provider field to the spec, is it a breaking change or can we infer the correct behavior and backfill on-the-fly as needed to update the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does core know which services to start today for say, mercury vs functions? is something in the jobspec or is it inferred from something else?

That comes from the plugin type on the job spec at the moment.

my real question is: if we add the provider field to the spec, is it a breaking change or can we infer the correct behavior and backfill on-the-fly as needed to update the spec?

For old job types of the OCR2 job type we could backfill on the fly. I don't know that we could do that in this particular case (ocrbootstrap) since I'm not sure if the pluginType is used. For functions I assume it isn't since they're checking the router DonID rather than the pluginType.

ctx,
types.RelayArgs{
ExternalJobID: jobSpec.ExternalJobID,
JobID: spec.ID,
ContractID: spec.ContractID,
RelayConfig: spec.RelayConfig.Bytes(),
New: d.isNewlyCreatedJob,
ProviderType: string(job.OCR2Functions),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmank88 @krehermann Was this the kind of change you had in mind? (Here taken explicitly, but taken from the job spec in the case of Median and Mercury)

I've coerced the value to a string since that way it's acts as a passthrough value when we source it from the providerType.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't realize this one was such an oddball 🤔
Yeah, I think this works for now, and we should be able to evolve in a compatible way 🤔

@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch from 75cc7d0 to 608f982 Compare September 7, 2023 09:58
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch from 608f982 to dc72147 Compare September 7, 2023 10:22
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch from dc72147 to 6be2fc3 Compare September 7, 2023 12:05
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch from 6be2fc3 to 316ccfe Compare September 7, 2023 13:49
@cedric-cordenier cedric-cordenier requested a review from a team as a code owner September 7, 2023 13:49
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

core/services/ocr2/plugins/median/services.go Show resolved Hide resolved
core/services/ocrbootstrap/delegate.go Show resolved Hide resolved
core/services/relay/evm/loop_impl.go Outdated Show resolved Hide resolved
core/services/relay/relay.go Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

- Adapt the MercuryProvider so that it strictly extends the PluginProvider
type. The additional functions in the MercuryTransmitter have moved to a
separate MercuryServerFetcher component.
- Introduce a wrapper relayerServerAdapter type which contains similar
logic to the GRPC relayerServer, whose NewPluginProvider function
returns a different provider type depending on the passed in
ProviderType.
- Replace uses of New{Mercury|Median|Functions}Provider with calls to
NewPluginProvider with the correct ProviderType passed in.
@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch from 8db4cb1 to c5f6e4f Compare September 7, 2023 16:58
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2023

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2023

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2023

@cedric-cordenier cedric-cordenier force-pushed the BCF-2365-combine-providers branch from 887424a to bfd60d2 Compare September 8, 2023 13:30
@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2023

@krehermann krehermann self-requested a review September 8, 2023 13:33
@cedric-cordenier cedric-cordenier added this pull request to the merge queue Sep 8, 2023
@cl-sonarqube-production
Copy link

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 8, 2023
@cedric-cordenier cedric-cordenier added this pull request to the merge queue Sep 8, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 8, 2023
@cedric-cordenier cedric-cordenier added this pull request to the merge queue Sep 8, 2023
Merged via the queue into develop with commit 6daa8ff Sep 8, 2023
117 checks passed
@cedric-cordenier cedric-cordenier deleted the BCF-2365-combine-providers branch September 8, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants