Skip to content

Commit

Permalink
Merge pull request #72 from OffchainLabs/skip-rebuild-opt
Browse files Browse the repository at this point in the history
Clarify logic around dev builds and rebuilding
  • Loading branch information
Tristan-Wilson authored Sep 4, 2024
2 parents 94b04c3 + a7c9f53 commit a5534b6
Showing 1 changed file with 102 additions and 49 deletions.
151 changes: 102 additions & 49 deletions test-node.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -eu

NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.1.0-7d1d84c-dev
BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.1.0-0e716c8
Expand Down Expand Up @@ -35,22 +35,31 @@ else
fi

run=true
force_build=false
validate=false
detach=false
blockscout=false
tokenbridge=false
l3node=false
consensusclient=false
redundantsequencers=0
dev_build_nitro=false
dev_build_blockscout=false
l3_custom_fee_token=false
l3_token_bridge=false
batchposters=1
devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
l1chainid=1337
simple=true

# Use the dev versions of nitro/blockscout
dev_nitro=false
dev_blockscout=false

# Rebuild docker images
build_dev_nitro=false
build_dev_blockscout=false
build_utils=false
force_build_utils=false
build_node_images=false

while [[ $# -gt 0 ]]; do
case $1 in
--init)
Expand All @@ -59,6 +68,8 @@ while [[ $# -gt 0 ]]; do
read -p "are you sure? [y/n]" -n 1 response
if [[ $response == "y" ]] || [[ $response == "Y" ]]; then
force_init=true
build_utils=true
build_node_images=true
echo
else
exit 0
Expand All @@ -68,28 +79,72 @@ while [[ $# -gt 0 ]]; do
;;
--init-force)
force_init=true
build_utils=true
build_node_images=true
shift
;;
--dev)
simple=false
shift
if [[ $# -eq 0 || $1 == -* ]]; then
# If no argument after --dev, set both flags to true
dev_build_nitro=true
dev_build_blockscout=true
dev_nitro=true
build_dev_nitro=true
dev_blockscout=true
build_dev_blockscout=true
else
while [[ $# -gt 0 && $1 != -* ]]; do
if [[ $1 == "nitro" ]]; then
dev_build_nitro=true
dev_nitro=true
build_dev_nitro=true
elif [[ $1 == "blockscout" ]]; then
dev_build_blockscout=true
dev_blockscout=true
build_dev_blockscout=true
fi
shift
done
fi
;;
--build)
force_build=true
build_dev_nitro=true
build_dev_blockscout=true
build_utils=true
build_node_images=true
shift
;;
--no-build)
build_dev_nitro=false
build_dev_blockscout=false
build_utils=false
build_node_images=false
shift
;;
--build-dev-nitro)
build_dev_nitro=true
shift
;;
--no-build-dev-nitro)
build_dev_nitro=false
shift
;;
--build-dev-blockscout)
build_dev_blockscout=true
shift
;;
--no-build-dev-blockscout)
build_dev_blockscout=false
shift
;;
--build-utils)
build_utils=true
shift
;;
--no-build-utils)
build_utils=false
shift
;;
--force-build-utils)
force_build_utils=true
shift
;;
--validate)
Expand Down Expand Up @@ -176,6 +231,7 @@ while [[ $# -gt 0 ]]; do
echo
echo OPTIONS:
echo --build rebuild docker images
echo --no-build don\'t rebuild docker images
echo --dev build nitro and blockscout dockers from source instead of pulling them. Disables simple mode
echo --init remove all data, rebuild, deploy new rollup
echo --pos l1 is a proof-of-stake chain \(using prysm for consensus\)
Expand All @@ -192,28 +248,19 @@ while [[ $# -gt 0 ]]; do
echo --no-tokenbridge don\'t build or launch tokenbridge
echo --no-run does not launch nodes \(useful with build or init\)
echo --no-simple run a full configuration with separate sequencer/batch-poster/validator/relayer
echo --build-dev-nitro rebuild dev nitro docker image
echo --no-build-dev-nitro don\'t rebuild dev nitro docker image
echo --build-dev-blockscout rebuild dev blockscout docker image
echo --no-build-dev-blockscout don\'t rebuild dev blockscout docker image
echo --build-utils rebuild scripts, rollupcreator, token bridge docker images
echo --no-build-utils don\'t rebuild scripts, rollupcreator, token bridge docker images
echo --force-build-utils force rebuilding utils, useful if NITRO_CONTRACTS_ or TOKEN_BRIDGE_BRANCH changes
echo
echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help
exit 0
esac
done

if $force_init; then
force_build=true
fi

if $dev_build_nitro; then
if [[ "$(docker images -q nitro-node-dev:latest 2> /dev/null)" == "" ]]; then
force_build=true
fi
fi

if $dev_build_blockscout; then
if [[ "$(docker images -q blockscout:latest 2> /dev/null)" == "" ]]; then
force_build=true
fi
fi

NODES="sequencer"
INITIAL_SEQ_NODES="sequencer"

Expand Down Expand Up @@ -253,51 +300,56 @@ fi
if $blockscout; then
NODES="$NODES blockscout"
fi
if $force_build; then
echo == Building..
if $dev_build_nitro; then
if ! [ -n "${NITRO_SRC+set}" ]; then
NITRO_SRC=`dirname $PWD`
fi
if ! grep ^FROM "${NITRO_SRC}/Dockerfile" | grep nitro-node 2>&1 > /dev/null; then
echo nitro source not found in "$NITRO_SRC"
echo execute from a sub-directory of nitro or use NITRO_SRC environment variable
exit 1
fi
docker build "$NITRO_SRC" -t nitro-node-dev --target nitro-node-dev


if $dev_nitro && $build_dev_nitro; then
echo == Building Nitro
if ! [ -n "${NITRO_SRC+set}" ]; then
NITRO_SRC=`dirname $PWD`
fi
if $dev_build_blockscout; then
if $blockscout; then
docker build blockscout -t blockscout -f blockscout/docker/Dockerfile
fi
if ! grep ^FROM "${NITRO_SRC}/Dockerfile" | grep nitro-node 2>&1 > /dev/null; then
echo nitro source not found in "$NITRO_SRC"
echo execute from a sub-directory of nitro or use NITRO_SRC environment variable
exit 1
fi
docker build "$NITRO_SRC" -t nitro-node-dev --target nitro-node-dev
fi
if $dev_blockscout && $build_dev_blockscout; then
if $blockscout; then
echo == Building Blockscout
docker build blockscout -t blockscout -f blockscout/docker/Dockerfile
fi
fi

if $build_utils; then
LOCAL_BUILD_NODES="scripts rollupcreator"
if $tokenbridge || $l3_token_bridge; then
LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge"
fi
docker compose build --no-rm $LOCAL_BUILD_NODES
UTILS_NOCACHE=""
if $force_build_utils; then
UTILS_NOCACHE="--no-cache"
fi
docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES
fi

if $dev_build_nitro; then
if $dev_nitro; then
docker tag nitro-node-dev:latest nitro-node-dev-testnode
else
docker pull $NITRO_NODE_VERSION
docker tag $NITRO_NODE_VERSION nitro-node-dev-testnode
fi

if $dev_build_blockscout; then
if $blockscout; then
if $blockscout; then
if $dev_blockscout; then
docker tag blockscout:latest blockscout-testnode
fi
else
if $blockscout; then
else
docker pull $BLOCKSCOUT_VERSION
docker tag $BLOCKSCOUT_VERSION blockscout-testnode
fi
fi

if $force_build; then
if $build_node_images; then
docker compose build --no-rm $NODES scripts
fi

Expand Down Expand Up @@ -417,6 +469,7 @@ if $force_init; then
echo l3owneraddress $l3owneraddress
docker compose run scripts --l2owner $l3owneraddress write-l3-chain-config

EXTRA_L3_DEPLOY_FLAG=""
if $l3_custom_fee_token; then
echo == Deploying custom fee token
nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --mintTo user_token_bridge_deployer --bridgeable $tokenbridge | tail -n 1 | awk '{ print $NF }'`
Expand Down

0 comments on commit a5534b6

Please sign in to comment.