refactor(types): move the interval grid into ethlambda-types - #569
Merged
Conversation
ethlambda-storage derives slot and interval from `store.time()` but cannot depend on ethlambda-blockchain, so it could only document the formula in a comment rather than use the constants. Housing MILLISECONDS_PER_INTERVAL, INTERVALS_PER_SLOT and MILLISECONDS_PER_SLOT in ethlambda-types — which both crates already depend on — removes that asymmetry and keeps a second copy of a consensus-critical constant from appearing in storage. Values are unchanged; blockchain re-exports all three so existing imports keep resolving.
3 tasks
Contributor
Greptile SummaryThis PR moves the consensus interval-grid constants into the shared
Confidence Score: 5/5The PR appears safe to merge because it preserves both the timing values and the existing public import paths. The shared constants module is public, blockchain already depends on the types crate, and the re-exported constants retain their original names,
|
| Filename | Overview |
|---|---|
| crates/blockchain/src/lib.rs | Replaces local timing constants with transparent public re-exports of the same names, types, and values. |
| crates/common/types/src/constants.rs | Adds the unchanged interval-grid constants to the shared types crate without affecting serialized types or consensus data layouts. |
Reviews (1): Last reviewed commit: "refactor(types): move the interval grid ..." | Re-trigger Greptile
pablodeymo
approved these changes
Aug 6, 2026
MegaRedHand
added a commit
that referenced
this pull request
Aug 7, 2026
## 🗒️ Description / Motivation Extracted from #561. Stacked on #569, which is what makes it possible: with the interval grid in `ethlambda-types`, `ethlambda-storage` can own the accessor. Deriving the slot from the store clock was open-coded at three call sites in the blockchain crate, each repeating `store.time() / INTERVALS_PER_SLOT` along with its own `expect` message. > [!NOTE] > Targets `refactor/interval-constants-in-types`. Merge #569 first and this rebases onto `main` on its own. ## What Changed - `crates/storage/src/store.rs` — new `Store::current_slot()`; the `Store::time()` doc comment now points at it for the slot case rather than spelling out the division. - `crates/blockchain/src/store.rs` — two call sites (`on_tick`, `on_block_core`). - `crates/blockchain/src/lib.rs` — one call site (the `NewAttestation` handler). ## Correctness / Behavior Guarantees Identical behavior. All three sites already panicked on a failed `time()` read (`unwrap` / `expect`), so `current_slot()`'s `expect("store time exists")` preserves the failure mode; only the panic message differs at two of them. Uses of `INTERVALS_PER_SLOT` that are *not* "derive the current slot from the clock" are deliberately untouched: the `% INTERVALS_PER_SLOT` interval derivation, `data.slot.saturating_mul(INTERVALS_PER_SLOT)`, the tick skip-check, and the `set_time(n * INTERVALS_PER_SLOT)` calls in tests. ## Tests Added / Run No new tests — no behavior change to cover. ``` make fmt make lint make leanSpec/fixtures # fixtures were absent in the worktree cargo test --workspace --profile release-fast --no-fail-fast ``` ## Related Issues / PRs - Stacked on #569 - Extracted from #561 ## ✅ Verification Checklist - [x] Ran `make fmt` — clean - [x] Ran `make lint` (clippy with `-D warnings`) — clean - [x] Ran `make test` (`cargo test --workspace --profile release-fast`) — all passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗒️ Description / Motivation
Extracted from #561, which needs the interval grid readable from
ethlambda-storage. The move stands on its own, so it lands here rather than riding along with the heartbeat work.ethlambda-storagederives slot and interval fromstore.time(), but it cannot depend onethlambda-blockchain— the dependency runs the other way. Today it can only document the formula in a comment onStore::time()instead of using the constants.ethlambda-typesis already a dependency of both crates, so housing them there removes the asymmetry and keeps a second copy of a consensus-critical constant from appearing in storage.What Changed
crates/common/types/src/constants.rs— now definesMILLISECONDS_PER_INTERVAL,INTERVALS_PER_SLOTandMILLISECONDS_PER_SLOT, docs carried over verbatim.crates/blockchain/src/lib.rs— the three definitions become a re-export of the same names fromethlambda_types::constants.Correctness / Behavior Guarantees
Pure move. Values are unchanged: 800 ms per interval, 5 intervals per slot, 4000 ms per slot.
ethlambda_blockchain::{MILLISECONDS_PER_INTERVAL, INTERVALS_PER_SLOT, MILLISECONDS_PER_SLOT}still resolve via the re-export, so no downstream import changes —crates/net/rpc/src/spec.rsin particular is untouched.tooling/event-monitorkeeps its ownDEFAULT_INTERVALS_PER_SLOT; it is a separate binary that reads the real value from/lean/v0/config/specover HTTP and only falls back to the local default when no node answers.Tests Added / Run
No new tests — there is no behavior to test. Existing suite covers the constants through every consumer.
Related Issues / PRs
✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — cleanmake test(cargo test --workspace --profile release-fast) — all passing