Skip to content

Commit

Permalink
Rhoop/docker compose and k8 2 (#292)
Browse files Browse the repository at this point in the history
* merge magi updates and changes from broken branch

* Added tx-fuzz

* encapsulate secret path for ambigious redirect error

* lots of changes to get k8 working

* shfmt fixes

---------

Co-authored-by: Richard Hoop <[email protected]>
Co-authored-by: macwis <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2024
1 parent 7c0de79 commit c3e5ad6
Show file tree
Hide file tree
Showing 11 changed files with 303 additions and 28 deletions.
1 change: 0 additions & 1 deletion config/local_docker/.genesis.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ GENESIS_PATH=./genesis.json
BASE_ROLLUP_CFG_PATH=./base_sp_rollup.json
ROLLUP_CFG_PATH=./sp_rollup.json
GENESIS_EXPORTED_HASH_PATH=./genesis_hash.json

L1_NETWORK=localhost
L1_STACK=geth
L1_ENDPOINT=ws://0.0.0.0:8545
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
tty: true
healthcheck:
test: bash -c "[ -f /tmp/.l1_started.lock ]"
test: bash -c "[ -f /tmp/.l1_started.sh.lock ]"
retries: 10
interval: 5s
start_period: 40s
Expand Down Expand Up @@ -43,7 +43,7 @@ services:
l1-geth:
condition: service_healthy
healthcheck:
test: bash -c "[ -f /tmp/.sp_geth_started.lock ]"
test: bash -c "[ -f /tmp/.start_sp_geth.sh.lock ]"
retries: 10
interval: 5s
start_period: 40s
Expand All @@ -67,7 +67,7 @@ services:
sp-geth:
condition: service_healthy
healthcheck:
test: bash -c "[ -f /tmp/.sp_magi_started.lock ]"
test: bash -c "[ -f /tmp/.sp_magi_started.sh.lock ]"
retries: 10
interval: 5s
start_period: 20s
Expand Down
123 changes: 123 additions & 0 deletions docker/docker-compose-local-devel-tx-fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
version: '3.8'

services:

#------- Secrets
generator:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: /bin/bash ../sbin/generate_secrets.sh -d -j -y

#------- L1
l1-geth:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
tty: true
healthcheck:
test: bash -c "[ -f /tmp/.start_l1.sh.lock ]"
retries: 60
interval: 5s
start_period: 40s
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: /bin/bash ../sbin/start_l1.sh -c -d -w -y
depends_on:
generator:
condition: service_completed_successfully
networks:
specular:
ipv4_address: 192.168.160.2
ports:
- "8545:8545"


#------- GETH
sp-geth:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
restart: on-failure
depends_on:
l1-geth:
condition: service_healthy
healthcheck:
test: bash -c "[ -f /tmp/.start_sp_geth.sh.lock ]"
retries: 10
interval: 5s
start_period: 40s
working_dir: /specular/workspace
entrypoint: ../sbin/start_sp_geth.sh -c -w
networks:
specular:
ipv4_address: 192.168.160.3
ports:
- "4011:4011"
- "4012:4012"
- "4013:4013"



#------- MAGI
sp-magi:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
restart: on-failure
depends_on:
sp-geth:
condition: service_healthy
healthcheck:
test: bash -c "[ -f /tmp/.start_sp_magi.sh.lock ]"
retries: 10
interval: 5s
start_period: 20s
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: bash ../sbin/start_sp_magi.sh
networks:
specular:
ipv4_address: 192.168.160.4

#------- SIDECAR
sidecar:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
restart: on-failure
depends_on:
sp-magi:
condition: service_healthy
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: bash ../sbin/start_sidecar.sh
networks:
specular:
ipv4_address: 192.168.160.5

#------- TX-FUZZ
tx-fuzz:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:tx-fuzz
restart: on-failure
depends_on:
sp-geth:
condition: service_healthy
volumes:
- ../workspace:/tmp
entrypoint: /tx-fuzz.bin spam --sk `cat /tmp/workspace/validator_pk.txt` --rpc http://192.168.160.3:4011 --txcount 2
networks:
specular:
ipv4_address: 192.168.160.6

networks:
specular:
name: sp_network
ipam:
config:
- subnet: 192.168.160.0/24


107 changes: 107 additions & 0 deletions docker/docker-compose-local-devel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
version: '3.8'

services:

#------- Secrets
generator:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: /bin/bash ../sbin/generate_secrets.sh -d -j -y

#------- L1
l1-geth:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
tty: true
healthcheck:
test: bash -c "[ -f /tmp/.start_l1.sh.lock ]"
retries: 60
interval: 5s
start_period: 40s
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: /bin/bash ../sbin/start_l1.sh -c -d -w -y
depends_on:
generator:
condition: service_completed_successfully
networks:
specular:
ipv4_address: 192.168.160.2
ports:
- "8545:8545"


#------- GETH
sp-geth:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
restart: on-failure
depends_on:
l1-geth:
condition: service_healthy
healthcheck:
test: bash -c "[ -f /tmp/.start_sp_geth.sh.lock ]"
retries: 10
interval: 5s
start_period: 40s
working_dir: /specular/workspace
entrypoint: ../sbin/start_sp_geth.sh -c -w
networks:
specular:
ipv4_address: 192.168.160.3
ports:
- "4011:4011"
- "4012:4012"
- "4013:4013"



#------- MAGI
sp-magi:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
restart: on-failure
depends_on:
sp-geth:
condition: service_healthy
healthcheck:
test: bash -c "[ -f /tmp/.start_sp_magi.sh.lock ]"
retries: 10
interval: 5s
start_period: 20s
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: bash ../sbin/start_sp_magi.sh
networks:
specular:
ipv4_address: 192.168.160.4

#------- SIDECAR
sidecar:
image: 792926601177.dkr.ecr.us-east-2.amazonaws.com/specular-platform:specular-latest
restart: on-failure
depends_on:
sp-magi:
condition: service_healthy
volumes:
- ../workspace:/specular/workspace
- ../sbin:/specular/sbin
working_dir: /specular/workspace
entrypoint: bash ../sbin/start_sidecar.sh
networks:
specular:
ipv4_address: 192.168.160.5

networks:
specular:
name: sp_network
ipam:
config:
- subnet: 192.168.160.0/24
8 changes: 4 additions & 4 deletions docker/sp-geth.Dockerfile → docker/specular.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ RUN npm install -g pnpm
RUN pnpm install


COPY --from=build /specular/config/kubernetes /specular/workspace
COPY --from=build /specular/sbin /specular/sbin
# COPY --from=build /specular/config/local_docker /specular/workspace
# COPY --from=build /specular/sbin /specular/sbin

# DEBUG/LOCAL BUILD
# COPY ../config/local_docker /specular/workspace
# COPY ../sbin /specular/sbin
COPY ../config/local_docker /specular/workspace
COPY ../sbin /specular/sbin
# COPY ../services /specular/services

WORKDIR /specular/workspace
Expand Down
4 changes: 2 additions & 2 deletions sbin/clean_sp_geth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ fi
echo "Removing sp-geth data dir $DATA_DIR"
rm -rf $DATA_DIR

if test -f .sp_geth_started.lock; then
if test -f .start_sp_geth.sh.lock; then

echo "Removing docker lock file"
L1_WAIT=$WAIT_DIR/.sp_geth_started.lock
L1_WAIT=$WAIT_DIR/.start_sp_geth.sh.lock
fi
30 changes: 27 additions & 3 deletions sbin/generate_secrets.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
optspec="djy"
optspec="djyw"
NUM_ACCOUNTS=0
AUTO_ACCEPT=false
while getopts "$optspec" optchar; do
Expand All @@ -13,11 +13,15 @@ while getopts "$optspec" optchar; do
j)
GEN_JWT=true
;;
w)
L1_WAIT=true
;;
*)
echo "usage: $0 [-d][-j][-y][-h]"
echo "usage: $0 [-d][-j][-y][-h][-w]"
echo "-d : generate deployer"
echo "-j : generate jwt secret"
echo "-y : auto accept prompts"
echo "-w : generate docker-compose wait for file"
exit
;;
esac
Expand All @@ -35,6 +39,21 @@ ROOT_DIR=$SBIN/..

reqdotenv "sp_magi" ".sp_magi.env"
reqdotenv "sidecar" ".sidecar.env"
reqdotenv "paths" ".paths.env"

# Generate waitfile for service init (docker/k8)
WAITFILE="/tmp/.${0##*/}.lock"

if [[ ! -z ${WAIT_DIR+x} ]]; then
WAITFILE=$WAIT_DIR/.${0##*/}.lock
fi

if [ "$L1_WAIT" = "true" ]; then
if test -f $WAITFILE; then
echo "Removing wait file for docker..."
rm $WAITFILE
fi
fi

CONTRACTS_ENV=".contracts.env"
guard_overwrite $CONTRACTS_ENV $AUTO_ACCEPT
Expand Down Expand Up @@ -67,5 +86,10 @@ fi

if [ "$GEN_JWT" = "true" ]; then
JWT=$(generate_jwt_secret)
echo $JWT >$JWT_SECRET_PATH
echo $JWT >"$JWT_SECRET_PATH"
fi

if [ "$L1_WAIT" = "true" ]; then
echo "Creating wait file for docker at $WAITFILE..."
touch $WAITFILE
fi
Loading

0 comments on commit c3e5ad6

Please sign in to comment.