Skip to content

Commit dea0eb0

Browse files
rodrigo-oedg-l
andauthored
feat(l1): run daily snapsync checks with trie validations (debug-assertions) (#5768)
**Motivation** We want to make sure that the snapsyncs running in loop, not just finish but their state is validated **Description** This PR acomplish 2 things: - It makes `debug-assertions` easily available for docker - It change how the daily snapsyncs work, building locally instead of using the main image and running with debug-assertions - timeouts are now longer --------- Co-authored-by: Edgar <[email protected]>
1 parent c88a1a3 commit dea0eb0

File tree

6 files changed

+106
-16
lines changed

6 files changed

+106
-16
lines changed

.github/actions/snapsync-run/action.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ inputs:
1515
description: Ethrex Docker image tag.
1616
required: false
1717
default: main
18+
build_local:
19+
description: Build ethrex image locally instead of using a pre-built image.
20+
required: false
21+
default: "false"
22+
build_profile:
23+
description: Cargo profile to use when building locally (e.g., release, release-with-debug-assertions).
24+
required: false
25+
default: release
1826
cl_type:
1927
description: Consensus layer type (lighthouse, prysm, etc).
2028
required: false
@@ -34,12 +42,25 @@ runs:
3442
shell: bash
3543
run: docker image rm -f ${{ inputs.ethrex_image }}:${{ inputs.ethrex_tag }} || true
3644

45+
- name: Build local ethrex image
46+
if: inputs.build_local == 'true'
47+
shell: bash
48+
env:
49+
BUILD_PROFILE: ${{ inputs.build_profile }}
50+
IMAGE_TAG: ${{ inputs.ethrex_tag }}
51+
run: |
52+
echo "Building ethrex with profile: ${BUILD_PROFILE}"
53+
docker build \
54+
--build-arg PROFILE="${BUILD_PROFILE}" \
55+
-t ethrex-local:${IMAGE_TAG} \
56+
-f Dockerfile .
57+
3758
- name: Generate Kurtosis args
3859
shell: bash
3960
env:
4061
NETWORK_NAME: ${{ inputs.network }}
4162
TIMEOUT: ${{ inputs.timeout }}
42-
ETHREX_IMAGE: ${{ inputs.ethrex_image }}
63+
ETHREX_IMAGE: ${{ inputs.build_local == 'true' && 'ethrex-local' || inputs.ethrex_image }}
4364
ETHREX_TAG: ${{ inputs.ethrex_tag }}
4465
CL_TYPE: ${{ inputs.cl_type }}
4566
CL_IMAGE: ${{ inputs.cl_image }}
@@ -91,11 +112,23 @@ runs:
91112
- name: Summarize ethrex version
92113
if: ${{ always() }}
93114
shell: bash
115+
env:
116+
BUILD_LOCAL: ${{ inputs.build_local }}
117+
BUILD_PROFILE: ${{ inputs.build_profile }}
118+
ETHREX_IMAGE: ${{ inputs.ethrex_image }}
119+
ETHREX_TAG: ${{ inputs.ethrex_tag }}
94120
run: |
95-
image="${{ inputs.ethrex_image }}:${{ inputs.ethrex_tag }}"
121+
if [ "$BUILD_LOCAL" = "true" ]; then
122+
image="ethrex-local:${ETHREX_TAG}"
123+
else
124+
image="${ETHREX_IMAGE}:${ETHREX_TAG}"
125+
fi
96126
version="$(docker run --rm "$image" --version 2>/dev/null || true)"
97127
{
98128
echo "### Ethrex Version"
99129
echo ""
100130
echo "- ${version:-unavailable}"
131+
if [ "$BUILD_LOCAL" = "true" ]; then
132+
echo "- Build Profile: ${BUILD_PROFILE}"
133+
fi
101134
} >> "${GITHUB_STEP_SUMMARY}"

.github/workflows/daily_snapsync.yaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
description: "Network name (hoodi or sepolia)"
1515
required: false
1616
default: "hoodi"
17+
build_profile:
18+
description: "Cargo build profile (release or release-with-debug-assertions)"
19+
required: false
20+
default: "release-with-debug-assertions"
1721

1822
permissions:
1923
contents: read
@@ -27,23 +31,24 @@ jobs:
2731
runs-on: ubuntu-latest
2832
outputs:
2933
matrix: ${{ steps.targets.outputs.matrix }}
34+
build_profile: ${{ steps.build_opts.outputs.build_profile }}
3035
steps:
3136
- id: targets
3237
run: |
3338
event_name="${GITHUB_EVENT_NAME}"
3439
if [[ "$event_name" == "schedule" ]]; then
35-
json='[{"network":"hoodi","timeout":"40m"},{"network":"sepolia","timeout":"2h30m"}]'
40+
json='[{"network":"hoodi","timeout":"1h"},{"network":"sepolia","timeout":"3h30m"}]'
3641
elif [[ "$event_name" == "pull_request" ]]; then
37-
json='[{"network":"hoodi","timeout":"40m"}]'
42+
json='[{"network":"hoodi","timeout":"1h"}]'
3843
else
3944
network=$(jq -r '.inputs.network // empty' "$GITHUB_EVENT_PATH")
4045
4146
case "$network" in
4247
hoodi)
43-
json='[{"network":"hoodi","timeout":"40m"}]'
48+
json='[{"network":"hoodi","timeout":"1h"}]'
4449
;;
4550
sepolia)
46-
json='[{"network":"sepolia","timeout":"2h30m"}]'
51+
json='[{"network":"sepolia","timeout":"3h30m"}]'
4752
;;
4853
*)
4954
echo "::error::Unsupported network value '$network'. Allowed values: hoodi, sepolia."
@@ -52,6 +57,17 @@ jobs:
5257
esac
5358
fi
5459
echo "matrix=$json" >> "$GITHUB_OUTPUT"
60+
- id: build_opts
61+
run: |
62+
event_name="${GITHUB_EVENT_NAME}"
63+
# Default to release-with-debug-assertions for scheduled runs and PRs
64+
# Manual runs can specify a different profile
65+
if [[ "$event_name" == "workflow_dispatch" ]]; then
66+
profile=$(jq -r '.inputs.build_profile // "release-with-debug-assertions"' "$GITHUB_EVENT_PATH")
67+
else
68+
profile="release-with-debug-assertions"
69+
fi
70+
echo "build_profile=$profile" >> "$GITHUB_OUTPUT"
5571
5672
sync-lighthouse:
5773
needs: prepare
@@ -78,6 +94,8 @@ jobs:
7894
timeout: ${{ matrix.timeout }}
7995
cl_type: lighthouse
8096
cl_image: "sigp/lighthouse:v8.0.1"
97+
build_local: "true"
98+
build_profile: ${{ needs.prepare.outputs.build_profile }}
8199

82100
- name: Post run on slack
83101
if: always()
@@ -117,6 +135,8 @@ jobs:
117135
timeout: ${{ matrix.timeout }}
118136
cl_type: prysm
119137
cl_image: "gcr.io/offchainlabs/prysm/beacon-chain:v7.1.0"
138+
build_local: "true"
139+
build_profile: ${{ needs.prepare.outputs.build_profile }}
120140

121141
- name: Post run on slack
122142
if: always()

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ codegen-units = 1
4848
inherits = "release"
4949
debug = 2
5050

51+
[profile.release-with-debug-assertions]
52+
inherits = "release"
53+
debug-assertions = true
54+
5155
[workspace.dependencies]
5256
ethrex-blockchain = { path = "./crates/blockchain", default-features = false }
5357
ethrex-common = { path = "./crates/common", default-features = false }

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ RUN cargo chef prepare --recipe-path recipe.json
3333
# previous stage has changed, which only happens when dependencies change.
3434
FROM chef AS builder
3535

36-
# Optional build flags
36+
# Build configuration
37+
# PROFILE: Cargo profile to use (release, release-with-debug-assertions, etc.)
38+
# BUILD_FLAGS: Additional cargo flags (features, etc.)
39+
ARG PROFILE="release"
3740
ARG BUILD_FLAGS=""
3841

3942
COPY --from=planner /ethrex/recipe.json recipe.json
@@ -60,7 +63,11 @@ COPY fixtures ./fixtures
6063
COPY .cargo/ ./.cargo
6164

6265
ENV COMPILE_CONTRACTS=true
63-
RUN cargo build --release $BUILD_FLAGS
66+
67+
RUN cargo build --profile $PROFILE $BUILD_FLAGS
68+
69+
RUN mkdir -p /ethrex/bin && \
70+
cp /ethrex/target/${PROFILE}/ethrex /ethrex/bin/ethrex
6471

6572
# --- Final Image ---
6673
# Copy the ethrex binary into a minimalist image to reduce bloat size.
@@ -71,7 +78,7 @@ WORKDIR /usr/local/bin
7178
RUN apt-get update && apt-get install -y --no-install-recommends libssl3
7279

7380
COPY cmd/ethrex/networks ./cmd/ethrex/networks
74-
COPY --from=builder /ethrex/target/release/ethrex .
81+
COPY --from=builder /ethrex/bin/ethrex .
7582

7683
# Common ports:
7784
# - 8545: RPC
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
# Daily Snapsync Check
22

3-
Inside [GitHub actions tab](https://github.com/lambdaclass/ethrex/actions) there is a pinned workflow called [Daily Snapsync Check](https://github.com/lambdaclass/ethrex/actions/workflows/daily_snapsync.yaml). As the name suggests, it runs an Ethrex node and attemps to complete a snap sync and catch the head of the chain. If it is not able to finish snapsync before the timeout, the job fails and an [alert](https://github.com/lambdaclass/ethrex/blob/9feefd2e3fd2e8bb2097e5e39e0d20f7315c5880/.github/workflows/common_failure_alerts.yaml#L8) is sent to Slack. The way it works is through an [Assertoor playbook](https://github.com/lambdaclass/ethrex/blob/9feefd2e3fd2e8bb2097e5e39e0d20f7315c5880/.github/config/assertoor/syncing-check.yaml#L1-L17) that checks that the node `eth_syncing` returns `false`.
3+
Inside [GitHub actions tab](https://github.com/lambdaclass/ethrex/actions) there is a pinned workflow called [Daily Snapsync Check](https://github.com/lambdaclass/ethrex/actions/workflows/daily_snapsync.yaml). As the name suggests, it runs an Ethrex node and attempts to complete a snap sync and catch the head of the chain. If it is not able to finish snapsync before the timeout, the job fails and an [alert](https://github.com/lambdaclass/ethrex/blob/9feefd2e3fd2e8bb2097e5e39e0d20f7315c5880/.github/workflows/common_failure_alerts.yaml#L8) is sent to Slack. The way it works is through an [Assertoor playbook](https://github.com/lambdaclass/ethrex/blob/9feefd2e3fd2e8bb2097e5e39e0d20f7315c5880/.github/config/assertoor/syncing-check.yaml#L1-L17) that checks that the node `eth_syncing` returns `false`.
44

5-
Currently it runs this check on Sepolia and Hoodi.
5+
Currently it runs this check on Sepolia and Hoodi with both Lighthouse and Prysm consensus clients.
66

7-
Apart from being a useful job to catch regressions, it is a good log to see if there were any speedups of slowdowns in terms of time to complete a snap sync.
7+
## Debug Assertions
88

9-
Nice to haves:
10-
- Currently the job runs on the `main` docker image of ethrex. It would be nice to be able to trigger this from a branch so that the workflow is executed by trying to sync the branch ethrex code.
9+
By default, the workflow builds ethrex with debug assertions enabled (`release-with-debug-assertions` profile). This helps catch potential bugs and invariant violations during the sync process.
10+
11+
The `release-with-debug-assertions` profile:
12+
- Inherits all release optimizations
13+
- Enables `debug_assert!()` macros to run
14+
15+
## Triggering the Workflow
16+
17+
The workflow can be triggered in three ways:
18+
19+
1. **Scheduled**: Runs every 6 hours automatically on both Hoodi and Sepolia networks
20+
2. **Pull Request**: Runs on PRs that modify the workflow file (Hoodi only)
21+
3. **Manual Dispatch**: Can be triggered manually via GitHub Actions UI with options:
22+
- `network`: Choose between `hoodi` or `sepolia`
23+
- `build_profile`: Choose between `release` or `release-with-debug-assertions` (default: `release-with-debug-assertions`)
24+
25+
## Use Cases
26+
27+
Apart from being a useful job to catch regressions, it is a good log to see if there were any speedups or slowdowns in terms of time to complete a snap sync. With debug assertions enabled, it also serves as an additional validation layer to catch bugs that might not manifest as crashes in release builds.

docs/developers/installing.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,17 @@ The Dockerfile is located at the root of the repository and can be built by runn
5050
docker build -t ethrex .
5151
```
5252

53-
The `BUILD_FLAGS` argument can be used to pass flags to cargo, for example
53+
Build arguments:
54+
- `PROFILE`: Cargo profile to use (default: `release`). Example: `release-with-debug-assertions`
55+
- `BUILD_FLAGS`: Additional cargo flags (features, etc.)
5456

5557
```
56-
docker build -t ethrex --build-arg BUILD_FLAGS="--features <features>" .
58+
# Custom profile
59+
docker build -t ethrex --build-arg PROFILE="release-with-debug-assertions" .
60+
61+
# With features
62+
docker build -t ethrex --build-arg BUILD_FLAGS="--features l2" .
63+
64+
# Both
65+
docker build -t ethrex --build-arg PROFILE="release-with-debug-assertions" --build-arg BUILD_FLAGS="--features l2" .
5766
```

0 commit comments

Comments
 (0)