diff --git a/contracts/gas-snapshots/ccip.gas-snapshot b/contracts/gas-snapshots/ccip.gas-snapshot index d8ae6cde30..2d2b83dd9d 100644 --- a/contracts/gas-snapshots/ccip.gas-snapshot +++ b/contracts/gas-snapshots/ccip.gas-snapshot @@ -810,35 +810,33 @@ PingPong_plumbing:test_Pausing_Success() (gas: 17810) PingPong_startPingPong:test_StartPingPong_With_OOO_Success() (gas: 162091) PingPong_startPingPong:test_StartPingPong_With_Sequenced_Ordered_Success() (gas: 181509) RMNHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_reverts() (gas: 9872) -RMNHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_reverts() (gas: 9901) -RMNHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_success() (gas: 275772) -RMNHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_success() (gas: 794676) -RMNHome_promoteSecondaryAndRevokePrimary:test_promoteSecondaryAndRevokePrimary_OnlyOwner_reverts() (gas: 11073) -RMNHome_promoteSecondaryAndRevokePrimary:test_promoteSecondaryAndRevokePrimary_OnlyOwner_reverts() (gas: 11119) +RMNHome_beforeCapabilityConfigSet:test_beforeCapabilityConfigSet_success() (gas: 275003) +RMNHome_promoteSecondaryAndRevokePrimary:test_promoteSecondaryAndRevokePrimary_OnlyOwner_reverts() (gas: 10907) +RMNHome_promoteSecondaryAndRevokePrimary:test_promoteSecondaryAndRevokePrimary_OnlyOwner_reverts() (gas: 10953) RMNHome_promoteSecondaryAndRevokePrimary:test_promoteSecondaryAndRevokePrimary_success() (gas: 209) RMNHome_promoteSecondaryAndRevokePrimary:test_promoteSecondaryAndRevokePrimary_success() (gas: 209) -RMNHome_revokeSecondary:test_revokeSecondary_ConfigDigestMismatch_reverts() (gas: 20060) -RMNHome_revokeSecondary:test_revokeSecondary_ConfigDigestMismatch_reverts() (gas: 20108) -RMNHome_revokeSecondary:test_revokeSecondary_OnlyOwner_reverts() (gas: 11085) -RMNHome_revokeSecondary:test_revokeSecondary_OnlyOwner_reverts() (gas: 11129) -RMNHome_revokeSecondary:test_revokeSecondary_success() (gas: 28514) -RMNHome_revokeSecondary:test_revokeSecondary_success() (gas: 30361) -RMNHome_setDynamicConfig:test_setDynamicConfig_DigestNotFound_reverts() (gas: 34065) -RMNHome_setDynamicConfig:test_setDynamicConfig_MinObserversTooHigh_reverts() (gas: 20901) -RMNHome_setDynamicConfig:test_setDynamicConfig_OnlyOwner_reverts() (gas: 11973) -RMNHome_setDynamicConfig:test_setDynamicConfig_OnlyOwner_reverts() (gas: 15786) -RMNHome_setDynamicConfig:test_setDynamicConfig_success() (gas: 135276) -RMNHome_setDynamicConfig:test_setDynamicConfig_success() (gas: 64750) -RMNHome_setSecondary:test_setSecondary_DuplicateOffchainPublicKey_reverts() (gas: 21062) -RMNHome_setSecondary:test_setSecondary_DuplicatePeerId_reverts() (gas: 20856) -RMNHome_setSecondary:test_setSecondary_DuplicateSourceChain_reverts() (gas: 24623) -RMNHome_setSecondary:test_setSecondary_MinObserversTooHigh_reverts() (gas: 25062) -RMNHome_setSecondary:test_setSecondary_OnlyOwner_reverts() (gas: 12873) -RMNHome_setSecondary:test_setSecondary_OnlyOwner_reverts() (gas: 18238) -RMNHome_setSecondary:test_setSecondary_OutOfBoundsNodesLength_reverts() (gas: 187001) -RMNHome_setSecondary:test_setSecondary_OutOfBoundsObserverNodeIndex_reverts() (gas: 24767) -RMNHome_setSecondary:test_setSecondary_success() (gas: 283462) -RMNHome_setSecondary:test_setSecondary_success() (gas: 821737) +RMNHome_revokeSecondary:test_revokeSecondary_ConfigDigestMismatch_reverts() (gas: 19344) +RMNHome_revokeSecondary:test_revokeSecondary_ConfigDigestMismatch_reverts() (gas: 19366) +RMNHome_revokeSecondary:test_revokeSecondary_OnlyOwner_reverts() (gas: 10912) +RMNHome_revokeSecondary:test_revokeSecondary_OnlyOwner_reverts() (gas: 10956) +RMNHome_revokeSecondary:test_revokeSecondary_success() (gas: 27066) +RMNHome_revokeSecondary:test_revokeSecondary_success() (gas: 28966) +RMNHome_setDynamicConfig:test_setDynamicConfig_DigestNotFound_reverts() (gas: 33266) +RMNHome_setDynamicConfig:test_setDynamicConfig_MinObserversTooHigh_reverts() (gas: 20422) +RMNHome_setDynamicConfig:test_setDynamicConfig_OnlyOwner_reverts() (gas: 11834) +RMNHome_setDynamicConfig:test_setDynamicConfig_OnlyOwner_reverts() (gas: 15457) +RMNHome_setDynamicConfig:test_setDynamicConfig_success() (gas: 133123) +RMNHome_setDynamicConfig:test_setDynamicConfig_success() (gas: 63135) +RMNHome_setSecondary:test_setSecondary_DuplicateOffchainPublicKey_reverts() (gas: 20894) +RMNHome_setSecondary:test_setSecondary_DuplicatePeerId_reverts() (gas: 20688) +RMNHome_setSecondary:test_setSecondary_DuplicateSourceChain_reverts() (gas: 24455) +RMNHome_setSecondary:test_setSecondary_MinObserversTooHigh_reverts() (gas: 24894) +RMNHome_setSecondary:test_setSecondary_OnlyOwner_reverts() (gas: 12661) +RMNHome_setSecondary:test_setSecondary_OnlyOwner_reverts() (gas: 18070) +RMNHome_setSecondary:test_setSecondary_OutOfBoundsNodesLength_reverts() (gas: 186826) +RMNHome_setSecondary:test_setSecondary_OutOfBoundsObserverNodeIndex_reverts() (gas: 24599) +RMNHome_setSecondary:test_setSecondary_success() (gas: 282478) +RMNHome_setSecondary:test_setSecondary_success() (gas: 820692) RMNRemote_constructor:test_constructor_success() (gas: 8334) RMNRemote_constructor:test_constructor_zeroChainSelector_reverts() (gas: 59165) RMNRemote_curse:test_curse_AlreadyCursed_duplicateSubject_reverts() (gas: 154457) diff --git a/contracts/src/v0.8/ccip/capability/CCIPHome.sol b/contracts/src/v0.8/ccip/capability/CCIPHome.sol index 9e612ea2a8..c1d336c927 100644 --- a/contracts/src/v0.8/ccip/capability/CCIPHome.sol +++ b/contracts/src/v0.8/ccip/capability/CCIPHome.sol @@ -106,11 +106,10 @@ contract CCIPHome is HomeBase { /// @return versionedConfig The config and its version. /// @return ok True if the config was found, false otherwise. function getConfig( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes32 configDigest ) external view returns (VersionedConfig memory versionedConfig, bool ok) { - (StoredConfig memory storedConfig, bool configOK) = _getStoredConfig(donId, pluginType, configDigest); + (StoredConfig memory storedConfig, bool configOK) = _getStoredConfig(pluginKey, configDigest); if (configOK) { return ( VersionedConfig({ @@ -126,10 +125,9 @@ contract CCIPHome is HomeBase { } function getAllConfigs( - uint32 donId, - uint8 pluginType + bytes32 pluginKey ) external view returns (VersionedConfig memory primaryConfig, VersionedConfig memory secondaryConfig) { - (StoredConfig memory primaryStoredConfig, bool primaryOk) = _getPrimaryStoredConfig(donId, pluginType); + (StoredConfig memory primaryStoredConfig, bool primaryOk) = _getPrimaryStoredConfig(pluginKey); if (primaryOk) { primaryConfig = VersionedConfig({ @@ -139,7 +137,7 @@ contract CCIPHome is HomeBase { }); } - (StoredConfig memory secondaryStoredConfig, bool secondaryOk) = _getSecondaryStoredConfig(donId, pluginType); + (StoredConfig memory secondaryStoredConfig, bool secondaryOk) = _getSecondaryStoredConfig(pluginKey); if (secondaryOk) { secondaryConfig = VersionedConfig({ diff --git a/contracts/src/v0.8/ccip/capability/HomeBase.sol b/contracts/src/v0.8/ccip/capability/HomeBase.sol index f182007a56..8c42dd8b8c 100644 --- a/contracts/src/v0.8/ccip/capability/HomeBase.sol +++ b/contracts/src/v0.8/ccip/capability/HomeBase.sol @@ -32,7 +32,7 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig /// @notice This array holds the configs. /// @dev Value i in this array is valid iff s_configs[i].configDigest != 0. - mapping(uint32 donId => mapping(uint8 pluginType => StoredConfig[MAX_CONCURRENT_CONFIGS])) private s_configs; + mapping(bytes32 pluginKey => StoredConfig[MAX_CONCURRENT_CONFIGS]) private s_configs; /// @notice The total number of configs ever set, used for generating the version of the configs. uint32 private s_configCount = 0; @@ -108,60 +108,56 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig /// @return primaryConfigDigest The digest of the primary config. /// @return secondaryConfigDigest The digest of the secondary config. function getConfigDigests( - uint32 donId, - uint8 pluginType + bytes32 pluginKey ) external view returns (bytes32 primaryConfigDigest, bytes32 secondaryConfigDigest) { return ( - s_configs[donId][pluginType][s_primaryConfigIndex].configDigest, - s_configs[donId][pluginType][s_primaryConfigIndex ^ 1].configDigest + s_configs[pluginKey][s_primaryConfigIndex].configDigest, + s_configs[pluginKey][s_primaryConfigIndex ^ 1].configDigest ); } - function getPrimaryDigest(uint32 donId, uint8 pluginType) public view returns (bytes32) { - return s_configs[donId][pluginType][s_primaryConfigIndex].configDigest; + function getPrimaryDigest(bytes32 pluginKey) public view returns (bytes32) { + return s_configs[pluginKey][s_primaryConfigIndex].configDigest; } - function getSecondaryDigest(uint32 donId, uint8 pluginType) public view returns (bytes32) { - return s_configs[donId][pluginType][s_primaryConfigIndex ^ 1].configDigest; + function getSecondaryDigest(bytes32 pluginKey) public view returns (bytes32) { + return s_configs[pluginKey][s_primaryConfigIndex ^ 1].configDigest; } /// @notice Returns the stored config for a given digest. Will always return an empty config if the digest is the zero /// digest. This is done to prevent exposing old config state that is invalid. function _getStoredConfig( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes32 configDigest ) internal view returns (StoredConfig memory storedConfig, bool ok) { for (uint256 i = 0; i < MAX_CONCURRENT_CONFIGS; ++i) { // We never want to return true for a zero digest, even if the caller is asking for it, as this can expose old // config state that is invalid. - if (s_configs[donId][pluginType][i].configDigest == configDigest && configDigest != ZERO_DIGEST) { - return (s_configs[donId][pluginType][i], true); + if (s_configs[pluginKey][i].configDigest == configDigest && configDigest != ZERO_DIGEST) { + return (s_configs[pluginKey][i], true); } } return (storedConfig, false); } function _getPrimaryStoredConfig( - uint32 donId, - uint8 pluginType + bytes32 pluginKey ) internal view returns (StoredConfig memory primaryConfig, bool ok) { - if (s_configs[donId][pluginType][s_primaryConfigIndex].configDigest == ZERO_DIGEST) { + if (s_configs[pluginKey][s_primaryConfigIndex].configDigest == ZERO_DIGEST) { return (StoredConfig(ZERO_DIGEST, 0, "", ""), false); } - return (s_configs[donId][pluginType][s_primaryConfigIndex], true); + return (s_configs[pluginKey][s_primaryConfigIndex], true); } function _getSecondaryStoredConfig( - uint32 donId, - uint8 pluginType + bytes32 pluginKey ) internal view returns (StoredConfig memory secondaryConfig, bool ok) { - if (s_configs[donId][pluginType][s_primaryConfigIndex ^ 1].configDigest == ZERO_DIGEST) { + if (s_configs[pluginKey][s_primaryConfigIndex ^ 1].configDigest == ZERO_DIGEST) { return (StoredConfig(ZERO_DIGEST, 0, "", ""), false); } - return (s_configs[donId][pluginType][s_primaryConfigIndex ^ 1], true); + return (s_configs[pluginKey][s_primaryConfigIndex ^ 1], true); } // ================================================================ @@ -172,15 +168,14 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig /// @param digestToOverwrite The digest of the config to overwrite, or ZERO_DIGEST if no config is to be overwritten. /// This is done to prevent accidental overwrites. function setSecondary( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes calldata encodedStaticConfig, bytes calldata encodedDynamicConfig, bytes32 digestToOverwrite ) external OnlyOwnerOrSelfCall returns (bytes32 newConfigDigest) { _validateStaticAndDynamicConfig(encodedStaticConfig, encodedDynamicConfig); - bytes32 existingDigest = getSecondaryDigest(donId, pluginType); + bytes32 existingDigest = getSecondaryDigest(pluginKey); if (existingDigest != digestToOverwrite) { revert ConfigDigestMismatch(existingDigest, digestToOverwrite); @@ -192,7 +187,7 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig } uint32 newVersion = ++s_configCount; - newConfigDigest = _calculateConfigDigest(donId, pluginType, encodedStaticConfig, newVersion); + newConfigDigest = _calculateConfigDigest(pluginKey, encodedStaticConfig, newVersion); StoredConfig memory newConfig = StoredConfig({ configDigest: newConfigDigest, @@ -201,7 +196,7 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig dynamicConfig: encodedDynamicConfig }); - s_configs[donId][pluginType][s_primaryConfigIndex ^ 1] = newConfig; + s_configs[pluginKey][s_primaryConfigIndex ^ 1] = newConfig; emit ConfigSet(newConfig); @@ -210,37 +205,36 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig /// @notice Revokes a specific config by digest. /// @param configDigest The digest of the config to revoke. This is done to prevent accidental revokes. - function revokeSecondary(uint32 donId, uint8 pluginType, bytes32 configDigest) external OnlyOwnerOrSelfCall { + function revokeSecondary(bytes32 pluginKey, bytes32 configDigest) external OnlyOwnerOrSelfCall { uint256 secondaryConfigIndex = s_primaryConfigIndex ^ 1; - if (s_configs[donId][pluginType][secondaryConfigIndex].configDigest != configDigest) { - revert ConfigDigestMismatch(s_configs[donId][pluginType][secondaryConfigIndex].configDigest, configDigest); + if (s_configs[pluginKey][secondaryConfigIndex].configDigest != configDigest) { + revert ConfigDigestMismatch(s_configs[pluginKey][secondaryConfigIndex].configDigest, configDigest); } emit ConfigRevoked(configDigest); // Delete only the digest, as that's what's used to determine if a config is active. This means the actual // config stays in storage which should significantly reduce the gas cost of overwriting that storage space in // the future. - delete s_configs[donId][pluginType][secondaryConfigIndex].configDigest; + delete s_configs[pluginKey][secondaryConfigIndex].configDigest; } /// @notice Promotes the secondary config to the primary config and revokes the primary config. function promoteSecondaryAndRevokePrimary( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes32 digestToPromote, bytes32 digestToRevoke ) external OnlyOwnerOrSelfCall { uint256 secondaryConfigIndex = s_primaryConfigIndex ^ 1; - if (s_configs[donId][pluginType][secondaryConfigIndex].configDigest != digestToPromote) { - revert ConfigDigestMismatch(s_configs[donId][pluginType][secondaryConfigIndex].configDigest, digestToPromote); + if (s_configs[pluginKey][secondaryConfigIndex].configDigest != digestToPromote) { + revert ConfigDigestMismatch(s_configs[pluginKey][secondaryConfigIndex].configDigest, digestToPromote); } uint256 primaryConfigIndex = s_primaryConfigIndex; - if (s_configs[donId][pluginType][primaryConfigIndex].configDigest != digestToRevoke) { - revert ConfigDigestMismatch(s_configs[donId][pluginType][primaryConfigIndex].configDigest, digestToRevoke); + if (s_configs[pluginKey][primaryConfigIndex].configDigest != digestToRevoke) { + revert ConfigDigestMismatch(s_configs[pluginKey][primaryConfigIndex].configDigest, digestToRevoke); } - delete s_configs[donId][pluginType][primaryConfigIndex].configDigest; + delete s_configs[pluginKey][primaryConfigIndex].configDigest; s_primaryConfigIndex ^= 1; if (digestToRevoke != ZERO_DIGEST) { @@ -250,17 +244,16 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig } function setDynamicConfig( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes calldata newDynamicConfig, bytes32 currentDigest ) external OnlyOwnerOrSelfCall { for (uint256 i = 0; i < MAX_CONCURRENT_CONFIGS; ++i) { - if (s_configs[donId][pluginType][i].configDigest == currentDigest && currentDigest != ZERO_DIGEST) { - _validateDynamicConfig(s_configs[donId][pluginType][i].staticConfig, newDynamicConfig); + if (s_configs[pluginKey][i].configDigest == currentDigest && currentDigest != ZERO_DIGEST) { + _validateDynamicConfig(s_configs[pluginKey][i].staticConfig, newDynamicConfig); // Since the static config doesn't change we don't have to update the digest or version. - s_configs[donId][pluginType][i].dynamicConfig = newDynamicConfig; + s_configs[pluginKey][i].dynamicConfig = newDynamicConfig; emit DynamicConfigSet(currentDigest, newDynamicConfig); return; @@ -271,8 +264,7 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig } function _calculateConfigDigest( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes memory staticConfig, uint32 version ) internal view returns (bytes32) { @@ -281,9 +273,7 @@ abstract contract HomeBase is OwnerIsCreator, ITypeAndVersion, ICapabilityConfig | ( uint256( keccak256( - bytes.concat( - abi.encode(bytes32("EVM"), block.chainid, address(this), donId, pluginType, version), staticConfig - ) + bytes.concat(abi.encode(bytes32("EVM"), block.chainid, address(this), pluginKey, version), staticConfig) ) ) & ~PREFIX_MASK ) diff --git a/contracts/src/v0.8/ccip/capability/RMNHome.sol b/contracts/src/v0.8/ccip/capability/RMNHome.sol index f11bd5ba87..a4f3c839d2 100644 --- a/contracts/src/v0.8/ccip/capability/RMNHome.sol +++ b/contracts/src/v0.8/ccip/capability/RMNHome.sol @@ -56,11 +56,10 @@ contract RMNHome is HomeBase { /// @return versionedConfig The config and its version. /// @return ok True if the config was found, false otherwise. function getConfig( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes32 configDigest ) external view returns (VersionedConfig memory versionedConfig, bool ok) { - (StoredConfig memory storedConfig, bool configOK) = _getStoredConfig(donId, pluginType, configDigest); + (StoredConfig memory storedConfig, bool configOK) = _getStoredConfig(pluginKey, configDigest); if (configOK) { return ( VersionedConfig({ @@ -77,10 +76,9 @@ contract RMNHome is HomeBase { } function getAllConfigs( - uint32 donId, - uint8 pluginType + bytes32 pluginKey ) external view returns (VersionedConfig memory primaryConfig, VersionedConfig memory secondaryConfig) { - (StoredConfig memory primaryStoredConfig, bool primaryOk) = _getPrimaryStoredConfig(donId, pluginType); + (StoredConfig memory primaryStoredConfig, bool primaryOk) = _getPrimaryStoredConfig(pluginKey); if (primaryOk) { primaryConfig = VersionedConfig({ @@ -91,7 +89,7 @@ contract RMNHome is HomeBase { }); } - (StoredConfig memory secondaryStoredConfig, bool secondaryOk) = _getSecondaryStoredConfig(donId, pluginType); + (StoredConfig memory secondaryStoredConfig, bool secondaryOk) = _getSecondaryStoredConfig(pluginKey); if (secondaryOk) { secondaryConfig = VersionedConfig({ diff --git a/contracts/src/v0.8/ccip/test/capability/HomeBaseTest.t.sol b/contracts/src/v0.8/ccip/test/capability/HomeBaseTest.t.sol index 6bb8e02557..f33d146aba 100644 --- a/contracts/src/v0.8/ccip/test/capability/HomeBaseTest.t.sol +++ b/contracts/src/v0.8/ccip/test/capability/HomeBaseTest.t.sol @@ -8,13 +8,12 @@ import {Test} from "forge-std/Test.sol"; import {Vm} from "forge-std/Vm.sol"; contract HomeBaseTest is Test { - uint32 internal constant DON_ID = 593; - uint8 internal constant PLUGIN_TYPE = 244; + bytes32 internal constant DON_ID = bytes32(uint256(0x87654321eabc)); bytes32 internal constant ZERO_DIGEST = bytes32(uint256(0)); HomeBaseHelper internal s_homeBase; - address private constant CAPABILITIES_REGISTRY = address(1); + address internal constant CAPABILITIES_REGISTRY = address(1); function setUp() public virtual { s_homeBase = new HomeBaseHelper(CAPABILITIES_REGISTRY); @@ -29,9 +28,7 @@ contract HomeBaseTest is Test { | ( uint256( keccak256( - bytes.concat( - abi.encode(bytes32("EVM"), block.chainid, address(s_homeBase), DON_ID, PLUGIN_TYPE, version), staticConfig - ) + bytes.concat(abi.encode(bytes32("EVM"), block.chainid, address(s_homeBase), DON_ID, version), staticConfig) ) ) & ~PREFIX_MASK ) @@ -61,9 +58,9 @@ contract RMNHome_setSecondary is HomeBaseTest { vm.expectEmit(); emit HomeBase.ConfigSet(encodedConfig); - s_homeBase.setSecondary(DON_ID, PLUGIN_TYPE, encodedConfig.staticConfig, encodedConfig.dynamicConfig, ZERO_DIGEST); + s_homeBase.setSecondary(DON_ID, encodedConfig.staticConfig, encodedConfig.dynamicConfig, ZERO_DIGEST); - (HomeBase.StoredConfig memory storedConfig, bool ok) = s_homeBase.getSecondaryStoredConfig(DON_ID, PLUGIN_TYPE); + (HomeBase.StoredConfig memory storedConfig, bool ok) = s_homeBase.getSecondaryStoredConfig(DON_ID); assertTrue(ok); assertEq(storedConfig.version, encodedConfig.version); assertEq(storedConfig.configDigest, encodedConfig.configDigest); @@ -75,33 +72,32 @@ contract RMNHome_setSecondary is HomeBaseTest { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_homeBase.setSecondary(DON_ID, PLUGIN_TYPE, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); + s_homeBase.setSecondary(DON_ID, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); } } contract RMNHome_setDynamicConfig is HomeBaseTest { function setUp() public override { super.setUp(); - s_homeBase.setSecondary(DON_ID, PLUGIN_TYPE, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); + s_homeBase.setSecondary(DON_ID, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); } function test_setDynamicConfig_success() public { - (bytes32 priorPrimaryDigest, bytes32 secondaryConfigDigest) = s_homeBase.getConfigDigests(DON_ID, PLUGIN_TYPE); + (bytes32 priorPrimaryDigest, bytes32 secondaryConfigDigest) = s_homeBase.getConfigDigests(DON_ID); bytes memory newDynamicConfig = abi.encode("newDynamicConfig"); vm.expectEmit(); emit HomeBase.DynamicConfigSet(secondaryConfigDigest, newDynamicConfig); - s_homeBase.setDynamicConfig(DON_ID, PLUGIN_TYPE, newDynamicConfig, secondaryConfigDigest); + s_homeBase.setDynamicConfig(DON_ID, newDynamicConfig, secondaryConfigDigest); - (HomeBase.StoredConfig memory storedConfig, bool ok) = - s_homeBase.getStoredConfig(DON_ID, PLUGIN_TYPE, secondaryConfigDigest); + (HomeBase.StoredConfig memory storedConfig, bool ok) = s_homeBase.getStoredConfig(DON_ID, secondaryConfigDigest); assertTrue(ok); assertEq(storedConfig.dynamicConfig, newDynamicConfig); // Asser the digests don't change when updating the dynamic config - (bytes32 primaryDigest, bytes32 secondaryDigest) = s_homeBase.getConfigDigests(DON_ID, PLUGIN_TYPE); + (bytes32 primaryDigest, bytes32 secondaryDigest) = s_homeBase.getConfigDigests(DON_ID); assertEq(primaryDigest, priorPrimaryDigest); assertEq(secondaryDigest, secondaryConfigDigest); } @@ -110,7 +106,7 @@ contract RMNHome_setDynamicConfig is HomeBaseTest { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_homeBase.setDynamicConfig(DON_ID, PLUGIN_TYPE, _getDynamicConfig(), keccak256("configDigest")); + s_homeBase.setDynamicConfig(DON_ID, _getDynamicConfig(), keccak256("configDigest")); } } @@ -118,21 +114,21 @@ contract RMNHome_revokeSecondary is HomeBaseTest { // Sets two configs function setUp() public override { super.setUp(); - bytes32 digest = s_homeBase.setSecondary(DON_ID, PLUGIN_TYPE, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); - s_homeBase.promoteSecondaryAndRevokePrimary(DON_ID, PLUGIN_TYPE, digest, ZERO_DIGEST); - s_homeBase.setSecondary(DON_ID, PLUGIN_TYPE, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); + bytes32 digest = s_homeBase.setSecondary(DON_ID, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); + s_homeBase.promoteSecondaryAndRevokePrimary(DON_ID, digest, ZERO_DIGEST); + s_homeBase.setSecondary(DON_ID, _getStaticConfig(), _getDynamicConfig(), ZERO_DIGEST); } function test_revokeSecondary_success() public { - (bytes32 priorPrimaryDigest, bytes32 priorSecondaryDigest) = s_homeBase.getConfigDigests(DON_ID, PLUGIN_TYPE); + (bytes32 priorPrimaryDigest, bytes32 priorSecondaryDigest) = s_homeBase.getConfigDigests(DON_ID); vm.expectEmit(); emit HomeBase.ConfigRevoked(priorSecondaryDigest); - s_homeBase.revokeSecondary(DON_ID, PLUGIN_TYPE, priorSecondaryDigest); + s_homeBase.revokeSecondary(DON_ID, priorSecondaryDigest); (HomeBase.StoredConfig memory storedVersionedConfig, bool ok) = - s_homeBase.getStoredConfig(DON_ID, PLUGIN_TYPE, priorSecondaryDigest); + s_homeBase.getStoredConfig(DON_ID, priorSecondaryDigest); assertFalse(ok); // Ensure no old data is returned, even though it's still in storage assertEq(storedVersionedConfig.version, 0); @@ -140,25 +136,25 @@ contract RMNHome_revokeSecondary is HomeBaseTest { assertEq(storedVersionedConfig.dynamicConfig.length, 0); // Asser the primary digest is unaffected but the secondary digest is set to zero - (bytes32 primaryDigest, bytes32 secondaryDigest) = s_homeBase.getConfigDigests(DON_ID, PLUGIN_TYPE); + (bytes32 primaryDigest, bytes32 secondaryDigest) = s_homeBase.getConfigDigests(DON_ID); assertEq(primaryDigest, priorPrimaryDigest); assertEq(secondaryDigest, ZERO_DIGEST); assertTrue(secondaryDigest != priorSecondaryDigest); } function test_revokeSecondary_ConfigDigestMismatch_reverts() public { - (, bytes32 priorSecondaryDigest) = s_homeBase.getConfigDigests(DON_ID, PLUGIN_TYPE); + (, bytes32 priorSecondaryDigest) = s_homeBase.getConfigDigests(DON_ID); bytes32 wrongDigest = keccak256("wrong_digest"); vm.expectRevert(abi.encodeWithSelector(HomeBase.ConfigDigestMismatch.selector, priorSecondaryDigest, wrongDigest)); - s_homeBase.revokeSecondary(DON_ID, PLUGIN_TYPE, wrongDigest); + s_homeBase.revokeSecondary(DON_ID, wrongDigest); } function test_revokeSecondary_OnlyOwner_reverts() public { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_homeBase.revokeSecondary(DON_ID, PLUGIN_TYPE, keccak256("configDigest")); + s_homeBase.revokeSecondary(DON_ID, keccak256("configDigest")); } } @@ -169,13 +165,13 @@ contract RMNHome_promoteSecondaryAndRevokePrimary is HomeBaseTest { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_homeBase.promoteSecondaryAndRevokePrimary(DON_ID, PLUGIN_TYPE, keccak256("toPromote"), keccak256("ToRevoke")); + s_homeBase.promoteSecondaryAndRevokePrimary(DON_ID, keccak256("toPromote"), keccak256("ToRevoke")); } } contract RMNHome_beforeCapabilityConfigSet is HomeBaseTest { function test_beforeCapabilityConfigSet_success() public { - vm.startPrank(address(1)); + vm.startPrank(CAPABILITIES_REGISTRY); HomeBase.StoredConfig memory encodedConfig = HomeBase.StoredConfig({ configDigest: ZERO_DIGEST, @@ -186,19 +182,19 @@ contract RMNHome_beforeCapabilityConfigSet is HomeBaseTest { encodedConfig.configDigest = _getConfigDigest(encodedConfig.staticConfig, encodedConfig.version); bytes memory callPayload = abi.encodeCall( - HomeBase.setSecondary, (DON_ID, PLUGIN_TYPE, encodedConfig.staticConfig, encodedConfig.dynamicConfig, ZERO_DIGEST) + HomeBase.setSecondary, (DON_ID, encodedConfig.staticConfig, encodedConfig.dynamicConfig, ZERO_DIGEST) ); vm.expectEmit(); emit HomeBase.ConfigSet(encodedConfig); - s_homeBase.beforeCapabilityConfigSet(new bytes32[](0), callPayload, 0, DON_ID); + s_homeBase.beforeCapabilityConfigSet(new bytes32[](0), callPayload, 0, 0); } function test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_reverts() public { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyCapabilitiesRegistryCanCall.selector); - s_homeBase.beforeCapabilityConfigSet(new bytes32[](0), new bytes(0), 0, DON_ID); + s_homeBase.beforeCapabilityConfigSet(new bytes32[](0), new bytes(0), 0, 0); } } diff --git a/contracts/src/v0.8/ccip/test/capability/RMNHomeTest.t.sol b/contracts/src/v0.8/ccip/test/capability/RMNHomeTest.t.sol index 07b7fb9c04..63b4e5dffc 100644 --- a/contracts/src/v0.8/ccip/test/capability/RMNHomeTest.t.sol +++ b/contracts/src/v0.8/ccip/test/capability/RMNHomeTest.t.sol @@ -8,8 +8,7 @@ import {Test} from "forge-std/Test.sol"; import {Vm} from "forge-std/Vm.sol"; contract RMNHomeTest is Test { - uint32 internal constant RMN_DON_ID = 593; - uint8 internal constant RMN_PLUGIN_TYPE = 244; + bytes32 internal constant RMN_DON_ID = bytes32(uint256(0xaaabbb333eee)); struct Config { RMNHome.StaticConfig staticConfig; @@ -52,8 +51,7 @@ contract RMNHomeTest is Test { uint256( keccak256( bytes.concat( - abi.encode(bytes32("EVM"), block.chainid, address(s_rmnHome), RMN_DON_ID, RMN_PLUGIN_TYPE, version), - staticConfig + abi.encode(bytes32("EVM"), block.chainid, address(s_rmnHome), RMN_DON_ID, version), staticConfig ) ) ) & ~PREFIX_MASK @@ -84,12 +82,10 @@ contract RMNHome_setSecondary is RMNHomeTest { vm.expectEmit(); emit HomeBase.ConfigSet(encodedConfig); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, encodedConfig.staticConfig, encodedConfig.dynamicConfig, ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, encodedConfig.staticConfig, encodedConfig.dynamicConfig, ZERO_DIGEST); (RMNHome.VersionedConfig memory storedVersionedConfig, bool ok) = - s_rmnHome.getConfig(RMN_DON_ID, RMN_PLUGIN_TYPE, versionedConfig.configDigest); + s_rmnHome.getConfig(RMN_DON_ID, versionedConfig.configDigest); assertTrue(ok); assertEq(storedVersionedConfig.version, versionedConfig.version); RMNHome.StaticConfig memory storedStaticConfig = storedVersionedConfig.staticConfig; @@ -118,9 +114,7 @@ contract RMNHome_setSecondary is RMNHomeTest { config.staticConfig.nodes = new RMNHome.Node[](257); vm.expectRevert(RMNHome.OutOfBoundsNodesLength.selector); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setSecondary_DuplicatePeerId_reverts() public { @@ -128,9 +122,7 @@ contract RMNHome_setSecondary is RMNHomeTest { config.staticConfig.nodes[1].peerId = config.staticConfig.nodes[0].peerId; vm.expectRevert(RMNHome.DuplicatePeerId.selector); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setSecondary_DuplicateOffchainPublicKey_reverts() public { @@ -138,9 +130,7 @@ contract RMNHome_setSecondary is RMNHomeTest { config.staticConfig.nodes[1].offchainPublicKey = config.staticConfig.nodes[0].offchainPublicKey; vm.expectRevert(RMNHome.DuplicateOffchainPublicKey.selector); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setSecondary_DuplicateSourceChain_reverts() public { @@ -148,9 +138,7 @@ contract RMNHome_setSecondary is RMNHomeTest { config.dynamicConfig.sourceChains[1].chainSelector = config.dynamicConfig.sourceChains[0].chainSelector; vm.expectRevert(RMNHome.DuplicateSourceChain.selector); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setSecondary_OutOfBoundsObserverNodeIndex_reverts() public { @@ -158,9 +146,7 @@ contract RMNHome_setSecondary is RMNHomeTest { config.dynamicConfig.sourceChains[0].observerNodesBitmap = 1 << config.staticConfig.nodes.length; vm.expectRevert(RMNHome.OutOfBoundsObserverNodeIndex.selector); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setSecondary_MinObserversTooHigh_reverts() public { @@ -168,9 +154,7 @@ contract RMNHome_setSecondary is RMNHomeTest { config.dynamicConfig.sourceChains[0].minObservers++; vm.expectRevert(RMNHome.MinObserversTooHigh.selector); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setSecondary_OnlyOwner_reverts() public { @@ -179,9 +163,7 @@ contract RMNHome_setSecondary is RMNHomeTest { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } } @@ -189,27 +171,25 @@ contract RMNHome_setDynamicConfig is RMNHomeTest { function setUp() public override { super.setUp(); Config memory config = _getBaseConfig(); - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setDynamicConfig_success() public { - (bytes32 priorPrimaryDigest,) = s_rmnHome.getConfigDigests(RMN_DON_ID, RMN_PLUGIN_TYPE); + (bytes32 priorPrimaryDigest,) = s_rmnHome.getConfigDigests(RMN_DON_ID); Config memory config = _getBaseConfig(); config.dynamicConfig.sourceChains[0].minObservers--; - (, bytes32 secondaryConfigDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID, RMN_PLUGIN_TYPE); + (, bytes32 secondaryConfigDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID); bytes memory encodedConfig = abi.encode(config.dynamicConfig); vm.expectEmit(); emit HomeBase.DynamicConfigSet(secondaryConfigDigest, encodedConfig); - s_rmnHome.setDynamicConfig(RMN_DON_ID, RMN_PLUGIN_TYPE, encodedConfig, secondaryConfigDigest); + s_rmnHome.setDynamicConfig(RMN_DON_ID, encodedConfig, secondaryConfigDigest); (RMNHome.VersionedConfig memory storedVersionedConfig, bool ok) = - s_rmnHome.getConfig(RMN_DON_ID, RMN_PLUGIN_TYPE, secondaryConfigDigest); + s_rmnHome.getConfig(RMN_DON_ID, secondaryConfigDigest); assertTrue(ok); assertEq( storedVersionedConfig.dynamicConfig.sourceChains[0].minObservers, @@ -217,7 +197,7 @@ contract RMNHome_setDynamicConfig is RMNHomeTest { ); // Asser the digests don't change when updating the dynamic config - (bytes32 primaryDigest, bytes32 secondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID, RMN_PLUGIN_TYPE); + (bytes32 primaryDigest, bytes32 secondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID); assertEq(primaryDigest, priorPrimaryDigest); assertEq(secondaryDigest, secondaryConfigDigest); } @@ -228,20 +208,18 @@ contract RMNHome_setDynamicConfig is RMNHomeTest { config.dynamicConfig.sourceChains[0].minObservers++; vm.expectRevert(abi.encodeWithSelector(HomeBase.DigestNotFound.selector, ZERO_DIGEST)); - s_rmnHome.setDynamicConfig(RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.dynamicConfig), ZERO_DIGEST); + s_rmnHome.setDynamicConfig(RMN_DON_ID, abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_setDynamicConfig_DigestNotFound_reverts() public { // Zero always reverts vm.expectRevert(abi.encodeWithSelector(HomeBase.DigestNotFound.selector, ZERO_DIGEST)); - s_rmnHome.setDynamicConfig(RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(_getBaseConfig().dynamicConfig), ZERO_DIGEST); + s_rmnHome.setDynamicConfig(RMN_DON_ID, abi.encode(_getBaseConfig().dynamicConfig), ZERO_DIGEST); // Non-existent digest reverts bytes32 nonExistentDigest = keccak256("nonExistentDigest"); vm.expectRevert(abi.encodeWithSelector(HomeBase.DigestNotFound.selector, nonExistentDigest)); - s_rmnHome.setDynamicConfig( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(_getBaseConfig().dynamicConfig), nonExistentDigest - ); + s_rmnHome.setDynamicConfig(RMN_DON_ID, abi.encode(_getBaseConfig().dynamicConfig), nonExistentDigest); } function test_setDynamicConfig_OnlyOwner_reverts() public { @@ -250,7 +228,7 @@ contract RMNHome_setDynamicConfig is RMNHomeTest { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_rmnHome.setDynamicConfig(RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.dynamicConfig), keccak256("configDigest")); + s_rmnHome.setDynamicConfig(RMN_DON_ID, abi.encode(config.dynamicConfig), keccak256("configDigest")); } } @@ -259,27 +237,24 @@ contract RMNHome_revokeSecondary is RMNHomeTest { function setUp() public override { super.setUp(); Config memory config = _getBaseConfig(); - bytes32 digest = s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); - s_rmnHome.promoteSecondaryAndRevokePrimary(RMN_DON_ID, RMN_PLUGIN_TYPE, digest, ZERO_DIGEST); + bytes32 digest = + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); + s_rmnHome.promoteSecondaryAndRevokePrimary(RMN_DON_ID, digest, ZERO_DIGEST); config.dynamicConfig.sourceChains[0].minObservers--; - s_rmnHome.setSecondary( - RMN_DON_ID, RMN_PLUGIN_TYPE, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST - ); + s_rmnHome.setSecondary(RMN_DON_ID, abi.encode(config.staticConfig), abi.encode(config.dynamicConfig), ZERO_DIGEST); } function test_revokeSecondary_success() public { - (bytes32 priorPrimaryDigest, bytes32 priorSecondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID, RMN_PLUGIN_TYPE); + (bytes32 priorPrimaryDigest, bytes32 priorSecondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID); vm.expectEmit(); emit HomeBase.ConfigRevoked(priorSecondaryDigest); - s_rmnHome.revokeSecondary(RMN_DON_ID, RMN_PLUGIN_TYPE, priorSecondaryDigest); + s_rmnHome.revokeSecondary(RMN_DON_ID, priorSecondaryDigest); (RMNHome.VersionedConfig memory storedVersionedConfig, bool ok) = - s_rmnHome.getConfig(RMN_DON_ID, RMN_PLUGIN_TYPE, priorSecondaryDigest); + s_rmnHome.getConfig(RMN_DON_ID, priorSecondaryDigest); assertFalse(ok); // Ensure no old data is returned, even though it's still in storage assertEq(storedVersionedConfig.version, 0); @@ -287,25 +262,25 @@ contract RMNHome_revokeSecondary is RMNHomeTest { assertEq(storedVersionedConfig.dynamicConfig.sourceChains.length, 0); // Asser the primary digest is unaffected but the secondary digest is set to zero - (bytes32 primaryDigest, bytes32 secondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID, RMN_PLUGIN_TYPE); + (bytes32 primaryDigest, bytes32 secondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID); assertEq(primaryDigest, priorPrimaryDigest); assertEq(secondaryDigest, ZERO_DIGEST); assertTrue(secondaryDigest != priorSecondaryDigest); } function test_revokeSecondary_ConfigDigestMismatch_reverts() public { - (, bytes32 priorSecondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID, RMN_PLUGIN_TYPE); + (, bytes32 priorSecondaryDigest) = s_rmnHome.getConfigDigests(RMN_DON_ID); bytes32 wrongDigest = keccak256("wrong_digest"); vm.expectRevert(abi.encodeWithSelector(HomeBase.ConfigDigestMismatch.selector, priorSecondaryDigest, wrongDigest)); - s_rmnHome.revokeSecondary(RMN_DON_ID, RMN_PLUGIN_TYPE, wrongDigest); + s_rmnHome.revokeSecondary(RMN_DON_ID, wrongDigest); } function test_revokeSecondary_OnlyOwner_reverts() public { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_rmnHome.revokeSecondary(RMN_DON_ID, RMN_PLUGIN_TYPE, keccak256("configDigest")); + s_rmnHome.revokeSecondary(RMN_DON_ID, keccak256("configDigest")); } } @@ -316,40 +291,6 @@ contract RMNHome_promoteSecondaryAndRevokePrimary is RMNHomeTest { vm.startPrank(address(0)); vm.expectRevert(HomeBase.OnlyOwnerOrSelfCallAllowed.selector); - s_rmnHome.promoteSecondaryAndRevokePrimary( - RMN_DON_ID, RMN_PLUGIN_TYPE, keccak256("toPromote"), keccak256("ToRevoke") - ); - } -} - -contract RMNHome_beforeCapabilityConfigSet is RMNHomeTest { - function test_beforeCapabilityConfigSet_success() public { - vm.startPrank(address(1)); - - Config memory config = _getBaseConfig(); - HomeBase.StoredConfig memory encodedConfig = HomeBase.StoredConfig({ - configDigest: ZERO_DIGEST, - version: 1, - staticConfig: abi.encode(config.staticConfig), - dynamicConfig: abi.encode(config.dynamicConfig) - }); - encodedConfig.configDigest = _getConfigDigest(encodedConfig.staticConfig, encodedConfig.version); - - bytes memory callPayload = abi.encodeCall( - HomeBase.setSecondary, - (RMN_DON_ID, RMN_PLUGIN_TYPE, encodedConfig.staticConfig, encodedConfig.dynamicConfig, ZERO_DIGEST) - ); - - vm.expectEmit(); - emit HomeBase.ConfigSet(encodedConfig); - - s_rmnHome.beforeCapabilityConfigSet(new bytes32[](0), callPayload, 0, RMN_DON_ID); - } - - function test_beforeCapabilityConfigSet_OnlyCapabilitiesRegistryCanCall_reverts() public { - vm.startPrank(address(0)); - - vm.expectRevert(HomeBase.OnlyCapabilitiesRegistryCanCall.selector); - s_rmnHome.beforeCapabilityConfigSet(new bytes32[](0), new bytes(0), 0, RMN_DON_ID); + s_rmnHome.promoteSecondaryAndRevokePrimary(RMN_DON_ID, keccak256("toPromote"), keccak256("ToRevoke")); } } diff --git a/contracts/src/v0.8/ccip/test/helpers/HomeBaseHelper.sol b/contracts/src/v0.8/ccip/test/helpers/HomeBaseHelper.sol index a18b9cb766..4b0bc18763 100644 --- a/contracts/src/v0.8/ccip/test/helpers/HomeBaseHelper.sol +++ b/contracts/src/v0.8/ccip/test/helpers/HomeBaseHelper.sol @@ -19,30 +19,25 @@ contract HomeBaseHelper is HomeBase { } function getStoredConfig( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes32 configDigest ) external view returns (StoredConfig memory, bool ok) { - return _getStoredConfig(donId, pluginType, configDigest); + return _getStoredConfig(pluginKey, configDigest); } - function getPrimaryStoredConfig(uint32 donId, uint8 pluginType) external view returns (StoredConfig memory, bool ok) { - return _getPrimaryStoredConfig(donId, pluginType); + function getPrimaryStoredConfig(bytes32 pluginKey) external view returns (StoredConfig memory, bool ok) { + return _getPrimaryStoredConfig(pluginKey); } - function getSecondaryStoredConfig( - uint32 donId, - uint8 pluginType - ) external view returns (StoredConfig memory, bool ok) { - return _getSecondaryStoredConfig(donId, pluginType); + function getSecondaryStoredConfig(bytes32 pluginKey) external view returns (StoredConfig memory, bool ok) { + return _getSecondaryStoredConfig(pluginKey); } function calculateConfigDigest( - uint32 donId, - uint8 pluginType, + bytes32 pluginKey, bytes memory staticConfig, uint32 version ) external view returns (bytes32) { - return _calculateConfigDigest(donId, pluginType, staticConfig, version); + return _calculateConfigDigest(pluginKey, staticConfig, version); } }