Skip to content

Commit

Permalink
allow updating key
Browse files Browse the repository at this point in the history
  • Loading branch information
KuphJr committed Oct 14, 2024
1 parent 37f3132 commit a8c1f06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit a8c1f06

Please sign in to comment.