@@ -2,30 +2,34 @@ name: 'C-Chain Re-Execution Benchmark'
22description : ' Run C-Chain re-execution benchmark'
33
44inputs :
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
6484runs :
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 }}
0 commit comments