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

feat: op stack integration #418

Merged
merged 39 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0800a3f
feat: test integration of the op stack into our package
leovct Dec 4, 2024
7215d4f
fix: typo
leovct Dec 4, 2024
ba1c845
chore: nit
leovct Dec 4, 2024
c25513f
chore: nit
leovct Dec 4, 2024
3fa095a
fix: typo
leovct Dec 4, 2024
815dbd3
test
leovct Dec 4, 2024
1530ebb
test: more progress (wip)
leovct Dec 4, 2024
e81cc81
feat: enable to deploy op stack rollup
leovct Dec 5, 2024
4617980
fix: make sure the op rollup is not deployed by default
leovct Dec 5, 2024
4d01f9c
ci: test op rollup deployment in ci
leovct Dec 5, 2024
7e7e5f7
ci: run op rollup test
leovct Dec 5, 2024
64bc6f5
feat: customize op rollup and pin versions
leovct Dec 5, 2024
7b9e4a4
feta: enable to customize op rollup args
leovct Dec 5, 2024
d4106c5
ci: add debug verbosity in tests
leovct Dec 5, 2024
39fe281
chore: clean up
leovct Dec 5, 2024
bf1a1b5
fix: typo
leovct Dec 5, 2024
3dfdacc
fix: typo
leovct Dec 5, 2024
0744473
chore: print args
leovct Dec 5, 2024
e478dc2
fix: typo
leovct Dec 5, 2024
564b66d
fix: typos
leovct Dec 5, 2024
af0f12e
doc: nit
leovct Dec 5, 2024
9594942
chore: pin version of op-batcher
leovct Dec 6, 2024
8fa1b4b
ci: monitor op rollup block finalization
leovct Dec 6, 2024
93dda26
docs: nit
leovct Dec 6, 2024
fe53df9
chore: rename script
leovct Dec 6, 2024
c4bef0b
fix: lint
leovct Dec 6, 2024
f10cd43
fix: lint
leovct Dec 6, 2024
887d13c
ci: fix typo
leovct Dec 6, 2024
3e6f460
feat: deploy deterministic proxy by default
leovct Dec 6, 2024
3a67c1c
fix: typo
leovct Dec 6, 2024
e87f1f6
chore: spin up a sequencer node and an rpc node for the op rollup stack
leovct Dec 6, 2024
538af86
fix: lint
leovct Dec 6, 2024
633ce54
Merge branch 'main' into feat/op-stack-integration
leovct Dec 10, 2024
ed8c633
Merge branch 'main' into feat/op-stack-integration
leovct Dec 16, 2024
de54cd1
chore: switch back to the original op package
leovct Dec 17, 2024
a6ca263
Merge branch 'main' into feat/op-stack-integration
leovct Dec 17, 2024
a6a52e7
fix: typo (lol!!!)
leovct Dec 17, 2024
fa87871
Merge branch 'main' into feat/op-stack-integration
leovct Dec 19, 2024
0deb14b
Merge branch 'main' into feat/op-stack-integration
leovct Dec 30, 2024
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
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
Loading