From ff639aaf37c89fa286f331a213b50aeccf5508b2 Mon Sep 17 00:00:00 2001 From: lesterli Date: Fri, 25 Oct 2024 11:30:14 +0800 Subject: [PATCH 1/2] fix: update multicall with .env.bridge file (#23) --- .env.example | 2 ++ .env.explorer.example | 3 --- .../l2-bridge-deploy-l1-multicall.sh | 27 ++++++++++++------- scripts/l2-bridge/l2-bridge-set-env.sh | 14 +++++----- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index 3db735f..87e2e95 100644 --- a/.env.example +++ b/.env.example @@ -11,6 +11,8 @@ L1_FUNDED_PRIVATE_KEY= L1_FUND_AMOUNT=1ether # L2 +L2_RPC_URL=http://localhost:9545 +L2_EXPLORER_URL=http://localhost L2_CHAIN_ID=11155420 L2_CHAIN_NAME="L2 Devnet" L2_BLOCK_TIME=2 diff --git a/.env.explorer.example b/.env.explorer.example index cf6420c..54b28a0 100644 --- a/.env.explorer.example +++ b/.env.explorer.example @@ -1,6 +1,3 @@ -# L2 -L2_RPC_URL=http://localhost:9545 - # blocscout - common configs COMMON_HOST=localhost DOCKER_TAG_BACKEND=6.8.1 diff --git a/scripts/l2-bridge/l2-bridge-deploy-l1-multicall.sh b/scripts/l2-bridge/l2-bridge-deploy-l1-multicall.sh index 8ebd110..27805d0 100755 --- a/scripts/l2-bridge/l2-bridge-deploy-l1-multicall.sh +++ b/scripts/l2-bridge/l2-bridge-deploy-l1-multicall.sh @@ -6,33 +6,42 @@ set -a source $(pwd)/.env set +a -cd "$(pwd)/multicall" -forge build +# Path to the .env.bridge file +ENV_FILE=$(pwd)/.env.bridge +echo "Checking if multicall contract is already deployed..." CHAIN_ID=$(cast chain-id --rpc-url "${L1_RPC_URL}") - -DEPLOYED_URL=$(curl https://raw.githubusercontent.com/mds1/multicall/main/deployments.json | grep -A 3 "\"chainId\": ${CHAIN_ID}," | grep "\"url\":" | awk -F'"' '{print $4}') +DEPLOYED_URL=$(curl -s https://raw.githubusercontent.com/mds1/multicall/main/deployments.json | jq -r ".[] | select(.chainId == $CHAIN_ID) | .url") if [ ! -z "${DEPLOYED_URL}" ]; then # Extract the Ethereum address from the URL + echo "Extracting multicall contract address from the deployed URL..." DEPLOYED_ADDRESS=$(echo "$DEPLOYED_URL" | grep -oE '0x[a-fA-F0-9]{40}') if [ -n "$DEPLOYED_ADDRESS" ]; then echo "Contract is already deployed. Exiting." - # Update the .env file with the deployed address - sed -i.bak "s/^NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=.*/NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=${DEPLOYED_ADDRESS}/" ../.env - rm ../.env.bak + # Update the .env.bridge file with the deployed address + sed -i.bak "s/^NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=.*/NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=${DEPLOYED_ADDRESS}/" $ENV_FILE + rm $ENV_FILE.bak + echo "Updated $ENV_FILE file with the deployed multicall contract address ${DEPLOYED_ADDRESS}" exit 0 else echo "No Ethereum address found in the URL" fi fi +echo "Building multicall contract..." +cd "$(pwd)/multicall" +forge build + +echo "Deploying multicall contract..." # Stream forge output in real-time forge create --rpc-url "${L1_RPC_URL}" --private-key "${L1_FUNDED_PRIVATE_KEY}" Multicall3 | tee forge_output.log # Extract the deployed address from the log file +echo "Extracting multicall contract address from the log file..." DEPLOYED_ADDRESS=$(grep "Deployed to:" forge_output.log | awk '{print $3}') rm forge_output.log # Update the .env.bridge file with the deployed address -sed -i.bak "s/^NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=.*/NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=${DEPLOYED_ADDRESS}/" ../.env.bridge -rm ../.env.bridge.bak +sed -i.bak "s/^NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=.*/NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=${DEPLOYED_ADDRESS}/" $ENV_FILE +rm $ENV_FILE.bak +echo "Updated $ENV_FILE file with the new deployed multicall contract address ${DEPLOYED_ADDRESS}" \ No newline at end of file diff --git a/scripts/l2-bridge/l2-bridge-set-env.sh b/scripts/l2-bridge/l2-bridge-set-env.sh index f13725c..033bbe4 100755 --- a/scripts/l2-bridge/l2-bridge-set-env.sh +++ b/scripts/l2-bridge/l2-bridge-set-env.sh @@ -6,6 +6,11 @@ set -a source $(pwd)/.env set +a +if [ -z "$L2_RPC_URL" ]; then + echo "L2_RPC_URL is not set in the .env file" + exit 1 +fi + # Path to the .env.bridge file ENV_FILE=$(pwd)/.env.bridge # Path to the rollup.json file @@ -20,10 +25,6 @@ L1_STANDARD_BRIDGE_PROXY=$(jq -r '.L1StandardBridgeProxy' "$OP_DEPLOYMENTS_JSON_ L1_OPTIMISM_PORTAL_PROXY=$(jq -r '.OptimismPortalProxy' "$OP_DEPLOYMENTS_JSON_PATH") L2_OUTPUT_ORACLE_PROXY=$(jq -r '.L2OutputOracleProxy' "$OP_DEPLOYMENTS_JSON_PATH") -# TODO: 9545 is now hardcoded in the docker-compose-l2.yml file and a few other places. -# we should make this more dynamic by defining a variable in the .env file -L2_RPC_URL="http://localhost:9545" - # Update .env.bridge file sed -i "s|^NEXT_PUBLIC_L1_CHAIN_ID=.*|NEXT_PUBLIC_L1_CHAIN_ID=$L1_CHAIN_ID|" "$ENV_FILE" sed -i "s|^NEXT_PUBLIC_L1_CHAIN_NAME=.*|NEXT_PUBLIC_L1_CHAIN_NAME=\"$L1_CHAIN_NAME\"|" "$ENV_FILE" @@ -34,11 +35,8 @@ sed -i "s|^NEXT_PUBLIC_L2_RPC_URL=.*|NEXT_PUBLIC_L2_RPC_URL=$L2_RPC_URL|" "$ENV_ sed -i "s|^NEXT_PUBLIC_L1_STANDARD_BRIDGE_PROXY=.*|NEXT_PUBLIC_L1_STANDARD_BRIDGE_PROXY=$L1_STANDARD_BRIDGE_PROXY|" "$ENV_FILE" sed -i "s|^NEXT_PUBLIC_L1_OPTIMISM_PORTAL_PROXY=.*|NEXT_PUBLIC_L1_OPTIMISM_PORTAL_PROXY=$L1_OPTIMISM_PORTAL_PROXY|" "$ENV_FILE" sed -i "s|^NEXT_PUBLIC_L2_OUTPUT_ORACLE_PROXY=.*|NEXT_PUBLIC_L2_OUTPUT_ORACLE_PROXY=$L2_OUTPUT_ORACLE_PROXY|" "$ENV_FILE" -sed -i "s|^NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=.*|NEXT_PUBLIC_L1_MULTICALL3_ADDRESS=$NEXT_PUBLIC_L1_MULTICALL3_ADDRESS|" "$ENV_FILE" - sed -i "s|^NEXT_PUBLIC_L1_EXPLORER_URL=.*|NEXT_PUBLIC_L1_EXPLORER_URL=$L1_EXPLORER_URL|" "$ENV_FILE" -# TODO: we should change this when explorer is available -sed -i "s|^NEXT_PUBLIC_L2_EXPLORER_URL=.*|NEXT_PUBLIC_L2_EXPLORER_URL=|" "$ENV_FILE" +sed -i "s|^NEXT_PUBLIC_L2_EXPLORER_URL=.*|NEXT_PUBLIC_L2_EXPLORER_URL=$L2_EXPLORER_URL|" "$ENV_FILE" # TODO: we should change this when fault proof is enabled sed -i "s|^NEXT_PUBLIC_DISPUTE_GAME_FACTORY_PROXY=.*|NEXT_PUBLIC_DISPUTE_GAME_FACTORY_PROXY=|" "$ENV_FILE" From b39ca0e28e265d19a1db0f06e3844eb4a61603a9 Mon Sep 17 00:00:00 2001 From: bap2pecs <111917526+bap2pecs@users.noreply.github.com> Date: Tue, 29 Oct 2024 06:06:13 -0400 Subject: [PATCH 2/2] chore: add l2-explorer-restart (#25) --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 5eaf57e..a14aff3 100644 --- a/Makefile +++ b/Makefile @@ -102,6 +102,11 @@ l2-explorer-start: @$(CURDIR)/scripts/l2-explorer/l2-explorer-start.sh .PHONY: l2-explorer-start +## Restart the OP chain explorer (without deleting the volumes) +l2-explorer-restart: + @$(CURDIR)/scripts/l2-explorer/l2-explorer-restart.sh +.PHONY: l2-explorer-restart + ## Stop the OP chain explorer and remove the volumes l2-explorer-stop: ## Stops all explorer services docker compose -f docker/docker-compose-l2-explorer.yml stop proxy visualizer-proxy sig-provider visualizer smart-contract-verifier stats frontend backend stats-db backend-db