Skip to content

Commit

Permalink
test: add attaching a third PP network into the CI + testing ulxly (#441
Browse files Browse the repository at this point in the history
)

* feat: add pp integration into workflow

Signed-off-by: Ji Hwan <[email protected]>

* fix: attaching third PP network

Signed-off-by: Ji Hwan <[email protected]>

* fix: replace verified batch number check for pp network

Signed-off-by: Ji Hwan <[email protected]>

* chore: change workflow trigger to main branch only

Signed-off-by: Ji Hwan <[email protected]>

* chore: update versions and add github secrets

Signed-off-by: Ji Hwan <[email protected]>

* feat: add bridge deposit and claim binaries for CI integration

Signed-off-by: Ji Hwan <[email protected]>

* test: change CI to use dynamic URLs as bridge txn inputs

Signed-off-by: Ji Hwan <[email protected]>

* chore: cleanup

Signed-off-by: Ji Hwan <[email protected]>

* chore: fix early exit in bridge txn test

Signed-off-by: Ji Hwan <[email protected]>

* test: add additional step in CI to bridge from third PP network to first rollup.

Signed-off-by: Ji Hwan <[email protected]>

* fix: network id for briding from PP -> rollup

Signed-off-by: Ji Hwan <[email protected]>

* chore: adjust sleep time for bridging from third PP -> first rollup

Signed-off-by: Ji Hwan <[email protected]>

* chore: correct secrets name for sp1 pvt key

Signed-off-by: Ji Hwan <[email protected]>

* chore: set global log level to info when using sp1 keys

Signed-off-by: Ji Hwan <[email protected]>

* chore: update pp third network image versions

Signed-off-by: Ji Hwan <[email protected]>

* chore: fix CI not having gh secrets when pushing from forks

Signed-off-by: Ji Hwan <[email protected]>

* chore: gh secrets and test conditional

Signed-off-by: Ji Hwan <[email protected]>

* chore: only run PP network steps if gh secrets for sp1 key available

Signed-off-by: Ji Hwan <[email protected]>

* refactor: change bridge binaries to use polycli ulxly

Signed-off-by: Ji Hwan <[email protected]>

* chore: fix flags

Signed-off-by: Ji Hwan <[email protected]>

* refactor: use bridge binaries until polycli ulxly merged

Signed-off-by: Ji Hwan <[email protected]>

* tests: fix ci for attaching multiple pp cdk and bridge testing

Signed-off-by: Ji Hwan <[email protected]>

* test: disable verified batches increment check for pp cdk

Signed-off-by: Ji Hwan <[email protected]>

* chore: revert to older agglayer version on input_parser.star

Signed-off-by: Ji Hwan <[email protected]>

* chore: cleanup

Signed-off-by: Ji Hwan <[email protected]>

* refactor: use polycli ulxly commands in ci

Signed-off-by: Ji Hwan <[email protected]>

* chore: add polycli command installation to ci

Signed-off-by: Ji Hwan <[email protected]>

* chore: update multi chain attach config

Signed-off-by: Ji Hwan <[email protected]>

* fix: add gas-price for polycli ulxly

Signed-off-by: Ji Hwan <[email protected]>

* chore: remove redundant bridge binaries in favour of polycli

Signed-off-by: Ji Hwan <[email protected]>

---------

Signed-off-by: Ji Hwan <[email protected]>
  • Loading branch information
jhkimqd authored Jan 16, 2025
1 parent 5f19993 commit d0da892
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 13 deletions.
9 changes: 9 additions & 0 deletions .github/tests/agglayer-sp1-key.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
args:
agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.23
agglayer_prover_sp1_key: ""
zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1
consensus_contract_type: pessimistic
erigon_strict_mode: false
gas_token_enabled: false
# zkevm_use_real_verifier: true
enable_normalcy: true
2 changes: 2 additions & 0 deletions .github/tests/attach-second-cdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ args:
zkevm_l2_dac_private_key: "0x992c9ab11d5eab6b6c2634b8bb0b85f3d8d1acf25024dc99c359cb2afd9b40a7"
zkevm_l2_proofsigner_address: "0xf1a661D7b601Ec46a040f57193cC99aB8c4132FA"
zkevm_l2_proofsigner_private_key: "0xc7fe3a006d75ba9326d9792523385abb49057c66aee0b8b4248821a89713f975"

zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1
62 changes: 62 additions & 0 deletions .github/tests/attach-third-cdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
deployment_stages:
deploy_l1: false
deploy_agglayer: false

args:
deployment_suffix: "-003"
zkevm_rollup_chain_id: 30303
zkevm_rollup_id: 3

# polycli wallet inspect --mnemonic 'holiday crunch rule artefact cinnamon suit uphold evil shrimp topic core abstract' --addresses 11 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner,l1testing,claimsponsor",roles,",")} {print "# " roles[NR] "\nzkevm_l2_" roles[NR] "_address: " $1 ""; print "zkevm_l2_" roles[NR] "_private_key: 0x" $2 "\n"}'

# sequencer
zkevm_l2_sequencer_address: "0x0d59BC8C02A089D48d9Cd465b74Cb6E23dEB950D"
zkevm_l2_sequencer_private_key: "0xf6385a27e7710349617340c6f9310e88f0aad10d01646a9bb204177431babcd8"

# aggregator
zkevm_l2_aggregator_address: "0x2D20D9081fb403E856355F2cddd1C4863D0109cb"
zkevm_l2_aggregator_private_key: "0x2cb77c2cca48d3fee64c14d73564fd6e90676a4f6da6545681e10c8b9b22fce2"

# claimtxmanager
zkevm_l2_claimtxmanager_address: "0x1359D1eAf25aADaA04304Ee7EFC5b94C43e0e1D5"
zkevm_l2_claimtxmanager_private_key: "0xb0244fcbf83d7aaa2d51dc78a55233058af31797a974d25f724de041f3484418"

# timelock
zkevm_l2_timelock_address: "0x7803E33388C695E7cbd85eD55f4abe6455E9ce2e"
zkevm_l2_timelock_private_key: "0xe12e739b58489a2c2f49c472169ba20eb89d039e71f04d5342ab645dc3fb6540"

# admin
# zkevm_l2_admin_address: "0x5666Cc6B46ad32b469D9Aec7C1eE6d02f7312759"
# zkevm_l2_admin_private_key: "0xd2ee309113fc97bed6030201fea0d1234d6b4acbc47b9a4fe12a8fa5270052aa"

# loadtest
zkevm_l2_loadtest_address: "0x5198d92d278Fd36e5745C308F728d256198A0e3d"
zkevm_l2_loadtest_private_key: "0xcc594c53eca19f9e56200cadf60c94757b0bdee1fc4bc73552ba879d51fd82b3"

# agglayer
zkevm_l2_agglayer_address: "0x9b5A1f2bC7bb48419d9f6407CFcA454F87884072"
zkevm_l2_agglayer_private_key: "0x7b1164f53f633e940089031a3c265c308d2bcf4756bc8dcf9046bf00e21ec3b1"

# dac
zkevm_l2_dac_address: "0xA9875E9B9FE3BD46da758ba69a5d4B9dFCA6F133"
zkevm_l2_dac_private_key: "0x5d1a923f60e2423932f782dab9510e1c2fd64b0f29b0893978864191ecdd6f4f"

# proofsigner
zkevm_l2_proofsigner_address: "0x3AA075513578d86dC63f9344cD9489b948d7686a"
zkevm_l2_proofsigner_private_key: "0xfd402dcc8c7fc7ce0df59fe12f33da7ac2ed760a619188ff16974fde16f9b00e"

# l1testing
zkevm_l2_l1testing_address: "0x943413d3b2E1B6aF09a758c35b6F5d23a4d6d262"
zkevm_l2_l1testing_private_key: "0x27d8ab2d65296d0da072b172ca9ca874583f9930adb6ac3222fd9494ae7c7f0d"

# claimsponsor
zkevm_l2_claimsponsor_address: "0xeA06890A8A547aDd71f98A6845542eb3B63C2862"
zkevm_l2_claimsponsor_private_key: "0xb97112e36cfcde131faa110430eed6593b75406e5d6991d8db3ed0f492a73b6f"

cdk_node_image: ghcr.io/0xpolygon/cdk:0.5.0-beta10
zkevm_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.3-pp-fork.12-patch.1
consensus_contract_type: pessimistic
erigon_strict_mode: false
gas_token_enabled: false
# zkevm_use_real_verifier: true
enable_normalcy: true
151 changes: 141 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ name: Deploy
on:
pull_request:
push:
branches: [main]
branches:
- '**'

concurrency:
group: deploy-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
POLYCLI_VERSION: v0.1.67 # https://github.com/0xPolygon/polygon-cli/releases/
ENCLAVE_NAME: cdk

jobs:
Expand Down Expand Up @@ -387,7 +389,7 @@ jobs:
name: dump_additional_services_${{ github.run_id }}
path: ./dump

attach-second-cdk:
attach-additional-cdks:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -405,22 +407,60 @@ jobs:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Install polycli
run: |
tmp_dir=$(mktemp -d)
curl -L "https://github.com/0xPolygon/polygon-cli/releases/download/${{ env.POLYCLI_VERSION }}/polycli_${{ env.POLYCLI_VERSION }}_linux_amd64.tar.gz" | tar -xz -C "$tmp_dir"
mv "$tmp_dir"/* /usr/local/bin/polycli
rm -rf "$tmp_dir"
sudo chmod +x /usr/local/bin/polycli
/usr/local/bin/polycli version
- name: Install Kurtosis CDK tools
uses: ./.github/actions/setup-kurtosis-cdk

# Step to handle when the SP1_PRIVATE_KEY secret is available.
- name: Replace Agglayer SP1 Prover Key with Github Secrets
run: |
sed -i "s/agglayer_prover_sp1_key: \"\"/agglayer_prover_sp1_key: \"${{ secrets.SP1_PRIVATE_KEY }}\"/" ./.github/tests/agglayer-sp1-key.yml
# This step will only execute if the necessary secrets are available, preventing failures
# on pull requests from forked repositories.
if: ${{ env.agglayer_prover_sp1_key && env.agglayer_prover_sp1_key != '' }}
env :
agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }}

- name: Deploy L1 chain and a first CDK L2 chain (cdk-erigon sequencer + cdk stack)
run: kurtosis run --enclave=${{ env.ENCLAVE_NAME }} .
run: kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=./.github/tests/agglayer-sp1-key.yml .

- name: Attach a second CDK L2 chain (cdk-erigon sequencer + cdk stack)
- name: Attach a second FEP CDK L2 chain (cdk-erigon sequencer + cdk FEP stack)
run: kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=./.github/tests/attach-second-cdk.yml .

# Only run this step if the SP1_PRIVATE_KEY secrets is available.
- name: Attach a third PP CDK L2 chain (cdk-erigon sequencer + cdk PP stack)
if: ${{ env.agglayer_prover_sp1_key || env.agglayer_prover_sp1_key != '' }}
run: |
kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=./.github/tests/attach-third-cdk.yml .
env:
agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }}

# Only run this step if the SP1_PRIVATE_KEY secrets is available.
- name: Restart the Erigon RPC of the PP network
if: ${{ env.agglayer_prover_sp1_key || env.agglayer_prover_sp1_key != '' }}
run: |
kurtosis service stop ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-003
kurtosis service start ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-003
env:
agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }}

- name: Update the agglayer config
run: |
# Download the agglayer config file.
kurtosis files download ${{ env.ENCLAVE_NAME }} agglayer-config-artifact
cd agglayer-config-artifact
# Update the config by adding the rpc and proof signer of the second chain.
tomlq -Y --toml-output --in-place '."full-node-rpcs" += {"2": "http://cdk-erigon-rpc-002:8123"}' agglayer-config.toml
# Update the config by adding the rpc and proof signer of the third chain.
tomlq -Y --toml-output --in-place '."full-node-rpcs" += {"3": "http://cdk-erigon-rpc-003:8123"}' agglayer-config.toml
# Replace the agglayer config.
agglayer_container_id="$(docker ps --filter name=agglayer --format json | jq -r -s '. | map(select(.Names | startswith("agglayer--"))) | .[].ID')"
docker cp agglayer-config.toml "$agglayer_container_id:/etc/zkevm/agglayer-config.toml"
Expand All @@ -431,12 +471,12 @@ jobs:
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

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

- name: Monitor CDK chain 2 verified batches (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
Expand All @@ -445,6 +485,97 @@ jobs:
--enclave ${{ env.ENCLAVE_NAME }} \
--rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-002 rpc)"
- name: Send bridge transactions from L1 to the third PP L2 chain
if: ${{ env.agglayer_prover_sp1_key || env.agglayer_prover_sp1_key != '' }}
working-directory: .github/scripts
run: |
echo "Sending a bridge transaction from L1 to the PP network Erigon RPC..."
originNetworkURL=$(kurtosis port print ${{ env.ENCLAVE_NAME }} el-1-geth-lighthouse rpc)
polycli ulxly bridge asset \
--private-key 12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \
--value 1000000000000000000 \
--rpc-url http://$originNetworkURL \
--bridge-address 0xd8886e9D827218a02B8C04323b5550f2F36BC8d5 \
--destination-network 3 \
--force-update-root=true \
--destination-address 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
if [[ $ret_code -eq 0 ]]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Exiting... Deposit Transaction successfuly sent!"
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Deposit Transaction failed!"
exit 1
fi
echo "Waiting for deposit to be claimable..."
sleep 60
destNetworkURL=$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-003 rpc)
bridgeURL=$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-bridge-service-003 rpc)
polycli ulxly claim asset \
--bridge-address 0xd8886e9D827218a02B8C04323b5550f2F36BC8d5 \
--private-key 12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \
--deposit-count 3 \
--destination-address 0xE34aaF64b29273B7D567FCFc40544c014EEe9970 \
--deposit-network 0 \
--rpc-url $destNetworkURL \
--bridge-service-url $bridgeURL \
--gas-price $(cast gas-price --rpc-url $destNetworkURL)
if [[ $ret_code -eq 0 ]]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Exiting... Claim Transaction successfuly sent!"
exit 0
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Claim Transaction failed!"
exit 1
fi
env:
agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }}

- name: Bridge from third PP L2 chain to first Rollup chain.
if: ${{ env.agglayer_prover_sp1_key || env.agglayer_prover_sp1_key != '' }}
working-directory: .github/scripts
run: |
echo "Sending a bridge transaction from third PP network to the first rollup Erigon RPC..."
originNetworkURL=$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-003 rpc)
polycli ulxly bridge asset \
--private-key 12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \
--value 1000000000000 \
--rpc-url $originNetworkURL \
--bridge-address 0xd8886e9D827218a02B8C04323b5550f2F36BC8d5 \
--destination-network 1 \
--force-update-root=true \
--destination-address 0xE34aaF64b29273B7D567FCFc40544c014EEe9970 \
--gas-price $(cast gas-price --rpc-url $originNetworkURL)
if [[ $ret_code -eq 0 ]]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Exiting... Deposit Transaction successfuly sent!"
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Deposit Transaction failed!"
exit 1
fi
echo "Waiting for deposit to be claimable..."
sleep 300
destNetworkURL=$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)
bridgeURL=$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-bridge-service-003 rpc)
polycli ulxly claim asset \
--bridge-address 0xd8886e9D827218a02B8C04323b5550f2F36BC8d5 \
--private-key 12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \
--deposit-count 0 \
--destination-address 0xE34aaF64b29273B7D567FCFc40544c014EEe9970 \
--deposit-network 3 \
--rpc-url $destNetworkURL \
--bridge-service-url $bridgeURL \
--gas-price $(cast gas-price --rpc-url $destNetworkURL)
if [[ $ret_code -eq 0 ]]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Exiting... Claim Transaction successfuly sent!"
exit 0
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Claim Transaction failed!"
exit 1
fi
env:
agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }}

- name: Dump enclave
if: ${{ !cancelled() }}
run: kurtosis enclave dump ${{ env.ENCLAVE_NAME }} ./dump
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
IMAGE_NAME: leovct/zkevm-contracts
POLYCLI_VERSION: v0.1.64 # https://github.com/0xPolygon/polygon-cli/releases/tag/v0.1.64 - 2024-11-25
POLYCLI_VERSION: v0.1.67 # https://github.com/0xPolygon/polygon-cli/releases/
FOUNDRY_VERSION: nightly-27cabbd6c905b1273a5ed3ba7c10acce90833d76 # https://github.com/foundry-rs/foundry/releases/tag/nightly-27cabbd6c905b1273a5ed3ba7c10acce90833d76 - 2024-11-29

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
cancel-in-progress: true

env:
POLYCLI_VERSION: v0.1.65 # 2024-12-16
POLYCLI_VERSION: v0.1.67 # https://github.com/0xPolygon/polygon-cli/releases/
CDK_VERSION: v0.5.0-beta10 # 2024-12-10

jobs:
Expand Down
2 changes: 1 addition & 1 deletion templates/contract-deploy/run-contract-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fund_account_on_l1() {

deploy_rollup_manager() {
# Deploy contracts.
echo_ts "Step 1: Preparing tesnet"
echo_ts "Step 1: Preparing testnet"
npx hardhat run deployment/testnet/prepareTestnet.ts --network localhost 2>&1 | tee 01_prepare_testnet.out

echo_ts "Step 2: Creating genesis"
Expand Down

0 comments on commit d0da892

Please sign in to comment.