-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor chain-selector to use chain specific chainID #65
Conversation
if exist { | ||
chainIDToSelectorMapForFamily[v.Family][v.ChainID] = k | ||
} else { | ||
chainIDToSelectorMapForFamily[v.Family] = make(map[string]uint64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to also call the below for this case right:
chainIDToSelectorMapForFamily[v.Family][v.ChainID] = k
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, thanks
selectors.go
Outdated
func NameFromChainId(chainId uint64) (string, error) { | ||
details, exist := evmChainIdToChainSelector[chainId] | ||
func NameFromChainIdAndFamily(chainId string, family string) (string, error) { | ||
// if family is missing use EVM as default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of duplicating all this code from above function, just call that?
SelectorFromChainIdAndFamily()
Then from selector, just fetch details.
|
||
for _, v := range selectorToChainDetails { | ||
if v.Name == name && family == v.Family { | ||
return v.ChainID, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has our schema enforced anywhere that name, family paid must be unique?
I know practically we use unique names, but nothing currently prevents from someone naming say 2 different EVM chains as same?
Just wondering, if we leave that logic as it-is, or add some validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could add a unit-test to ensure that name+family combination should not have duplicates, if others agree with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TestNoSameChainIDAndFamilyAreGenerated
selectors.go
Outdated
if exist { | ||
testChainIDToSelectorMapForFamily[v.Family][v.ChainID] = k | ||
} else { | ||
testChainIDToSelectorMapForFamily[v.Family] = make(map[string]uint64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I am actually going to combine regular and test chains, noticed var evmChainIdToChainSelector = loadAllSelectors()
has the two combined
Be careful, this project is public, and many internal and external dependents require exact format, and even hardcode the selectors.yml URL from this repo. Any such change should be a major version bump, and we'd be better doing as much as we can to keep backwards compatibility on this. |
I kept function like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets cut a major version - create a v2 directory and place all these changes there?
Replaced with #70 |
https://smartcontract-it.atlassian.net/browse/NONEVM-827
To generalize plugin component to support Solana, we need to help CCIP team to refactor chain-selector. The existing chainID is uint64, this PR converts it to string since for solana we will use genesis hash as chainID.
Instead of use previous selector.yml (
chainID
->{selector+name}
) and selector_families(selector
->family
), provides a reconstructed config usingselector
->{chainID + name + family}
, and making chainID a string instead of uint64.update rest of the code/test to use the
selector_restructured.yml
config that key by selector. The originalselectors.yml
andselector_families.yml
are left for reference and can be removed in a following PR.preserve the existing functions that use uint64 chainID for backward compatibility, but mark as deprecated