Skip to content

Commit

Permalink
Add getChainConfig (#15570)
Browse files Browse the repository at this point in the history
* add getChainConfig

* [Bot] Update changeset file with jira issues

---------

Co-authored-by: app-token-issuer-infra-releng[bot] <120227048+app-token-issuer-infra-releng[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 62c2376 commit c1341a5
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 24 deletions.
10 changes: 10 additions & 0 deletions contracts/.changeset/young-bats-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@chainlink/contracts': patch
---

add getChainConfig to ccipHome


PR issue: CCIP-4517

Solidity Review issue: CCIP-3966
42 changes: 21 additions & 21 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,30 @@ CCIPHome__validateConfig:test__validateConfig_Success() (gas: 299797)
CCIPHome__validateConfig:test__validateConfig_TooManySigners_Reverts() (gas: 773105)
CCIPHome__validateConfig:test__validateConfig_ZeroP2PId_Reverts() (gas: 293455)
CCIPHome__validateConfig:test__validateConfig_ZeroSignerKey_Reverts() (gas: 293503)
CCIPHome_applyChainConfigUpdates:test__applyChainConfigUpdates_FChainNotPositive_Reverts() (gas: 187738)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_addChainConfigs_Success() (gas: 349623)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_nodeNotInRegistry_Reverts() (gas: 18065)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_removeChainConfigs_Success() (gas: 272742)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_selectorNotFound_Reverts() (gas: 14952)
CCIPHome_applyChainConfigUpdates:test_getPaginatedCCIPHomes_Success() (gas: 372561)
CCIPHome_applyChainConfigUpdates:test__applyChainConfigUpdates_FChainNotPositive_Reverts() (gas: 187822)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_addChainConfigs_Success() (gas: 350051)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_nodeNotInRegistry_Reverts() (gas: 18089)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_removeChainConfigs_Success() (gas: 282212)
CCIPHome_applyChainConfigUpdates:test_applyChainConfigUpdates_selectorNotFound_Reverts() (gas: 14976)
CCIPHome_applyChainConfigUpdates:test_getPaginatedCCIPHomes_Success() (gas: 373475)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_DONIdMismatch_reverts() (gas: 38098)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_InnerCallReverts_reverts() (gas: 11827)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_InnerCallReverts_reverts() (gas: 11783)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_InvalidSelector_reverts() (gas: 11015)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_reverts() (gas: 37072)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_success() (gas: 1455716)
CCIPHome_constructor:test_constructor_CapabilitiesRegistryAddressZero_reverts() (gas: 63767)
CCIPHome_constructor:test_constructor_success() (gas: 3455841)
CCIPHome_getAllConfigs:test_getAllConfigs_success() (gas: 2773000)
CCIPHome_getCapabilityConfiguration:test_getCapabilityConfiguration_success() (gas: 9138)
CCIPHome_getConfigDigests:test_getConfigDigests_success() (gas: 2547397)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_CanOnlySelfCall_reverts() (gas: 9087)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_ConfigDigestMismatch_reverts() (gas: 23005)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_NoOpStateTransitionNotAllowed_reverts() (gas: 8817)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_multiplePlugins_success() (gas: 5113570)
CCIPHome_revokeCandidate:test_revokeCandidate_CanOnlySelfCall_reverts() (gas: 9068)
CCIPHome_revokeCandidate:test_revokeCandidate_ConfigDigestMismatch_reverts() (gas: 19105)
CCIPHome_revokeCandidate:test_revokeCandidate_RevokingZeroDigestNotAllowed_reverts() (gas: 8817)
CCIPHome_revokeCandidate:test_revokeCandidate_success() (gas: 30674)
CCIPHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_success() (gas: 1455674)
CCIPHome_constructor:test_constructor_CapabilitiesRegistryAddressZero_reverts() (gas: 63865)
CCIPHome_constructor:test_constructor_success() (gas: 3531036)
CCIPHome_getAllConfigs:test_getAllConfigs_success() (gas: 2773023)
CCIPHome_getCapabilityConfiguration:test_getCapabilityConfiguration_success() (gas: 9116)
CCIPHome_getConfigDigests:test_getConfigDigests_success() (gas: 2547513)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_CanOnlySelfCall_reverts() (gas: 9110)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_ConfigDigestMismatch_reverts() (gas: 23074)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_NoOpStateTransitionNotAllowed_reverts() (gas: 8840)
CCIPHome_promoteCandidateAndRevokeActive:test_promoteCandidateAndRevokeActive_multiplePlugins_success() (gas: 5113754)
CCIPHome_revokeCandidate:test_revokeCandidate_CanOnlySelfCall_reverts() (gas: 9024)
CCIPHome_revokeCandidate:test_revokeCandidate_ConfigDigestMismatch_reverts() (gas: 19084)
CCIPHome_revokeCandidate:test_revokeCandidate_RevokingZeroDigestNotAllowed_reverts() (gas: 8773)
CCIPHome_revokeCandidate:test_revokeCandidate_success() (gas: 30676)
CCIPHome_setCandidate:test_setCandidate_CanOnlySelfCall_reverts() (gas: 29383)
CCIPHome_setCandidate:test_setCandidate_ConfigDigestMismatch_reverts() (gas: 1395154)
CCIPHome_setCandidate:test_setCandidate_success() (gas: 1365439)
Expand Down
9 changes: 9 additions & 0 deletions contracts/src/v0.8/ccip/capability/CCIPHome.sol
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,15 @@ contract CCIPHome is Ownable2StepMsgSender, ITypeAndVersion, ICapabilityConfigur
return s_remoteChainSelectors.length();
}

/// @notice Returns the chain configuration for a given chain selector.
/// @param chainSelector The chain selector.
/// @return chainConfig The chain configuration.
function getChainConfig(
uint64 chainSelector
) external view returns (ChainConfig memory) {
return s_chainConfigurations[chainSelector];
}

/// @notice Returns all the chain configurations.
/// @param pageIndex The page index.
/// @param pageSize The page size.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ contract CCIPHome_applyChainConfigUpdates is CCIPHomeTestSetup {
function test_applyChainConfigUpdates_removeChainConfigs_Success() public {
bytes32[] memory chainReaders = new bytes32[](1);
chainReaders[0] = keccak256(abi.encode(1));

CCIPHome.ChainConfigArgs[] memory adds = new CCIPHome.ChainConfigArgs[](2);
adds[0] = CCIPHome.ChainConfigArgs({
chainSelector: 1,
Expand All @@ -130,6 +131,7 @@ contract CCIPHome_applyChainConfigUpdates is CCIPHomeTestSetup {
workflowDONId: uint32(1),
capabilitiesDONIds: new uint256[](0)
});

vm.mockCall(
CAPABILITIES_REGISTRY,
abi.encodeWithSelector(INodeInfoProvider.getNodesByP2PIds.selector, chainReaders),
Expand All @@ -140,10 +142,14 @@ contract CCIPHome_applyChainConfigUpdates is CCIPHomeTestSetup {
emit CCIPHome.ChainConfigSet(1, adds[0].chainConfig);
vm.expectEmit();
emit CCIPHome.ChainConfigSet(2, adds[1].chainConfig);

s_ccipHome.applyChainConfigUpdates(new uint64[](0), adds);

assertEq(s_ccipHome.getNumChainConfigurations(), 2, "total chain configs must be 2");

assertEq(s_ccipHome.getChainConfig(adds[0].chainSelector).config, adds[0].chainConfig.config);
assertEq(s_ccipHome.getChainConfig(adds[1].chainSelector).config, adds[1].chainConfig.config);

uint64[] memory removes = new uint64[](1);
removes[0] = uint64(1);

Expand Down
Loading

0 comments on commit c1341a5

Please sign in to comment.