From d2b249dd79ff2cc2df48302c959e5ed371eea7bd Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 20 Feb 2024 14:18:38 +0530 Subject: [PATCH] Fund accounts for txs on L2 --- .../docker-compose-fixturenet-optimism.yml | 3 +- .../optimism-contracts/fund-accounts-on-l2.sh | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 stack_orchestrator/data/config/fixturenet-optimism/optimism-contracts/fund-accounts-on-l2.sh diff --git a/stack_orchestrator/data/compose/docker-compose-fixturenet-optimism.yml b/stack_orchestrator/data/compose/docker-compose-fixturenet-optimism.yml index fe1eac50..0254a088 100644 --- a/stack_orchestrator/data/compose/docker-compose-fixturenet-optimism.yml +++ b/stack_orchestrator/data/compose/docker-compose-fixturenet-optimism.yml @@ -20,12 +20,13 @@ services: volumes: - ../config/network/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh - ../config/fixturenet-optimism/optimism-contracts/deploy-contracts.sh:/app/packages/contracts-bedrock/deploy-contracts.sh + - ../config/fixturenet-optimism/optimism-contracts/fund-accounts-on-l2.sh:/app/packages/contracts-bedrock/fund-accounts-on-l2.sh - l2_accounts:/l2-accounts - l1_deployment:/l1-deployment - l2_config:/l2-config # Waits for L1 endpoint to be up before running the contract deploy script command: | - "./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- ./deploy-contracts.sh" + "./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- ./deploy-contracts.sh && ./fund-accounts-on-l2.sh" # Initializes and runs the L2 execution client (outputs to volume l2_geth_data) op-geth: diff --git a/stack_orchestrator/data/config/fixturenet-optimism/optimism-contracts/fund-accounts-on-l2.sh b/stack_orchestrator/data/config/fixturenet-optimism/optimism-contracts/fund-accounts-on-l2.sh new file mode 100755 index 00000000..1248f6cc --- /dev/null +++ b/stack_orchestrator/data/config/fixturenet-optimism/optimism-contracts/fund-accounts-on-l2.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}" +CERC_L1_CHAIN_ID="${CERC_L1_CHAIN_ID:-${DEFAULT_CERC_L1_CHAIN_ID}}" + +CERC_L1_ACCOUNTS_CSV_URL="${CERC_L1_ACCOUNTS_CSV_URL:-${DEFAULT_CERC_L1_ACCOUNTS_CSV_URL}}" + +# Fetch the L1 funded accounts +curl -o accounts.csv $CERC_L1_ACCOUNTS_CSV_URL + +# Use the accounts other than the ones used for Optimism deployment +ACCOUNT_1=$(awk -F ',' 'NR == 5 {print $2}' accounts.csv) +ACCOUNT_1_KEY=$(awk -F ',' 'NR == 5 {print $3}' accounts.csv) + +ACCOUNT_2=$(awk -F ',' 'NR == 6 {print $2}' accounts.csv) +ACCOUNT_2_KEY=$(awk -F ',' 'NR == 6 {print $3}' accounts.csv) + +# Get the bridge contract address +DEPLOYMENT_CONTEXT="$CERC_L1_CHAIN_ID" +BRIDGE=$(cat /l1-deployment/$DEPLOYMENT_CONTEXT/L1StandardBridgeProxy.json | jq -r .address) + +# Send balance to bridge contract on L1 +cast send --from $ACCOUNT_1 --rpc-url $CERC_L1_RPC --value 1000ether $BRIDGE --private-key $ACCOUNT_1_KEY +cast send --from $ACCOUNT_2 --rpc-url $CERC_L1_RPC --value 1000ether $BRIDGE --private-key $ACCOUNT_2_KEY + +echo "Following accounts have been funded; use them for transactions on L2:" +echo "${ACCOUNT_1}" +echo "${ACCOUNT_2}"