From ea3f69f2a468b16ad9bb7102a2ffd6532c00abe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8r=E2=88=82=C2=A1?= Date: Wed, 30 Oct 2024 12:01:12 +0400 Subject: [PATCH] Final touches --- .env.dev.example => .env.test.example | 0 .gitignore | 4 +- Makefile | 62 +++++++++++++-------------- README.md | 45 ++++++++++--------- script/DeployGauges.s.sol | 51 +++++++++++----------- test/fork/e2eV2.t.sol | 2 +- 6 files changed, 81 insertions(+), 83 deletions(-) rename .env.dev.example => .env.test.example (100%) diff --git a/.env.dev.example b/.env.test.example similarity index 100% rename from .env.dev.example rename to .env.test.example diff --git a/.gitignore b/.gitignore index 1c0e98d..09d3b94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -^.env.example -^.env.dev.example .env* +!.env.example +!.env.test.example # Logs *.log diff --git a/Makefile b/Makefile index 313e650..f4ab0d5 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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 @@ -61,13 +57,13 @@ 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 @@ -75,16 +71,16 @@ clean: ## Clean the artifacts 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 @@ -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) @@ -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: diff --git a/README.md b/README.md index eb2b44f..2a79170 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/script/DeployGauges.s.sol b/script/DeployGauges.s.sol index 97bec0a..c25ddc5 100644 --- a/script/DeployGauges.s.sol +++ b/script/DeployGauges.s.sol @@ -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); @@ -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 @@ -107,15 +107,31 @@ 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"), @@ -123,28 +139,13 @@ contract DeployGauges is Script { }); 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" - }); } } @@ -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++; diff --git a/test/fork/e2eV2.t.sol b/test/fork/e2eV2.t.sol index a3704a6..d3493f8 100644 --- a/test/fork/e2eV2.t.sol +++ b/test/fork/e2eV2.t.sol @@ -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();