Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update multicall with .env.bridge file #23

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ L1_FUNDED_PRIVATE_KEY=<DEPLOYER_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
Expand Down
3 changes: 0 additions & 3 deletions .env.explorer.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# L2
L2_RPC_URL=http://localhost:9545

# blocscout - common configs
COMMON_HOST=localhost
DOCKER_TAG_BACKEND=6.8.1
Expand Down
27 changes: 18 additions & 9 deletions scripts/l2-bridge/l2-bridge-deploy-l1-multicall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
bap2pecs marked this conversation as resolved.
Show resolved Hide resolved
# 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}"
14 changes: 6 additions & 8 deletions scripts/l2-bridge/l2-bridge-set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"

Expand Down