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

feat: add getter to return all source chain config #1477

Merged
merged 14 commits into from
Oct 7, 2024

Conversation

0xsuryansh
Copy link
Member

@0xsuryansh 0xsuryansh commented Oct 1, 2024

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.

Copy link
Contributor

github-actions bot commented Oct 1, 2024

LCOV of commit d2c3165 during Solidity Foundry #8524

Summary coverage rate:
  lines......: 97.8% (2270 of 2320 lines)
  functions..: 95.3% (427 of 448 functions)
  branches...: 93.6% (537 of 574 branches)

Files changed coverage rate: n/a

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]>
@0xsuryansh 0xsuryansh marked this pull request as ready for review October 1, 2024 10:27
@0xsuryansh 0xsuryansh requested a review from RyanRHall October 1, 2024 10:27
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) {
Copy link
Collaborator

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?

Copy link
Member Author

@0xsuryansh 0xsuryansh Oct 2, 2024

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);
Copy link
Collaborator

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -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) {
Copy link
Contributor

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

Copy link
Collaborator

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

Copy link
Member Author

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);
Copy link
Collaborator

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

Copy link
Member Author

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]>
@cl-sonarqube-production
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@0xsuryansh 0xsuryansh merged commit f77ff21 into ccip-develop Oct 7, 2024
127 checks passed
@0xsuryansh 0xsuryansh deleted the feat/OffRamp_getAllSourceChainConfig branch October 7, 2024 12: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