forked from erigontech/erigon
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'zkevm' into xiong/cache-tx-sender
- Loading branch information
Showing
170 changed files
with
9,824 additions
and
2,640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
name: "Setup Kurtosis" | ||
description: "Setup Kurtosis CDK for tests" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout cdk-erigon | ||
uses: actions/checkout@v4 | ||
with: | ||
path: cdk-erigon | ||
|
||
- name: Checkout kurtosis-cdk | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 0xPolygon/kurtosis-cdk | ||
ref: v0.2.24 | ||
path: kurtosis-cdk | ||
|
||
- name: Install Kurtosis CDK tools | ||
uses: ./kurtosis-cdk/.github/actions/setup-kurtosis-cdk | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Install polycli | ||
shell: bash | ||
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" | ||
sudo chmod +x /usr/local/bin/polycli | ||
/usr/local/bin/polycli version | ||
- name: Install yq | ||
shell: bash | ||
run: | | ||
sudo curl -L https://github.com/mikefarah/yq/releases/download/v4.44.2/yq_linux_amd64 -o /usr/local/bin/yq | ||
sudo chmod +x /usr/local/bin/yq | ||
/usr/local/bin/yq --version | ||
- name: Build docker image | ||
working-directory: ./cdk-erigon | ||
shell: bash | ||
run: docker build -t cdk-erigon:local --file Dockerfile . | ||
|
||
- name: Remove unused flags | ||
working-directory: ./kurtosis-cdk | ||
shell: bash | ||
run: | | ||
sed -i '/zkevm.sequencer-batch-seal-time:/d' templates/cdk-erigon/config.yml | ||
sed -i '/zkevm.sequencer-non-empty-batch-seal-time:/d' templates/cdk-erigon/config.yml | ||
sed -i '/zkevm\.sequencer-initial-fork-id/d' ./templates/cdk-erigon/config.yml | ||
sed -i '/sentry.drop-useless-peers:/d' templates/cdk-erigon/config.yml | ||
sed -i '/zkevm\.pool-manager-url/d' ./templates/cdk-erigon/config.yml | ||
sed -i '$a\zkevm.disable-virtual-counters: true' ./templates/cdk-erigon/config.yml | ||
sed -i '/zkevm.l2-datastreamer-timeout:/d' templates/cdk-erigon/config.yml | ||
- name: Create params.yml overrides | ||
working-directory: ./kurtosis-cdk | ||
shell: bash | ||
run: | | ||
echo 'args:' > params.yml | ||
echo ' cdk_erigon_node_image: cdk-erigon:local' >> params.yml | ||
echo ' el-1-geth-lighthouse: ethpandaops/lighthouse@sha256:4902d9e4a6b6b8d4c136ea54f0e51582a32f356f3dec7194a1adee13ed2d662e' >> params.yml | ||
/usr/local/bin/yq -i '.args.data_availability_mode = "${{ matrix.da-mode }}"' params.yml | ||
sed -i 's/"londonBlock": [0-9]\+/"londonBlock": 0/' ./templates/cdk-erigon/chainspec.json | ||
sed -i 's/"normalcyBlock": [0-9]\+/"normalcyBlock": 0/' ./templates/cdk-erigon/chainspec.json | ||
sed -i 's/"shanghaiTime": [0-9]\+/"shanghaiTime": 0/' ./templates/cdk-erigon/chainspec.json | ||
sed -i 's/"cancunTime": [0-9]\+/"cancunTime": 0/' ./templates/cdk-erigon/chainspec.json | ||
sed -i '/"terminalTotalDifficulty"/d' ./templates/cdk-erigon/chainspec.json | ||
- name: Deploy Kurtosis CDK package | ||
working-directory: ./kurtosis-cdk | ||
shell: bash | ||
run: | | ||
kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . '{"args": {"erigon_strict_mode": false, "cdk_erigon_node_image": "cdk-erigon:local"}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#!/bin/bash | ||
|
||
# Configuration | ||
THRESHOLD=80 | ||
MEASUREMENTS_FILE="/tmp/cpu_measurements.txt" | ||
MONITOR_INTERVAL=5 # seconds | ||
PROCESS_NAME="cdk-erigon" | ||
DETAILED_LOG="/tmp/cpu_detailed.log" | ||
|
||
# Function to get CPU usage for all matching processes | ||
get_process_cpu() { | ||
# Clear previous detailed log | ||
> "$DETAILED_LOG" | ||
|
||
# Get PIDs of cdk-erigon processes | ||
pids=$(pgrep -f "[c]dk-erigon") | ||
|
||
if [ -n "$pids" ]; then | ||
# Use top in batch mode for each PID to get current CPU usage | ||
for pid in $pids; do | ||
# Get process command | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
cmd=$(ps -p $pid -o command=) | ||
cpu=$(top -l 1 -pid $pid | tail -1 | awk '{print $3}') | ||
else | ||
cmd=$(ps -p $pid -o cmd=) | ||
cpu=$(top -b -n 1 -p $pid | tail -1 | awk '{print $9}') | ||
fi | ||
# Get current CPU usage | ||
echo "$pid $cpu $cmd" >> "$DETAILED_LOG" | ||
done | ||
fi | ||
|
||
# Sum total CPU usage | ||
total_cpu=$(awk '{sum += $2} END {printf "%.1f", sum}' "$DETAILED_LOG") | ||
|
||
# Return 0 if no process found | ||
if [ -z "$total_cpu" ]; then | ||
echo "0.0" | ||
else | ||
echo "$total_cpu" | ||
fi | ||
} | ||
|
||
# Function to show current process details | ||
show_process_details() { | ||
if [ -s "$DETAILED_LOG" ]; then | ||
echo "Individual process details:" | ||
printf "%-10s %-8s %-s\n" "PID" "CPU%" "Command" | ||
echo "----------------------------------------" | ||
while read -r line; do | ||
pid=$(echo "$line" | awk '{print $1}') | ||
cpu=$(echo "$line" | awk '{print $2}') | ||
cmd=$(echo "$line" | cut -d' ' -f3-) | ||
printf "%-10s %-8.1f %-s\n" "$pid" "$cpu" "$cmd" | ||
done < "$DETAILED_LOG" | ||
echo "----------------------------------------" | ||
else | ||
echo "No $PROCESS_NAME processes found" | ||
fi | ||
} | ||
|
||
# Function to analyze CPU measurements | ||
analyze_cpu() { | ||
if [ -f "$MEASUREMENTS_FILE" ]; then | ||
# Calculate statistics | ||
avg_cpu=$(awk '{ sum += $1 } END { print sum/NR }' "$MEASUREMENTS_FILE") | ||
avg_cpu_rounded=$(printf "%.1f" "$avg_cpu") | ||
max_cpu=$(awk 'BEGIN{max=0} {if($1>max) max=$1} END{print max}' "$MEASUREMENTS_FILE") | ||
measurement_count=$(wc -l < "$MEASUREMENTS_FILE") | ||
|
||
echo "" | ||
echo "=== CPU Usage Analysis for all $PROCESS_NAME processes ===" | ||
echo "Number of measurements: $measurement_count" | ||
echo "Average Combined CPU Usage: $avg_cpu_rounded%" | ||
echo "Peak Combined CPU Usage: $max_cpu%" | ||
echo "Threshold: $THRESHOLD%" | ||
|
||
# Get final process details for the report | ||
echo "" | ||
echo "Final process state:" | ||
show_process_details | ||
|
||
# Compare with threshold | ||
if [ "$(echo "$avg_cpu > $THRESHOLD" | bc -l)" -eq 1 ]; then | ||
echo "" | ||
echo "ERROR: Average CPU usage ($avg_cpu_rounded%) exceeded threshold of $THRESHOLD%" | ||
cleanup_and_exit 1 | ||
else | ||
echo "" | ||
echo "SUCCESS: CPU usage ($avg_cpu_rounded%) is within threshold of $THRESHOLD%" | ||
cleanup_and_exit 0 | ||
fi | ||
else | ||
echo "ERROR: No CPU measurements found at $MEASUREMENTS_FILE" | ||
cleanup_and_exit 1 | ||
fi | ||
} | ||
|
||
# Function to clean up and exit | ||
cleanup_and_exit() { | ||
exit_code=$1 | ||
rm -f "$DETAILED_LOG" | ||
exit $exit_code | ||
} | ||
|
||
# Function to handle interruption | ||
handle_interrupt() { | ||
echo "" | ||
echo "Monitoring interrupted. Analyzing collected data..." | ||
analyze_cpu | ||
} | ||
|
||
# Set up trap for various signals | ||
trap handle_interrupt TERM INT | ||
|
||
# Clear measurements file | ||
> "$MEASUREMENTS_FILE" | ||
> "$DETAILED_LOG" | ||
|
||
echo "Starting CPU monitoring for all '$PROCESS_NAME' processes" | ||
echo "Storing measurements in $MEASUREMENTS_FILE" | ||
echo "Monitoring interval: ${MONITOR_INTERVAL}s" | ||
echo "Press Ctrl+C to stop monitoring and see analysis" | ||
echo "" | ||
|
||
# Start monitoring loop | ||
while true; do | ||
# Get CPU usage for all matching processes | ||
cpu_usage=$(get_process_cpu) | ||
echo "$cpu_usage" >> "$MEASUREMENTS_FILE" | ||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Combined CPU Usage: $cpu_usage%" | ||
show_process_details | ||
echo "" | ||
sleep "$MONITOR_INTERVAL" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.