Skip to content

Conversation

@maru-ava
Copy link
Contributor

@maru-ava maru-ava commented Dec 17, 2025

Why this should be merged

Doing anything non-trivial in tasks is not recommended. This change moves the reexec logic to a new script for ease of maintenance and to simplify usage.

How this was tested

  • CI

Need to be documented in RELEASES.md?

N/A

@maru-ava maru-ava self-assigned this Dec 17, 2025
@maru-ava maru-ava added the ci This focuses on changes to the CI process label Dec 17, 2025
description: 'The password for the Prometheus instance.'
required: true
default: ''
workspace:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed this was unused.

role-to-assume: ${{ inputs.aws-role }}
aws-region: ${{ inputs.aws-region }}
role-duration-seconds: ${{ inputs.aws-role-duration-seconds }}
- name: Validate inputs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Validation moved to the script so its defined once for use locally and in CI and it can be subject to shellcheck linting.

run: echo "BENCHMARK_OUTPUT_FILE=${GITHUB_WORKSPACE}/benchmark-output.json" >> "$GITHUB_ENV"
- name: Run C-Chain Re-execution Benchmark
shell: nix develop --impure --command bash -x {0}
run: |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this configuration to the script

- name: Set task env
- name: Set benchmark output file
shell: bash
run: |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

EXECUTION_DATA_DIR is now set in the script

summary-always: true
github-token: ${{ inputs.github-token }}
auto-push: ${{ inputs.push-github-action-benchmark }}
- name: Push Post-State to S3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aaronbuchwald I might have been overzealous here - was your intent to only push to s3 if the benchmark comparison succeeded?

@maru-ava maru-ava moved this to Ready 🚦 in avalanchego Dec 17, 2025
@maru-ava maru-ava marked this pull request as ready for review December 17, 2025 17:45
@maru-ava maru-ava requested a review from a team as a code owner December 17, 2025 17:45
Copilot AI review requested due to automatic review settings December 17, 2025 17:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates C-Chain re-execution logic from multiple Taskfile tasks into a single unified shell script to simplify maintenance and usage.

Key Changes:

  • Introduces reexecute_cchain.sh script with preset test configurations and custom test support
  • Removes complex Taskfile orchestration in favor of direct script execution
  • Simplifies GitHub Actions workflows by replacing task-based invocation with direct script calls

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/reexecute_cchain.sh New unified script that handles test presets, S3 data import, execution, and optional post-state pushing
Taskfile.yml Removes reexecution-related tasks and adds simplified test-c-chain-reexecution entry point; simplifies export-cchain-block-range task
.github/workflows/c-chain-reexecution-benchmark-gh-native.yml Updates workflow to use test parameter instead of task parameter
.github/workflows/c-chain-reexecution-benchmark-gh-native.json Updates matrix configuration to use test instead of task
.github/workflows/c-chain-reexecution-benchmark-container.yml Updates workflow to use test parameter instead of task parameter
.github/workflows/c-chain-reexecution-benchmark-container.json Updates matrix configuration to use test instead of task
.github/actions/c-chain-reexecution-benchmark/action.yml Simplifies action inputs and logic to call script directly with environment variable overrides

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 14 to 15
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
S3_BOOTSTRAP_BUCKET="${S3_BOOTSTRAP_BUCKET:-s3://avalanchego-bootstrap-testing}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I'm not mistaken, we switched to turning each of these sets of parameters into tasks to comply with the notion that tasks should be fully encompassed within the task instead of passing in a bunch of parameters.

I'd argue that a wide range of different sets of options like this is not as common to place within a bash script.

Would you still push to keep each of these baked into one configuration options within this script if we are going to move it out of the taskfile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intended for tasks to be both discoverable and to serve as entrypoints into CI so that reproducing CI was as simple as possible. The goal was not to implement anything non-trivial directly in the tasks, though, and I think that the reexec task logic is better maintained outside of the taskfile as I've proposed in this PR.

I think creating a task per reexec test configuration makes about as much sense as creating a task per e2e test. It's still possible to target the execution of an e2e test but it's the e2e test suite that's responsible for enabling that rather than something we need to do in the taskfile. I think it similarly makes sense for there to be an entrypoint in the taskfile for executing reexec tests, and that the entrypoint be responsible for defining both common test configurations and enabling ad-hoc configuration.

@aaronbuchwald
Copy link
Collaborator

Could you please validate the change by stepping through the README and updating it as needed?

set -euo pipefail

# C-Chain Re-execution Script
# Usage: ./scripts/reexecute_cchain.sh <test-name>
Copy link
Contributor

Choose a reason for hiding this comment

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

Running START_BLOCK=1 END_BLOCK=200_000 task test-c-chain-reexecution -- custom locally fails with the following error message:

task: [test-c-chain-reexecution] ./scripts/reexecute_cchain.sh custom
Error: Missing required env vars: S3_BLOCK_DIR S3_STATE_DIR

Ideally, I shouldn't have to set the S3 variables if I'm using my own current state/block directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're using your own state/block directory, you can call the benchmark_cchain_range.sh script directly. But to your point, maybe there should be a single more flexible script?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally yes. To my understanding, reexecute_cchain_range.sh is an extension of benchmark_cchain_range.sh and so I think it would make sense to have one script rather than have two scripts which can be confusing (e.g. I ran reexecute_cchain_range.sh rather than benchmark_cchain_range.sh)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I'll tackle that first thing tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the existing script and added a new script/task for the import. PTAL

@maru-ava
Copy link
Contributor Author

Could you please validate the change by stepping through the README and updating it as needed?

Done

@maru-ava maru-ava force-pushed the maru/simplify-reexec-tasks branch 3 times, most recently from 91851f9 to 0df3f05 Compare December 18, 2025 15:47
@maru-ava
Copy link
Contributor Author

Not ideal that we have a README with complex instructions that have to be manually verified when things change. Mental note: prefer an executable script in future with inline comments instead of a static README.

Comment on lines 132 to 140
missing=()
[[ -z "${BLOCK_DIR_SRC:-}" ]] && missing+=("BLOCK_DIR_SRC")
[[ -z "${CURRENT_STATE_DIR_SRC:-}" ]] && missing+=("CURRENT_STATE_DIR_SRC")
[[ -z "${START_BLOCK:-}" ]] && missing+=("START_BLOCK")
[[ -z "${END_BLOCK:-}" ]] && missing+=("END_BLOCK")

if [[ ${#missing[@]} -gt 0 ]]; then
error "Missing required env vars: ${missing[*]}"
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

When running task test-cchain-reexecution with just BLOCK_DIR and CURRENT_STATE_DIR set, I get the following error message:

Without test-name, expects env vars: BLOCK_DIR, CURRENT_STATE_DIR, START_BLOCK, END_BLOCK

Ideally, it should tell me that just START_BLOCK and END_BLOCK are missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to indicate the status of required env vars.

# METRICS_COLLECTOR_ENABLED: If set, enables the metrics collector.
# PUSH_POST_STATE: S3 destination to push current-state after execution.
#
# For 'custom' test or S3 import with other tests:
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit / feel-free-to-ignore): could we say something along the lines of "For all other tests which fetch from S3" to make it clear that any predefined/custom test uses S3?

Copy link
Contributor Author

@maru-ava maru-ava Dec 19, 2025

Choose a reason for hiding this comment

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

Done.

Though 'runs a predefined test that automatically imports data from S3' on L12 already tried to convey this.

Edit: Rewrite this section as part of removing custom

### Using Custom Parameters

[Taskfile](https://taskfile.dev/) supports reading arguments via both environment variables and named arguments on the command line, so we'll set `EXECUTION_DATA_DIR` and use the defaults for the remainder of the parameters:
For custom benchmark runs, use the `custom` test with environment variables:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this seems like ./scripts/benchmark_cchain_range.sh and ./scripts/benchmark_cchain_range.sh custom do the same thing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, removed custom

@maru-ava maru-ava force-pushed the maru/simplify-reexec-tasks branch from 0df3f05 to 809baac Compare December 19, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci This focuses on changes to the CI process

Projects

Status: Ready 🚦

Development

Successfully merging this pull request may close these issues.

4 participants