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

Allow rotating encryptionPublicKey in CapabilitiesRegistry #14760

Merged
merged 5 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/forty-lizards-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Enable rotating encryptionPublicKey in CapabilitiesRegistry contract
5 changes: 5 additions & 0 deletions contracts/.changeset/silent-houses-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': patch
---

Enable rotating encryptionPublicKey in CapabilitiesRegistry contract
3 changes: 3 additions & 0 deletions contracts/src/v0.8/keystone/CapabilitiesRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ contract CapabilitiesRegistry is OwnerIsCreator, TypeAndVersionInterface {
s_nodeSigners.add(node.signer);
}

if (node.encryptionPublicKey == bytes32("")) revert InvalidNodeEncryptionPublicKey(node.encryptionPublicKey);

bytes32[] memory supportedHashedCapabilityIds = node.hashedCapabilityIds;
if (supportedHashedCapabilityIds.length == 0) revert InvalidNodeCapabilities(supportedHashedCapabilityIds);

Expand Down Expand Up @@ -678,6 +680,7 @@ contract CapabilitiesRegistry is OwnerIsCreator, TypeAndVersionInterface {

storedNode.nodeOperatorId = node.nodeOperatorId;
storedNode.p2pId = node.p2pId;
storedNode.encryptionPublicKey = node.encryptionPublicKey;

emit NodeUpdated(node.p2pId, node.nodeOperatorId, node.signer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@ contract CapabilitiesRegistry_UpdateNodesTest is BaseTest {
s_CapabilitiesRegistry.updateNodes(nodes);
}

function test_RevertWhen_EncryptionPublicKeyEmpty() public {
changePrank(NODE_OPERATOR_ONE_ADMIN);
CapabilitiesRegistry.NodeParams[] memory nodes = new CapabilitiesRegistry.NodeParams[](1);

bytes32[] memory hashedCapabilityIds = new bytes32[](1);
hashedCapabilityIds[0] = s_basicHashedCapabilityId;

nodes[0] = CapabilitiesRegistry.NodeParams({
nodeOperatorId: TEST_NODE_OPERATOR_ONE_ID,
p2pId: P2P_ID,
signer: NODE_OPERATOR_ONE_SIGNER_ADDRESS,
encryptionPublicKey: bytes32(""),
hashedCapabilityIds: hashedCapabilityIds
});

vm.expectRevert(abi.encodeWithSelector(CapabilitiesRegistry.InvalidNodeEncryptionPublicKey.selector, bytes32("")));
s_CapabilitiesRegistry.updateNodes(nodes);
}

function test_RevertWhen_NodeSignerAlreadyAssignedToAnotherNode() public {
changePrank(NODE_OPERATOR_ONE_ADMIN);
CapabilitiesRegistry.NodeParams[] memory nodes = new CapabilitiesRegistry.NodeParams[](1);
Expand Down
Loading
Loading