Skip to content

Add test to re-execute specified range of mainnet C-Chain blocks #4019

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

Open
wants to merge 108 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
a9f395f
feat(scripts): add copy_dir.sh script to copy from local filesystem o…
aaronbuchwald Jun 17, 2025
197214e
feat(scripts): add script and task def to import cchain data for reex…
aaronbuchwald Jun 17, 2025
ba1a234
test(cchain): add vm reexecution test and task to import required dat…
aaronbuchwald Jun 17, 2025
d1cdb8e
improve comment on cchain bench test
aaronbuchwald Jun 17, 2025
3ca35a8
Move required data to avalanchego-bootstrap-testing s3 bucket
aaronbuchwald Jun 17, 2025
0dee263
add TestPrometheusIntegration
aaronbuchwald Jun 25, 2025
962a250
remove no files found err condition
aaronbuchwald Jun 25, 2025
ef940be
remove bash -x prefix from run monitored tmpnet cmd
aaronbuchwald Jun 25, 2025
8dfee2b
Add grafana preview dashboard name as input to run monitored tmpnet cmd
aaronbuchwald Jun 26, 2025
1aa89e5
Add helper to write prometheus sd config file
aaronbuchwald Jun 26, 2025
65e64c7
Get vm test working
aaronbuchwald Jun 26, 2025
0240e3a
move bash -x in cmd of run monitored tmpnet cmd to call sites
aaronbuchwald Jun 26, 2025
7e3ef87
use runtime input to disable artifact collection and avoid err
aaronbuchwald Jun 26, 2025
ef9ed07
fix up monitor processes
aaronbuchwald Jun 26, 2025
c010bf8
move prometheus server into separate test file
aaronbuchwald Jun 26, 2025
8d2c061
Add aws read only role usage
aaronbuchwald Jun 26, 2025
b625ee8
cleanup
aaronbuchwald Jun 26, 2025
ee19b2d
Merge branch 'master' into aaronbuchwald/cchain-reexecute-range-test
aaronbuchwald Jun 26, 2025
8027234
ensure s5cmd exists in copy dir script
aaronbuchwald Jun 26, 2025
0335061
fix s5cmd install
aaronbuchwald Jun 26, 2025
111bb53
add combo task
aaronbuchwald Jun 26, 2025
dbd3f34
remove s5cmd from flake.nix
aaronbuchwald Jun 26, 2025
bc28c6b
add s5cmd
aaronbuchwald Jun 26, 2025
9f84199
remove debugging tests
aaronbuchwald Jun 26, 2025
96d1af4
cleanup
aaronbuchwald Jun 26, 2025
3c01f26
cleanup
aaronbuchwald Jun 26, 2025
ef909b1
re-arrange for block export
aaronbuchwald Jun 30, 2025
871cc02
Fix atomic memory db mismatch
aaronbuchwald Jun 30, 2025
7fb4bb4
Add task to export c-chain current state data
aaronbuchwald Jun 30, 2025
3f8d706
Fix import/export
aaronbuchwald Jun 30, 2025
ecceb9e
update ci
aaronbuchwald Jun 30, 2025
ca7a903
avoid relative path
aaronbuchwald Jun 30, 2025
2e27b7b
revert underscore to dash
aaronbuchwald Jul 1, 2025
4abb96f
Add README for c-chain benchmarks
aaronbuchwald Jul 1, 2025
06b2345
add section on setting up credentials
aaronbuchwald Jul 1, 2025
ebc6917
update readme
aaronbuchwald Jul 1, 2025
29342f3
fix s3 expressions following readme instructions
aaronbuchwald Jul 1, 2025
c4c4906
Ensure final metrics scrape
aaronbuchwald Jul 1, 2025
543459b
Improve readme
aaronbuchwald Jul 1, 2025
dc8f9f5
Add export-cchain-block-range
aaronbuchwald Jul 1, 2025
4a545b7
export blocks to leveldb
aaronbuchwald Jul 2, 2025
d515598
Remove helpers for old db format
aaronbuchwald Jul 2, 2025
97c5a66
change to use 10k blocks
aaronbuchwald Jul 2, 2025
ac1bd21
nit label and disable test timeout in tasks
aaronbuchwald Jul 2, 2025
a6b8967
change to periodic logs
aaronbuchwald Jul 2, 2025
9117022
fix lint
aaronbuchwald Jul 7, 2025
4dace59
Apply suggestions from code review
aaronbuchwald Jul 7, 2025
960c63f
Merge branch 'master' into aaronbuchwald/cchain-reexecute-range-test
aaronbuchwald Jul 7, 2025
3d8008c
fix merge
aaronbuchwald Jul 7, 2025
1e80318
fix merge
aaronbuchwald Jul 7, 2025
28b3417
Fix lint
aaronbuchwald Jul 8, 2025
9b419da
fix copy dir and vm constructor
aaronbuchwald Jul 8, 2025
410aee7
Remove debug logs on every block
aaronbuchwald Jul 8, 2025
371d5d0
debug
aaronbuchwald Jul 8, 2025
69a46af
debug ordering of collectRegistry
aaronbuchwald Jul 8, 2025
dbb3a03
Add chain=C label to vm metrics
aaronbuchwald Jul 9, 2025
9f7030c
Add consensus metrics registry and last accepted height gauge to benc…
aaronbuchwald Jul 9, 2025
b7ba60b
migrate c chain benchmark to separate workflow file
aaronbuchwald Jul 9, 2025
b1f029a
Add execution timeout without error
aaronbuchwald Jul 9, 2025
098c180
fix actionslint
aaronbuchwald Jul 9, 2025
e19b7bf
cleanup
aaronbuchwald Jul 10, 2025
a34047b
Move env var back to end of line
aaronbuchwald Jul 10, 2025
2ac1876
cleanup
aaronbuchwald Jul 10, 2025
5190026
Shorten default block range to [100, 250k] to cut PR CI runtime
aaronbuchwald Jul 10, 2025
45e5b12
improve readme
aaronbuchwald Jul 10, 2025
20e4c20
Merge branch 'master' into aaronbuchwald/cchain-reexecute-range-test
aaronbuchwald Jul 10, 2025
89d9ffa
fix grafana preview link
aaronbuchwald Jul 10, 2025
5c62527
fix grafana dashboard input
aaronbuchwald Jul 10, 2025
88a59db
Simplify C-Chain label and add is_ephemeral_node=false
aaronbuchwald Jul 10, 2025
4b327c9
update s3 zip name used in readme to follow convention
aaronbuchwald Jul 11, 2025
5579435
Use benchmark syntax to generate top-level metrics
aaronbuchwald Jul 11, 2025
ec4eecb
Add github action benchmark step
aaronbuchwald Jul 11, 2025
73812dc
Update exec dir param in cchain benchmark yml
aaronbuchwald Jul 11, 2025
8bb9ccf
Merge branch 'master' into aaronbuchwald/cchain-reexecute-range-test
aaronbuchwald Jul 11, 2025
e0967ed
fix output file name
aaronbuchwald Jul 11, 2025
86c7ec5
update taskfile to use separate block dir
aaronbuchwald Jul 11, 2025
0f40d3d
Add support for attaching custom labels
aaronbuchwald Jul 11, 2025
d948c35
fix formatting
aaronbuchwald Jul 11, 2025
2ee1ee7
fix formatting
aaronbuchwald Jul 11, 2025
2e1d408
Fix cache usage for bench comparison
aaronbuchwald Jul 11, 2025
7bf39d8
check comparison
aaronbuchwald Jul 11, 2025
59f33b4
Add chainID to subnetID lookup to snow ctx
aaronbuchwald Jul 14, 2025
f39d9ce
fix lint
aaronbuchwald Jul 14, 2025
96e3d47
update to use ARC
aaronbuchwald Jul 15, 2025
2ac8765
add xz before nix
aaronbuchwald Jul 15, 2025
e4aca3c
update to use GITHUB_ACTION_PATH
aaronbuchwald Jul 15, 2025
4dcf897
Fix github workspace var usage
aaronbuchwald Jul 15, 2025
69240ea
cleanup var names
aaronbuchwald Jul 15, 2025
35481c0
Merge branch 'master' into aaronbuchwald/cchain-reexecute-range-test
aaronbuchwald Jul 16, 2025
4fcbf0c
fix lint
aaronbuchwald Jul 16, 2025
b064fb5
revert back to gh runner
aaronbuchwald Jul 16, 2025
70e3db2
remove bash -x prefix
aaronbuchwald Jul 16, 2025
030cc87
revert bash -x from ci.yml
aaronbuchwald Jul 16, 2025
7a69cea
cleanup
aaronbuchwald Jul 16, 2025
dba9a84
Update taskfile var names
aaronbuchwald Jul 16, 2025
de17f16
move benchmark output file to arg
aaronbuchwald Jul 16, 2025
9c71b7b
switch back to using gh context
aaronbuchwald Jul 16, 2025
a39a1e4
Add cronjob for C-Chain benchmark to run weekly on Sunday
aaronbuchwald Jul 16, 2025
df1d074
Use default config
aaronbuchwald Jul 17, 2025
1402892
Address comments
aaronbuchwald Jul 18, 2025
815929e
revert use of env context where it's not available
aaronbuchwald Jul 18, 2025
9ee02d2
Merge branch 'master' into aaronbuchwald/cchain-reexecute-range-test
aaronbuchwald Jul 18, 2025
dc5e63c
Update test filter
aaronbuchwald Jul 18, 2025
857624d
upate benchmark path in readme
aaronbuchwald Jul 18, 2025
baa4452
rename
aaronbuchwald Jul 18, 2025
701bfa9
remove unused env vars
aaronbuchwald Jul 18, 2025
67e1741
fix default start param in workflow
aaronbuchwald Jul 18, 2025
3ce4d26
Change default back to 250k
aaronbuchwald Jul 18, 2025
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
73 changes: 73 additions & 0 deletions .github/workflows/c-chain-reexecution-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: C-Chain Re-Execution Benchmark

on:
pull_request:
workflow_dispatch:
inputs:
start-block:
description: 'The start block for the benchmark.'
required: false
default: 101
end-block:
description: 'The end block for the benchmark.'
required: false
default: 250000
source-block-dir:
description: 'The source block directory. Supports S3 directory/zip and local directories.'
required: false
default: s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb.zip
current-state-dir:
description: 'The current state directory. Supports S3 directory/zip and local directories.'
required: false
default: s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100.zip
schedule:
- cron: '0 6 * * 0' # Runs every Sunday at 06:00 UTC

jobs:
c-chain-reexecution:
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_S3_READ_ONLY_ROLE }}
aws-region: us-east-2
- name: Set task env via GITHUB_ENV
id: set-params
run: |
{
echo "START_BLOCK=${{ github.event.inputs.start-block || 101 }}"
echo "END_BLOCK=${{ github.event.inputs.end-block || 250000 }}"
echo "SOURCE_BLOCK_DIR=${{ github.event.inputs.source-block-dir || 's3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb.zip' }}"
echo "CURRENT_STATE_DIR=${{ github.event.inputs.current-state-dir || 's3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100.zip' }}"
} >> "$GITHUB_ENV"
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- name: Run C-Chain Re-Execution
uses: ./.github/actions/run-monitored-tmpnet-cmd
with:
run: ./scripts/run_task.sh reexecute-cchain-range-with-copied-data EXECUTION_DATA_DIR=${{ github.workspace }}/reexecution-data BENCHMARK_OUTPUT_FILE=${{ github.workspace }}/reexecute-cchain-range-benchmark-res.txt
prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }}
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
grafana_dashboard_id: 'Gl1I20mnk/c-chain'
loki_username: ${{ secrets.LOKI_ID || '' }}
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
runtime: "" # Set runtime input to empty string to disable log collection
- name: Download Previous Benchmark Result
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-reexecute-cchain-range-benchmark.json
- name: Compare Benchmark Results
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'go'
output-file-path: ${{ github.workspace }}/reexecute-cchain-range-benchmark-res.txt
external-data-json-path: ./cache/${{ runner.os }}-reexecute-cchain-range-benchmark.json
fail-on-alert: true
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
comment-on-alert: true
85 changes: 85 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ tasks:
- cmd: go mod tidy
- task: check-clean-branch

export-cchain-block-range:
desc: Export range of C-Chain blocks from source to target directory.
vars:
SOURCE_BLOCK_DIR: '{{.SOURCE_BLOCK_DIR}}'
TARGET_BLOCK_DIR: '{{.TARGET_BLOCK_DIR}}'
START_BLOCK: '{{.START_BLOCK}}'
END_BLOCK: '{{.END_BLOCK}}'
cmds:
- cmd: go test -timeout=0 -run=TestExportBlockRange github.com/ava-labs/avalanchego/tests/reexecute/c --source-block-dir={{.SOURCE_BLOCK_DIR}} --target-block-dir={{.TARGET_BLOCK_DIR}} --start-block={{.START_BLOCK}} --end-block={{.END_BLOCK}}

export-dir-to-s3:
desc: Copies a directory to s3
vars:
LOCAL_SRC: '{{.LOCAL_SRC}}'
S3_DST: '{{.S3_DST}}'
cmds:
- cmd: s5cmd cp {{.LOCAL_SRC}} {{.S3_DST}}

generate-mocks:
desc: Generates testing mocks
cmds:
Expand All @@ -109,6 +127,30 @@ tasks:
desc: Runs ginkgo against the current working directory
cmd: ./bin/ginkgo build {{.USER_WORKING_DIR}}

import-cchain-reexecute-range:
desc: Imports the C-Chain block and state data to re-execute. Defaults to import the first 200 and the current state created with the default config of the C-Chain (hashdb).
vars:
EXECUTION_DATA_DIR: '{{.EXECUTION_DATA_DIR}}'
SOURCE_BLOCK_DIR: '{{.SOURCE_BLOCK_DIR | default "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-200.zip"}}'
CURRENT_STATE_DIR: '{{.CURRENT_STATE_DIR | default "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100.zip"}}'
cmds:
- task: import-s3-to-dir
vars:
SRC: '{{.SOURCE_BLOCK_DIR}}'
DST: '{{.EXECUTION_DATA_DIR}}/blocks'
- task: import-s3-to-dir
vars:
SRC: '{{.CURRENT_STATE_DIR}}'
DST: '{{.EXECUTION_DATA_DIR}}/current-state'

import-s3-to-dir:
desc: Imports an S3 path to a local directory. Unzipping if needed.
vars:
SRC: '{{.SRC}}'
DST: '{{.DST}}'
cmds:
- cmd: bash -x ./scripts/copy_dir.sh {{.SRC}} {{.DST}}

install-nix:
desc: Installs nix with the determinate systems installer
cmd: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Expand Down Expand Up @@ -139,6 +181,49 @@ tasks:
desc: Runs shellcheck to check sanity of shell scripts
cmd: ./scripts/shellcheck.sh

reexecute-cchain-range:
desc: Re-execute a range of C-Chain blocks.
vars:
CURRENT_STATE_DIR: '{{.CURRENT_STATE_DIR}}'
SOURCE_BLOCK_DIR: '{{.SOURCE_BLOCK_DIR}}'
START_BLOCK: '{{.START_BLOCK}}'
END_BLOCK: '{{.END_BLOCK}}'
LABELS: '{{.LABELS | default ""}}'
BENCHMARK_OUTPUT_FILE: '{{.BENCHMARK_OUTPUT_FILE | default ""}}'
cmd: |
CURRENT_STATE_DIR={{.CURRENT_STATE_DIR}} \
SOURCE_BLOCK_DIR={{.SOURCE_BLOCK_DIR}} \
START_BLOCK={{.START_BLOCK}} \
END_BLOCK={{.END_BLOCK}} \
LABELS={{.LABELS}} \
BENCHMARK_OUTPUT_FILE={{.BENCHMARK_OUTPUT_FILE}} \
bash -x ./scripts/benchmark_cchain_range.sh

reexecute-cchain-range-with-copied-data:
desc: Combines import-cchain-reexecute-range and reexecute-cchain-range
vars:
EXECUTION_DATA_DIR: '{{.EXECUTION_DATA_DIR}}'
SOURCE_BLOCK_DIR: '{{.SOURCE_BLOCK_DIR | default "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb.zip"}}'
CURRENT_STATE_DIR: '{{.CURRENT_STATE_DIR | default "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100.zip"}}'
START_BLOCK: '{{.START_BLOCK | default "101"}}'
END_BLOCK: '{{.END_BLOCK | default "250000"}}'
LABELS: '{{.LABELS | default ""}}'
BENCHMARK_OUTPUT_FILE: '{{.BENCHMARK_OUTPUT_FILE | default ""}}'
cmds:
- task: import-cchain-reexecute-range
vars:
SOURCE_BLOCK_DIR: '{{.SOURCE_BLOCK_DIR}}'
CURRENT_STATE_DIR: '{{.CURRENT_STATE_DIR}}'
EXECUTION_DATA_DIR: '{{.EXECUTION_DATA_DIR}}'
- task: reexecute-cchain-range
vars:
SOURCE_BLOCK_DIR: '{{.EXECUTION_DATA_DIR}}/blocks'
CURRENT_STATE_DIR: '{{.EXECUTION_DATA_DIR}}/current-state'
START_BLOCK: '{{.START_BLOCK}}'
END_BLOCK: '{{.END_BLOCK}}'
LABELS: '{{.LABELS}}'
BENCHMARK_OUTPUT_FILE: '{{.BENCHMARK_OUTPUT_FILE}}'

test-bootstrap-monitor-e2e:
desc: Runs bootstrap monitor e2e tests
cmd: bash -x ./scripts/tests.e2e.bootstrap_monitor.sh
Expand Down
10 changes: 5 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@

# Solidity compiler
solc

# s5cmd for rapid s3 interactions
s5cmd
] ++ lib.optionals stdenv.isDarwin [
# macOS-specific frameworks
darwin.apple_sdk.frameworks.Security
Expand Down
25 changes: 25 additions & 0 deletions scripts/benchmark_cchain_range.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -euo pipefail

# This script runs the C-Chain re-execution benchmark with a single iteration.
# It expects the following environment variables to be set:
# SOURCE_BLOCK_DIR: Path or S3 URL to the source block directory or zip.
# CURRENT_STATE_DIR: Path or S3 URL to the current state directory or zip.
# START_BLOCK: The starting block height (exclusive).
# END_BLOCK: The ending block height (inclusive).
# LABELS (optional): Comma-separated key=value pairs for metric labels.
# BENCHMARK_OUTPUT_FILE (optional): If set, benchmark output is also written to this file.

: "${SOURCE_BLOCK_DIR:?SOURCE_BLOCK_DIR must be set}"
: "${CURRENT_STATE_DIR:?CURRENT_STATE_DIR must be set}"
: "${START_BLOCK:?START_BLOCK must be set}"
: "${END_BLOCK:?END_BLOCK must be set}"

cmd="go test -timeout=0 -v -benchtime=1x -bench=BenchmarkReexecuteRange -run=^$ github.com/ava-labs/avalanchego/tests/reexecute/c --source-block-dir=\"${SOURCE_BLOCK_DIR}\" --target-dir=\"${CURRENT_STATE_DIR}\" --start-block=\"${START_BLOCK}\" --end-block=\"${END_BLOCK}\" ${LABELS:+--labels=\"${LABELS}\"}"

if [ -n "${BENCHMARK_OUTPUT_FILE:-}" ]; then
eval "$cmd" | tee "${BENCHMARK_OUTPUT_FILE}"
else
eval "$cmd"
fi
2 changes: 1 addition & 1 deletion scripts/build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
# Load the constants
source "$AVALANCHE_PATH"/scripts/constants.sh

EXCLUDED_TARGETS="| grep -v /mocks | grep -v proto | grep -v tests/e2e | grep -v tests/load/c | grep -v tests/upgrade | grep -v tests/fixture/bootstrapmonitor/e2e"
EXCLUDED_TARGETS="| grep -v /mocks | grep -v proto | grep -v tests/e2e | grep -v tests/load/c | grep -v tests/upgrade | grep -v tests/fixture/bootstrapmonitor/e2e | grep -v tests/reexecute"

if [[ "$(go env GOOS)" == "windows" ]]; then
# Test discovery for the antithesis test setups is broken due to
Expand Down
54 changes: 54 additions & 0 deletions scripts/copy_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

set -euo pipefail
Copy link
Collaborator Author

@aaronbuchwald aaronbuchwald Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future improvement: consider replacing with rclone


# Usage: ./scripts/copy_dir.sh source_directory destination_directory
# Sources can be S3 URLs (s3://bucket/path) or a local file path
# Assumes s5cmd has been installed and is available in the PATH.
# s5cmd is included in the nix dev shell.

if [ $# -ne 2 ]; then
echo "Usage: $0 <source_directory> <destination_directory>"
echo "S3 Example: $0 's3://bucket1/path1' /dest/dir"
echo "Local Example: $0 '/local/path1' /dest/dir"
exit 1
fi

SRC="$1"
DST="$2"

# Ensure destination directory exists
mkdir -p "$DST"

# Function to copy from a single source to destination
copy_source() {
local source="$1"
local dest="$2"

# Check if source starts with s3://
if [[ "$source" == s3://* ]]; then
echo "Copying from S3: $source -> $dest"
# Use s5cmd to copy from S3
time s5cmd cp "$source" "$dest"

# If we copied a zip, extract it in place
if [[ "$source" == *.zip ]]; then
echo "Extracting zip file in place"
time unzip "$dest"/*.zip -d "$dest"
rm "$dest"/*.zip
fi
else
echo "Copying from local filesystem: $source -> $dest"
# Use cp for local filesystem with recursive support
if [ -d "$source" ]; then
time cp -r "$source"/* "$dest/"
elif [ -f "$source" ]; then
time cp "$source" "$dest/"
else
echo "Warning: Source not found: $source"
return 1
fi
fi
}

copy_source "$SRC" "$DST"
Loading