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

KS-199: Update node signer type #13206

Merged
Show file tree
Hide file tree
Changes from 1 commit
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/two-papayas-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal update node signer type
5 changes: 5 additions & 0 deletions contracts/.changeset/sour-parents-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts": patch
---

update node signer type
16 changes: 8 additions & 8 deletions contracts/src/v0.8/keystone/CapabilityRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
/// @notice The id of the node operator that manages this node
uint32 nodeOperatorId;
/// @notice The signer address for application-layer message verification.
address signer;
bytes32 signer;
/// @notice This is an Ed25519 public key that is used to identify a node.
/// This key is guaranteed to be unique in the CapabilityRegistry. It is
/// used to identify a node in the the P2P network.
Expand All @@ -42,7 +42,7 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
/// @notice The number of times the node's capability has been updated
uint32 configCount;
/// @notice The signer address for application-layer message verification.
address signer;
bytes32 signer;
/// @notice This is an Ed25519 public key that is used to identify a node.
/// This key is guaranteed to be unique in the CapabilityRegistry. It is
/// used to identify a node in the the P2P network.
Expand Down Expand Up @@ -161,7 +161,7 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
/// @param p2pId The P2P ID of the node
/// @param nodeOperatorId The ID of the node operator that manages this node
/// @param signer The node's signer address
event NodeUpdated(bytes32 p2pId, uint256 nodeOperatorId, address signer);
event NodeUpdated(bytes32 p2pId, uint256 nodeOperatorId, bytes32 signer);

/// @notice This event is emitted when a new DON is created
/// @param donId The ID of the newly created DON
Expand Down Expand Up @@ -331,10 +331,10 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
NodeOperator memory nodeOperator = s_nodeOperators[node.nodeOperatorId];
if (!isOwner && msg.sender != nodeOperator.admin) revert AccessForbidden();

bool nodeExists = s_nodes[node.p2pId].signer != address(0);
bool nodeExists = bytes32(s_nodes[node.p2pId].signer) != bytes32("");
cds95 marked this conversation as resolved.
Show resolved Hide resolved
if (nodeExists || bytes32(node.p2pId) == bytes32("")) revert InvalidNodeP2PId(node.p2pId);

if (node.signer == address(0)) revert InvalidNodeSigner();
if (bytes32(node.signer) == bytes32("")) revert InvalidNodeSigner();

bytes32[] memory capabilityIds = node.hashedCapabilityIds;
if (capabilityIds.length == 0) revert InvalidNodeCapabilities(capabilityIds);
Expand Down Expand Up @@ -362,7 +362,7 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
for (uint256 i; i < removedNodeP2PIds.length; ++i) {
bytes32 p2pId = removedNodeP2PIds[i];

bool nodeExists = s_nodes[p2pId].signer != address(0);
bool nodeExists = bytes32(s_nodes[p2pId].signer) != bytes32("");
if (!nodeExists) revert InvalidNodeP2PId(p2pId);

NodeOperator memory nodeOperator = s_nodeOperators[s_nodes[p2pId].nodeOperatorId];
Expand All @@ -385,10 +385,10 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
NodeOperator memory nodeOperator = s_nodeOperators[node.nodeOperatorId];
if (!isOwner && msg.sender != nodeOperator.admin) revert AccessForbidden();

bool nodeExists = s_nodes[node.p2pId].signer != address(0);
bool nodeExists = bytes32(s_nodes[node.p2pId].signer) != bytes32("");
if (!nodeExists) revert InvalidNodeP2PId(node.p2pId);

if (node.signer == address(0)) revert InvalidNodeSigner();
if (bytes32(node.signer) == bytes32("")) revert InvalidNodeSigner();

bytes32[] memory supportedCapabilityIds = node.hashedCapabilityIds;
if (supportedCapabilityIds.length == 0) revert InvalidNodeCapabilities(supportedCapabilityIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract CapabilityRegistry_AddNodesTest is BaseTest {
nodes[0] = CapabilityRegistry.NodeParams({
nodeOperatorId: TEST_NODE_OPERATOR_ONE_ID,
p2pId: P2P_ID,
signer: address(0),
signer: bytes32(""),
hashedCapabilityIds: hashedCapabilityIds
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ contract CapabilityRegistry_RemoveNodesTest is BaseTest {
(CapabilityRegistry.NodeParams memory node, uint32 configCount) = s_capabilityRegistry.getNode(P2P_ID);
assertEq(node.nodeOperatorId, 0);
assertEq(node.p2pId, bytes32(""));
assertEq(node.signer, address(0));
assertEq(node.signer, bytes32(""));
assertEq(node.hashedCapabilityIds.length, 0);
assertEq(configCount, 0);
}
Expand All @@ -93,7 +93,7 @@ contract CapabilityRegistry_RemoveNodesTest is BaseTest {
(CapabilityRegistry.NodeParams memory node, uint32 configCount) = s_capabilityRegistry.getNode(P2P_ID);
assertEq(node.nodeOperatorId, 0);
assertEq(node.p2pId, bytes32(""));
assertEq(node.signer, address(0));
assertEq(node.signer, bytes32(""));
assertEq(node.hashedCapabilityIds.length, 0);
assertEq(configCount, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {BaseTest} from "./BaseTest.t.sol";
import {CapabilityRegistry} from "../CapabilityRegistry.sol";

contract CapabilityRegistry_UpdateNodesTest is BaseTest {
event NodeUpdated(bytes32 p2pId, uint256 nodeOperatorId, address signer);
event NodeUpdated(bytes32 p2pId, uint256 nodeOperatorId, bytes32 signer);

uint32 private constant TEST_NODE_OPERATOR_ONE_ID = 0;
uint256 private constant TEST_NODE_OPERATOR_TWO_ID = 1;
Expand Down Expand Up @@ -99,7 +99,7 @@ contract CapabilityRegistry_UpdateNodesTest is BaseTest {
nodes[0] = CapabilityRegistry.NodeParams({
nodeOperatorId: TEST_NODE_OPERATOR_ONE_ID,
p2pId: P2P_ID,
signer: address(0),
signer: bytes32(""),
hashedCapabilityIds: hashedCapabilityIds
});

Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/keystone/test/Constants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ contract Constants {
address internal STRANGER = address(2);
address internal NODE_OPERATOR_ONE_ADMIN = address(3);
string internal NODE_OPERATOR_ONE_NAME = "node-operator-one";
address internal NODE_OPERATOR_ONE_SIGNER_ADDRESS = address(3333);
bytes32 internal NODE_OPERATOR_ONE_SIGNER_ADDRESS = bytes32(abi.encodePacked(address(3333)));
address internal NODE_OPERATOR_TWO_ADMIN = address(4);
string internal NODE_OPERATOR_TWO_NAME = "node-operator-two";
address internal NODE_OPERATOR_TWO_SIGNER_ADDRESS = address(4444);
bytes32 internal NODE_OPERATOR_TWO_SIGNER_ADDRESS = bytes32(abi.encodePacked(address(4444)));

bytes32 internal P2P_ID = hex"e42415859707d90ed4dc534ad730f187a17b0c368e1beec2e9b995587c4b0a05";
bytes32 internal P2P_ID_TWO = hex"f53415859707d90ed4dc534ad730f187a17b0c368e1beec2e9b995587c4b0a05";
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 b4c900aae9e022f01abbac7993d41f93912247613ac6270b0c4da4ef6f2016e3
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin d4e0661491c2adc7f0d7553287c938fb32664b9f07770f6d57ae6511ce9884cd
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin df7d808203dd2420f9f8a7a137ccf9c7e54d5f59cd0bb1c0bb452a9d0c720fb2
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2
Loading