Skip to content

Commit

Permalink
fix: try to fix the test_resequence.sh (attempt 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Oct 23, 2024
1 parent c9372e6 commit 88cbefb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 21 additions & 12 deletions .github/scripts/test_resequence.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/bash

get_latest_l2_batch() {
local cdk_erigon_seq_url
cdk_erigon_seq_url=$(kurtosis port print cdk-v1 cdk-erigon-sequencer-001 rpc)

local latest_block
latest_block=$(cast block latest --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-sequencer-001 rpc)" | grep "number" | awk '{print $2}')
latest_block=$(cast block latest --rpc-url $cdk_erigon_seq_url | grep "number" | awk '{print $2}')

local latest_batch
latest_batch=$(cast rpc zkevm_batchNumberByBlockNumber "$latest_block" --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-sequencer-001 rpc)" | sed 's/^"//;s/"$//')
latest_batch=$(cast rpc zkevm_batchNumberByBlockNumber "$latest_block" --rpc-url $cdk_erigon_seq_url | sed 's/^"//;s/"$//')

if [[ -z "$latest_batch" ]]; then
echo "Error: Failed to get latest batch number" >&2
return 1
fi

latest_batch_dec=$((latest_batch))

echo "$latest_batch_dec"
}

Expand All @@ -23,7 +26,6 @@ get_latest_l1_verified_batch() {
echo "$current_batch_dec"
}


wait_for_l1_batch() {
local timeout=$1
local batch_type=$2
Expand Down Expand Up @@ -84,7 +86,7 @@ set -e
stop_cdk_erigon_sequencer

echo "Copying and modifying config"
kurtosis service exec cdk-v1 cdk-erigon-sequencer-001 'cp \-r /etc/cdk-erigon/ /tmp/ && sed -i '\''s/zkevm\.executor-strict: true/zkevm.executor-strict: false/;s/zkevm\.executor-urls: zkevm-stateless-executor-001:50071/zkevm.executor-urls: ","/;$a zkevm.disable-virtual-counters: true'\'' /tmp/cdk-erigon/config.yaml'
kurtosis service exec cdk-v1 cdk-erigon-sequencer-001 'cp \-r /etc/cdk-erigon/ /tmp/ && sed -i '\''s/zkevm\.executor-strict: true/zkevm.executor-strict: false/;s/zkevm\.executor-urls: zkevm-stateless-executor-001:50071/zkevm.executor-urls: ","/;$a zkevm.disable-virtual-counters: true'\'' /tmp/cdk-erigon/config.yaml'

echo "Starting cdk-erigon with modified config"
kurtosis service exec cdk-v1 cdk-erigon-sequencer-001 "nohup cdk-erigon --pprof=true --pprof.addr 0.0.0.0 --config /tmp/cdk-erigon/config.yaml --datadir /home/erigon/data/dynamic-kurtosis-sequencer > /proc/1/fd/1 2>&1 &"
Expand All @@ -93,7 +95,15 @@ kurtosis service exec cdk-v1 cdk-erigon-sequencer-001 "nohup cdk-erigon --pprof=
sleep 30

echo "Running loadtest using polycli"
/usr/local/bin/polycli loadtest --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-node-001 rpc)" --private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" --verbosity 600 --requests 2000 --rate-limit 500 --mode uniswapv3 --legacy

local cdk_erigon_rpc_url
cdk_erigon_rpc_url=$(kurtosis port print cdk-v1 cdk-erigon-node-001 rpc)

local cdk_erigon_seq_url
cdk_erigon_seq_url=$(kurtosis port print cdk-v1 cdk-erigon-sequencer-001 rpc)

/usr/local/bin/polycli loadtest uniswapv3 --legacy --rpc-url $cdk_erigon_rpc_url --private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" \
--verbosity 600 --requests 2000 --rate-limit 500

echo "Waiting for batch virtualization"
if ! wait_for_l1_batch 600 "virtual"; then
Expand All @@ -106,7 +116,6 @@ kurtosis service stop cdk-v1 cdk-node-001

stop_cdk_erigon_sequencer


# Good batch before counter overflow
latest_verified_batch=$(get_latest_l1_verified_batch)

Expand All @@ -132,18 +141,18 @@ echo "Restarting cdk node"
kurtosis service start cdk-v1 cdk-node-001

echo "Getting latest block number from sequencer"
latest_block=$(cast block latest --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-sequencer-001 rpc)" | grep "number" | awk '{print $2}')
latest_block=$(cast block latest --rpc-url $cdk_erigon_seq_url | grep "number" | awk '{print $2}')
echo "Latest block number from sequencer: $latest_block"

echo "Calculating comparison block number"
comparison_block=$((latest_block - 10))
echo "Block number to compare (10 blocks behind): $comparison_block"

echo "Getting block hash from sequencer"
sequencer_hash=$(cast block $comparison_block --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-sequencer-001 rpc)" | grep "hash" | awk '{print $2}')
sequencer_hash=$(cast block $comparison_block --rpc-url $cdk_erigon_seq_url | grep "hash" | awk '{print $2}')

echo "Getting block hash from node"
node_hash=$(cast block $comparison_block --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-node-001 rpc)" | grep "hash" | awk '{print $2}')
node_hash=$(cast block $comparison_block --rpc-url $cdk_erigon_rpc_url | grep "hash" | awk '{print $2}')

echo "Sequencer block hash: $sequencer_hash"
echo "Node block hash: $node_hash"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-resequence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
/usr/local/bin/yq --version
- name: Install polycli
run: |
tmp_dir=$(mktemp -d) && curl -L https://github.com/0xPolygon/polygon-cli/releases/download/v0.1.48/polycli_v0.1.48_linux_amd64.tar.gz | tar -xz -C "$tmp_dir" && mv "$tmp_dir"/* /usr/local/bin/polycli && rm -rf "$tmp_dir"
tmp_dir=$(mktemp -d) && curl -L https://github.com/0xPolygon/polygon-cli/releases/download/v0.1.60/polycli_v0.1.60_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: Build docker image
Expand Down

0 comments on commit 88cbefb

Please sign in to comment.