From 2939d549cd74a4350825e219a98ceccc2af78f4a Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Sun, 18 Aug 2024 12:31:51 -0400 Subject: [PATCH] Use optimism contracts image --- .../docker-compose-fixturenet-optimism.yml | 7 +++--- .../optimism-contracts/deploy-contracts.sh | 10 ++++---- .../cerc-optimism-contracts/Dockerfile | 24 ------------------- .../cerc-optimism-contracts/build.sh | 8 ++++++- 4 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 container-build/cerc-optimism-contracts/Dockerfile diff --git a/compose/docker-compose-fixturenet-optimism.yml b/compose/docker-compose-fixturenet-optimism.yml index b2f59ab..fce6bdc 100644 --- a/compose/docker-compose-fixturenet-optimism.yml +++ b/compose/docker-compose-fixturenet-optimism.yml @@ -20,14 +20,15 @@ services: CERC_PROPOSER_AMOUNT: ${CERC_PROPOSER_AMOUNT} CERC_BATCHER_AMOUNT: ${CERC_BATCHER_AMOUNT} volumes: - - ../config/network/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh - - ../config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh:/app/packages/contracts-bedrock/deploy-contracts.sh + - ../config/network/wait-for-it.sh:/wait-for-it.sh + - ../config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh:/deploy-contracts.sh - l2_accounts:/l2-accounts - l1_deployment:/l1-deployment - l2_config:/l2-config + entrypoint: ["sh", "-c"] # Waits for L1 endpoint to be up before running the contract deploy script command: | - "./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- ./deploy-contracts.sh" + "/wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- /deploy-contracts.sh" extra_hosts: - "host.docker.internal:host-gateway" diff --git a/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh b/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh index 678f6c7..618f462 100755 --- a/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh +++ b/config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh @@ -157,7 +157,7 @@ if [ "$create2CodeSize" -eq 0 ]; then fi # Create the L2 deployment -# Writes out artifact to /app/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json +# Writes out artifact to $OPTIMISM_ROOT/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json echo "Deploying L1 Optimism contracts..." DEPLOY_CONFIG_PATH=$deploy_config_file forge script scripts/deploy/Deploy.s.sol:Deploy --private-key $ADMIN_KEY --broadcast --rpc-url $CERC_L1_RPC echo "Done deploying contracts." @@ -168,14 +168,16 @@ DEPLOY_CONFIG_PATH=$deploy_config_file \ CONTRACT_ADDRESSES_PATH=deployments/$DEPLOYMENT_CONTEXT-deploy.json \ forge script --chain-id $L2_CHAIN_ID scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithAllUpgrades()' --private-key $ADMIN_KEY -cp /app/packages/contracts-bedrock/state-dump-$L2_CHAIN_ID.json allocs-l2.json +OPTIMISM_ROOT=/opt/optimism + +cp $OPTIMISM_ROOT/contracts-bedrock/state-dump-$L2_CHAIN_ID.json allocs-l2.json echo "Done." echo "*************************************" # Copy files needed by other containers to the appropriate shared volumes echo "Copying deployment artifacts volume l1_deployment and deploy-config to volume l2_config" -cp /app/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json /l1-deployment -cp /app/packages/contracts-bedrock/deploy-config/$DEPLOYMENT_CONTEXT.json /l2-config +cp $OPTIMISM_ROOT/packages/contracts-bedrock/deployments/$DEPLOYMENT_CONTEXT-deploy.json /l1-deployment +cp $OPTIMISM_ROOT/packages/contracts-bedrock/deploy-config/$DEPLOYMENT_CONTEXT.json /l2-config cp allocs-l2.json /l2-config echo "Deployment successful. Exiting" diff --git a/container-build/cerc-optimism-contracts/Dockerfile b/container-build/cerc-optimism-contracts/Dockerfile deleted file mode 100644 index 38bd6c4..0000000 --- a/container-build/cerc-optimism-contracts/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# TODO: Make work for arm64/Apple Silicon -FROM ghcr.io/foundry-rs/foundry:nightly-c4a984fbf2c48b793c8cd53af84f56009dd1070c - -RUN apk update - -# Install node (use edge repo to get latest version) -RUN apk add --update --no-cache curl wget bash git busybox jq openssl \ - && apk add nodejs --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main --allow-untrusted \ - && apk add npm \ - && node -v - -# Add corepack for yarn and pnpm -RUN npm install -g corepack && corepack enable \ - && yarn --version - -WORKDIR /app - -# Copy optimism repo contents -COPY . . - -RUN echo "Building optimism" && \ - pnpm install && pnpm build - -WORKDIR /app/packages/contracts-bedrock diff --git a/container-build/cerc-optimism-contracts/build.sh b/container-build/cerc-optimism-contracts/build.sh index b1ddd81..c666159 100755 --- a/container-build/cerc-optimism-contracts/build.sh +++ b/container-build/cerc-optimism-contracts/build.sh @@ -6,4 +6,10 @@ source ${CERC_CONTAINER_BASE_DIR}/build-base.sh # See: https://stackoverflow.com/a/246128/1701505 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -docker build -t cerc/optimism-contracts:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/optimism +# The optimism contracts image has dependencies with no aarch64 support, so on aarch64 use an +# emulated amd64 image +if [[ $(docker info --format='{{ .Architecture }}') == "aarch64" ]]; then + PLATFORM_ARG="--platform linux/amd64" +fi + +docker build -t cerc/optimism-contracts:local -f ${CERC_REPO_BASE_DIR}/optimism/ops/docker/Dockerfile.packages ${build_command_args} ${CERC_REPO_BASE_DIR}/optimism $PLATFORM_ARG