@@ -157,20 +157,33 @@ impl ChainSpec {
157157 }
158158
159159 /// Returns an `EnrForkId` for the given `slot`.
160- ///
161- /// Presently, we don't have any forks so we just ignore the slot. In the future this function
162- /// may return something different based upon the slot.
163- pub fn enr_fork_id ( & self , _slot : Slot , genesis_validators_root : Hash256 ) -> EnrForkId {
160+ pub fn enr_fork_id ( & self , slot : Slot , genesis_validators_root : Hash256 ) -> EnrForkId {
164161 EnrForkId {
165- fork_digest : Self :: compute_fork_digest (
166- self . genesis_fork_version ,
167- genesis_validators_root,
168- ) ,
162+ fork_digest : self . fork_digest ( slot, genesis_validators_root) ,
169163 next_fork_version : self . genesis_fork_version ,
170164 next_fork_epoch : self . far_future_epoch ,
171165 }
172166 }
173167
168+ /// Returns the `ForkDigest` for the given slot.
169+ ///
170+ /// Add additional if else branches with additional forks.
171+ pub fn fork_digest ( & self , slot : Slot , genesis_validators_root : Hash256 ) -> [ u8 ; 4 ] {
172+ if slot >= self . altair_fork_slot {
173+ Self :: compute_fork_digest ( self . altair_fork_version , genesis_validators_root)
174+ } else {
175+ Self :: compute_fork_digest ( self . genesis_fork_version , genesis_validators_root)
176+ }
177+ }
178+
179+ pub fn genesis_fork_digest ( & self , genesis_validators_root : Hash256 ) -> [ u8 ; 4 ] {
180+ Self :: compute_fork_digest ( self . genesis_fork_version , genesis_validators_root)
181+ }
182+
183+ pub fn altair_fork_digest ( & self , genesis_validators_root : Hash256 ) -> [ u8 ; 4 ] {
184+ Self :: compute_fork_digest ( self . altair_fork_version , genesis_validators_root)
185+ }
186+
174187 /// Returns the epoch of the next scheduled change in the `fork.current_version`.
175188 ///
176189 /// There are no future forks scheduled so this function always returns `None`. This may not
0 commit comments