-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
KSI-189: Implement remove nodes #13102
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": patch | ||
--- | ||
|
||
#internal generate geth wrappers for capability registry remove nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@chainlink/contracts": patch | ||
--- | ||
|
||
implement remove nodes on capability registry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
contracts/src/v0.8/keystone/test/CapabilityRegistry_RemoveNodesTest.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {BaseTest} from "./BaseTest.t.sol"; | ||
import {CapabilityRegistry} from "../CapabilityRegistry.sol"; | ||
|
||
contract CapabilityRegistry_RemoveNodesTest is BaseTest { | ||
event NodeRemoved(bytes32 p2pId); | ||
|
||
uint256 private constant TEST_NODE_OPERATOR_ONE_ID = 0; | ||
uint256 private constant TEST_NODE_OPERATOR_TWO_ID = 1; | ||
bytes32 private constant INVALID_P2P_ID = bytes32("fake-p2p"); | ||
|
||
function setUp() public override { | ||
BaseTest.setUp(); | ||
changePrank(ADMIN); | ||
s_capabilityRegistry.addNodeOperators(_getNodeOperators()); | ||
s_capabilityRegistry.addCapability(s_basicCapability); | ||
s_capabilityRegistry.addCapability(s_capabilityWithConfigurationContract); | ||
|
||
CapabilityRegistry.Node[] memory nodes = new CapabilityRegistry.Node[](1); | ||
bytes32[] memory hashedCapabilityIds = new bytes32[](2); | ||
hashedCapabilityIds[0] = s_basicHashedCapabilityId; | ||
hashedCapabilityIds[1] = s_capabilityWithConfigurationContractId; | ||
|
||
nodes[0] = CapabilityRegistry.Node({ | ||
nodeOperatorId: TEST_NODE_OPERATOR_ONE_ID, | ||
p2pId: P2P_ID, | ||
signer: NODE_OPERATOR_ONE_SIGNER_ADDRESS, | ||
supportedHashedCapabilityIds: hashedCapabilityIds | ||
}); | ||
|
||
changePrank(NODE_OPERATOR_ONE_ADMIN); | ||
|
||
s_capabilityRegistry.addNodes(nodes); | ||
} | ||
|
||
function test_RevertWhen_CalledByNonNodeOperatorAdminAndNonOwner() public { | ||
changePrank(STRANGER); | ||
bytes32[] memory nodes = new bytes32[](1); | ||
nodes[0] = P2P_ID; | ||
|
||
vm.expectRevert(CapabilityRegistry.AccessForbidden.selector); | ||
s_capabilityRegistry.removeNodes(nodes); | ||
} | ||
|
||
function test_RevertWhen_NodeDoesNotExist() public { | ||
changePrank(NODE_OPERATOR_ONE_ADMIN); | ||
bytes32[] memory nodes = new bytes32[](1); | ||
nodes[0] = INVALID_P2P_ID; | ||
|
||
vm.expectRevert(abi.encodeWithSelector(CapabilityRegistry.InvalidNodeP2PId.selector, INVALID_P2P_ID)); | ||
s_capabilityRegistry.removeNodes(nodes); | ||
} | ||
|
||
function test_RevertWhen_P2PIDEmpty() public { | ||
changePrank(NODE_OPERATOR_ONE_ADMIN); | ||
bytes32[] memory nodes = new bytes32[](1); | ||
nodes[0] = bytes32(""); | ||
|
||
vm.expectRevert(abi.encodeWithSelector(CapabilityRegistry.InvalidNodeP2PId.selector, bytes32(""))); | ||
s_capabilityRegistry.removeNodes(nodes); | ||
} | ||
|
||
function test_RemovesNode() public { | ||
changePrank(NODE_OPERATOR_ONE_ADMIN); | ||
|
||
bytes32[] memory nodes = new bytes32[](1); | ||
nodes[0] = P2P_ID; | ||
|
||
vm.expectEmit(address(s_capabilityRegistry)); | ||
emit NodeRemoved(P2P_ID); | ||
s_capabilityRegistry.removeNodes(nodes); | ||
|
||
CapabilityRegistry.Node memory node = s_capabilityRegistry.getNode(P2P_ID); | ||
assertEq(node.nodeOperatorId, 0); | ||
assertEq(node.p2pId, bytes32("")); | ||
assertEq(node.signer, address(0)); | ||
assertEq(node.supportedHashedCapabilityIds.length, 0); | ||
} | ||
|
||
function test_OwnerCanRemoveNodes() public { | ||
changePrank(ADMIN); | ||
|
||
bytes32[] memory nodes = new bytes32[](1); | ||
nodes[0] = P2P_ID; | ||
|
||
vm.expectEmit(address(s_capabilityRegistry)); | ||
emit NodeRemoved(P2P_ID); | ||
s_capabilityRegistry.removeNodes(nodes); | ||
|
||
CapabilityRegistry.Node memory node = s_capabilityRegistry.getNode(P2P_ID); | ||
assertEq(node.nodeOperatorId, 0); | ||
assertEq(node.p2pId, bytes32("")); | ||
assertEq(node.signer, address(0)); | ||
assertEq(node.supportedHashedCapabilityIds.length, 0); | ||
} | ||
} |
147 changes: 145 additions & 2 deletions
147
...hwrappers/keystone/generated/keystone_capability_registry/keystone_capability_registry.go
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
core/gethwrappers/keystone/generation/generated-wrapper-dependency-versions-do-not-edit.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 98d53a1997053a3037827ffd170c12f49d2005a5c266a1ea9eb69bb51e862f37 | ||
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin 878d2b539e07962af90e8c283fa5a90a15b5b59ddbc0854a137a3be621f0afcd | ||
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once DON management is complete, we must validate that the node doesn't belong to any DONs. It'd be great if you could create a ticket to keep track of it.