-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13220 from smartcontractkit/KSI-128/remove-DON
KS-128: Implement remove DONs in capability registry
- Loading branch information
Showing
6 changed files
with
277 additions
and
3 deletions.
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 implement remove DONs in 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@chainlink/contracts": patch | ||
--- | ||
|
||
implement remove DONs in 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
99 changes: 99 additions & 0 deletions
99
contracts/src/v0.8/keystone/test/CapabilityRegistry_RemoveDONsTest.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,99 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {BaseTest} from "./BaseTest.t.sol"; | ||
|
||
import {CapabilityRegistry} from "../CapabilityRegistry.sol"; | ||
|
||
contract CapabilityRegistry_RemoveDONsTest is BaseTest { | ||
event DONRemoved(uint32 donId); | ||
|
||
uint32 private constant DON_ID = 1; | ||
uint32 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"); | ||
bytes private constant CONFIG = bytes("onchain-config"); | ||
|
||
function setUp() public override { | ||
BaseTest.setUp(); | ||
|
||
s_capabilityRegistry.addNodeOperators(_getNodeOperators()); | ||
s_capabilityRegistry.addCapability(s_basicCapability); | ||
s_capabilityRegistry.addCapability(s_capabilityWithConfigurationContract); | ||
|
||
CapabilityRegistry.NodeParams[] memory nodes = new CapabilityRegistry.NodeParams[](2); | ||
bytes32[] memory capabilityIds = new bytes32[](2); | ||
capabilityIds[0] = s_basicHashedCapabilityId; | ||
capabilityIds[1] = s_capabilityWithConfigurationContractId; | ||
|
||
nodes[0] = CapabilityRegistry.NodeParams({ | ||
nodeOperatorId: TEST_NODE_OPERATOR_ONE_ID, | ||
p2pId: P2P_ID, | ||
signer: NODE_OPERATOR_ONE_SIGNER_ADDRESS, | ||
hashedCapabilityIds: capabilityIds | ||
}); | ||
|
||
bytes32[] memory nodeTwoCapabilityIds = new bytes32[](1); | ||
nodeTwoCapabilityIds[0] = s_basicHashedCapabilityId; | ||
|
||
nodes[1] = CapabilityRegistry.NodeParams({ | ||
nodeOperatorId: TEST_NODE_OPERATOR_ONE_ID, | ||
p2pId: P2P_ID_TWO, | ||
signer: NODE_OPERATOR_TWO_SIGNER_ADDRESS, | ||
hashedCapabilityIds: nodeTwoCapabilityIds | ||
}); | ||
|
||
changePrank(NODE_OPERATOR_ONE_ADMIN); | ||
s_capabilityRegistry.addNodes(nodes); | ||
|
||
CapabilityRegistry.CapabilityConfiguration[] | ||
memory capabilityConfigs = new CapabilityRegistry.CapabilityConfiguration[](1); | ||
capabilityConfigs[0] = CapabilityRegistry.CapabilityConfiguration({ | ||
capabilityId: s_basicHashedCapabilityId, | ||
config: CONFIG | ||
}); | ||
|
||
bytes32[] memory nodeIds = new bytes32[](2); | ||
nodeIds[0] = P2P_ID; | ||
nodeIds[1] = P2P_ID_TWO; | ||
|
||
changePrank(ADMIN); | ||
s_capabilityRegistry.addDON(nodeIds, capabilityConfigs, true); | ||
} | ||
|
||
function test_RevertWhen_CalledByNonAdmin() public { | ||
uint32[] memory donIDs = new uint32[](1); | ||
donIDs[0] = 1; | ||
changePrank(STRANGER); | ||
vm.expectRevert("Only callable by owner"); | ||
s_capabilityRegistry.removeDONs(donIDs); | ||
} | ||
|
||
function test_RevertWhen_DONDoesNotExist() public { | ||
uint32 invalidDONId = 10; | ||
uint32[] memory donIDs = new uint32[](1); | ||
donIDs[0] = invalidDONId; | ||
vm.expectRevert(abi.encodeWithSelector(CapabilityRegistry.DONDoesNotExist.selector, invalidDONId)); | ||
s_capabilityRegistry.removeDONs(donIDs); | ||
} | ||
|
||
function test_RemovesDON() public { | ||
uint32[] memory donIDs = new uint32[](1); | ||
donIDs[0] = DON_ID; | ||
vm.expectEmit(true, true, true, true, address(s_capabilityRegistry)); | ||
emit DONRemoved(DON_ID); | ||
s_capabilityRegistry.removeDONs(donIDs); | ||
|
||
( | ||
uint32 id, | ||
bool isPublic, | ||
bytes32[] memory donNodes, | ||
CapabilityRegistry.CapabilityConfiguration[] memory donCapabilityConfigs | ||
) = s_capabilityRegistry.getDON(DON_ID); | ||
assertEq(id, 0); | ||
assertEq(isPublic, false); | ||
assertEq(donCapabilityConfigs.length, 0); | ||
assertEq(s_capabilityRegistry.getDONCapabilityConfig(DON_ID, s_basicHashedCapabilityId), bytes("")); | ||
assertEq(donNodes.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 efa84b7cae3ce74a85bccd04544ce8176c33cbaf83af24370c0f6e52b2fde0c6 | ||
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin f44b8bf19bb83bb51c2291fc1967b5c6084b19b7fd6aa5ab3352d0f0c1bd3754 | ||
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2 |