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

[DPA-1151]: fix: handle duplicate chain id across network better for ethkeys, ethTransactions & chains query. #14791

Merged

Conversation

graham-chainlink
Copy link
Collaborator

@graham-chainlink graham-chainlink commented Oct 16, 2024

I recommend going through each commit one at a time for better reviewing experience

We currently have a loader loadByIDs but this does not take into consideration when same Id exists across different network. It has a bug in there where it will either return an error or worst returns an incorrect results from a different chain. Eg if solana and ethereum both have chain ID 1.

loadByRelayIDs rectifies this by performing lookup with ID and Network. It migrates ethKeys , ethTransactions and chain to use the new loader.

This PR also introduce lookup for chain query to include network argument.

Node and Nodes graphQL query are still using the loadByIDs loader. To fix them, we need to rewrite Node and Nodes to fetch relayid from the relayer and use that to perform lookup.

JIRA: https://smartcontract-it.atlassian.net/browse/DPA-1151

Chain query with network lookup

Screenshot 2024-10-17 at 1 03 50 pm

@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch from 8915795 to f116714 Compare October 17, 2024 03:09
Copy link
Contributor

github-actions bot commented Oct 17, 2024

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch 4 times, most recently from b402d38 to d93a55f Compare October 17, 2024 06:39
@graham-chainlink graham-chainlink changed the title testing [DPA-1151]: fix: handle duplicate chain id across network better. Oct 17, 2024
@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch 2 times, most recently from 0be8692 to 41a6b00 Compare October 18, 2024 04:10
@graham-chainlink graham-chainlink marked this pull request as ready for review October 18, 2024 04:10
@graham-chainlink graham-chainlink requested review from a team as code owners October 18, 2024 04:10
@graham-chainlink graham-chainlink changed the title [DPA-1151]: fix: handle duplicate chain id across network better. [DPA-1151]: fix: handle duplicate chain id across network better for ethkeys, ethTransactions & chains query. Oct 18, 2024
@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch 3 times, most recently from 5f85e57 to 7f834e2 Compare October 22, 2024 13:06
@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch from 7f834e2 to 780e581 Compare October 23, 2024 14:24
core/services/relay/relay.go Outdated Show resolved Hide resolved
core/services/relay/relay.go Outdated Show resolved Hide resolved
core/web/schema/type/chain.graphql Outdated Show resolved Hide resolved
@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch from 780e581 to e9a7615 Compare October 29, 2024 04:38
@graham-chainlink graham-chainlink requested a review from a team as a code owner October 29, 2024 04:38
core/web/loader/chain.go Outdated Show resolved Hide resolved
@jmank88
Copy link
Contributor

jmank88 commented Oct 29, 2024

Does this PR need a corresponding operator-ui change?

@graham-chainlink
Copy link
Collaborator Author

I thought the readme instructions suggested that a follow up PR is necessary since that repo depends on this one. Is that not always the case?

@jmank88 I dont believe so. Since the types are generated on the fly, the schema is always updated. However because the chain graphql query is not being used in the operator ui, the generated typescript typings were never referenced in the react code, so there are no code to change too.

@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch from a58e3e5 to 38a40ad Compare October 30, 2024 02:28
@graham-chainlink graham-chainlink requested a review from a team as a code owner October 30, 2024 02:28
We currently have a loader `loadByIDs` but this does not take into consideration when same Id exists across different network. Eg if solana and ethereum both have chain ID 1. `loadByIDs` will either return an error or worst returns an incorrect results.

`loadByRelayIDs` rectifies this by performing lookup with ID and Network.

JIRA: https://smartcontract-it.atlassian.net/browse/DPA-1151
Update ethKeys & ethTransaction query to use the new dataloader `GetChainByRelayID` as the existing loader does not handle duplicate Id across different network.
Allow chain lookup by network and chain Id so we can differentiate same chain id in different networks.

JIRA: https://smartcontract-it.atlassian.net/browse/DPA-1151
@graham-chainlink graham-chainlink force-pushed the ggoh/DPA-1151/handle-same-id-differentnetwork branch from 38a40ad to dc96cdc Compare October 30, 2024 02:30
@graham-chainlink graham-chainlink requested review from a team as code owners October 30, 2024 02:30
func GetChainByRelayID(ctx context.Context, id string) (*commonTypes.ChainStatusWithID, error) {
ldr := For(ctx)

thunk := ldr.ChainsByRelayIDLoader.Load(ctx, dataloader.StringKey(id))
Copy link
Contributor

Choose a reason for hiding this comment

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

what does thunk mean as a var?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great question, in this context, thunk is just promise, but mainly i was following the rest of the data loaders, they seem to call the value returned by load thunk

@@ -45,6 +46,7 @@ func New(app chainlink.Application) *Dataloader {
app: app,

ChainsByIDLoader: dataloader.NewBatchedLoader(chains.loadByIDs),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a ticket to clean out the ChainsByIDLoader usage?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not yet, there is still code using it for backwards compatibility as it is exposed via API, and to be honest i dont know enough about how this repo works and removing this is a breaking change for the API, like we would have to communicate to consumers to not use this or monitor the usage of it.

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.

5 participants