Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
cli: updates for standard bridge (#187)
Browse files Browse the repository at this point in the history
* wip

* deploy both gateways

* Update mev-commit-cli.sh

* naming

* deploy whitelist too

* Update mev-commit-cli.sh

* Update mev-commit-cli.sh

* correct addrs

* Update mev-commit-cli.sh

* update expected settlement gateway addr

* populate start/stop for standard bridge

* changed dir name

* changes from PR

* global default chain id
  • Loading branch information
shaspitz authored Feb 29, 2024
1 parent 5944031 commit 1f84fbd
Showing 1 changed file with 101 additions and 25 deletions.
126 changes: 101 additions & 25 deletions mev-commit-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
L1_RPC_BASE_URL=https://sepolia.infura.io/v3
DEFAULT_RPC_URL="http://sl-bootnode:8545"
PRIMEV_DIR="$HOME/.primev"
DEFAULT_CHAIN_ID="17864"

GETH_REPO_NAME="mev-commit-geth"
CONTRACT_REPO_NAME="contracts"
Expand Down Expand Up @@ -104,19 +105,23 @@ EOF
export AGENT_BASE_IMAGE=nil
export L2_NODE_URL=nil

AGENT_BASE_IMAGE=nil SETTLEMENT_RPC_URL=nil PUBLIC_SETTLEMENT_RPC_URL=nil docker compose --profile settlement -f "$GETH_POA_PATH/geth-poa/docker-compose.yml" up -d --build
DD_KEY=nil docker compose --profile settlement -f "$GETH_POA_PATH/geth-poa/docker-compose.yml" up -d --build

# Wait for settlement layer to be up before deploying create2
sleep 10

deploy_create2
}

stop_settlement_layer() {
AGENT_BASE_IMAGE=nil SETTLEMENT_RPC_URL=nil PUBLIC_SETTLEMENT_RPC_URL=nil docker compose --profile settlement -f "$GETH_POA_PATH/geth-poa/docker-compose.yml" down
DD_KEY=nil docker compose --profile settlement -f "$GETH_POA_PATH/geth-poa/docker-compose.yml" down
}

start_mev_commit_minimal() {
echo "Starting MEV-Commit..."
docker compose --profile minimal-setup -f "$MEV_COMMIT_PATH/integration-compose.yml" up --build -d
}


start_mev_commit_e2e() {
local datadog_key=""
local sepolia_key=""
Expand Down Expand Up @@ -186,13 +191,13 @@ build_contract_deployer() {
docker build -t contract-deployer "$CONTRACTS_PATH"
}

# Deploy create2 proxy from alpine container.
# This script is able to handle the proxy already being deployed.
deploy_create2() {
local rpc_url=${1:-$DEFAULT_RPC_URL}
local network_name=${2:-"$DOCKER_NETWORK_NAME"}
chmod +x "$GETH_POA_PATH/geth-poa/util/deploy_create2.sh"
docker run \
--rm \
--network "$DOCKER_NETWORK_NAME" \
--network "$network_name" \
-v "$GETH_POA_PATH/geth-poa/util/deploy_create2.sh:/deploy_create2.sh" \
alpine /bin/sh -c \
"apk add --no-cache curl jq \
Expand All @@ -201,7 +206,7 @@ deploy_create2() {

deploy_contracts() {
local rpc_url=${1:-$DEFAULT_RPC_URL}
local chain_id=${2:-17864} # Default chain ID
local chain_id=${2:-$DEFAULT_CHAIN_ID}
local private_key=${3:-"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"} # Default private key

# Wait for the Geth POA network to be up and running
Expand All @@ -210,8 +215,6 @@ deploy_contracts() {

build_contract_deployer

deploy_create2

# Run the Docker container to deploy the contracts
echo "Deploying Contracts with RPC URL: $rpc_url, Chain ID: $chain_id, and Private Key: [HIDDEN]"
docker run --rm --network "$DOCKER_NETWORK_NAME" \
Expand All @@ -233,10 +236,10 @@ stop_oracle(){
docker compose -f "$ORACLE_PATH/integration-compose.yml" down
}

start_bridge(){
start_hyperlane(){
local public_rpc_url=${1:-$DEFAULT_RPC_URL}
local rpc_url=${2:-$DEFAULT_RPC_URL}
local chain_id=${3:-17864} # Default chain ID
local chain_id=${3:-$DEFAULT_CHAIN_ID}
local private_key=${4:-"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"}
AGENT_BASE_IMAGE=gcr.io/abacus-labs-dev/hyperlane-agent@sha256:854f92966eac6b49e5132e152cc58168ecdddc76c2d390e657b81bdaf1396af0 \
PUBLIC_SETTLEMENT_RPC_URL="$public_rpc_url" \
Expand All @@ -253,8 +256,6 @@ start_bridge(){

build_contract_deployer

deploy_create2

# Deploy whitelist contract
docker run --rm --network "$DOCKER_NETWORK_NAME" \
-e RPC_URL="$rpc_url" \
Expand All @@ -265,10 +266,67 @@ start_bridge(){
contract-deployer
}

stop_bridge(){
stop_hyperlane(){
AGENT_BASE_IMAGE=gcr.io/abacus-labs-dev/hyperlane-agent@sha256:854f92966eac6b49e5132e152cc58168ecdddc76c2d390e657b81bdaf1396af0 PUBLIC_SETTLEMENT_RPC_URL="$public_rpc_url" SETTLEMENT_RPC_URL="$rpc_url" docker compose -f "$BRIDGE_PATH/hyperlane/docker-compose.yml" --profile bridge down
}

start_local_l1() {
DD_KEY=nil docker compose --profile local_l1 -f "$GETH_POA_PATH/geth-poa/docker-compose.yml" up -d --build
# wait for l1 to be up before deploying create2
sleep 10
deploy_create2 "http://l1-bootnode:8545" "geth-poa_l1_net"
}

stop_local_l1() {
DD_KEY=nil docker compose --profile local_l1 -f "$GETH_POA_PATH/geth-poa/docker-compose.yml" down
}

deploy_standard_bridge_contracts() {
local rpc_url=$DEFAULT_RPC_URL
local chain_id=$DEFAULT_CHAIN_ID
# Pre-funded account for deployment on settlement layer
local private_key="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

build_contract_deployer

docker run --rm --network "$DOCKER_NETWORK_NAME" \
-e RPC_URL="$rpc_url" \
-e CHAIN_ID="$chain_id" \
-e PRIVATE_KEY="$private_key" \
-e DEPLOY_TYPE="settlement-gateway" \
-e RELAYER_ADDR="0x0DCaa27B9E4Db92F820189345792f8eC5Ef148F6" \
contract-deployer

local settlement_gateway_addr="0xc1f93bE11D7472c9B9a4d87B41dD0a491F1fbc75"
docker run --rm --network "$DOCKER_NETWORK_NAME" \
-e RPC_URL="$rpc_url" \
-e CHAIN_ID="$chain_id" \
-e PRIVATE_KEY="$private_key" \
-e DEPLOY_TYPE="whitelist" \
-e HYP_ERC20_ADDR="$settlement_gateway_addr" \
contract-deployer

docker run --rm --network "geth-poa_l1_net" \
-e RPC_URL="http://l1-bootnode:8545" \
-e CHAIN_ID="39999" \
-e PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
-e DEPLOY_TYPE="l1-gateway" \
-e RELAYER_ADDR="0x0DCaa27B9E4Db92F820189345792f8eC5Ef148F6" \
contract-deployer

echo "Standard bridge gateway contracts finished deploying on both chains"
}

start_standard_bridge() {
echo "Starting standard bridge..."
docker compose -f "$BRIDGE_PATH/standard/bridge-v1/docker-compose.yml" up --build -d
}

stop_standard_bridge() {
echo "Stopping standard bridge..."
docker compose -f "$BRIDGE_PATH/standard/bridge-v1/docker-compose.yml" down
}

clean() {
echo "Cleaning up..."
# Docker cleanup script
Expand Down Expand Up @@ -304,21 +362,29 @@ stop_services() {
"oracle")
stop_oracle # Assuming stop_oracle is a function you've defined elsewhere
;;
"bridge")
stop_bridge
"hyperlane")
stop_hyperlane
;;
"mev-commit")
docker compose -f "$MEV_COMMIT_PATH/integration-compose.yml" down
;;
"local_l1")
stop_local_l1
;;
"standard_bridge")
stop_standard_bridge
;;
"all")
stop_settlement_layer
stop_oracle
stop_bridge
stop_hyperlane
stop_local_l1
stop_standard_bridge
docker compose -f "$MEV_COMMIT_PATH/integration-compose.yml" down
;;
*)
echo "Invalid service: $service"
echo "Valid services: sl, oracle, mev-commit, all"
echo "Valid services: sl, oracle, mev-commit, hyperlane, local_l1, standard_bridge, all"
return 1
esac

Expand All @@ -334,7 +400,7 @@ start_service() {
deploy_contracts "$rpc_url"
start_mev_commit "$datadog_key"
start_oracle "$sepolia_key" "$datadog_key"
start_bridge "$public_rpc_url"
start_hyperlane "$public_rpc_url"
;;
"e2e")
initialize_environment
Expand All @@ -343,7 +409,7 @@ start_service() {
start_mev_commit_e2e "--sepolia-key=$sepolia_key" "--datadog-key=$datadog_key"
sleep 12
start_oracle "$sepolia_key" "$datadog_key"
start_bridge "$public_rpc_url"
start_hyperlane "$public_rpc_url"
;;
"mev-commit")
start_mev_commit "$datadog_key"
Expand All @@ -354,18 +420,28 @@ start_service() {
"sl")
start_settlement_layer "$datadog_key"
;;
"bridge")
start_bridge "$public_rpc_url"
"hyperlane")
start_hyperlane "$public_rpc_url"
;;
"minimal")
initialize_environment
start_settlement_layer "$datadog_key"
deploy_contracts "$rpc_url"
start_mev_commit_minimal
;;
"local_l1")
start_local_l1
;;
"standard_bridge")
create_docker_network
start_settlement_layer
start_local_l1
deploy_standard_bridge_contracts
start_standard_bridge
;;
*)
echo "Invalid service name: $service_name"
echo "Valid services: all, e2e, oracle, sl, bridge"
echo "Valid services: all, e2e, oracle, sl, hyperlane, minimal, local_l1, standard_bridge"
return 1
;;
esac
Expand All @@ -377,8 +453,8 @@ show_help() {
echo ""
echo "Commands:"
echo " deploy_contracts Deploy contracts"
echo " start [services] Start specified services. Available services: all, e2e, mev-commit, oracle, sl, bridge, minimal"
echo " stop [service] Stop specified service. Available services: sl, mev-commit, all"
echo " start [services] Start specified services. Available services: all, e2e, mev-commit, oracle, sl, hyperlane, minimal, local_l1, standard_bridge"
echo " stop [service] Stop specified service. Available services: sl, mev-commit, hyperlane, local_l1, standard_bridge, all"
echo " update Update repositories"
echo " clean Cleanup Docker"
echo ""
Expand Down

0 comments on commit 1f84fbd

Please sign in to comment.