Skip to content

Commit c267010

Browse files
authored
chore: task reexecution (#4443)
1 parent ee44f68 commit c267010

File tree

12 files changed

+350
-171
lines changed

12 files changed

+350
-171
lines changed

.github/actions/c-chain-reexecution-benchmark/action.yml

Lines changed: 121 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,34 @@ name: 'C-Chain Re-Execution Benchmark'
22
description: 'Run C-Chain re-execution benchmark'
33

44
inputs:
5-
runner_name:
6-
description: 'The name of the runner to use and include in the Golang Benchmark name.'
7-
required: true
5+
task:
6+
description: 'Task name to execute from Taskfile.yml. Leave empty to use custom inputs below.'
7+
default: ''
8+
# Custom inputs (alternative to task-based approach)
89
config:
910
description: 'The config to pass to the VM for the benchmark. See BenchmarkReexecuteRange for details.'
1011
default: ''
1112
start-block:
1213
description: 'The start block for the benchmark.'
13-
default: '101'
14+
default: ''
1415
end-block:
1516
description: 'The end block for the benchmark.'
16-
default: '250000'
17+
default: ''
1718
block-dir-src:
1819
description: 'The source block directory. Supports S3 directory/zip and local directories.'
19-
default: 's3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb/**'
20+
default: ''
2021
current-state-dir-src:
2122
description: 'The current state directory. Supports S3 directory/zip and local directories.'
22-
default: 's3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100/**'
23+
default: ''
24+
runner_name:
25+
description: 'The name of the runner to use and include in the Golang Benchmark name.'
26+
required: true
2327
aws-role:
2428
description: 'AWS role to assume for S3 access.'
2529
required: true
2630
aws-region:
2731
description: 'AWS region to use for S3 access.'
28-
required: true
32+
default: 'us-east-2'
2933
aws-role-duration-seconds:
3034
description: 'The duration of the AWS role to assume for S3 access.'
3135
required: true
@@ -56,54 +60,126 @@ inputs:
5660
push-github-action-benchmark:
5761
description: 'Whether to push the benchmark result to GitHub.'
5862
required: true
59-
default: false
6063
push-post-state:
6164
description: 'S3 destination to copy the current-state directory after completing re-execution. If empty, this will be skipped.'
6265
default: ''
66+
# The following inputs need never be provided by the caller. They
67+
# default to context values that the action's steps are unable to
68+
# access directly.
69+
repository-owner:
70+
default: ${{ github.repository_owner }}
71+
repository-name:
72+
default: ${{ github.event.repository.name }}
73+
workflow:
74+
default: ${{ github.workflow }}
75+
run-id:
76+
default: ${{ github.run_id }}
77+
run-number:
78+
default: ${{ github.run_number }}
79+
run-attempt:
80+
default: ${{ github.run_attempt }}
81+
job:
82+
default: ${{ github.job }}
6383

6484
runs:
6585
using: composite
6686
steps:
67-
- name: Set task env
87+
- uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f #v31
88+
with:
89+
github_access_token: ${{ inputs.github-token }}
90+
- run: echo "dependencies installed"
91+
shell: nix develop --command bash {0}
92+
# Cache Go modules (architecture-independent)
93+
- uses: actions/cache@v4
94+
id: go-mod-cache
95+
with:
96+
path: ~/go/pkg/mod
97+
key: ${{ runner.os }}-go-mod-${{ hashFiles('go.sum') }}
98+
restore-keys: ${{ runner.os }}-go-mod-
99+
# Cache Go build cache (architecture-specific)
100+
- uses: actions/cache@v4
101+
with:
102+
path: ~/.cache/go-build
103+
key: ${{ runner.os }}-${{ runner.arch }}-go-build-${{ hashFiles('go.sum') }}
104+
restore-keys: ${{ runner.os }}-${{ runner.arch }}-go-build-
105+
# Download modules only on cache miss
106+
- run: go mod download
107+
if: steps.go-mod-cache.outputs.cache-hit != 'true'
108+
shell: nix develop --command bash -x {0}
109+
- name: Notify of metrics availability
110+
if: inputs.prometheus-username != ''
68111
shell: bash
69112
run: |
70-
{
71-
echo "EXECUTION_DATA_DIR=${{ inputs.workspace }}/reexecution-data"
72-
echo "BENCHMARK_OUTPUT_FILE=output.txt"
73-
echo "START_BLOCK=${{ inputs.start-block }}"
74-
echo "END_BLOCK=${{ inputs.end-block }}"
75-
echo "BLOCK_DIR_SRC=${{ inputs.block-dir-src }}"
76-
echo "CURRENT_STATE_DIR_SRC=${{ inputs.current-state-dir-src }}"
77-
} >> $GITHUB_ENV
113+
metrics_url=$($GITHUB_ACTION_PATH/output-metrics-url.sh)
114+
echo "Grafana: ${metrics_url}"
115+
echo "🔗 [View Grafana Dashboard](${metrics_url})" >> "$GITHUB_STEP_SUMMARY"
116+
env:
117+
GRAFANA_URL: https://grafana-poc.avax-dev.network/d/Gl1I20mnk/c-chain?orgId=1&refresh=10s&var-filter=is_ephemeral_node%7C%3D%7Cfalse&var-filter=gh_repo%7C%3D%7C${{ inputs.repository_owner }}%2F${{ inputs.repository_name }}&var-filter=gh_run_id%7C%3D%7C${{ inputs.run_id }}&var-filter=gh_run_attempt%7C%3D%7C${{ inputs.run_attempt }}
118+
GH_JOB_ID: ${{ inputs.job }}
119+
- name: Warn that collection of metrics and logs will not be performed
120+
if: inputs.prometheus-username == ''
121+
shell: bash
122+
run: echo "::warning::Monitoring credentials not found. Skipping collector start. Is the PR from a fork branch?"
78123
- name: Configure AWS Credentials
79124
uses: aws-actions/configure-aws-credentials@v4
80125
with:
81126
role-to-assume: ${{ inputs.aws-role }}
82127
aws-region: ${{ inputs.aws-region }}
83128
role-duration-seconds: ${{ inputs.aws-role-duration-seconds }}
84-
- name: Run C-Chain Re-Execution
85-
uses: ./.github/actions/run-monitored-tmpnet-cmd
86-
with:
87-
run: |
129+
- name: Validate inputs
130+
shell: bash
131+
run: |
132+
if [[ -z "${{ inputs.task }}" ]]; then
133+
# Granular mode - validate required inputs
134+
missing=()
135+
[[ -z "${{ inputs.block-dir-src }}" ]] && missing+=("block-dir-src")
136+
[[ -z "${{ inputs.current-state-dir-src }}" ]] && missing+=("current-state-dir-src")
137+
[[ -z "${{ inputs.start-block }}" ]] && missing+=("start-block")
138+
[[ -z "${{ inputs.end-block }}" ]] && missing+=("end-block")
139+
140+
if [[ ${#missing[@]} -gt 0 ]]; then
141+
echo "::error::When 'task' is empty, the following inputs are required: ${missing[*]}"
142+
exit 1
143+
fi
144+
fi
145+
- name: Set task env
146+
shell: bash
147+
run: |
148+
TIMESTAMP=$(date '+%Y%m%d-%H%M%S')
149+
echo "EXECUTION_DATA_DIR=/tmp/reexecution-data-${TIMESTAMP}" >> "$GITHUB_ENV"
150+
echo "BENCHMARK_OUTPUT_FILE=${GITHUB_WORKSPACE}/benchmark-output.txt" >> "$GITHUB_ENV"
151+
- name: Run C-Chain Re-execution Benchmark
152+
shell: nix develop --impure --command bash -x {0}
153+
run: |
154+
if [[ -n "${{ inputs.task }}" ]]; then
155+
# Task-based approach
156+
./scripts/run_task.sh ${{ inputs.task }} \
157+
BENCHMARK_OUTPUT_FILE="${{ env.BENCHMARK_OUTPUT_FILE }}" \
158+
EXECUTION_DATA_DIR="${{ env.EXECUTION_DATA_DIR }}"
159+
else
160+
# Granular approach
88161
./scripts/run_task.sh reexecute-cchain-range-with-copied-data \
89162
CONFIG=${{ inputs.config }} \
90163
EXECUTION_DATA_DIR=${{ env.EXECUTION_DATA_DIR }} \
91-
BLOCK_DIR_SRC=${{ env.BLOCK_DIR_SRC }} \
92-
CURRENT_STATE_DIR_SRC=${{ env.CURRENT_STATE_DIR_SRC }} \
93-
START_BLOCK=${{ env.START_BLOCK }} \
94-
END_BLOCK=${{ env.END_BLOCK }} \
95-
LABELS=${{ env.LABELS }} \
96-
BENCHMARK_OUTPUT_FILE=${{ env.BENCHMARK_OUTPUT_FILE }} \
97-
RUNNER_NAME=${{ inputs.runner_name }} \
98-
METRICS_SERVER_ENABLED=true \
99-
METRICS_COLLECTOR_ENABLED=true
100-
prometheus_url: ${{ inputs.prometheus-url }}
101-
prometheus_push_url: ${{ inputs.prometheus-push-url }}
102-
prometheus_username: ${{ inputs.prometheus-username }}
103-
prometheus_password: ${{ inputs.prometheus-password }}
104-
grafana_dashboard_id: 'Gl1I20mnk/c-chain'
105-
runtime: "" # Set runtime input to empty string to disable log collection
106-
164+
BLOCK_DIR_SRC=${{ inputs.block-dir-src }} \
165+
CURRENT_STATE_DIR_SRC=${{ inputs.current-state-dir-src }} \
166+
START_BLOCK=${{ inputs.start-block }} \
167+
END_BLOCK=${{ inputs.end-block }} \
168+
BENCHMARK_OUTPUT_FILE="${{ env.BENCHMARK_OUTPUT_FILE }}"
169+
fi
170+
env:
171+
RUNNER_NAME: ${{ inputs.runner_name }}
172+
METRICS_COLLECTOR_ENABLED: ${{ inputs.prometheus-username != '' }}
173+
PROMETHEUS_URL: ${{ inputs.prometheus-url }}
174+
PROMETHEUS_PUSH_URL: ${{ inputs.prometheus-push-url }}
175+
PROMETHEUS_USERNAME: ${{ inputs.prometheus-username }}
176+
PROMETHEUS_PASSWORD: ${{ inputs.prometheus-password }}
177+
GH_REPO: ${{ inputs.repository_owner }}/${{ inputs.repository_name }}
178+
GH_WORKFLOW: ${{ inputs.workflow }}
179+
GH_RUN_ID: ${{ inputs.run_id }}
180+
GH_RUN_NUMBER: ${{ inputs.run_number }}
181+
GH_RUN_ATTEMPT: ${{ inputs.run_attempt }}
182+
GH_JOB_ID: ${{ inputs.job }}
107183
- name: Compare Benchmark Results
108184
uses: benchmark-action/github-action-benchmark@v1
109185
with:
@@ -112,8 +188,10 @@ runs:
112188
summary-always: true
113189
github-token: ${{ inputs.github-token }}
114190
auto-push: ${{ inputs.push-github-action-benchmark }}
115-
116-
- name: Push Post-State to S3 (if not exists)
117-
if: ${{ inputs.push-post-state != '' }}
118-
shell: nix develop --command bash -x {0}
119-
run: ./scripts/run_task.sh export-dir-to-s3 SRC=${{ env.EXECUTION_DATA_DIR }}/current-state/ DST=${{ inputs.push-post-state }}
191+
- name: Push Post-State to S3
192+
if: inputs.push-post-state != ''
193+
shell: nix develop --impure --command bash -x {0}
194+
run: |
195+
./scripts/run_task.sh export-dir-to-s3 \
196+
SRC=${{ env.EXECUTION_DATA_DIR }}/current-state/ \
197+
DST=${{ inputs.push-post-state }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# WARNING: This file is a duplication of:
4+
# - .github/actions/run-monitored-tmpnet-cmd/output-metrics-url.sh (source of truth)
5+
# Changes must be made to BOTH files.
6+
7+
set -euo pipefail
8+
9+
# Timestamps are in seconds
10+
from_timestamp="$(date '+%s')"
11+
monitoring_period=900 # 15 minutes
12+
to_timestamp="$((from_timestamp + monitoring_period))"
13+
14+
# Grafana expects microseconds, so pad timestamps with 3 zeros
15+
metrics_url="${GRAFANA_URL}&var-filter=gh_job_id%7C%3D%7C${GH_JOB_ID}&from=${from_timestamp}000&to=${to_timestamp}000"
16+
17+
# Optionally ensure that the link displays metrics only for the shared
18+
# network rather than mixing it with the results for private networks.
19+
if [[ -n "${FILTER_BY_OWNER:-}" ]]; then
20+
metrics_url="${metrics_url}&var-filter=network_owner%7C%3D%7C${FILTER_BY_OWNER}"
21+
fi
22+
23+
echo "${metrics_url}"

.github/actions/run-monitored-tmpnet-cmd/output-metrics-url.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env bash
22

3+
# WARNING: This file is duplicated at:
4+
# - .github/actions/c-chain-reexecution-benchmark/output-metrics-url.sh (copy)
5+
# Changes must be made to BOTH files.
6+
37
set -euo pipefail
48

59
# Timestamps are in seconds

.github/workflows/c-chain-reexecution-benchmark-container.json

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33
"include": [
44
{
55
"runner": "ubuntu-latest",
6-
"config": "default",
7-
"start-block": 101,
8-
"end-block": 250000,
9-
"block-dir-src": "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb/**",
10-
"current-state-dir-src": "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100/**",
6+
"task": "c-chain-reexecution-hashdb-101-250k",
117
"timeout-minutes": 30
128
},
139
{
1410
"runner": "avalanche-avalanchego-runner-2ti",
1511
"config": "default",
1612
"start-block": 101,
1713
"end-block": 250000,
18-
"block-dir-src": "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb/**",
19-
"current-state-dir-src": "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100/**",
14+
"block-dir-src": "cchain-mainnet-blocks-1m-ldb",
15+
"current-state-dir-src": "cchain-current-state-hashdb-full-100",
2016
"timeout-minutes": 30
2117
}
2218
]
@@ -25,20 +21,12 @@
2521
"include": [
2622
{
2723
"runner": "avago-runner-m6i-4xlarge-ebs-fast",
28-
"config": "default",
29-
"start-block": 33000001,
30-
"end-block": 33500000,
31-
"block-dir-src": "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-30m-40m-ldb/**",
32-
"current-state-dir-src": "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-33m/**",
24+
"task": "c-chain-reexecution-hashdb-33m-33m500k",
3325
"timeout-minutes": 1440
3426
},
3527
{
3628
"runner": "avago-runner-i4i-4xlarge-local-ssd",
37-
"config": "default",
38-
"start-block": 33000001,
39-
"end-block": 33500000,
40-
"block-dir-src": "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-30m-40m-ldb/**",
41-
"current-state-dir-src": "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-33m/**",
29+
"task": "c-chain-reexecution-hashdb-33m-33m500k",
4230
"timeout-minutes": 1440
4331
}
4432
]

.github/workflows/c-chain-reexecution-benchmark-container.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,32 @@ on:
44
pull_request:
55
workflow_dispatch:
66
inputs:
7+
task:
8+
description: 'Taskfile task to execute (e.g., c-chain-reexecution-hashdb-101-250k)'
9+
default: ''
710
config:
811
description: 'The config to pass to the VM for the benchmark. See BenchmarkReexecuteRange for details.'
9-
required: false
1012
default: ''
1113
start-block:
1214
description: 'The start block for the benchmark.'
13-
required: false
14-
default: 101
15+
default: ''
1516
end-block:
1617
description: 'The end block for the benchmark.'
17-
required: false
18-
default: 250000
18+
default: ''
1919
block-dir-src:
2020
description: 'The source block directory. Supports S3 directory/zip and local directories.'
21-
required: false
22-
default: s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb/**
21+
default: ''
2322
current-state-dir-src:
2423
description: 'The current state directory. Supports S3 directory/zip and local directories.'
25-
required: false
26-
default: s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100/**
24+
default: ''
2725
runner:
2826
description: 'Runner to execute the benchmark. Input to the runs-on field of the job.'
29-
required: false
30-
default: ubuntu-latest
27+
required: true
3128
push-post-state:
3229
description: 'S3 location to push post-execution state directory. Skips this step if left unpopulated.'
3330
default: ''
3431
timeout-minutes:
3532
description: 'Timeout in minutes for the job.'
36-
required: false
3733
default: 30
3834

3935
# Disabled because scheduled trigger is empty. To enable, uncomment and add at least one vector to the schedule
@@ -55,7 +51,8 @@ jobs:
5551
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
5652
{
5753
echo "matrix<<EOF"
58-
printf '{ "include": [{ "start-block": "%s", "end-block": "%s", "block-dir-src": "%s", "current-state-dir-src": "%s", "config": "%s", "runner": "%s", "timeout-minutes": %s }] }\n' \
54+
printf '{ "include": [{ "task": "%s", "start-block": "%s", "end-block": "%s", "block-dir-src": "%s", "current-state-dir-src": "%s", "config": "%s", "runner": "%s", "timeout-minutes": %s }] }\n' \
55+
"${{ github.event.inputs.task }}" \
5956
"${{ github.event.inputs.start-block }}" \
6057
"${{ github.event.inputs.end-block }}" \
6158
"${{ github.event.inputs.block-dir-src }}" \
@@ -100,6 +97,7 @@ jobs:
10097
- name: Run C-Chain Re-Execution Benchmark
10198
uses: ./.github/actions/c-chain-reexecution-benchmark
10299
with:
100+
task: ${{ matrix.task }}
103101
config: ${{ matrix.config }}
104102
start-block: ${{ matrix.start-block }}
105103
end-block: ${{ matrix.end-block }}

.github/workflows/c-chain-reexecution-benchmark-gh-native.json

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,18 @@
22
"pull_request": {
33
"include": [
44
{
5-
"runner": "ubuntu-latest",
6-
"config": "default",
7-
"start-block": 101,
8-
"end-block": 250000,
9-
"block-dir-src": "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb/**",
10-
"current-state-dir-src": "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100/**",
11-
"timeout-minutes": 30
5+
"runner": "ubuntu-latest",
6+
"task": "c-chain-reexecution-hashdb-101-250k",
7+
"timeout-minutes": 30
128
},
139
{
1410
"runner": "blacksmith-4vcpu-ubuntu-2404",
15-
"config": "default",
16-
"start-block": 101,
17-
"end-block": 250000,
18-
"block-dir-src": "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb/**",
19-
"current-state-dir-src": "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-full-100/**",
11+
"task": "c-chain-reexecution-hashdb-101-250k",
2012
"timeout-minutes": 30
2113
},
2214
{
2315
"runner": "blacksmith-4vcpu-ubuntu-2404",
24-
"config": "archive",
25-
"start-block": 101,
26-
"end-block": 250000,
27-
"block-dir-src": "s3://avalanchego-bootstrap-testing/cchain-mainnet-blocks-1m-ldb/**",
28-
"current-state-dir-src": "s3://avalanchego-bootstrap-testing/cchain-current-state-hashdb-archive-100/**",
16+
"task": "c-chain-reexecution-hashdb-archive-101-250k",
2917
"timeout-minutes": 30
3018
}
3119
]

0 commit comments

Comments
 (0)