diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f58c7cee..48dd99bc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -23,4 +23,4 @@ - [ ] Ran `make fmt` โ€” clean - [ ] Ran `make lint` (clippy with `-D warnings`) โ€” clean -- [ ] Ran `cargo test --workspace --release` โ€” all passing \ No newline at end of file +- [ ] Ran `make test` (`cargo test --workspace --profile release-fast`) โ€” all passing \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 2a1c99a9..5eb367d2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -316,11 +316,17 @@ GENESIS_VALIDATORS: ### Running Tests ```bash -cargo test --workspace --release # All workspace tests +cargo test --workspace --profile release-fast # All workspace tests cargo test -p ethlambda-blockchain --test forkchoice_spectests cargo test -p ethlambda-blockchain --test forkchoice_spectests -- --test-threads=1 # Sequential ``` +Tests run under `release-fast`: release-grade opt-level (needed to avoid stack +overflows in signature verification/aggregation) but no LTO, parallel codegen, +incremental, and line-tables-only debuginfo, so rebuilds are much faster than +`--release`. Artifacts land in `target/release-fast/`, separate from +`cargo build --release`. + ## Common Gotchas ### Aggregator Flag Required for Finalization diff --git a/Cargo.toml b/Cargo.toml index 9856e46d..0013defe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,32 @@ repository = "https://github.com/lambdaclass/ethlambda" rust-version = "1.97.1" version = "0.1.0" +# Cross-crate inlining matters here: the hot paths (SSZ encode/decode, hashing, +# fork choice traversal) are split across workspace crates and their +# dependencies, so keeping every crate in its own codegen unit leaves inlining +# opportunities on the table. Fat LTO plus a single codegen unit trades build +# time for that. +# +# Fat rather than thin: on an 8-node devnet, fat cut mean state transition time +# a further 2.1% over thin (every fat node beat every thin node) at no measurable +# build-time or image-size cost. ethrex uses thin here; we diverge deliberately. +[profile.release] +opt-level = 3 +lto = "fat" +codegen-units = 1 + +# Test profile (see the `test` target in the Makefile). Tests need release-grade +# opt-level: signature verification/aggregation stack-overflows without it. They +# do not need a whole-program-optimized binary, so this drops LTO, restores +# parallel codegen, and keeps line tables for backtraces, which makes test +# rebuilds finish in a fraction of the time of a `release` build. +[profile.release-fast] +inherits = "release" +lto = false +codegen-units = 16 +debug = "line-tables-only" +incremental = true + [workspace.dependencies] ethlambda-blockchain = { path = "crates/blockchain" } ethlambda-fork-choice = { path = "crates/blockchain/fork_choice" } diff --git a/Makefile b/Makefile index d28dc505..d404100a 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,9 @@ lint: ## ๐Ÿ” Run clippy on all workspace crates cargo clippy --workspace --all-targets -- -D warnings test: leanSpec/fixtures ## ๐Ÿงช Run all tests - # Tests need to be run on release to avoid stack overflows during signature verification/aggregation - cargo test --workspace --release + # release-fast: release-grade opt-level to avoid stack overflows during + # signature verification/aggregation, without paying for LTO on every rebuild + cargo test --workspace --profile release-fast GIT_COMMIT=$(shell git rev-parse HEAD) GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)