Skip to content

Commit

Permalink
Merge pull request #13407 from smartcontractkit/KS-200/get-don-capabi…
Browse files Browse the repository at this point in the history
…lity-config

KS 200:  Return capability config contract config in Get DON capability config
  • Loading branch information
cds95 authored Jun 4, 2024
2 parents 0d15615 + df04262 commit b2db48b
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-tools-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal return don capability config contract config from capability registry
5 changes: 5 additions & 0 deletions contracts/.changeset/yellow-snails-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': patch
---

return don capability config contract config from capability registry
16 changes: 13 additions & 3 deletions contracts/src/v0.8/keystone/CapabilityRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,20 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
/// @notice Returns the DON specific configuration for a capability
/// @param donId The DON's ID
/// @param capabilityId The Capability ID
/// @return bytes The DON specific configuration for the capability
function getDONCapabilityConfig(uint32 donId, bytes32 capabilityId) external view returns (bytes memory) {
/// @return bytes The DON specific configuration for the capability stored on the capability registry
/// @return bytes The DON specific configuration stored on the capability's configuration contract
function getCapabilityConfigs(uint32 donId, bytes32 capabilityId) external view returns (bytes memory, bytes memory) {
uint32 configCount = s_dons[donId].configCount;
return s_dons[donId].config[configCount].capabilityConfigs[capabilityId];

bytes memory donCapabilityConfig = s_dons[donId].config[configCount].capabilityConfigs[capabilityId];
bytes memory globalCapabilityConfig;

if (s_capabilities[capabilityId].configurationContract != address(0)) {
globalCapabilityConfig = ICapabilityConfiguration(s_capabilities[capabilityId].configurationContract)
.getCapabilityConfiguration(donId);
}

return (donCapabilityConfig, globalCapabilityConfig);
}

/// @notice Sets the configuration for a DON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,16 @@ contract CapabilityRegistry_AddDONTest is BaseTest {
assertEq(donInfo.isPublic, true);
assertEq(donInfo.capabilityConfigurations.length, capabilityConfigs.length);
assertEq(donInfo.capabilityConfigurations[0].capabilityId, s_basicHashedCapabilityId);
assertEq(s_capabilityRegistry.getDONCapabilityConfig(DON_ID, s_basicHashedCapabilityId), BASIC_CAPABILITY_CONFIG);

(bytes memory capabilityRegistryDONConfig, bytes memory capabilityConfigContractConfig) = s_capabilityRegistry
.getCapabilityConfigs(DON_ID, s_basicHashedCapabilityId);
assertEq(capabilityRegistryDONConfig, BASIC_CAPABILITY_CONFIG);
assertEq(capabilityConfigContractConfig, bytes(""));

(bytes memory capabilityRegistryDONConfigTwo, bytes memory capabilityConfigContractConfigTwo) = s_capabilityRegistry
.getCapabilityConfigs(DON_ID, s_capabilityWithConfigurationContractId);
assertEq(capabilityRegistryDONConfigTwo, CONFIG_CAPABILITY_CONFIG);
assertEq(capabilityConfigContractConfigTwo, CONFIG_CAPABILITY_CONFIG);

assertEq(donInfo.nodeP2PIds.length, nodes.length);
assertEq(donInfo.nodeP2PIds[0], P2P_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ contract CapabilityRegistry_RemoveDONsTest is BaseTest {
assertEq(donInfo.configCount, 0);
assertEq(donInfo.isPublic, false);
assertEq(donInfo.capabilityConfigurations.length, 0);
assertEq(s_capabilityRegistry.getDONCapabilityConfig(DON_ID, s_basicHashedCapabilityId), bytes(""));

(bytes memory capabilityRegistryDONConfig, bytes memory capabilityConfigContractConfig) = s_capabilityRegistry
.getCapabilityConfigs(DON_ID, s_basicHashedCapabilityId);

assertEq(capabilityRegistryDONConfig, bytes(""));
assertEq(capabilityConfigContractConfig, bytes(""));
assertEq(donInfo.nodeP2PIds.length, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ contract CapabilityRegistry_UpdateDONTest is BaseTest {
assertEq(donInfo.isPublic, false);
assertEq(donInfo.capabilityConfigurations.length, capabilityConfigs.length);
assertEq(donInfo.capabilityConfigurations[0].capabilityId, s_basicHashedCapabilityId);
assertEq(s_capabilityRegistry.getDONCapabilityConfig(DON_ID, s_basicHashedCapabilityId), BASIC_CAPABILITY_CONFIG);

(bytes memory capabilityRegistryDONConfig, bytes memory capabilityConfigContractConfig) = s_capabilityRegistry
.getCapabilityConfigs(DON_ID, s_basicHashedCapabilityId);
assertEq(capabilityRegistryDONConfig, BASIC_CAPABILITY_CONFIG);
assertEq(capabilityConfigContractConfig, bytes(""));

assertEq(donInfo.nodeP2PIds.length, nodes.length);
assertEq(donInfo.nodeP2PIds[0], P2P_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract CapabilityRegistry_UpdateNodeOperatorTest is BaseTest {
}

function test_RevertWhen_NodeOperatorIdAndParamLengthsMismatch() public {
changePrank(ADMIN);
changePrank(ADMIN);
CapabilityRegistry.NodeOperator[] memory nodeOperators = new CapabilityRegistry.NodeOperator[](1);
nodeOperators[0] = CapabilityRegistry.NodeOperator({admin: NEW_NODE_OPERATOR_ADMIN, name: NEW_NODE_OPERATOR_NAME});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ contract CapabilityConfigurationContract is ICapabilityConfiguration, ERC165 {
return s_donConfiguration[donId];
}

function beforeCapabilityConfigSet(
bytes32[] calldata nodes,
bytes calldata config,
uint64 configCount,
uint32 donId
) external {}
function beforeCapabilityConfigSet(bytes32[] calldata, bytes calldata config, uint64, uint32 donId) external {
// In practice a real capability configuration contract will do more than just store
// the config for a DON
s_donConfiguration[donId] = config;
}

function supportsInterface(bytes4 interfaceId) public pure override returns (bool) {
return interfaceId == this.getCapabilityConfiguration.selector ^ this.beforeCapabilityConfigSet.selector;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.13.8
forwarder: ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.abi ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.bin ed9164cfe4619dff824b11df46b66f4c6834b2ca072923f10d9ebc57ce508ed8
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin cd46d1b33a7647f99307c5dd85263e8d7d336c49e0197c2c9fdc73ee961e17b5
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin d95781054b4491e1469038a2857372f7bbaf455a244e138880579d15bb9471c6
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2

0 comments on commit b2db48b

Please sign in to comment.