Skip to content

Commit

Permalink
Final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Oct 30, 2024
1 parent ec49783 commit ea3f69f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 83 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
^.env.example
^.env.dev.example
.env*
!.env.example
!.env.test.example

# Logs
*.log
Expand Down
62 changes: 30 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

# Import the .env files and export their values (ignore any error if missing)
-include .env
-include .env.dev
-include .env.test

# VARIABLE ASSIGNMENTS

# Set the RPC URL's for each target
test-fork-testnet: export RPC_URL = $(TESTNET_RPC_URL)
test-fork-prodnet: export RPC_URL = $(PRODNET_RPC_URL)
test-fork-holesky: export RPC_URL = "https://holesky.drpc.org"
test-fork-sepolia: export RPC_URL = "https://sepolia.drpc.org"

pre-deploy-testnet: export RPC_URL = $(TESTNET_RPC_URL)
pre-deploy-prodnet: export RPC_URL = $(PRODNET_RPC_URL)
Expand All @@ -29,17 +27,15 @@ deploy-testnet: export VERIFIER_URL_PARAM = --verifier-url "https://sepolia.expl
deploy-prodnet: export ETHERSCAN_API_KEY_PARAM = --etherscan-api-key $(ETHERSCAN_API_KEY)

# Set production deployments' flag
test-fork-prod-testnet: export DEPLOY_AS_PRODUCTION = true
test-fork-prod-prodnet: export DEPLOY_AS_PRODUCTION = true
test-fork-prod-holesky: export DEPLOY_AS_PRODUCTION = true
test-fork-prod-sepolia: export DEPLOY_AS_PRODUCTION = true
deploy: export DEPLOY_AS_PRODUCTION = true
test-fork-mint-testnet: export MINT_TEST_TOKENS = true
test-fork-mint-prodnet: export MINT_TEST_TOKENS = true

pre-deploy-mint-testnet: export MINT_TEST_TOKENS = true
deploy-mint-testnet: export MINT_TEST_TOKENS = true

# Override the fork test mode (existing)
test-fork-factory-testnet: export FORK_TEST_MODE = fork-existing
test-fork-factory-prodnet: export FORK_TEST_MODE = fork-existing
test-fork-factory-holesky: export FORK_TEST_MODE = fork-existing
test-fork-factory-sepolia: export FORK_TEST_MODE = fork-existing

# CONSTANTS

Expand All @@ -61,30 +57,30 @@ help:
| sed 's/^- make $$//g'

.PHONY: init
init: .env .env.dev ## Check the required tools and dependencies
init: .env .env.test ## Check the required tools and dependencies
@which forge > /dev/null || curl -L https://foundry.paradigm.xyz | bash
@forge build
@which lcov > /dev/null || echo "Note: lcov can be installed by running 'sudo apt install lcov'"

.PHONY: clean
clean: ## Clean the artifacts
clean: ## Clean the artifacts
rm -Rf ./out/* lcov.info* ./report/*

# Copy the .env files if not present
.env:
cp .env.example .env
@echo "NOTE: Edit the correct values of .env before you continue"

.env.dev:
cp .env.dev.example .env.dev
@echo "NOTE: Edit the correct values of .env.dev before you continue"
.env.test:
cp .env.test.example .env.test
@echo "NOTE: Edit the correct values of .env.test before you continue"

: ##

test-unit: ## Run unit tests, locally
test-unit: ## Run unit tests, locally
forge test --no-match-path $(FORK_TEST_WILDCARD)

test-coverage: report/index.html ## Make an HTML coverage report under ./report
test-coverage: report/index.html ## Generate an HTML coverage report under ./report
@which open > /dev/null && open report/index.html || echo -n
@which xdg-open > /dev/null && xdg-open report/index.html || echo -n

Expand All @@ -101,20 +97,18 @@ lcov.info: $(TEST_SRC_FILES)

#### Fork testing ####

test-fork-testnet: test-fork ## Run a clean fork test (testnet)
test-fork-prodnet: test-fork ## Run a clean fork test (production network)
test-fork-holesky: test-fork ## Run a clean fork test (Holesky)
test-fork-sepolia: test-fork ## Run a clean fork test (Sepolia)
test-fork-mint-testnet: test-fork-testnet ## Clean fork test, minting test tokens (testnet)
test-fork-mint-prodnet: test-fork-prodnet ## Clean fork test, minting test tokens (production network)

: ##

test-fork-prod-testnet: test-fork-testnet ## Fork test using the .env token params (testnet)
test-fork-prod-prodnet: test-fork-prodnet ## Fork test using the .env token params (production network)
test-fork-prod-holesky: test-fork-holesky ## Fork test using the .env token params (Holesky)
test-fork-prod-sepolia: test-fork-sepolia ## Fork test using the .env token params (Sepolia)
test-fork-testnet: test-fork ## Fork test using the existing token(s) (testnet)
test-fork-prodnet: test-fork ## Fork test using the existing token(s) (production network)

test-fork-factory-testnet: test-fork-testnet ## Fork test on an existing factory (testnet)
test-fork-factory-prodnet: test-fork-prodnet ## Fork test on an existing factory (production network)
test-fork-factory-holesky: test-fork-holesky ## Fork test on an existing factory (Holesky)
test-fork-factory-sepolia: test-fork-sepolia ## Fork test on an existing factory (Sepolia)
: ##

test-fork-factory-testnet: test-fork-testnet ## Fork test using an existing factory (testnet)
test-fork-factory-prodnet: test-fork-prodnet ## Fork test using an existing factory (production network)

test-fork:
forge test --match-contract $(E2E_TEST_NAME) --rpc-url $(RPC_URL) $(VERBOSITY)
Expand All @@ -123,10 +117,14 @@ test-fork:

#### Deployment targets ####

pre-deploy-testnet: pre-deploy ## Simulate a deployment to the defined testnet
pre-deploy-prodnet: pre-deploy ## Simulate a deployment to the defined production network
pre-deploy-mint-testnet: pre-deploy ## Simulate a deployment to the testnet, minting test token(s)
pre-deploy-testnet: pre-deploy ## Simulate a deployment to the testnet
pre-deploy-prodnet: pre-deploy ## Simulate a deployment to the production network

: ##

deploy-testnet: deploy ## Deploy to the defined testnet network and verify
deploy-mint-testnet: deploy ## Deploy to the testnet, mint test tokens and verify
deploy-testnet: deploy ## Deploy to the testnet and verify
deploy-prodnet: deploy ## Deploy to the production network and verify

pre-deploy:
Expand Down
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,36 @@ The `Makefile` as the target launcher of the project. It's the recommended way t
$ make
Available targets:
- make init Check the required tools and dependencies
- make clean Clean the artifacts
- make test-unit Run unit tests, locally
- make test-coverage Make an HTML coverage report under ./report
- make test-fork-testnet Run a clean fork test (testnet)
- make test-fork-prodnet Run a clean fork test (production network)
- make test-fork-holesky Run a clean fork test (Holesky)
- make test-fork-sepolia Run a clean fork test (Sepolia)
- make test-fork-prod-testnet Fork test using the .env token params (testnet)
- make test-fork-prod-prodnet Fork test using the .env token params (production network)
- make test-fork-prod-holesky Fork test using the .env token params (Holesky)
- make test-fork-prod-sepolia Fork test using the .env token params (Sepolia)
- make test-fork-factory-testnet Fork test on an existing factory (testnet)
- make test-fork-factory-prodnet Fork test on an existing factory (production network)
- make test-fork-factory-holesky Fork test on an existing factory (Holesky)
- make test-fork-factory-sepolia Fork test on an existing factory (Sepolia)
- make init Check the required tools and dependencies
- make clean Clean the artifacts
- make pre-deploy-testnet Simulate a deployment to the defined testnet
- make pre-deploy-prodnet Simulate a deployment to the defined production network
- make deploy-testnet Deploy to the defined testnet network and verify
- make test-unit Run unit tests, locally
- make test-coverage Generate an HTML coverage report under ./report
- make test-fork-mint-testnet Clean fork test, minting test tokens (testnet)
- make test-fork-mint-prodnet Clean fork test, minting test tokens (production network)
- make test-fork-testnet Fork test using the existing token(s) (testnet)
- make test-fork-prodnet Fork test using the existing token(s) (production network)
- make test-fork-factory-testnet Fork test using an existing factory (testnet)
- make test-fork-factory-prodnet Fork test using an existing factory (production network)
- make pre-deploy-mint-testnet Simulate a deployment to the testnet, minting test token(s)
- make pre-deploy-testnet Simulate a deployment to the testnet
- make pre-deploy-prodnet Simulate a deployment to the production network
- make deploy-mint-testnet Deploy to the testnet, mint test tokens and verify
- make deploy-testnet Deploy to the testnet and verify
- make deploy-prodnet Deploy to the production network and verify
```

Run `make init`:
- It ensures that Foundry is installed
- It runs a first compilation of the project
- It copies `.env.example` into `.env` and `.env.dev.example` into `.env.dev`
- It copies `.env.example` into `.env` and `.env.test.example` into `.env.test`

Next, customize the values of `.env` and optionally `.env.dev`.
Next, customize the values of `.env` and optionally `.env.test`.

### Understanding `.env.example`

Expand Down
51 changes: 26 additions & 25 deletions script/DeployGauges.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ contract DeployGauges is Script {
/// @notice Runs the deployment flow, records the given parameters and artifacts, and it becomes read only
function run() public broadcast {
// Prepare all parameters
bool isProduction = vm.envOr("DEPLOY_AS_PRODUCTION", false);
DeploymentParameters memory parameters = getDeploymentParameters(isProduction);
bool mintTestTokens = vm.envOr("MINT_TEST_TOKENS", false);
DeploymentParameters memory parameters = getDeploymentParameters(mintTestTokens);

// Create the DAO
GaugesDaoFactory factory = new GaugesDaoFactory(parameters);
Expand All @@ -45,10 +45,10 @@ contract DeployGauges is Script {
}

function getDeploymentParameters(
bool isProduction
bool mintTestTokens
) public returns (DeploymentParameters memory parameters) {
address[] memory multisigMembers = readMultisigMembers();
TokenParameters[] memory tokenParameters = getTokenParameters(isProduction);
TokenParameters[] memory tokenParameters = getTokenParameters(mintTestTokens);

// NOTE: Multisig is already deployed, using the existing Aragon's repo
// NOTE: Deploying the plugin setup from the current script to avoid code size constraints
Expand Down Expand Up @@ -107,44 +107,45 @@ contract DeployGauges is Script {
}

function getTokenParameters(
bool isProduction
bool mintTestTokens
) internal returns (TokenParameters[] memory tokenParameters) {
if (isProduction) {
if (mintTestTokens) {
// MINT
console.log("Deploying 2 token contracts (testing)");

address[] memory multisigMembers = readMultisigMembers();
tokenParameters = new TokenParameters[](2);
tokenParameters[0] = TokenParameters({
token: createTestToken(multisigMembers),
veTokenName: "VE Token 1",
veTokenSymbol: "veTK1"
});
tokenParameters[1] = TokenParameters({
token: createTestToken(multisigMembers),
veTokenName: "VE Token 2",
veTokenSymbol: "veTK2"
});
} else {
// USE TOKEN(s)
console.log("Using production parameters");

bool hasTwoTokens = vm.envAddress("TOKEN2_ADDRESS") != address(0);
tokenParameters = new TokenParameters[](hasTwoTokens ? 2 : 1);

console.log("Using token", vm.envAddress("TOKEN1_ADDRESS"));
tokenParameters[0] = TokenParameters({
token: vm.envAddress("TOKEN1_ADDRESS"),
veTokenName: vm.envString("VE_TOKEN1_NAME"),
veTokenSymbol: vm.envString("VE_TOKEN1_SYMBOL")
});

if (hasTwoTokens) {
console.log("Using token", vm.envAddress("TOKEN2_ADDRESS"));
tokenParameters[1] = TokenParameters({
token: vm.envAddress("TOKEN2_ADDRESS"),
veTokenName: vm.envString("VE_TOKEN2_NAME"),
veTokenSymbol: vm.envString("VE_TOKEN2_SYMBOL")
});
}
} else {
// MINT TEST TOKEN
console.log("Using testing parameters (minting 2 dev tokens)");

address[] memory multisigMembers = readMultisigMembers();
tokenParameters = new TokenParameters[](2);
tokenParameters[0] = TokenParameters({
token: createTestToken(multisigMembers),
veTokenName: "VE Token 1",
veTokenSymbol: "veTK1"
});
tokenParameters[1] = TokenParameters({
token: createTestToken(multisigMembers),
veTokenName: "VE Token 2",
veTokenSymbol: "veTK2"
});
}
}

Expand All @@ -153,8 +154,8 @@ contract DeployGauges is Script {
MockERC20 newToken = new MockERC20();

for (uint i = 0; i < holders.length; ) {
newToken.mint(holders[i], 50 ether);
console.log("Minting 50 eth for", holders[i]);
newToken.mint(holders[i], 5000 ether);
console.log("Minting 5000 tokens for", holders[i]);

unchecked {
i++;
Expand Down
2 changes: 1 addition & 1 deletion test/fork/e2eV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contract TestE2EV2 is AragonTest, IWithdrawalQueueErrors, IGaugeVote, IEscrowCur

// fetch the deployment parameters
DeploymentParameters memory deploymentParameters = deploy.getDeploymentParameters(
vm.envOr("DEPLOY_AS_PRODUCTION", false)
vm.envOr("MINT_TEST_TOKENS", false)
);

signers = deploy.readMultisigMembers();
Expand Down

0 comments on commit ea3f69f

Please sign in to comment.