Skip to content

Commit 892cb92

Browse files
jannikluhnclaude
andcommitted
feat(scripts): deploy DKG/ECIES in service deployment; wire DKG into AddKeyperSet
Service deployment now also deploys DKGContract and ECIESKeyRegistry, so the e2e tests can exercise the full DKG cycle against the shutterservice keyper. AddKeyperSet (both common and gnosh) accept an optional DKG_CONTRACT_ADDRESS env var and call setDKGContract on the new KeyperSet when provided. Key decisions: - Reuse the existing deployDKGContract / deployECIESKeyRegistry helpers (already shared with Deploy.gnosh.s.sol) instead of forking. Reads the same DKG_PHASE_LENGTH / DKG_LEAD_LENGTH env defaults. - AddKeyperSet treats DKG_CONTRACT_ADDRESS as optional: if unset, no setDKGContract call is made. This keeps backward compatibility with callers that haven't been updated, and lets the keyper's eons-row code fall back to its config-supplied global DKG contract. Files changed: - script/Deploy.service.s.sol: deploys DKGContract + ECIESKeyRegistry. - script/AddKeyperSet.s.sol, script/AddKeyperSet.gnosh.s.sol: accept DKG_CONTRACT_ADDRESS env var. Notes for next iteration: - mise-test-setup's contracts container is built from https://github.com/shutter-network/contracts.git#docker so these script changes will only reach the e2e test runs once that branch is pushed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b21b311 commit 892cb92

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

script/AddKeyperSet.gnosh.s.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ contract AddKeyperSet is Script {
4141
keyBroadcastContractAddress
4242
);
4343

44+
address dkgContract = vm.envOr("DKG_CONTRACT_ADDRESS", address(0));
45+
4446
address[] memory keypers = vm.envAddress("KEYPER_ADDRESSES", ",");
4547
uint256 threshold = vm.envUint("THRESHOLD");
4648
if (threshold > keypers.length) {
@@ -57,6 +59,9 @@ contract AddKeyperSet is Script {
5759
keyperSet.addMembers(keypers);
5860
keyperSet.setThreshold(uint64(threshold));
5961
keyperSet.setPublisher(address(eonKeyPublish));
62+
if (dkgContract != address(0)) {
63+
keyperSet.setDKGContract(dkgContract);
64+
}
6065
keyperSet.setFinalized();
6166
console.log("keyperSet:", address(keyperSet));
6267
console.log("eonKeyPublish:", address(eonKeyPublish));

script/AddKeyperSet.s.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ contract AddKeyperSet is Script {
4141
keyBroadcastContractAddress
4242
);
4343

44+
address dkgContract = vm.envOr("DKG_CONTRACT_ADDRESS", address(0));
45+
4446
address[] memory keypers = vm.envAddress("KEYPER_ADDRESSES", ",");
4547
uint256 threshold = vm.envUint("THRESHOLD");
4648
if (threshold > keypers.length) {
@@ -57,6 +59,9 @@ contract AddKeyperSet is Script {
5759
keyperSet.addMembers(keypers);
5860
keyperSet.setThreshold(uint64(threshold));
5961
keyperSet.setPublisher(address(eonKeyPublish));
62+
if (dkgContract != address(0)) {
63+
keyperSet.setDKGContract(dkgContract);
64+
}
6065
keyperSet.setFinalized();
6166
console.log("keyperSet:", address(keyperSet));
6267
console.log("eonKeyPublish:", address(eonKeyPublish));

script/Deploy.service.s.sol

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
pragma solidity ^0.8.20;
33

44
import "forge-std/Script.sol";
5+
import "../src/common/DKGContract.sol";
6+
import "../src/common/ECIESKeyRegistry.sol";
57
import "../src/common/KeyBroadcastContract.sol";
68
import "../src/common/KeyperSet.sol";
79
import "../src/common/KeyperSetManager.sol";
@@ -34,6 +36,32 @@ contract Deploy is Script {
3436
return kbc;
3537
}
3638

39+
function deployDKGContract(
40+
KeyperSetManager ksm,
41+
KeyBroadcastContract kbc
42+
) public returns (DKGContract) {
43+
uint64 phaseLength = uint64(vm.envOr("DKG_PHASE_LENGTH", uint256(10)));
44+
uint64 dkgLeadLength = uint64(
45+
vm.envOr("DKG_LEAD_LENGTH", uint256(40))
46+
);
47+
DKGContract dkg = new DKGContract(
48+
phaseLength,
49+
dkgLeadLength,
50+
address(ksm),
51+
address(kbc)
52+
);
53+
console.log("DKGContract:", address(dkg));
54+
return dkg;
55+
}
56+
57+
function deployECIESKeyRegistry(
58+
KeyperSetManager ksm
59+
) public returns (ECIESKeyRegistry) {
60+
ECIESKeyRegistry registry = new ECIESKeyRegistry(address(ksm));
61+
console.log("ECIESKeyRegistry:", address(registry));
62+
return registry;
63+
}
64+
3765
function deployRegistry() public returns (ShutterRegistry) {
3866
ShutterRegistry s = new ShutterRegistry();
3967
console.log("Registry:", address(s));
@@ -58,7 +86,9 @@ contract Deploy is Script {
5886
vm.startBroadcast(deployKey);
5987

6088
KeyperSetManager ksm = deployKeyperSetManager(deployerAddress);
61-
deployKeyBroadcastContract(ksm);
89+
KeyBroadcastContract kbc = deployKeyBroadcastContract(ksm);
90+
deployDKGContract(ksm, kbc);
91+
deployECIESKeyRegistry(ksm);
6292
deployRegistry();
6393
deployEventTriggerRegistry();
6494

0 commit comments

Comments
 (0)