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

Update application registry when chains change. #42

Merged
merged 8 commits into from
May 27, 2024

Conversation

nodiesBlade
Copy link
Collaborator

@nodiesBlade nodiesBlade commented May 22, 2024

Github issue

#41

Description

This addresses #41 by detecting if applications change by adjusting the equal function to check for chains field as well.

Type of change

Please delete option that is not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Related PRs

List related PRs below

branch PR
other_pr link

@nodiesBlade nodiesBlade changed the title different chains Update application registry when chains change. May 22, 2024
}

// Gateway operator may have updated chains staked
if !strings.EqualFold(strings.Join(networkApp1.Chains, ","), strings.Join(networkApp2.Chains, ",")) {
Copy link
Contributor

@Maxitosh Maxitosh May 23, 2024

Choose a reason for hiding this comment

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

@nodiesBlade what if the order of Chain IDs is different for two applications?
Let's say:

  • networkApp1.Chains = ["111", "222", "333"]
  • networkApp2.Chains = ["222", "333", "111"]

I don't know if Chains are ordered before assigning to PoktApplication, but it is better not to rely on string concatenation equality.

Copy link
Contributor

@Maxitosh Maxitosh May 23, 2024

Choose a reason for hiding this comment

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

+ worth adding a unit test for such a case.

Copy link
Collaborator Author

@nodiesBlade nodiesBlade May 23, 2024

Choose a reason for hiding this comment

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

Due to the nature of blockchain and how hashing works, if the chains ordering change, i would argue the application is still technically different and we should recache it. and so that's why I took a little shortcut.

Though I'm glad you mentioned it as well, wouldn't mind adding the extra security. will push up some changes for it

Copy link
Contributor

@Maxitosh Maxitosh May 23, 2024

Choose a reason for hiding this comment

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

Yeah, I was talking only about the way Chains were compared.

Absolutely agree with what you say about Applications equivalency on different Chains order. No need to re-cache such.

Copy link
Collaborator

@dachi-nodies dachi-nodies left a comment

Choose a reason for hiding this comment

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

LGTM

@nodiesBlade nodiesBlade merged commit 5f1aad1 into main May 27, 2024
2 checks passed
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