From 6ca42893ade9f3aa04b6c5490505ad015f4c0480 Mon Sep 17 00:00:00 2001 From: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Date: Thu, 13 Jun 2024 14:23:00 -0700 Subject: [PATCH] build: Update configuration and workflows for Devnet (#152) * build: Rename solver, job creator, and contracts secrets * chore: Remove unused Cloudflare token and Doppler config * chore: Rename local_l2 to dev Matches other places where we refer to local development as dev. * fix: update network on run cmd * chore: Update print-env network, RPC URL, and chain ID * build: Remove Devnet contracts deploy job We have decided to rebuild the chain from scratch on Devnet. --------- Co-authored-by: Gorka <gorka@aquigorka.com> --- .github/workflows/devnet_deploy.yml | 49 +++++++---------------------- hardhat/hardhat.config.ts | 4 +-- hardhat/scripts/print-env.ts | 6 ++-- hardhat/scripts/print-l2-config.ts | 12 +++---- stack | 14 ++++----- 5 files changed, 30 insertions(+), 55 deletions(-) diff --git a/.github/workflows/devnet_deploy.yml b/.github/workflows/devnet_deploy.yml index 48aeee33..d9037883 100644 --- a/.github/workflows/devnet_deploy.yml +++ b/.github/workflows/devnet_deploy.yml @@ -6,27 +6,6 @@ on: - main jobs: - contracts: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - context: app - - - name: Install Doppler CLI - uses: dopplerhq/cli-action@v1 - - # TODO Avoid re-deploying contracts that are already on chain - - name: Deploy contracts - id: deploy-contracts - env: - DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN_CONTRACTS_DEPLOY_DEVNET }} - run: | - cd hardhat - npm ci - doppler run -- npx hardhat deploy --network geth - solver-build-deploy: runs-on: ubuntu-latest steps: @@ -53,14 +32,11 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY_SOLVER: ${{ secrets.ECR_REPOSITORY_SOLVER }} - CLOUDFLARE_TOKEN_SOLVER: ${{ secrets.CLOUDFLARE_TOKEN_SOLVER }} run: | docker build \ -t $ECR_REPOSITORY_SOLVER \ -f ./docker/solver/Dockerfile \ --build-arg="expose_via=cloudflare" \ - --build-arg="cloudflare_token=${CLOUDFLARE_TOKEN_SOLVER}"\ - --build-arg="doppler_config=devnet" \ --build-arg="network=devnet" \ . docker tag $ECR_REPOSITORY_SOLVER:latest $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest @@ -71,12 +47,12 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY_SOLVER: ${{ secrets.ECR_REPOSITORY_SOLVER }} - DOPPLER_TOKEN_SOLVER: ${{ secrets.DOPPLER_TOKEN_SOLVER }} + DEVNET_DOPPLER_TOKEN_SOLVER: ${{ secrets.DEVNET_DOPPLER_TOKEN_SOLVER }} with: - host: ${{ secrets.EC2_HOST_SOLVER }} - username: ${{ secrets.EC2_USERNAME_SOLVER }} - key: ${{ secrets.EC2_PRIVATE_KEY_SOLVER }} - envs: ECR_REGISTRY, ECR_REPOSITORY_SOLVER, DOPPLER_TOKEN_SOLVER + host: ${{ secrets.DEVNET_EC2_HOST_SOLVER }} + username: ${{ secrets.DEVNET_EC2_USERNAME_SOLVER }} + key: ${{ secrets.DEVNET_EC2_PRIVATE_KEY_SOLVER }} + envs: ECR_REGISTRY, ECR_REPOSITORY_SOLVER, DEVNET_DOPPLER_TOKEN_SOLVER script_stop: true script: | docker stop solver || true @@ -88,7 +64,7 @@ jobs: -d \ --restart always \ --name solver \ - -e DOPPLER_TOKEN=$DOPPLER_TOKEN_SOLVER \ + -e DOPPLER_TOKEN=$DEVNET_DOPPLER_TOKEN_SOLVER \ $ECR_REGISTRY/$ECR_REPOSITORY_SOLVER:latest job-creator-build-deploy: @@ -122,7 +98,6 @@ jobs: docker build \ -t $ECR_REPOSITORY_JOB_CREATOR \ -f ./docker/job-creator/Dockerfile \ - --build-arg doppler_config=devnet \ --build-arg="network=devnet" \ . docker tag $ECR_REPOSITORY_JOB_CREATOR:latest $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest @@ -133,12 +108,12 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY_JOB_CREATOR: ${{ secrets.ECR_REPOSITORY_JOB_CREATOR }} - DOPPLER_TOKEN_JOB_CREATOR: ${{ secrets.DOPPLER_TOKEN_JOB_CREATOR }} + DEVNET_DOPPLER_TOKEN_JOB_CREATOR: ${{ secrets.DEVNET_DOPPLER_TOKEN_JOB_CREATOR }} with: - host: ${{ secrets.EC2_HOST_JOB_CREATOR }} - username: ${{ secrets.EC2_USERNAME_JOB_CREATOR }} - key: ${{ secrets.EC2_PRIVATE_KEY_JOB_CREATOR }} - envs: ECR_REGISTRY, ECR_REPOSITORY_JOB_CREATOR, DOPPLER_TOKEN_JOB_CREATOR + host: ${{ secrets.DEVNET_EC2_HOST_JOB_CREATOR }} + username: ${{ secrets.DEVNET_EC2_USERNAME_JOB_CREATOR }} + key: ${{ secrets.DEVNET_EC2_PRIVATE_KEY_JOB_CREATOR }} + envs: ECR_REGISTRY, ECR_REPOSITORY_JOB_CREATOR, DEVNET_DOPPLER_TOKEN_JOB_CREATOR script_stop: true script: | docker stop job-creator || true @@ -150,5 +125,5 @@ jobs: -d \ --restart always \ --name job-creator \ - -e DOPPLER_TOKEN=$DOPPLER_TOKEN_JOB_CREATOR \ + -e DOPPLER_TOKEN=$DEVNET_DOPPLER_TOKEN_JOB_CREATOR \ $ECR_REGISTRY/$ECR_REPOSITORY_JOB_CREATOR:latest diff --git a/hardhat/hardhat.config.ts b/hardhat/hardhat.config.ts index 70457e7f..338ecd8c 100644 --- a/hardhat/hardhat.config.ts +++ b/hardhat/hardhat.config.ts @@ -14,7 +14,7 @@ import { const ENV_FILE = process.env.DOTENV_CONFIG_PATH || '../.env' dotenv.config({ path: ENV_FILE }) -const NETWORK = process.env.NETWORK || "local_l2"; +const NETWORK = process.env.NETWORK || "dev"; const NETWORK_URL = process.env.WEB3_HTTP_URL || 'http://localhost:8547'; const CHAIN_ID = Number(process.env.CHAIN_ID) || 412346; const INFURA_KEY = process.env.INFURA_KEY || ""; @@ -29,7 +29,7 @@ const config: HardhatUserConfig = { url: `https://sepolia.infura.io/v3/${INFURA_KEY}`, accounts: [getAccount('admin').privateKey], }, - local_l2: { + dev: { url: NETWORK_URL, chainId: CHAIN_ID, accounts: [getAccount('admin').privateKey], diff --git a/hardhat/scripts/print-env.ts b/hardhat/scripts/print-env.ts index f2a0d916..164601d2 100644 --- a/hardhat/scripts/print-env.ts +++ b/hardhat/scripts/print-env.ts @@ -10,9 +10,9 @@ async function main() { }) console.log('export INFURA_KEY=') console.log('export LOG_LEVEL=info') - console.log('export NETWORK=geth') - console.log('export WEB3_RPC_URL=ws://localhost:8546') - console.log('export WEB3_CHAIN_ID=1337') + console.log('export NETWORK=dev') + console.log('export WEB3_RPC_URL=ws://localhost:8548') + console.log('export WEB3_CHAIN_ID=412346') } main().catch((error) => { diff --git a/hardhat/scripts/print-l2-config.ts b/hardhat/scripts/print-l2-config.ts index 96a2c372..1a6acc53 100644 --- a/hardhat/scripts/print-l2-config.ts +++ b/hardhat/scripts/print-l2-config.ts @@ -10,7 +10,7 @@ import { getStorageAddress, getUsersAddress } from '../utils/web3' - + async function main() { const controllerAddress = await getControllerAddress() const tokenAddress = await getTokenAddress() @@ -19,7 +19,7 @@ import { const paymentsAddress = await getPaymentsAddress() const storageAddress = await getStorageAddress() const usersAddress = await getUsersAddress() - + // console.log(`export WEB3_RPC_URL=ws://localhost:8548`) console.log('#################################################################################################') console.log(`export WEB3_CONTROLLER_ADDRESS=${controllerAddress}`) @@ -29,7 +29,7 @@ import { console.log(`export WEB3_PAYMENTS_ADDRESS=${paymentsAddress}`) console.log(`export WEB3_STORAGE_ADDRESS=${storageAddress}`) console.log(`export WEB3_USERS_ADDRESS=${usersAddress}`) - + // loop over accounts and print env for address and private key ACCOUNTS.forEach((account) => { @@ -42,15 +42,15 @@ import { console.log('export API_HOST=http://localhost:8002/') console.log('export INFURA_KEY=') console.log('export LOG_LEVEL=debug') - console.log('export NETWORK=local_l2') + console.log('export NETWORK=dev') console.log('export WEB3_RPC_URL=ws://localhost:8548') console.log('export WEB3_CHAIN_ID=412346') console.log('#################################################################################################') console.log("Optional: append the exports above to ~/.bashrc or ~/.bash_profile and run 'source ~/.bashrc' or 'source ~/.bash_profile' to set the environment variables.") // console.log("Example: code ~/.bashrc") } - + main().catch((error) => { console.error(error); process.exitCode = 1; - }); \ No newline at end of file + }); diff --git a/stack b/stack index dca45fd5..29ef6509 100755 --- a/stack +++ b/stack @@ -41,16 +41,16 @@ function chain-boot() { echo "- Install local dependencies" cd hardhat && npm install -y echo "- Fund services with ether" - npx hardhat run scripts/fund-services-ether.ts --network local_l2 + npx hardhat run scripts/fund-services-ether.ts --network dev echo "- Compile contracts" - npx hardhat compile --network local_l2 + npx hardhat compile --network dev cd .. go-bindings echo "- Deploy contracts" cd hardhat - npx hardhat deploy --network local_l2 + npx hardhat deploy --network dev echo "- Fund services with tokens" - npx hardhat run scripts/fund-services-tokens.ts --network local_l2 + npx hardhat run scripts/fund-services-tokens.ts --network dev echo "- Done" } @@ -114,7 +114,7 @@ function chain-clean(){ rm -rf $(pwd)/hardhat/artifacts rm -rf $(pwd)/hardhat/cache rm -rf $(pwd)/hardhat/deployments/geth - rm -rf $(pwd)/hardhat/deployments/local_l2 + rm -rf $(pwd)/hardhat/deployments/dev } ############################################################################ @@ -285,7 +285,7 @@ function integration-tests() { # run ############################################################################ function run() { - doppler run --preserve-env -p run -c dev -- go run . run "$@" + doppler run --preserve-env -p run -c dev -- go run . run --network dev "$@" } -eval "$@" \ No newline at end of file +eval "$@"