@@ -182,10 +182,14 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
182
182
# Add new block and state to the store
183
183
BlockStates . store_state ( block_root , state )
184
184
185
+ is_first_block = store . proposer_boost_root == << 0 :: 256 >>
186
+ # TODO: store block timeliness data?
187
+ is_timely = Store . get_current_slot ( store ) == block . slot and is_before_attesting_interval
188
+
185
189
store
186
190
|> Store . store_block ( block_root , signed_block )
187
191
|> if_then_update (
188
- is_before_attesting_interval and Store . get_current_slot ( store ) == block . slot ,
192
+ is_timely and is_first_block ,
189
193
& % Store { & 1 | proposer_boost_root: block_root }
190
194
)
191
195
# Update checkpoints in store if necessary
@@ -254,7 +258,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
254
258
def compute_pulled_up_tip ( % Store { } = store , block_root , block , state ) do
255
259
with { :ok , state } <- EpochProcessing . process_justification_and_finalization ( state ) do
256
260
block_epoch = Misc . compute_epoch_at_slot ( block . slot )
257
- current_epoch = store |> Store . get_current_slot ( ) |> Misc . compute_epoch_at_slot ( )
261
+ current_epoch = Store . get_current_epoch ( store )
258
262
259
263
unrealized_justifications =
260
264
Map . put ( store . unrealized_justifications , block_root , state . current_justified_checkpoint )
@@ -355,7 +359,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
355
359
target = attestation . data . target
356
360
357
361
# Attestations must be from the current or previous epoch
358
- current_epoch = store |> Store . get_current_slot ( ) |> Misc . compute_epoch_at_slot ( )
362
+ current_epoch = Store . get_current_epoch ( store )
359
363
# Use GENESIS_EPOCH for previous when genesis to avoid underflow
360
364
previous_epoch = max ( current_epoch - 1 , Constants . genesis_epoch ( ) )
361
365
0 commit comments