Skip to content

Commit

Permalink
feat: op stack integration (#418)
Browse files Browse the repository at this point in the history
* feat: test integration of the op stack into our package

* fix: typo

* chore: nit

* chore: nit

* fix: typo

* test

* test: more progress (wip)

* feat: enable to deploy op stack rollup

* fix: make sure the op rollup is not deployed by default

* ci: test op rollup deployment in ci

* ci: run op rollup test

* feat: customize op rollup and pin versions

* feta: enable to customize op rollup args

* ci: add debug verbosity in tests

* chore: clean up

* fix: typo

* fix: typo

* chore: print args

* fix: typo

* fix: typos

* doc: nit

* chore: pin version of op-batcher

* ci: monitor op rollup block finalization

* docs: nit

* chore: rename script

* fix: lint

* fix: lint

* ci: fix typo

* feat: deploy deterministic proxy by default

* fix: typo

* chore: spin up a sequencer node and an rpc node for the op rollup stack

* fix: lint

* chore: switch back to the original op package

* fix: typo (lol!!!)
  • Loading branch information
leovct authored Dec 30, 2024
1 parent 97dbb4e commit 2edcc2f
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ echo
# Calculate the end time based on the current time and the specified timeout.
start_time=$(date +%s)
end_time=$((start_time + timeout))
gas_price_factor=1

# Main loop to monitor batch verification.
gas_price_factor=1
while true; do
# Check if there are any stopped services.
stopped_services="$(kurtosis enclave inspect "$enclave" | grep STOPPED)"
Expand Down
113 changes: 113 additions & 0 deletions .github/scripts/monitor-op-rollup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash

# This script monitors the finality of OP rollup blocks.
# TODO: Once we migrate the OP rollup into a type 1 zkEVM rollup, we'll be able to monitor the
# verification of those blocks.

# Function to display usage information.
usage() {
echo "Usage: $0 --enclave <ENCLAVE> --rpc-url <URL> --target <TARGET> --timeout <TIMEOUT>"
echo " --enclave: The name of the Kurtosis enclave."
echo " --cl-rpc-url: The consensus layer RPC URL to query."
echo " --target: The target number of finalized blocks."
echo " --timeout: The script timeout in seconds."
exit 1
}

# Initialize variables.
enclave=""
cl_rpc_url=""
target="50"
timeout="900" # 15 minutes.

# Parse command line arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--enclave)
enclave="$2"
shift 2
;;
--cl-rpc-url)
cl_rpc_url="$2"
shift 2
;;
--target)
target="$2"
shift 2
;;
--timeout)
timeout="$2"
shift 2
;;
*)
echo "Error: unknown argument: $key"
usage
;;
esac
done

# Check if the required argument is provided.
if [ -z "$enclave" ]; then
echo "Error: enclave name is required."
usage
fi

if [ -z "$cl_rpc_url" ]; then
echo "Error: cl rpc url is required."
usage
fi

# Print script parameters for debug purposes.
echo "Running script with values:"
echo "- Enclave: $enclave"
echo "- CL RPC URL: $cl_rpc_url"
echo "- Target: $target"
echo "- Timeout: $timeout"
echo

# Calculate the end time based on the current time and the specified timeout.
start_time=$(date +%s)
end_time=$((start_time + timeout))

# Main loop to monitor block finalization.
while true; do
# Check if there are any stopped services.
stopped_services="$(kurtosis enclave inspect "$enclave" | grep STOPPED)"
if [[ -n "$stopped_services" ]]; then
echo "It looks like there is at least one stopped service in the enclave... Something must have halted..."
echo "$stopped_services"
echo

kurtosis enclave inspect "$enclave" --full-uuids | grep STOPPED | awk '{print $2 "--" $1}' |
while read -r container; do
echo "Printing logs for $container"
docker logs --tail 50 "$container"
done
exit 1
fi

# Query the number of finalized blocks from the CL RPC URL.
op_rollup_sync_status="$(cast rpc --rpc-url "$cl_rpc_url" optimism_syncStatus)"
unsafe_l2_block_number="$(jq '.unsafe_l2.number' <<<"$op_rollup_sync_status")"
safe_l2_block_number="$(jq '.safe_l2.number' <<<"$op_rollup_sync_status")"
finalized_l2_block_number="$(jq '.finalized_l2.number' <<<"$op_rollup_sync_status")"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Unsafe: $unsafe_l2_block_number, Safe: $safe_l2_block_number, Finalized: $finalized_l2_block_number"

# Check if the finalized block target has been reached.
if ((finalized_l2_block_number > target)); then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Exiting... More than $target L2 blocks were finalized!"
exit 0
fi

# Check if the timeout has been reached.
current_time=$(date +%s)
if ((current_time > end_time)); then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Timeout reached!"
exit 1
fi

echo "Waiting a few seconds before the next iteration..."
echo
sleep 10
done
14 changes: 14 additions & 0 deletions .github/tests/op-rollup/custom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
deployment_stages:
deploy_optimism_rollup: true

optimism_package:
chains:
- participants:
- el_type: op-geth
cl_type: op-node
- el_type: op-reth
- el_type: op-erigon
- el_type: op-nethermind

args:
verbosity: debug
5 changes: 5 additions & 0 deletions .github/tests/op-rollup/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
deployment_stages:
deploy_optimism_rollup: true

args:
verbosity: debug
50 changes: 31 additions & 19 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ jobs:
postgres_port=$(kurtosis port print ${{ env.ENCLAVE_NAME }} postgres-001 postgres | cut -d':' -f3)
PGPASSWORD=master_password psql --host 127.0.0.1 --port "$postgres_port" --username master_user --dbname master --list
- name: Monitor verified batches (CDK Erigon Permissionless RPC)
- name: Monitor CDK chain verified batches (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: |
./monitor-verified-batches.sh \
./monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)
Expand Down Expand Up @@ -86,6 +86,7 @@ jobs:
./.github/tests/gas-token/auto.yml \
./.github/tests/static-ports/custom-static-ports.yml \
./.github/tests/static-ports/default-static-ports.yml \
./.github/tests/op-rollup/*.yml \
| grep -v 'additional-services.yml')
matrix=$(echo "$files" | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -125,7 +126,7 @@ jobs:

- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Verify static ports
run: |
if [[ ${{ matrix.file_name }} == "./.github/tests/static-ports/default-static-ports.yml" ]]; then
Expand All @@ -141,10 +142,10 @@ jobs:
exit 1
fi
else
echo "Skipping."
echo "Skipping."
fi
- name: Monitor verified batches (Central RPC)
- name: Monitor CDK chain verified batches (Central RPC)
run: |
sequencer_type=$(yq --raw-output '.args.sequencer_type' ${{ matrix.file_name }})
rpc_name=""
Expand All @@ -159,21 +160,32 @@ jobs:
exit 1
fi
echo "RPC name: $rpc_name"
./.github/scripts/monitor-verified-batches.sh \
./.github/scripts/monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} $rpc_name rpc)
- name: Monitor verified batches (zkEVM Permissionless RPC)
- name: Monitor CDK chain verified batches (zkEVM Permissionless RPC)
run: |
result=$(yq --raw-output '.args.additional_services // [] | contains(["pless_zkevm_node"])' ${{ matrix.file_name }})
if [[ "$result" == "true" ]]; then
./.github/scripts/monitor-verified-batches.sh \
./.github/scripts/monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 rpc)
else
echo "Skipping batch verification as there is no zkevm permissionless RPC in the environment"
fi
- name: Monitor OP rollup finalized blocks (OP CL RPC)
run: |
result=$(yq --raw-output '.deployment_stages.deploy_optimism_rollup' ${{ matrix.file_name }})
if [[ "$result" == "true" ]]; then
./.github/scripts/monitor-op-rollup.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--cl-rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} op-cl-1-op-node-op-geth-op-kurtosis http)
else
echo "Skipping block verification as there is no OP rollup in the environment"
fi
- name: Dump enclave
if: ${{ !cancelled() }}
run: kurtosis enclave dump ${{ env.ENCLAVE_NAME }} ./dump
Expand Down Expand Up @@ -216,7 +228,7 @@ jobs:

- name: Deploy L1 chain
run: kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=./.github/tests/external-l1/deploy-local-l1.yml .

- name: Deploy gas token on L1
run: |
zkevm_contracts_version="v8.0.0-rc.4-fork.12"
Expand Down Expand Up @@ -254,10 +266,10 @@ jobs:
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Monitor verified batches
- name: Monitor CDK chain verified batches (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: |
./monitor-verified-batches.sh \
./monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)"
Expand Down Expand Up @@ -299,10 +311,10 @@ jobs:
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Monitor verified batches (CDK Erigon Permissionless RPC)
- name: Monitor CDK chain verified batches (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: |
./monitor-verified-batches.sh \
./monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)
Expand Down Expand Up @@ -419,17 +431,17 @@ jobs:
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Monitor verified batches of the first L2 chain (CDK Erigon Permissionless RPC)
- name: Monitor CDK chain 1 verified batches (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: |
./monitor-verified-batches.sh \
./monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)"
- name: Monitor verified batches of the second L2 chain (CDK Erigon Permissionless RPC)
- name: Monitor CDK chain 2 verified batches (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: |
./monitor-verified-batches.sh \
./monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-002 rpc)"
Expand Down Expand Up @@ -475,10 +487,10 @@ jobs:
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Monitor verified batches
- name: Monitor CDK chain verified batches (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: |
./monitor-verified-batches.sh \
./monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ jobs:
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Monitor verified batches (zkEVM Node Permissionless RPC)
- name: Monitor CDK chain verified batches (zkEVM Node Permissionless RPC)
working-directory: .github/scripts
run: |
./monitor-verified-batches.sh \
./monitor-cdk-chain.sh \
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 rpc)"
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:

# - name: Monitor verified batches (CDK Erigon Permissionless RPC)
# working-directory: .github/scripts
# run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)"
# run: ./monitor-cdk-chain.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)"

# Deploy the CDK environment incrementally, stage by stage.
# TODO: Fix this job.
Expand Down Expand Up @@ -194,4 +194,4 @@ jobs:

# - name: Monitor verified batches (CDK Erigon Permissionless RPC)
# working-directory: .github/scripts
# run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)"
# run: ./monitor-cdk-chain.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)"
Loading

0 comments on commit 2edcc2f

Please sign in to comment.