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-423: Prevent editing DON accepts workflows field #14092

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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/new-eagles-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal prevent editing whether or not a DON accepts workflows
5 changes: 5 additions & 0 deletions contracts/.changeset/slimy-pens-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': patch
---

#internal prevent editing whether or not a DON accepts workflows
20 changes: 15 additions & 5 deletions contracts/src/v0.8/keystone/CapabilitiesRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,9 @@ contract CapabilitiesRegistry is OwnerIsCreator, TypeAndVersionInterface {
/// @param nodes The nodes making up the DON
/// @param capabilityConfigurations The list of configurations for the
/// capabilities supported by the DON
/// @param isPublic True if the DON is public
/// @param isPublic True if the DON is can accept external capability requests
/// @param acceptsWorkflows True if the DON can accept workflows
/// @param f The maximum number of faulty nodes the DON can tolerate
function addDON(
bytes32[] calldata nodes,
CapabilityConfiguration[] calldata capabilityConfigurations,
Expand All @@ -797,24 +799,32 @@ contract CapabilitiesRegistry is OwnerIsCreator, TypeAndVersionInterface {
/// the admin to reconfigure the list of capabilities supported
/// by the DON, the list of nodes that make up the DON as well
/// as whether or not the DON can accept external workflows
/// @param donId The ID of the DON to update
/// @param nodes The nodes making up the DON
/// @param capabilityConfigurations The list of configurations for the
/// capabilities supported by the DON
/// @param isPublic True if the DON is can accept external workflows
/// @param isPublic True if the DON is can accept external capability requests
/// @param f The maximum number of nodes that can fail
function updateDON(
uint32 donId,
bytes32[] calldata nodes,
CapabilityConfiguration[] calldata capabilityConfigurations,
bool isPublic,
bool acceptsWorkflows,
uint8 f
) external onlyOwner {
uint32 configCount = s_dons[donId].configCount;
DON storage don = s_dons[donId];
uint32 configCount = don.configCount;
if (configCount == 0) revert DONDoesNotExist(donId);
_setDONConfig(
nodes,
capabilityConfigurations,
DONParams({id: donId, configCount: ++configCount, isPublic: isPublic, acceptsWorkflows: acceptsWorkflows, f: f})
DONParams({
id: donId,
configCount: ++configCount,
isPublic: isPublic,
acceptsWorkflows: don.acceptsWorkflows,
f: f
})
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ contract CapabilitiesRegistry_RemoveNodesTest is BaseTest {
bytes32[] memory updatedNodes = new bytes32[](2);
updatedNodes[0] = P2P_ID;
updatedNodes[1] = P2P_ID_THREE;
s_CapabilitiesRegistry.updateDON(DON_ID, updatedNodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, updatedNodes, capabilityConfigs, true, F_VALUE);

// Remove node
s_CapabilitiesRegistry.removeNodes(removedNodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
capabilityId: s_basicHashedCapabilityId,
config: BASIC_CAPABILITY_CONFIG
});
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, F_VALUE);
}

function test_RevertWhen_NodeDoesNotSupportCapability() public {
Expand All @@ -91,7 +91,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
s_capabilityWithConfigurationContractId
)
);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, F_VALUE);
}

function test_RevertWhen_DONDoesNotExist() public {
Expand All @@ -106,7 +106,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
config: BASIC_CAPABILITY_CONFIG
});
vm.expectRevert(abi.encodeWithSelector(CapabilitiesRegistry.DONDoesNotExist.selector, nonExistentDONId));
s_CapabilitiesRegistry.updateDON(nonExistentDONId, nodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(nonExistentDONId, nodes, capabilityConfigs, true, F_VALUE);
}

function test_RevertWhen_CapabilityDoesNotExist() public {
Expand All @@ -122,7 +122,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
vm.expectRevert(
abi.encodeWithSelector(CapabilitiesRegistry.CapabilityDoesNotExist.selector, s_nonExistentHashedCapabilityId)
);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, F_VALUE);
}

function test_RevertWhen_DuplicateCapabilityAdded() public {
Expand All @@ -144,7 +144,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
vm.expectRevert(
abi.encodeWithSelector(CapabilitiesRegistry.DuplicateDONCapability.selector, 1, s_basicHashedCapabilityId)
);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, F_VALUE);
}

function test_RevertWhen_DeprecatedCapabilityAdded() public {
Expand All @@ -165,7 +165,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
});

vm.expectRevert(abi.encodeWithSelector(CapabilitiesRegistry.CapabilityIsDeprecated.selector, capabilityId));
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, F_VALUE);
}

function test_RevertWhen_DuplicateNodeAdded() public {
Expand All @@ -180,7 +180,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
config: BASIC_CAPABILITY_CONFIG
});
vm.expectRevert(abi.encodeWithSelector(CapabilitiesRegistry.DuplicateDONNode.selector, 1, P2P_ID));
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, true, F_VALUE);
}

function test_UpdatesDON() public {
Expand Down Expand Up @@ -217,7 +217,7 @@ contract CapabilitiesRegistry_UpdateDONTest is BaseTest {
),
1
);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, expectedDONIsPublic, true, F_VALUE);
s_CapabilitiesRegistry.updateDON(DON_ID, nodes, capabilityConfigs, expectedDONIsPublic, F_VALUE);

CapabilitiesRegistry.DONInfo memory donInfo = s_CapabilitiesRegistry.getDON(DON_ID);
assertEq(donInfo.id, DON_ID);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GETH_VERSION: 1.13.8
capabilities_registry: ../../../contracts/solc/v0.8.24/CapabilitiesRegistry/CapabilitiesRegistry.abi ../../../contracts/solc/v0.8.24/CapabilitiesRegistry/CapabilitiesRegistry.bin bb794cc0042784b060d1d63090e2086670b88ba3685067cd436305f36054c82b
capabilities_registry: ../../../contracts/solc/v0.8.24/CapabilitiesRegistry/CapabilitiesRegistry.abi ../../../contracts/solc/v0.8.24/CapabilitiesRegistry/CapabilitiesRegistry.bin 7e95d72f24940f08ada0ee3b85d894d6bfccfd6c8a3e0ceeff65bae52c899d54
feeds_consumer: ../../../contracts/solc/v0.8.24/KeystoneFeedsConsumer/KeystoneFeedsConsumer.abi ../../../contracts/solc/v0.8.24/KeystoneFeedsConsumer/KeystoneFeedsConsumer.bin 8c3a2b18a80be41e7c40d2bc3a4c8d1b5e18d55c1fd20ad5af68cebb66109fc5
forwarder: ../../../contracts/solc/v0.8.24/KeystoneForwarder/KeystoneForwarder.abi ../../../contracts/solc/v0.8.24/KeystoneForwarder/KeystoneForwarder.bin 45d9b866c64b41c1349a90b6764aee42a6d078b454d38f369b5fe02b23b9d16e
ocr3_capability: ../../../contracts/solc/v0.8.24/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.24/OCR3Capability/OCR3Capability.bin 8bf0f53f222efce7143dea6134552eb26ea1eef845407b4475a0d79b7d7ba9f8
Loading