From 720fbb961869b4b70ebfb6920218944cbd401182 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 7 Aug 2024 13:19:44 +0200 Subject: [PATCH 1/6] Disable rebuild of dev docker imgs w --build false --- test-node.bash | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test-node.bash b/test-node.bash index dd112c95..96bb9d2d 100755 --- a/test-node.bash +++ b/test-node.bash @@ -38,6 +38,7 @@ fi run=true force_build=false +skip_build=false validate=false detach=false blockscout=false @@ -91,8 +92,19 @@ while [[ $# -gt 0 ]]; do fi ;; --build) - force_build=true shift + if [[ $# -eq 0 || $1 == -* ]]; then + # If no argument after --build, set flag to true + force_build=true + else + while [[ $# -gt 0 && $1 != -* ]]; do + if [[ $1 == "false" ]]; then + force_build=false + skip_build=true + fi + shift + done + fi ;; --validate) simple=false @@ -177,7 +189,7 @@ while [[ $# -gt 0 ]]; do echo $0 script [SCRIPT-ARGS] echo echo OPTIONS: - echo --build rebuild docker images + echo --build rebuild docker images. --build false disables rebuild 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\) @@ -200,17 +212,17 @@ while [[ $# -gt 0 ]]; do esac done -if $force_init; then +if ! $skip_build && $force_init; then force_build=true fi -if $dev_build_nitro; then +if ! $skip_build && $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 ! $skip_build && $dev_build_blockscout; then if [[ "$(docker images -q blockscout:latest 2> /dev/null)" == "" ]]; then force_build=true fi From 26ffe7d84206856d1baa47c99743eb8188469a2d Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 12 Aug 2024 12:35:50 +0200 Subject: [PATCH 2/6] Clarify logic around dev builds and rebuilding The concepts of using the dev builds for nitro and blockscout and rebuilding are now split into different variables internally to the test-node.bash script and can be controlled independently. The --dev flag by itself means to use the dev builds and to rebuild them. --no-build-dev-nitro and -no-build-dev-blockscout disable rebuilding the respective dev images. --no-build disables rebuilding the dev images and also rebuilding contracts related images, and the node images. This finer grained control saves time in the development cycle by allowing the user to rebuild only what is needed. An example command line to reinitialize the blockchain, use the dev images, but not rebuild anything except blockscout would be: ./test-node.bash --init --dev --no-build --build-dev-blockscout --blockscout Flags are read from left to right; flags to the right cancel the effects of flags to the left. --- test-node.bash | 147 +++++++++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 60 deletions(-) diff --git a/test-node.bash b/test-node.bash index 96bb9d2d..2bdb5133 100755 --- a/test-node.bash +++ b/test-node.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -eu NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 @@ -37,7 +37,6 @@ else fi run=true -force_build=false skip_build=false validate=false detach=false @@ -46,14 +45,23 @@ 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_contracts=false +build_node_images=false + while [[ $# -gt 0 ]]; do case $1 in --init) @@ -78,33 +86,60 @@ while [[ $# -gt 0 ]]; do 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) + build_dev_nitro=true + build_dev_blockscout=true + build_contracts=true + build_node_images=true + shift + ;; + --no-build) + build_dev_nitro=false + build_dev_blockscout=false + build_contracts=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-contracts) + build_contracts=true + shift + ;; + --no-build-contracts) + build_contracts=false shift - if [[ $# -eq 0 || $1 == -* ]]; then - # If no argument after --build, set flag to true - force_build=true - else - while [[ $# -gt 0 && $1 != -* ]]; do - if [[ $1 == "false" ]]; then - force_build=false - skip_build=true - fi - shift - done - fi ;; --validate) simple=false @@ -189,7 +224,8 @@ while [[ $# -gt 0 ]]; do echo $0 script [SCRIPT-ARGS] echo echo OPTIONS: - echo --build rebuild docker images. --build false disables rebuild + 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\) @@ -206,28 +242,18 @@ 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-contracts rebuild contracts related docker images + echo --no-build-contracts rebuild contracts related docker images echo echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help exit 0 esac done -if ! $skip_build && $force_init; then - force_build=true -fi - -if ! $skip_build && $dev_build_nitro; then - if [[ "$(docker images -q nitro-node-dev:latest 2> /dev/null)" == "" ]]; then - force_build=true - fi -fi - -if ! $skip_build && $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" @@ -267,25 +293,28 @@ 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_contracts; then LOCAL_BUILD_NODES="scripts rollupcreator" if $tokenbridge || $l3_token_bridge; then LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge" @@ -293,25 +322,23 @@ if $force_build; then docker compose build --no-rm $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 From 0e22925fbd2c6df9636a78b430629eb553ab5c87 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 12 Aug 2024 12:45:50 +0200 Subject: [PATCH 3/6] No skip_build --- test-node.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index 2bdb5133..c202a470 100755 --- a/test-node.bash +++ b/test-node.bash @@ -37,7 +37,6 @@ else fi run=true -skip_build=false validate=false detach=false blockscout=false From aae904b31c95c7931e197a57cb873377cdef9ac2 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 13 Aug 2024 13:52:28 +0200 Subject: [PATCH 4/6] Contracts and node images should rebuild on --init --- test-node.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test-node.bash b/test-node.bash index c202a470..4fa253a8 100755 --- a/test-node.bash +++ b/test-node.bash @@ -69,6 +69,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_contracts=true + build_node_images=true echo else exit 0 @@ -78,6 +80,8 @@ while [[ $# -gt 0 ]]; do ;; --init-force) force_init=true + build_contracts=true + build_node_images=true shift ;; --dev) From 4732c5d0278e85e291b9d425b7a6361be1bcae25 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 13 Aug 2024 16:45:57 +0200 Subject: [PATCH 5/6] Declare variable before use for -u flag --- test-node.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/test-node.bash b/test-node.bash index 4fa253a8..81401aa5 100755 --- a/test-node.bash +++ b/test-node.bash @@ -461,6 +461,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 }'` From 4c489a79c7bb1c4c648d9fa46b4f2101a8083818 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 14 Aug 2024 11:44:52 +0200 Subject: [PATCH 6/6] Change contracts to utils, add --force-build-utils --- test-node.bash | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/test-node.bash b/test-node.bash index 81401aa5..75f6d30a 100755 --- a/test-node.bash +++ b/test-node.bash @@ -58,7 +58,8 @@ dev_blockscout=false # Rebuild docker images build_dev_nitro=false build_dev_blockscout=false -build_contracts=false +build_utils=false +force_build_utils=false build_node_images=false while [[ $# -gt 0 ]]; do @@ -69,7 +70,7 @@ while [[ $# -gt 0 ]]; do read -p "are you sure? [y/n]" -n 1 response if [[ $response == "y" ]] || [[ $response == "Y" ]]; then force_init=true - build_contracts=true + build_utils=true build_node_images=true echo else @@ -80,7 +81,7 @@ while [[ $# -gt 0 ]]; do ;; --init-force) force_init=true - build_contracts=true + build_utils=true build_node_images=true shift ;; @@ -109,14 +110,14 @@ while [[ $# -gt 0 ]]; do --build) build_dev_nitro=true build_dev_blockscout=true - build_contracts=true + build_utils=true build_node_images=true shift ;; --no-build) build_dev_nitro=false build_dev_blockscout=false - build_contracts=false + build_utils=false build_node_images=false shift ;; @@ -136,12 +137,16 @@ while [[ $# -gt 0 ]]; do build_dev_blockscout=false shift ;; - --build-contracts) - build_contracts=true + --build-utils) + build_utils=true shift ;; - --no-build-contracts) - build_contracts=false + --no-build-utils) + build_utils=false + shift + ;; + --force-build-utils) + force_build_utils=true shift ;; --validate) @@ -249,8 +254,9 @@ while [[ $# -gt 0 ]]; do 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-contracts rebuild contracts related docker images - echo --no-build-contracts rebuild contracts related docker images + 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 @@ -317,12 +323,16 @@ if $dev_blockscout && $build_dev_blockscout; then fi fi -if $build_contracts; then +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_nitro; then