Skip to content

Commit

Permalink
build: Update configuration and workflows for Devnet (#152)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
bgins and AquiGorka committed Jun 13, 2024
1 parent 689ab42 commit 6ca4289
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 55 deletions.
49 changes: 12 additions & 37 deletions .github/workflows/devnet_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || "";
Expand All @@ -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],
Expand Down
6 changes: 3 additions & 3 deletions hardhat/scripts/print-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
12 changes: 6 additions & 6 deletions hardhat/scripts/print-l2-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getStorageAddress,
getUsersAddress
} from '../utils/web3'

async function main() {
const controllerAddress = await getControllerAddress()
const tokenAddress = await getTokenAddress()
Expand All @@ -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}`)
Expand All @@ -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) => {
Expand All @@ -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;
});
});
14 changes: 7 additions & 7 deletions stack
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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
}

############################################################################
Expand Down Expand Up @@ -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 "$@"
eval "$@"

0 comments on commit 6ca4289

Please sign in to comment.