From 87b7561cd041c066b7404e109a669283ea298869 Mon Sep 17 00:00:00 2001 From: Victor Castell <0x@vcastellm.xyz> Date: Tue, 13 Aug 2024 17:08:05 +0000 Subject: [PATCH] refactor: do not depend on external testing scripts --- test/run-e2e.sh | 2 +- test/scripts/batch_verification_monitor.sh | 47 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100755 test/scripts/batch_verification_monitor.sh diff --git a/test/run-e2e.sh b/test/run-e2e.sh index 34842a95..a0db5d56 100755 --- a/test/run-e2e.sh +++ b/test/run-e2e.sh @@ -25,4 +25,4 @@ kurtosis clean --all kurtosis run --enclave cdk-v1 --args-file $DEST_KURTOSIS_PARAMS_YML --image-download always $KURTOSIS_FOLDER #[ $? -ne 0 ] && echo "Error running kurtosis" && exit 1 echo "Waiting 10 minutes to get some verified batch...." -$KURTOSIS_FOLDER/.github/actions/monitor-cdk-verified-batches/batch_verification_monitor.sh 0 600 +scripts/batch_verification_monitor.sh 0 600 diff --git a/test/scripts/batch_verification_monitor.sh b/test/scripts/batch_verification_monitor.sh new file mode 100755 index 00000000..9dc18e64 --- /dev/null +++ b/test/scripts/batch_verification_monitor.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# This script monitors the verification progress of zkEVM batches. + +# Check if the required arguments are provided. +if [ "$#" -lt 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# The number of batches to be verified. +verified_batches_target="$1" + +# The script timeout (in seconds). +timeout="$2" + +start_time=$(date +%s) +end_time=$((start_time + timeout)) + +rpc_url="$(kurtosis port print cdk-v1 cdk-erigon-node-001 http-rpc)" + +while true; do + verified_batches="$(cast to-dec "$(cast rpc --rpc-url "$rpc_url" zkevm_verifiedBatchNumber | sed 's/"//g')")" + echo "[$(date '+%Y-%m-%d %H:%M:%S')] Verified Batches: $verified_batches" + + # The aim is to take up some space in the batch, so that the number of batches actually increases during the test. + cast send \ + --legacy \ + --rpc-url "$rpc_url" \ + --private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" \ + --gas-limit 100_000 \ + --create 0x600160015B810190630000000456 \ + >/dev/null 2>&1 + + current_time=$(date +%s) + if ((current_time > end_time)); then + echo "[$(date '+%Y-%m-%d %H:%M:%S')] ❌ Exiting... Timeout reached!" + exit 1 + fi + + if ((verified_batches > verified_batches_target)); then + echo "[$(date '+%Y-%m-%d %H:%M:%S')] ✅ Exiting... $verified_batches batches were verified!" + exit 0 + fi + + sleep 10 +done