Skip to content

refactor(types): move the interval grid into ethlambda-types - #569

Merged
MegaRedHand merged 1 commit into
mainfrom
refactor/interval-constants-in-types
Aug 6, 2026
Merged

refactor(types): move the interval grid into ethlambda-types#569
MegaRedHand merged 1 commit into
mainfrom
refactor/interval-constants-in-types

Conversation

@MegaRedHand

Copy link
Copy Markdown
Collaborator

🗒️ 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-storage derives slot and interval from store.time(), but it cannot depend on ethlambda-blockchain — the dependency runs the other way. Today it can only document the formula in a comment on Store::time() instead of using the constants. ethlambda-types is 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 defines MILLISECONDS_PER_INTERVAL, INTERVALS_PER_SLOT and MILLISECONDS_PER_SLOT, docs carried over verbatim.
  • crates/blockchain/src/lib.rs — the three definitions become a re-export of the same names from ethlambda_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.rs in particular is untouched.

tooling/event-monitor keeps its own DEFAULT_INTERVALS_PER_SLOT; it is a separate binary that reads the real value from /lean/v0/config/spec over 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.

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

✅ Verification Checklist

  • Ran make fmt — clean
  • Ran make lint (clippy with -D warnings) — clean
  • Ran make test (cargo test --workspace --profile release-fast) — all passing

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.
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves the consensus interval-grid constants into the shared ethlambda-types crate while preserving the existing ethlambda-blockchain API through re-exports.

  • Defines the 800 ms interval, five intervals per slot, and derived 4000 ms slot duration in ethlambda_types::constants.
  • Re-exports all three constants from ethlambda_blockchain so existing consumers require no import changes.

Confidence Score: 5/5

The 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, u64 types, and values.

Important Files Changed

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

@MegaRedHand
MegaRedHand merged commit 0ec7ecc into main Aug 6, 2026
5 of 13 checks passed
@MegaRedHand
MegaRedHand deleted the refactor/interval-constants-in-types branch August 6, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants