From dd768ba707747870086e649bcf96b678aff64038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 6 Aug 2026 13:10:52 -0300 Subject: [PATCH] refactor(types): move the interval grid into ethlambda-types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- crates/blockchain/src/lib.rs | 12 ++++++------ crates/common/types/src/constants.rs | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crates/blockchain/src/lib.rs b/crates/blockchain/src/lib.rs index 7faa1163..dc4f1268 100644 --- a/crates/blockchain/src/lib.rs +++ b/crates/blockchain/src/lib.rs @@ -68,13 +68,13 @@ pub struct BlockChainConfig { pub proposer_config: ProposerConfig, } -/// Milliseconds per interval (800ms ticks). -pub const MILLISECONDS_PER_INTERVAL: u64 = 800; -/// Number of intervals per slot (5 intervals of 800ms = 4 seconds). -pub const INTERVALS_PER_SLOT: u64 = 5; -/// Milliseconds in a slot (derived from interval duration and count). -pub const MILLISECONDS_PER_SLOT: u64 = MILLISECONDS_PER_INTERVAL * INTERVALS_PER_SLOT; +// The interval grid lives in `ethlambda-types` because `ethlambda-storage` also +// derives slots from `store.time()` and must not carry a second copy of a +// consensus-critical constant. pub use ethlambda_types::block::MAX_ATTESTATIONS_DATA; +pub use ethlambda_types::constants::{ + INTERVALS_PER_SLOT, MILLISECONDS_PER_INTERVAL, MILLISECONDS_PER_SLOT, +}; pub use sync_status::SyncStatusController; /// Future-slot tolerance for gossip attestations, expressed in intervals. /// diff --git a/crates/common/types/src/constants.rs b/crates/common/types/src/constants.rs index 3066b344..c3434d9a 100644 --- a/crates/common/types/src/constants.rs +++ b/crates/common/types/src/constants.rs @@ -8,3 +8,10 @@ /// eventually be derived from the fork version and genesis validators root. // TODO: derive dynamically once the spec defines fork identification. pub const FORK_DIGEST: &str = "12345678"; + +/// Milliseconds per interval (800ms ticks). +pub const MILLISECONDS_PER_INTERVAL: u64 = 800; +/// Number of intervals per slot (5 intervals of 800ms = 4 seconds). +pub const INTERVALS_PER_SLOT: u64 = 5; +/// Milliseconds in a slot (derived from interval duration and count). +pub const MILLISECONDS_PER_SLOT: u64 = MILLISECONDS_PER_INTERVAL * INTERVALS_PER_SLOT;