Skip to content

Commit

Permalink
First pass at dev environment for proxy colonies
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Aug 12, 2024
1 parent 8cca59f commit 831310f
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docker/colony-cdapp-dev-env-network
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM colony-cdapp-dev-env/base:latest

ENV NETWORK_HASH=b20c6962b8be9ec89bef83051f3d4f7a8635726d
ENV NETWORK_HASH=45f052f5a680da3487d5a86c8f69909cf25d21f3

# Declare volumes to set up metadata
VOLUME [ "/colonyCDapp/amplify/mock-data" ]
Expand Down Expand Up @@ -30,6 +30,8 @@ RUN git submodule update --init --recursive --depth 1
# Install required network dependencies
RUN pnpm i --frozen-lockfile

RUN npx hardhat compile

# Initialize the justification tree cache
# To avoid the error spewed by the miner at startup
RUN echo "{}" > ./packages/reputation-miner/justificationTreeCache.json
Expand Down
17 changes: 17 additions & 0 deletions docker/colony-cdapp-dev-env-network-remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM colony-cdapp-dev-env/network:latest
# Add dependencies from the host
# Note: these are listed individually so that if they change, they won't affect
# the build of the other images
ADD docker/files/network-remote/run.sh.base /colonyCDappBackend/run.sh

WORKDIR /colonyCDappBackend

# Open up ports to the docker image
# Ganache
EXPOSE 8545

# Make the run script executable
RUN chmod +x ./run.sh

# Battlecruiser Operational!
CMD [ "./run.sh" ]
33 changes: 33 additions & 0 deletions docker/colony-cdapp-dev-env-network-wormhole-relayer
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM colony-cdapp-dev-env/network:latest
# Add dependencies from the host
# Note: these are listed individually so that if they change, they won't affect
# the build of the other images
ADD docker/files/network-wormhole-relayer/run.sh.base /colonyCDappBackend/run.sh

WORKDIR /colonyCDappBackend

# Open up ports to the docker image
# Ganache
# EXPOSE 8545

RUN apt-get update
RUN apt-get install -y ca-certificates curl
RUN install -m 0755 -d /etc/apt/keyrings
RUN curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
RUN chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update
RUN apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

RUN cd ./colonyNetwork/lib/wormhole/sdk/js-proto-node && npm i

# Make the run script executable
RUN chmod +x ./run.sh

# Battlecruiser Operational!
CMD [ "./run.sh" ]
47 changes: 47 additions & 0 deletions docker/colony-cdapp-dev-env-orchestration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,40 @@ services:
amplify-setup:
condition: service_completed_successfully

network-contracts-remote:
container_name: 'network-remote'
image: colony-cdapp-dev-env/network-remote:latest
volumes:
- 'amplify-mock-data:/colonyCDapp/amplify/mock-data'
ports:
- '8546:8545'
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8545']
interval: 5s
retries: 1000
depends_on:
amplify-setup:
condition: service_completed_successfully
environment:
CHAIN_ID: 265669101

network-contracts-remote-2:
container_name: 'network-remote-2'
image: colony-cdapp-dev-env/network-remote:latest
volumes:
- 'amplify-mock-data:/colonyCDapp/amplify/mock-data'
ports:
- '8547:8545'
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8545']
interval: 5s
retries: 1000
depends_on:
amplify-setup:
condition: service_completed_successfully
environment:
CHAIN_ID: 265669102

reputation-monitor:
container_name: 'monitor'
image: colony-cdapp-dev-env/reputation-monitor:latest
Expand Down Expand Up @@ -104,6 +138,19 @@ services:
network-contracts:
condition: service_healthy

wormhole-relayer:
container_name: 'wormhole-relayer'
image: colony-cdapp-dev-env/network-wormhole-relayer:latest
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
depends_on:
network-contracts:
condition: service_healthy
network-contracts-remote:
condition: service_healthy
network-contracts-remote-2:
condition: service_healthy

volumes:
amplify-backend:
amplify-mock-data:
17 changes: 17 additions & 0 deletions docker/files/network-remote/run.sh.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

cd colonyNetwork

# Ganache

# Uncomment the line below if you need ganache to run in verbose mode
# sed -i 's/100000000000000000000" >\/dev\/null 2>&1/100000000000000000000" --verbose/g' scripts/start-blockchain-client.sh
# sed -i 's/--db $DBPATH/--db $DBPATH --server.host "0.0.0.0"/g' scripts/start-blockchain-client.sh
pnpm run start:blockchain:client

# Colony Network Contracts

npx hardhat compile
npx hardhat deploy-proxy-network --network development

sleep infinity
48 changes: 48 additions & 0 deletions docker/files/network-wormhole-relayer/run.sh.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
cd ./colonyNetwork/lib/wormhole/ && DOCKER_BUILDKIT=1 docker build --target node-export -f Dockerfile.proto -o type=local,dest=. .
cd ../.. && npx tsc --esModuleInterop --downlevelIteration ./scripts/mockGuardianSpy.ts

cd ./lib/safe-contracts

# This is the private key for the first account we create on ganache, so has ether to pay for gas fees
rm -rf ./deployments/custom
PK="0x0355596cdb5e5242ad082c4fe3f8bbe48c9dba843fe1f99dd8272f487e70efae" NODE_URL=http://network:8545 npx hardhat deploy --network custom

rm -rf ./deployments/custom
PK="0x0355596cdb5e5242ad082c4fe3f8bbe48c9dba843fe1f99dd8272f487e70efae" NODE_URL=http://network-remote:8545 npx hardhat deploy --network custom

rm -rf ./deployments/custom
PK="0x0355596cdb5e5242ad082c4fe3f8bbe48c9dba843fe1f99dd8272f487e70efae" NODE_URL=http://network-remote-2:8545 npx hardhat deploy --network custom

cd ../../

echo "const wormhole = require("@certusone/wormhole-sdk");
module.exports = {
chains: {
[wormhole.CHAIN_ID_ARBITRUM_SEPOLIA]: {
endpoints: ["http://localhost:8545"],
colonyBridgeAddress: "0x633899227A3BC1f79de097149E1E3C8097c07b1a",
payForGas: true,
evmChainId: 265669100,
},
[wormhole.CHAIN_ID_SEPOLIA]: {
endpoints: ["http://localhost:8546"],
colonyBridgeAddress: "0x161944B5601a7d3004E20d4Ca823F710838Ea1be",
payForGas: true,
evmChainId: 265669101,
},
[wormhole.CHAIN_ID_OPTIMISM_SEPOLIA]: {
endpoints: ["http://localhost:8547"],
colonyBridgeAddress: "0x161944B5601a7d3004E20d4Ca823F710838Ea1be",
payForGas: false,
evmChainId: 265669102,
},
}
},
};
" > ./packages/wormhole-relayer/config.js

node -e 'require("./scripts/setup-bridging-contracts.js").setupBridging("http://network:8545", ["http://network-remote:8545", "http://network-remote-2:8545"])'

sleep infinity
2 changes: 1 addition & 1 deletion docker/files/network/run.sh.base
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cd colonyNetwork
# Uncomment the line below if you need ganache to run in verbose mode
# sed -i 's/100000000000000000000" >\/dev\/null 2>&1/100000000000000000000" --verbose/g' scripts/start-blockchain-client.sh
# sed -i 's/--db $DBPATH/--db $DBPATH --server.host "0.0.0.0"/g' scripts/start-blockchain-client.sh
pnpm run start:blockchain:client &
pnpm run start:blockchain:client

# Colony Network Contracts

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"scripts": {
"docker:build:base": "DOCKER_BUILDKIT=1 docker build --build-arg AMAZON_ARCH_FLAG=$(bash scripts/amazon-arch-flag.sh) --tag colony-cdapp-dev-env/base --file ./docker/colony-cdapp-dev-env-base .",
"docker:build:network": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/network --file ./docker/colony-cdapp-dev-env-network .",
"docker:build:network-remote": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/network-remote --file ./docker/colony-cdapp-dev-env-network-remote .",
"docker:build:network-wormhole-relayer": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/network-wormhole-relayer --file ./docker/colony-cdapp-dev-env-network-wormhole-relayer .",
"docker:build:monitor": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/reputation-monitor --file ./docker/colony-cdapp-dev-env-reputation-monitor .",
"docker:build:mocking": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/mocking --file ./docker/colony-cdapp-dev-env-mocking .",
"docker:build:ingestor": "DOCKER_BUILDKIT=1 docker build --ulimit nofile=5000:5000 --tag colony-cdapp-dev-env/block-ingestor --file ./docker/colony-cdapp-dev-env-block-ingestor .",
"docker:build:amplify": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/amplify --file ./docker/colony-cdapp-dev-env-amplify .",
"docker:build:safe": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/safe --file ./docker/colony-cdapp-dev-env-safe .",
"docker:build:auth": "DOCKER_BUILDKIT=1 docker build --tag colony-cdapp-dev-env/auth-proxy --file ./docker/colony-cdapp-dev-env-auth-proxy .",
"docker:build:core": "npm run docker:build:base && npm run docker:build:network && npm run docker:build:monitor && npm run docker:build:mocking && npm run docker:build:ingestor && npm run docker:build:amplify && npm run docker:build:auth",
"docker:build:all": "npm run docker:build:base && npm run docker:build:network && npm run docker:build:monitor && npm run docker:build:mocking && npm run docker:build:ingestor && npm run docker:build:amplify && npm run docker:build:safe && npm run docker:build:auth",
"docker:build:core": "npm run docker:build:base && npm run docker:build:network && npm run docker:build:network-remote && npm run docker:build:network-wormhole-relayer && npm run docker:build:monitor && npm run docker:build:mocking && npm run docker:build:ingestor && npm run docker:build:amplify && npm run docker:build:auth",
"docker:build:all": "npm run docker:build:base && npm run docker:build:network && npm run docker:build:network-remote && && npm run docker:build:network-wormhole-relayer && npm run docker:build:monitor && npm run docker:build:mocking && npm run docker:build:ingestor && npm run docker:build:amplify && npm run docker:build:safe && npm run docker:build:auth",
"docker:compose:core": "docker compose --file docker/colony-cdapp-dev-env-orchestration.yaml",
"docker:compose:all": "docker compose --file docker/colony-cdapp-dev-env-orchestration-all.yaml",
"dev": "npm run watch-amplify & npm run docker:build:core && npm run docker:compose:core up -- --force-recreate -V",
Expand Down

0 comments on commit 831310f

Please sign in to comment.