Skip to content

Commit 82a7172

Browse files
authored
feat(gateway-contracts): add function to update operators (#1176)
1 parent 6d403b5 commit 82a7172

File tree

12 files changed

+7137
-3595
lines changed

12 files changed

+7137
-3595
lines changed

.github/workflows/gateway-contracts-upgrade-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
with:
4646
# This version should be updated whenever we release new contract versions or
4747
# touch a contract upgrade path.
48-
ref: v0.9.1
48+
ref: v0.9.3
4949
path: previous-fhevm
5050
persist-credentials: 'false'
5151

gateway-contracts/contracts/GatewayConfig.sol

Lines changed: 216 additions & 96 deletions
Large diffs are not rendered by default.

gateway-contracts/contracts/interfaces/IGatewayConfig.sol

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,39 @@ interface IGatewayConfig {
3636
);
3737

3838
/**
39-
* @notice Emitted when the GatewayConfig is re-initialized from V2.
39+
* @notice Emitted when the GatewayConfig is re-initialized from V3.
40+
* @param newKmsNodes The new KMS nodes.
41+
*/
42+
event ReinitializeGatewayConfigV3(KmsNode[] newKmsNodes);
43+
44+
/**
45+
* @notice Emitted when the KMS nodes have been updated.
46+
* @param newKmsNodes The new KMS nodes.
47+
* @param newMpcThreshold The new MPC threshold.
48+
* @param newPublicDecryptionThreshold The new public decryption threshold.
49+
* @param newUserDecryptionThreshold The new user decryption threshold.
50+
* @param newKmsGenThreshold The new key and CRS generation threshold.
51+
*/
52+
event UpdateKmsNodes(
53+
KmsNode[] newKmsNodes,
54+
uint256 newMpcThreshold,
55+
uint256 newPublicDecryptionThreshold,
56+
uint256 newUserDecryptionThreshold,
57+
uint256 newKmsGenThreshold
58+
);
59+
60+
/**
61+
* @notice Emitted when the coprocessors have been updated.
4062
* @param newCoprocessors The new coprocessors.
41-
* @param coprocessorThreshold The new coprocessor threshold.
63+
* @param newCoprocessorThreshold The new coprocessor threshold.
64+
*/
65+
event UpdateCoprocessors(Coprocessor[] newCoprocessors, uint256 newCoprocessorThreshold);
66+
67+
/**
68+
* @notice Emitted when the custodians have been updated.
69+
* @param newCustodians The new custodians.
4270
*/
43-
event ReinitializeGatewayConfigV2(Coprocessor[] newCoprocessors, uint256 coprocessorThreshold);
71+
event UpdateCustodians(Custodian[] newCustodians);
4472

4573
/**
4674
* @notice Emitted when the MPC threshold has been updated.
@@ -182,11 +210,38 @@ interface IGatewayConfig {
182210
error ChainIdNotUint64(uint256 chainId);
183211

184212
/**
185-
* @notice Add a new host chain metadata to the GatewayConfig contract.
186-
* @dev The associated chain ID must be non-zero and representable by a uint64.
187-
* @param hostChain The new host chain metadata to include.
213+
* @notice Update the list of KMS nodes and their thresholds.
214+
* @dev ⚠️ This function should be used with caution as it can lead to unexpected behavior in
215+
* some requests and the contracts should first be paused. It will be deprecated in the future.
216+
* @param newKmsNodes The new KMS nodes.
217+
* @param newMpcThreshold The new MPC threshold.
218+
* @param newPublicDecryptionThreshold The new public decryption threshold.
219+
* @param newUserDecryptionThreshold The new user decryption threshold.
220+
* @param newKmsGenThreshold The new key and CRS generation threshold.
188221
*/
189-
function addHostChain(HostChain calldata hostChain) external;
222+
function updateKmsNodes(
223+
KmsNode[] calldata newKmsNodes,
224+
uint256 newMpcThreshold,
225+
uint256 newPublicDecryptionThreshold,
226+
uint256 newUserDecryptionThreshold,
227+
uint256 newKmsGenThreshold
228+
) external;
229+
230+
/**
231+
* @notice Update the list of coprocessors and their threshold.
232+
* @dev ⚠️ This function should be used with caution as it can lead to unexpected behavior in
233+
* some requests and the contracts should first be paused. It will be deprecated in the future.
234+
* @param newCoprocessors The new coprocessors.
235+
* @param newCoprocessorThreshold The new coprocessor threshold.
236+
*/
237+
function updateCoprocessors(Coprocessor[] calldata newCoprocessors, uint256 newCoprocessorThreshold) external;
238+
239+
/**
240+
* @notice Update the list of custodians.
241+
* @dev ⚠️ This function should be used with caution. It will be deprecated in the future.
242+
* @param newCustodians The new custodians.
243+
*/
244+
function updateCustodians(Custodian[] calldata newCustodians) external;
190245

191246
/**
192247
* @notice Update the MPC threshold.
@@ -223,6 +278,13 @@ interface IGatewayConfig {
223278
*/
224279
function updateCoprocessorThreshold(uint256 newCoprocessorThreshold) external;
225280

281+
/**
282+
* @notice Add a new host chain metadata to the GatewayConfig contract.
283+
* @dev The associated chain ID must be non-zero and representable by a uint64.
284+
* @param hostChain The new host chain metadata to include.
285+
*/
286+
function addHostChain(HostChain calldata hostChain) external;
287+
226288
/**
227289
* @notice Pause all pausable gateway contracts.
228290
*/

gateway-contracts/contracts/mocks/GatewayConfigMock.sol

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ pragma solidity ^0.8.24;
33
import "../shared/Structs.sol";
44

55
contract GatewayConfigMock {
6+
struct Thresholds {
7+
uint256 mpcThreshold;
8+
uint256 publicDecryptionThreshold;
9+
uint256 userDecryptionThreshold;
10+
uint256 kmsGenThreshold;
11+
uint256 coprocessorThreshold;
12+
}
13+
614
event InitializeGatewayConfig(
715
ProtocolMetadata metadata,
816
uint256 mpcThreshold,
@@ -11,7 +19,19 @@ contract GatewayConfigMock {
1119
Custodian[] custodians
1220
);
1321

14-
event ReinitializeGatewayConfigV2(Coprocessor[] newCoprocessors, uint256 coprocessorThreshold);
22+
event ReinitializeGatewayConfigV3(KmsNode[] newKmsNodes);
23+
24+
event UpdateKmsNodes(
25+
KmsNode[] newKmsNodes,
26+
uint256 newMpcThreshold,
27+
uint256 newPublicDecryptionThreshold,
28+
uint256 newUserDecryptionThreshold,
29+
uint256 newKmsGenThreshold
30+
);
31+
32+
event UpdateCoprocessors(Coprocessor[] newCoprocessors, uint256 newCoprocessorThreshold);
33+
34+
event UpdateCustodians(Custodian[] newCustodians);
1535

1636
event UpdateMpcThreshold(uint256 newMpcThreshold);
1737

@@ -30,15 +50,11 @@ contract GatewayConfigMock {
3050
event UnpauseAllGatewayContracts();
3151

3252
function initializeFromEmptyProxy(
33-
ProtocolMetadata memory initialMetadata,
34-
uint256 initialMpcThreshold,
35-
uint256 initialPublicDecryptionThreshold,
36-
uint256 initialUserDecryptionThreshold,
37-
uint256 initialKmsGenThreshold,
38-
uint256 initialCoprocessorThreshold,
39-
KmsNode[] memory initialKmsNodes,
40-
Coprocessor[] memory initialCoprocessors,
41-
Custodian[] memory initialCustodians
53+
ProtocolMetadata calldata initialMetadata,
54+
Thresholds calldata initialThresholds,
55+
KmsNode[] calldata initialKmsNodes,
56+
Coprocessor[] calldata initialCoprocessors,
57+
Custodian[] calldata initialCustodians
4258
) public {
4359
ProtocolMetadata memory metadata;
4460
uint256 mpcThreshold;
@@ -49,8 +65,32 @@ contract GatewayConfigMock {
4965
emit InitializeGatewayConfig(metadata, mpcThreshold, kmsNodes, coprocessors, custodians);
5066
}
5167

52-
function reinitializeV2(Coprocessor[] memory newCoprocessors, uint256 coprocessorThreshold) public {
53-
emit ReinitializeGatewayConfigV2(newCoprocessors, coprocessorThreshold);
68+
function reinitializeV3(KmsNode[] calldata newKmsNodes) public {
69+
emit ReinitializeGatewayConfigV3(newKmsNodes);
70+
}
71+
72+
function updateKmsNodes(
73+
KmsNode[] calldata newKmsNodes,
74+
uint256 newMpcThreshold,
75+
uint256 newPublicDecryptionThreshold,
76+
uint256 newUserDecryptionThreshold,
77+
uint256 newKmsGenThreshold
78+
) public {
79+
emit UpdateKmsNodes(
80+
newKmsNodes,
81+
newMpcThreshold,
82+
newPublicDecryptionThreshold,
83+
newUserDecryptionThreshold,
84+
newKmsGenThreshold
85+
);
86+
}
87+
88+
function updateCoprocessors(Coprocessor[] calldata newCoprocessors, uint256 newCoprocessorThreshold) external {
89+
emit UpdateCoprocessors(newCoprocessors, newCoprocessorThreshold);
90+
}
91+
92+
function updateCustodians(Custodian[] calldata newCustodians) external {
93+
emit UpdateCustodians(newCustodians);
5494
}
5595

5696
function updateMpcThreshold(uint256 newMpcThreshold) external {

0 commit comments

Comments
 (0)