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

Add base deployment #253

Merged
merged 5 commits into from
Jan 8, 2025
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
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DEPLOYER_ADDRESS=
RPC_URL=
ETHERSCAN_API_KEY=
NETWORK=
NETWORK=
PRIVATE_KEY=
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: "CI"

env:
FOUNDRY_PROFILE: "ci"
PRIVATE_KEY: "0xafdfd9c3d2095ef696594f6cedcae59e72dcd697e2a7521b1578140422a4f890"
SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }}

on:
pull_request:
Expand Down Expand Up @@ -56,9 +58,6 @@ jobs:
- name: "Show the Foundry config"
run: "forge config"

- name: "Create env file"
run: "touch .env && echo GOERLI_RPC_URL=${{ secrets.GOERLI_RPC_URL }} >> .env"

- name: "Run the tests"
run: "yarn test"
coverage:
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions deployments/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ActiveProposalsLimiterProposalValidationStrategy": "0x399821c9Ea977387a0DEcCF1C9692B4dF925FF38",
"AvatarExecutionStrategyImplementation": "0xecE4f6b01a2d7FF5A9765cA44162D453fC455e42",
"CompTimelockCompatibleExecutionStrategyImplementation": "0x91086017D5eAEc4BeEc86ac770b5eE672e4Be589",
"CompVotingStrategy": "0x0c2De612982Efd102803161fc7C74CcA15Db932c",
"EthSigAuthenticator": "0x5f9B7D78c9a37a439D78f801E0E339C6E711e260",
"EthTxAuthenticator": "0xBA06E6cCb877C332181A6867c05c8b746A21Aed1",
"MerkleWhitelistVotingStrategy": "0x34f0AfFF5A739bBf3E285615F50e40ddAaf2A829",
"OZVotesVotingStrategy": "0x2c8631584474E750CEdF2Fb6A904f2e84777Aefe",
"OptimisticCompTimelockCompatibleExecutionStrategyImplementation": "0x77e7Aa43b28Df1e467bd4806fE3bF26F5c3EAD27",
"OptimisticTimelockExecutionStrategyImplementation": "0x49AF19f9318d55ad8e7CE743De9Ce76ED408CE0C",
"PropositionPowerAndActiveProposalsLimiterValidationStrategy": "0x358e4Ba219CC1e1c7084A14c3a504772acfc40b1",
"PropositionPowerProposalValidationStrategy": "0x6D9d6D08EF6b26348Bd18F1FC8D953696b7cf311",
"ProxyFactory": "0x4B4F7f64Be813Ccc66AEFC3bFCe2baA01188631c",
"SpaceImplementation": "0xC3031A7d3326E47D49BfF9D374d74f364B29CE4D",
"TimelockExecutionStrategyImplementation": "0xf2A1C2f2098161af98b2Cc7E382AB7F3ba86Ebc4",
"VanillaAuthenticator": "0xb9BE0a0093933968E3B4c4fC5d939B6c1Fe45142",
"VanillaProposalValidationStrategy": "0x9A39194F870c410633C170889E9025fba2113c79",
"VanillaVotingStrategy": "0xC1245C5DCa7885C73E32294140F1e5d30688c202",
"WhitelistVotingStrategy": "0x3CEE21A33751A2722413fF62dEC3dEc48e7748A4"
}
21 changes: 21 additions & 0 deletions deployments/optimism.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ActiveProposalsLimiterProposalValidationStrategy": "0x399821c9Ea977387a0DEcCF1C9692B4dF925FF38",
"AvatarExecutionStrategyImplementation": "0xecE4f6b01a2d7FF5A9765cA44162D453fC455e42",
"CompTimelockCompatibleExecutionStrategyImplementation": "0x91086017D5eAEc4BeEc86ac770b5eE672e4Be589",
"CompVotingStrategy": "0x0c2De612982Efd102803161fc7C74CcA15Db932c",
"EthSigAuthenticator": "0x5f9B7D78c9a37a439D78f801E0E339C6E711e260",
"EthTxAuthenticator": "0xBA06E6cCb877C332181A6867c05c8b746A21Aed1",
"MerkleWhitelistVotingStrategy": "0x34f0AfFF5A739bBf3E285615F50e40ddAaf2A829",
"OZVotesVotingStrategy": "0x2c8631584474E750CEdF2Fb6A904f2e84777Aefe",
"OptimisticCompTimelockCompatibleExecutionStrategyImplementation": "0x77e7Aa43b28Df1e467bd4806fE3bF26F5c3EAD27",
"OptimisticTimelockExecutionStrategyImplementation": "0x49AF19f9318d55ad8e7CE743De9Ce76ED408CE0C",
"PropositionPowerAndActiveProposalsLimiterValidationStrategy": "0x358e4Ba219CC1e1c7084A14c3a504772acfc40b1",
"PropositionPowerProposalValidationStrategy": "0x6D9d6D08EF6b26348Bd18F1FC8D953696b7cf311",
"ProxyFactory": "0x4B4F7f64Be813Ccc66AEFC3bFCe2baA01188631c",
"SpaceImplementation": "0xC3031A7d3326E47D49BfF9D374d74f364B29CE4D",
"TimelockExecutionStrategyImplementation": "0xf2A1C2f2098161af98b2Cc7E382AB7F3ba86Ebc4",
"VanillaAuthenticator": "0xb9BE0a0093933968E3B4c4fC5d939B6c1Fe45142",
"VanillaProposalValidationStrategy": "0x9A39194F870c410633C170889E9025fba2113c79",
"VanillaVotingStrategy": "0xC1245C5DCa7885C73E32294140F1e5d30688c202",
"WhitelistVotingStrategy": "0x3CEE21A33751A2722413fF62dEC3dEc48e7748A4"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"prettier": "prettier --write \"**/*.{json,md,sol,yml}\"",
"format": "yarn prettier",
"test": "forge test --optimize -vv",
"deploy-modules": "forge script script/ModulesSetup.s.sol:ModulesSetup --rpc-url $GOERLI_RPC_URL --optimize --broadcast --verify -vvvv",
"deploy-space": "forge script script/SpaceSetup.s.sol:SpaceSetup --rpc-url $GOERLI_RPC_URL --optimize --broadcast --verify -vvvv",
"deploy-modules": "forge script script/ModulesSetup.s.sol:ModulesSetup --rpc-url $SEPOLIA_RPC_URL --optimize --broadcast --verify -vvvv",
"deploy-space": "forge script script/SpaceSetup.s.sol:SpaceSetup --rpc-url $SEPOLIA_RPC_URL --optimize --broadcast --verify -vvvv",
"prepare": "husky install"
},
"lint-staged": {
Expand Down
44 changes: 14 additions & 30 deletions script/Deployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@

SingletonFactory internal singletonFactory = SingletonFactory(0xce0042B868300000d44A59004Da54A005ffdcf9f);
address internal deployer;

// Legacy value from the original deployment
address internal address_salt = address(0x2dBCb4c373E99E27D1E357F42a40Ef114e9270c3);

Check warning on line 59 in script/Deployer.s.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase
string internal deployments;
string internal deploymentsPath;

Expand All @@ -66,7 +69,7 @@
uint256 internal saltNonce = 0;

function run() public {
deployer = vm.envAddress("DEPLOYER_ADDRESS");
deployer = vm.addr(vm.envUint("PRIVATE_KEY"));

string memory network = vm.envString("NETWORK");

Expand All @@ -77,7 +80,6 @@
// ------- EXECUTION STRATEGIES -------

(address avatarExecutionStrategy, ) = noRedeploy(
deployer,
abi.encodePacked(
type(AvatarExecutionStrategy).creationCode,
abi.encode(address(0x1), address(0x1), new address[](0), 0)
Expand All @@ -88,23 +90,20 @@
deployments.serialize("AvatarExecutionStrategyImplementation", avatarExecutionStrategy);

(address timelockExecutionStrategy, ) = noRedeploy(
deployer,
abi.encodePacked(type(TimelockExecutionStrategy).creationCode),
saltNonce
);

deployments.serialize("TimelockExecutionStrategyImplementation", timelockExecutionStrategy);

(address optimisticTimelockExecutionStrategy, ) = noRedeploy(
deployer,
abi.encodePacked(type(OptimisticTimelockExecutionStrategy).creationCode),
saltNonce
);

deployments.serialize("OptimisticTimelockExecutionStrategyImplementation", optimisticTimelockExecutionStrategy);

(address compTimelockCompatibleExecutionStrategy, ) = noRedeploy(
deployer,
abi.encodePacked(
type(CompTimelockCompatibleExecutionStrategy).creationCode,
abi.encode(address(0x1), address(0x1), new address[](0), 0, 0)
Expand All @@ -118,7 +117,6 @@
);

(address optimisticCompTimelockCompatibleExecutionStrategy, ) = noRedeploy(
deployer,
abi.encodePacked(
type(OptimisticCompTimelockCompatibleExecutionStrategy).creationCode,
abi.encode(address(0x1), address(0x1), new address[](0), 0, 0)
Expand All @@ -133,39 +131,33 @@

// ------- AUTHENTICATORS -------

(address vanillaAuthenticator, ) = noRedeploy(deployer, type(VanillaAuthenticator).creationCode, saltNonce);
(address vanillaAuthenticator, ) = noRedeploy(type(VanillaAuthenticator).creationCode, saltNonce);
deployments.serialize("VanillaAuthenticator", vanillaAuthenticator);

(address ethTxAuthenticator, ) = noRedeploy(deployer, type(EthTxAuthenticator).creationCode, saltNonce);
(address ethTxAuthenticator, ) = noRedeploy(type(EthTxAuthenticator).creationCode, saltNonce);
deployments.serialize("EthTxAuthenticator", ethTxAuthenticator);

(address ethSigAuthenticator, ) = noRedeploy(
deployer,
abi.encodePacked(type(EthSigAuthenticator).creationCode, abi.encode(name, version)),
saltNonce
);
deployments.serialize("EthSigAuthenticator", ethSigAuthenticator);

// ------- VOTING STRATEGIES -------

(address vanillaVotingStrategy, ) = noRedeploy(deployer, type(VanillaVotingStrategy).creationCode, saltNonce);
(address vanillaVotingStrategy, ) = noRedeploy(type(VanillaVotingStrategy).creationCode, saltNonce);
deployments.serialize("VanillaVotingStrategy", vanillaVotingStrategy);

(address whitelistVotingStrategy, ) = noRedeploy(
deployer,
type(WhitelistVotingStrategy).creationCode,
saltNonce
);
(address whitelistVotingStrategy, ) = noRedeploy(type(WhitelistVotingStrategy).creationCode, saltNonce);
deployments.serialize("WhitelistVotingStrategy", whitelistVotingStrategy);

(address compVotingStrategy, ) = noRedeploy(deployer, type(CompVotingStrategy).creationCode, saltNonce);
(address compVotingStrategy, ) = noRedeploy(type(CompVotingStrategy).creationCode, saltNonce);
deployments.serialize("CompVotingStrategy", compVotingStrategy);

(address ozVotesVotingStrategy, ) = noRedeploy(deployer, type(OZVotesVotingStrategy).creationCode, saltNonce);
(address ozVotesVotingStrategy, ) = noRedeploy(type(OZVotesVotingStrategy).creationCode, saltNonce);
deployments.serialize("OZVotesVotingStrategy", ozVotesVotingStrategy);

(address merkleWhitelistVotingStrategy, ) = noRedeploy(
deployer,
type(MerkleWhitelistVotingStrategy).creationCode,
saltNonce
);
Expand All @@ -174,21 +166,18 @@
// ------- PROPOSAL VALIDATION STRATEGIES -------

(address vanillaProposalValidationStrategy, ) = noRedeploy(
deployer,
type(VanillaProposalValidationStrategy).creationCode,
saltNonce
);
deployments.serialize("VanillaProposalValidationStrategy", vanillaProposalValidationStrategy);

(address propositionPowerProposalValidationStrategy, ) = noRedeploy(
deployer,
type(PropositionPowerProposalValidationStrategy).creationCode,
saltNonce
);
deployments.serialize("PropositionPowerProposalValidationStrategy", propositionPowerProposalValidationStrategy);

(address activeProposalsLimiterProposalValidationStrategy, ) = noRedeploy(
deployer,
type(ActiveProposalsLimiterProposalValidationStrategy).creationCode,
saltNonce
);
Expand All @@ -199,7 +188,6 @@
);

(address propositionPowerAndActiveProposalsLimiterValidationStrategy, ) = noRedeploy(
deployer,
type(PropositionPowerAndActiveProposalsLimiterValidationStrategy).creationCode,
saltNonce
);
Expand All @@ -211,12 +199,12 @@

// ------- PROXY FACTORY -------

(address proxyFactory, ) = noRedeploy(deployer, type(ProxyFactory).creationCode, saltNonce);
(address proxyFactory, ) = noRedeploy(type(ProxyFactory).creationCode, saltNonce);
deployments.serialize("ProxyFactory", proxyFactory);

// ------- SPACE -------

(address space, ) = noRedeploy(deployer, type(Space).creationCode, saltNonce);
(address space, ) = noRedeploy(type(Space).creationCode, saltNonce);

// If the master space is not initialized, initialize it
if (Space(space).owner() == address(0x0)) {
Expand Down Expand Up @@ -257,12 +245,8 @@
}

// Deploys contract if it doesn't exist, otherwise returns the create2 address
function noRedeploy(
address _deployer,
bytes memory _initCode,
uint256 _saltNonce
) internal returns (address, bool) {
bytes32 salt = keccak256(abi.encodePacked(_deployer, _saltNonce));
function noRedeploy(bytes memory _initCode, uint256 _saltNonce) internal returns (address, bool) {
bytes32 salt = keccak256(abi.encodePacked(address_salt, _saltNonce));
address addy = computeCreate2Address(salt, keccak256(_initCode), address(singletonFactory));
if (addy.code.length == 0) {
address _addy = singletonFactory.deploy(_initCode, salt);
Expand Down
8 changes: 4 additions & 4 deletions test/ForkedTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Choice, IndexedStrategy, Strategy, UpdateSettingsCalldata } from "../sr
// Similar to "GasSnapshots.t.sol" except this uses a forked network
// solhint-disable-next-line max-states-count
contract ForkedTest is SpaceTest, SigUtils {
uint256 internal goerliFork;
uint256 internal sepoliaFork;

CompVotingStrategy internal compVotingStrategy;
CompToken internal compToken;
Expand Down Expand Up @@ -47,8 +47,8 @@ contract ForkedTest is SpaceTest, SigUtils {
function setUp() public virtual override {
super.setUp();

string memory GOERLI_RPC_URL = vm.envString("GOERLI_RPC_URL");
goerliFork = vm.createFork(GOERLI_RPC_URL);
string memory SEPOLIA_RPC_URL = vm.envString("SEPOLIA_RPC_URL");
sepoliaFork = vm.createFork(SEPOLIA_RPC_URL);

(voter2, key2) = makeAddrAndKey("Voter 2 Key");
(voter3, key3) = makeAddrAndKey("Voter 3 Key");
Expand Down Expand Up @@ -162,7 +162,7 @@ contract ForkedTest is SpaceTest, SigUtils {
}

function testFork_VoteAndProposeWithCompToken() public {
vm.selectFork(goerliFork);
vm.selectFork(sepoliaFork);

vm.roll(block.number + 1);

Expand Down
Loading