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"