From a0f1290f2c727613da3883b0b6899ca32dd478ce Mon Sep 17 00:00:00 2001 From: Vicente Vieytes Date: Wed, 11 Sep 2024 17:19:54 -0300 Subject: [PATCH] refactor hardcoded variables to .env files --- .env.template | 10 ++++++++++ Makefile | 7 +------ README.md | 11 ++++++++++- contracts/.env.template | 3 +++ .../script/IncredibleSquaringDeployer.s.sol | 17 ++++++++--------- 5 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 .env.template create mode 100644 contracts/.env.template diff --git a/.env.template b/.env.template new file mode 100644 index 00000000..03f37337 --- /dev/null +++ b/.env.template @@ -0,0 +1,10 @@ +# These default values work for devnet deployment only + +AGGREGATOR_ECDSA_PRIV_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 +CHALLENGER_ECDSA_PRIV_KEY=0x5de4111afa1a4b94908f83103eb1f17 + +CHAINID=31337 +# Make sure to update this if the strategy address changes +# check in contracts/script/output/${CHAINID}/credible_squaring_avs_deployment_output.json +STRATEGY_ADDRESS=0x7a2088a1bFc9d81c55368AE168C2C02570cB814F + diff --git a/Makefile b/Makefile index 6b7fba5c..edec3083 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,8 @@ help: @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -AGGREGATOR_ECDSA_PRIV_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 -CHALLENGER_ECDSA_PRIV_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a +include .env -CHAINID=31337 -# Make sure to update this if the strategy address changes -# check in contracts/script/output/${CHAINID}/credible_squaring_avs_deployment_output.json -STRATEGY_ADDRESS=0x7a2088a1bFc9d81c55368AE168C2C02570cB814F DEPLOYMENT_FILES_DIR=contracts/script/output/${CHAINID} -----------------------------: ## diff --git a/README.md b/README.md index 6d9a80ce..d7187e5f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,14 @@ Basic repo demoing a simple AVS middleware with full eigenlayer integration. See this [video walkthrough](https://www.loom.com/share/50314b3ec0f34e2ba386d45724602d76?sid=9d68d8cb-d2d5-4123-bd06-776de2076de0). +## Set environment variables + +``` +cp .env.template .env +cp contracts/.env.template contracts/.env +``` +The .env templates provide default values for devnet development, you should modify them for testnet deployment. + ## Dependencies You will need [foundry](https://book.getfoundry.sh/getting-started/installation) and [zap-pretty](https://github.com/maoueh/zap-pretty) and docker to run the examples below. @@ -19,6 +27,7 @@ You will also need to [install docker](https://docs.docker.com/get-docker/), and make build-contracts ``` + ## Running via make This simple session illustrates the basic flow of the AVS. The makefile commands are hardcoded for a single operator, but it's however easy to create new operator config files, and start more operators manually (see the actual commands that the makefile calls). @@ -114,4 +123,4 @@ When running on anvil, a typical log for the operator is [2024-04-09 18:25:10.679 PDT] INFO (logging/zap_logger.go:49) Signed task response header accepted by aggregator. {"reply":false} ``` -The error `task 2 not initialized or already completed` is expected behavior. This is because the aggregator needs to setup its data structures before it can accept responses. But on a local anvil setup, the operator had time to receive the websocket event for the new task, square the number, sign the response, and send it to the aggregator process before the aggregator has finalized its setup. Hence, the operator retries sending the response 2 seconds later and it is accepted. \ No newline at end of file +The error `task 2 not initialized or already completed` is expected behavior. This is because the aggregator needs to setup its data structures before it can accept responses. But on a local anvil setup, the operator had time to receive the websocket event for the new task, square the number, sign the response, and send it to the aggregator process before the aggregator has finalized its setup. Hence, the operator retries sending the response 2 seconds later and it is accepted. diff --git a/contracts/.env.template b/contracts/.env.template new file mode 100644 index 00000000..0de219ff --- /dev/null +++ b/contracts/.env.template @@ -0,0 +1,3 @@ +AGGREGATOR_ADDR=0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 +TASK_GENERATOR_ADDR=0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 + diff --git a/contracts/script/IncredibleSquaringDeployer.s.sol b/contracts/script/IncredibleSquaringDeployer.s.sol index e455112c..39f767fd 100644 --- a/contracts/script/IncredibleSquaringDeployer.s.sol +++ b/contracts/script/IncredibleSquaringDeployer.s.sol @@ -31,18 +31,12 @@ import "forge-std/StdJson.sol"; import "forge-std/console.sol"; // # To deploy and verify our contract -// forge script script/CredibleSquaringDeployer.s.sol:CredibleSquaringDeployer --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv +// forge script script/IncredibleSquaringDeployer.s.sol:IncredibleSquaringDeployer --rpc-url $RPC_URL --private-key $PRIVATE_KEY --constructor-args $AGGREGATOR_ADDR $TASK_GENERATOR_ADDR --broadcast -vvvv contract IncredibleSquaringDeployer is Script, Utils { // DEPLOYMENT CONSTANTS uint256 public constant QUORUM_THRESHOLD_PERCENTAGE = 100; uint32 public constant TASK_RESPONSE_WINDOW_BLOCK = 30; uint32 public constant TASK_DURATION_BLOCKS = 0; - // TODO: right now hardcoding these (this address is anvil's default address 9) - address public constant AGGREGATOR_ADDR = - 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720; - address public constant TASK_GENERATOR_ADDR = - 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720; - // ERC20 and Strategy: we need to deploy this erc20, create a strategy for it, and whitelist this strategy in the strategymanager ERC20Mock public erc20Mock; @@ -73,7 +67,12 @@ contract IncredibleSquaringDeployer is Script, Utils { IIncredibleSquaringTaskManager public incredibleSquaringTaskManagerImplementation; + address public aggregatorAddr; + address public taskGeneratorAddr; + function run() external { + aggregatorAddr = vm.envAddress("AGGREGATOR_ADDR"); + taskGeneratorAddr = vm.envAddress("TASK_GENERATOR_ADDR"); // Eigenlayer contracts string memory eigenlayerDeployedContracts = readOutput( "eigenlayer_deployment_output" @@ -387,8 +386,8 @@ contract IncredibleSquaringDeployer is Script, Utils { incredibleSquaringTaskManager.initialize.selector, incredibleSquaringPauserReg, incredibleSquaringCommunityMultisig, - AGGREGATOR_ADDR, - TASK_GENERATOR_ADDR + aggregatorAddr, + taskGeneratorAddr ) );