@@ -22,7 +22,10 @@ pub fn proposer_duties<T: BeaconChainTypes>(
22
22
log : & Logger ,
23
23
) -> Result < ApiDuties , warp:: reject:: Rejection > {
24
24
let current_epoch = chain
25
- . epoch ( )
25
+ . slot_clock
26
+ . now_or_genesis ( )
27
+ . map ( |slot| slot. epoch ( T :: EthSpec :: slots_per_epoch ( ) ) )
28
+ . ok_or ( BeaconChainError :: UnableToReadSlot )
26
29
. map_err ( warp_utils:: reject:: beacon_chain_error) ?;
27
30
28
31
// Determine what the current epoch would be if we fast-forward our system clock by
@@ -31,11 +34,17 @@ pub fn proposer_duties<T: BeaconChainTypes>(
31
34
// Most of the time, `tolerant_current_epoch` will be equal to `current_epoch`. However, during
32
35
// the first `MAXIMUM_GOSSIP_CLOCK_DISPARITY` duration of the epoch `tolerant_current_epoch`
33
36
// will equal `current_epoch + 1`
34
- let tolerant_current_epoch = chain
35
- . slot_clock
36
- . now_with_future_tolerance ( chain. spec . maximum_gossip_clock_disparity ( ) )
37
- . ok_or_else ( || warp_utils:: reject:: custom_server_error ( "unable to read slot clock" . into ( ) ) ) ?
38
- . epoch ( T :: EthSpec :: slots_per_epoch ( ) ) ;
37
+ let tolerant_current_epoch = if chain. slot_clock . is_prior_to_genesis ( ) . unwrap_or ( true ) {
38
+ current_epoch
39
+ } else {
40
+ chain
41
+ . slot_clock
42
+ . now_with_future_tolerance ( chain. spec . maximum_gossip_clock_disparity ( ) )
43
+ . ok_or_else ( || {
44
+ warp_utils:: reject:: custom_server_error ( "unable to read slot clock" . into ( ) )
45
+ } ) ?
46
+ . epoch ( T :: EthSpec :: slots_per_epoch ( ) )
47
+ } ;
39
48
40
49
if request_epoch == current_epoch || request_epoch == tolerant_current_epoch {
41
50
// If we could consider ourselves in the `request_epoch` when allowing for clock disparity
0 commit comments