Skip to content

Commit c8a18b9

Browse files
committed
Add deploy and management scripts for Gnosis
1 parent f78daec commit c8a18b9

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

script/AddKeyperSet.s.sol

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.22;
3+
4+
import "forge-std/Script.sol";
5+
import {KeyperSet} from "../src/KeyperSet.sol";
6+
import {KeyperSetManager} from "../src/KeyperSetManager.sol";
7+
import {KeyBroadcastContract} from "../src/KeyBroadcastContract.sol";
8+
import {EonKeyPublish} from "../src/EonKeyPublish.sol";
9+
10+
error ActivationDeltaTooLow();
11+
error ThresholdExceedsKeyperSetSize(uint256 threshold, uint256 keyperSetSize);
12+
error UnexpectedKeyperSet(
13+
uint256 index,
14+
address expectedKeyperSet,
15+
address actualKeyperSet
16+
);
17+
18+
contract AddKeyperSet is Script {
19+
function run() public {
20+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
21+
address deployerAddress = vm.addr(deployerPrivateKey);
22+
console.log("deployer:", deployerAddress);
23+
vm.startBroadcast(deployerPrivateKey);
24+
25+
uint256 activationDelta = vm.envOr("ACTIVATION_DELTA", uint256(1));
26+
if (activationDelta < 1) {
27+
revert ActivationDeltaTooLow();
28+
}
29+
30+
address keyperSetManagerAddress = vm.envAddress(
31+
"KEYPERSETMANAGER_ADDRESS"
32+
);
33+
KeyperSetManager keyperSetManager = KeyperSetManager(
34+
keyperSetManagerAddress
35+
);
36+
37+
address keyBroadcastContractAddress = vm.envAddress(
38+
"KEYBROADCAST_ADDRESS"
39+
);
40+
KeyBroadcastContract keyBroadcastContract = KeyBroadcastContract(
41+
keyBroadcastContractAddress
42+
);
43+
44+
address[] memory keypers = vm.envAddress("KEYPER_ADDRESSES", ",");
45+
uint256 threshold = vm.envUint("THRESHOLD");
46+
if (threshold > keypers.length) {
47+
revert ThresholdExceedsKeyperSetSize(threshold, keypers.length);
48+
}
49+
50+
uint64 keyperSetIndex = keyperSetManager.getNumKeyperSets();
51+
KeyperSet keyperSet = new KeyperSet();
52+
EonKeyPublish eonKeyPublish = new EonKeyPublish(
53+
address(keyperSet),
54+
address(keyBroadcastContract),
55+
keyperSetIndex
56+
);
57+
keyperSet.addMembers(keypers);
58+
keyperSet.setThreshold(uint64(threshold));
59+
keyperSet.setPublisher(address(eonKeyPublish));
60+
keyperSet.setFinalized();
61+
console.log("keyperSet:", address(keyperSet));
62+
console.log("eonKeyPublish:", address(eonKeyPublish));
63+
64+
uint64 activationBlock = uint64(block.number + activationDelta);
65+
keyperSetManager.addKeyperSet(activationBlock, address(keyperSet));
66+
console.log("activationBlock:", activationBlock);
67+
console.log("keyperSetIndex:", keyperSetIndex);
68+
69+
address actualKeyperSet = keyperSetManager.getKeyperSetAddress(
70+
keyperSetIndex
71+
);
72+
if (actualKeyperSet != address(keyperSet)) {
73+
revert UnexpectedKeyperSet(
74+
keyperSetIndex,
75+
address(keyperSet),
76+
actualKeyperSet
77+
);
78+
}
79+
80+
vm.stopBroadcast();
81+
}
82+
}

script/DeployGnosis.s.sol

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.22;
3+
4+
import "forge-std/Script.sol";
5+
import {KeyperSetManager} from "../src/KeyperSetManager.sol";
6+
import {KeyBroadcastContract} from "../src/KeyBroadcastContract.sol";
7+
8+
contract DeployGnosis is Script {
9+
function run() public {
10+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
11+
address deployerAddress = vm.addr(deployerPrivateKey);
12+
console.log("deployer:", vm.addr(deployerPrivateKey));
13+
vm.startBroadcast(deployerPrivateKey);
14+
15+
KeyperSetManager keyperSetManager = new KeyperSetManager(
16+
deployerAddress
17+
);
18+
keyperSetManager.initialize(deployerAddress, deployerAddress);
19+
console.log("keyperSetManager:", address(keyperSetManager));
20+
21+
KeyBroadcastContract keyBroadcastContract = new KeyBroadcastContract(
22+
address(keyperSetManager)
23+
);
24+
console.log("keyBroadcastContract:", address(keyBroadcastContract));
25+
26+
vm.stopBroadcast();
27+
}
28+
}

0 commit comments

Comments
 (0)