-
Notifications
You must be signed in to change notification settings - Fork 51
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
feat: add getter to return all source chain config #1477
feat: add getter to return all source chain config #1477
Conversation
Signed-off-by: 0xsuryansh <[email protected]>
LCOV of commit
|
Signed-off-by: 0xsuryansh <[email protected]> feat: add getter to return all source chain config Signed-off-by: 0xsuryansh <[email protected]>
Signed-off-by: 0xsuryansh <[email protected]>
Signed-off-by: 0xsuryansh <[email protected]>
Signed-off-by: 0xsuryansh <[email protected]>
@@ -919,6 +924,16 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |||
return s_sourceChainConfigs[sourceChainSelector]; | |||
} | |||
|
|||
/// @notice Returns all source chain configs | |||
/// @return sourceChainConfigs The source chain configs corresponding to all the supported chain selectors | |||
function getAllSourceChainConfig() external view returns (SourceChainConfig[] memory) { |
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 doesn't return the chain selectors, which I would suspect are required?
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.
@@ -931,6 +946,7 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |||
for (uint256 i = 0; i < sourceChainConfigUpdates.length; ++i) { | |||
SourceChainConfigArgs memory sourceConfigUpdate = sourceChainConfigUpdates[i]; | |||
uint64 sourceChainSelector = sourceConfigUpdate.sourceChainSelector; | |||
s_sourceChainSelectors.add(sourceChainSelector); |
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 do this after the sanity checks
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.
Signed-off-by: 0xsuryansh <[email protected]>
Signed-off-by: 0xsuryansh <[email protected]>
@@ -919,6 +924,18 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |||
return s_sourceChainConfigs[sourceChainSelector]; | |||
} | |||
|
|||
/// @notice Returns all source chain configs | |||
/// @return sourceChainConfigs The source chain configs corresponding to all the supported chain selectors | |||
function getAllSourceChainConfig() external view returns (uint64[] memory, SourceChainConfig[] memory) { |
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.
naming nit: getAllSourceChainConfigs
(with an s
at the end)? Whats the preference for this @RensR
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.
Its a list so yeah good call
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.
@@ -962,6 +979,8 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |||
currentConfig.isEnabled = sourceConfigUpdate.isEnabled; | |||
currentConfig.router = sourceConfigUpdate.router; | |||
|
|||
s_sourceChainSelectors.add(sourceChainSelector); |
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.
nit: this returns a bool for "inserted" or "already exists". maybe add a comment explaining we don't care about the return value as adding it twice should not do anything
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.
Signed-off-by: 0xsuryansh <[email protected]>
# Conflicts: # contracts/gas-snapshots/ccip.gas-snapshot # core/gethwrappers/ccip/generated/offramp/offramp.go # core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt
Signed-off-by: 0xsuryansh <[email protected]>
Quality Gate passedIssues Measures |
Motivation
The current offchain initialization process involves calling getSourceChainConfig(sourceChainSelector), which retrieves configurations for a specific source chain selector. However, there's no mechanism to fetch a complete list of supported source chains during the initialization phase. This limitation complicates the process, as the full list of source chain selectors is not readily available.
Solution
To address this, the proposed solution introduces an enumerable set of all source chain selectors. By implementing a getAllSourceChainConfig() function, we can easily retrieve the complete list of source chains on-chain. This eliminates the need for additional rounds of OCR gossip to share known source chains, simplifying initialization and improving efficiency.