Fund fixture accounts on L2

This commit is contained in:
Prathamesh Musale 2024-02-21 11:31:48 +05:30
parent 7c29b8c36c
commit 777f4524de
4 changed files with 67 additions and 6 deletions

View File

@ -20,13 +20,12 @@ services:
volumes: volumes:
- ../config/network/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh - ../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/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 - l2_accounts:/l2-accounts
- l1_deployment:/l1-deployment - l1_deployment:/l1-deployment
- l2_config:/l2-config - l2_config:/l2-config
# Waits for L1 endpoint to be up before running the contract deploy script # Waits for L1 endpoint to be up before running the contract deploy script
command: | 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 && ./fund-accounts-on-l2.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"
# Initializes and runs the L2 execution client (outputs to volume l2_geth_data) # Initializes and runs the L2 execution client (outputs to volume l2_geth_data)
op-geth: op-geth:

View File

@ -1,11 +1,16 @@
# Watchers # Watchers
CERC_ETH_RPC_ENDPOINT="http://op-geth:8545" CERC_ETH_RPC_ENDPOINT="http://op-geth:8545"
CERC_PRIVATE_KEY_DEPLOYER="0xbe4aa664815ea3bc3d63118649a733f6c96b243744310806ecb6d96359ab62cf" # L1 faucet account #4, funded on L2
# L1 pre-funded account #4, funded on L2 as well
CERC_PRIVATE_KEY_DEPLOYER="0xbe4aa664815ea3bc3d63118649a733f6c96b243744310806ecb6d96359ab62cf"
CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3004/#" CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3004/#"
CERC_ETH_RPC_QUERY_ENDPOINT="http://op-geth:8545" CERC_ETH_RPC_QUERY_ENDPOINT="http://op-geth:8545"
CERC_ETH_RPC_MUTATION_ENDPOINT="http://op-geth:8545" CERC_ETH_RPC_MUTATION_ENDPOINT="http://op-geth:8545"
CERC_NITRO_CHAIN_URL="http://op-geth:8546" # TODO: Does this work?
# App # App
CERC_APP_WATCHER_URL="http://localhost:3001" CERC_APP_WATCHER_URL="http://localhost:3001"
CERC_SNAP_URL=http://localhost:8080 CERC_SNAP_URL=http://localhost:8080

View File

@ -4,13 +4,26 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
echo "Funding accounts on L2"
CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}" 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_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}}" CERC_L1_ACCOUNTS_CSV_URL="${CERC_L1_ACCOUNTS_CSV_URL:-${DEFAULT_CERC_L1_ACCOUNTS_CSV_URL}}"
# Fixture accounts
WATCHER_1_ACCOUNT=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
WATCHER_1_ACCOUNT=0x70997970C51812dc3A010C7d01b50e0d17dc79C8
WATCHER_1_ACCOUNT=0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65
NITRO_APP_ACCOUNT=0xbDA5747bFD65F08deb54cb465eB87D40e51B197E
# Check if watcher 1 account already funded
L2_RPC="http://op-geth:8545"
WATCHER_1_ACCOUNT_BALANCE=$(cast balance ${WATCHER_1_ACCOUNT} --rpc-url $L2_RPC)
if [ $WATCHER_1_ACCOUNT_BALANCE -gt 0 ]; then
echo "Watcher account already funded, exiting."
exit 0
fi
echo "Funding accounts on L2"
# Fetch the L1 funded accounts # Fetch the L1 funded accounts
curl -o accounts.csv $CERC_L1_ACCOUNTS_CSV_URL curl -o accounts.csv $CERC_L1_ACCOUNTS_CSV_URL
@ -32,3 +45,9 @@ cast send --from $ACCOUNT_2 --rpc-url $CERC_L1_RPC --value 10000ether $BRIDGE --
echo "Following accounts have been funded; use them for transactions on L2:" echo "Following accounts have been funded; use them for transactions on L2:"
echo "${ACCOUNT_1}" echo "${ACCOUNT_1}"
echo "${ACCOUNT_2}" echo "${ACCOUNT_2}"
echo "Funding the watcher and app Nitro accounts on L2"
cast send --rpc-url $L2_RPC --value 100ether WATCHER_1_ACCOUNT --private-key $ACCOUNT_1_KEY
cast send --rpc-url $L2_RPC --value 100ether WATCHER_2_ACCOUNT --private-key $ACCOUNT_1_KEY
cast send --rpc-url $L2_RPC --value 100ether WATCHER_3_ACCOUNT --private-key $ACCOUNT_1_KEY
cast send --rpc-url $L2_RPC --value 100ether NITRO_APP_ACCOUNT --private-key $ACCOUNT_1_KEY

View File

@ -0,0 +1,38 @@
# Copyright © 2023 Vulcanize
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
from stack_orchestrator.deploy.deployment_context import DeploymentContext
from ruamel.yaml import YAML
def create(context: DeploymentContext, extra_args):
# load fixturenet-optimism compose file
fixturenet_optimism_compose_file = context.deployment_dir.joinpath('compose', 'docker-compose-fixturenet-optimism.yml')
with open(fixturenet_optimism_compose_file, 'r') as yaml_file:
yaml = YAML()
yaml_data = yaml.load(yaml_file)
# mount the funding script to volumes
fund_accounts_script = '../config/watcher-mobymask-v3-demo/local/fund-accounts-on-l2.sh:/app/packages/contracts-bedrock/fund-accounts-on-l2.sh'
yaml_data['services']['fixturenet-optimism-contracts']['volumes'].append(fund_accounts_script)
# update command to run the script
yaml_data['services']['fixturenet-optimism-contracts']['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 && ./fund-accounts-on-l2.sh"
with open(fixturenet_optimism_compose_file, 'w') as yaml_file:
yaml = YAML()
yaml.dump(yaml_data, yaml_file)
return None