Skip to content

Commit

Permalink
Allow rotating encryptionPublicKey in CapabilitiesRegistry (#14760)
Browse files Browse the repository at this point in the history
* allow updating key

* added changesets

* prettier & wrappers

* bump

---------

Co-authored-by: krehermann <[email protected]>
  • Loading branch information
KuphJr and krehermann authored Oct 14, 2024
1 parent 16499e5 commit 3af39c8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
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

0 comments on commit 3af39c8

Please sign in to comment.