Skip to content

Commit 38d8e52

Browse files
authored
chore: bump spectest version to v1.4.0-beta.7-hotfix (#774)
1 parent d3782ba commit 38d8e52

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

Diff for: .spectest_version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.4.0-alpha.0
1+
v1.4.0-beta.7-hotfix

Diff for: config/networks/minimal/config.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ INACTIVITY_SCORE_RECOVERY_RATE: 16
7878
# 2**4 * 10**9 (= 16,000,000,000) Gwei
7979
EJECTION_BALANCE: 16000000000
8080
# [customized] more easily demonstrate the difference between this value and the activation churn limit
81-
# TODO: 1. update code to latest spec; 2. bump spectest version; 3. update this value
82-
MIN_PER_EPOCH_CHURN_LIMIT: 4 # 2
81+
MIN_PER_EPOCH_CHURN_LIMIT: 2
8382
# [customized] scale queue churn at much lower validator counts for testing
8483
CHURN_LIMIT_QUOTIENT: 32
8584
# [New in Deneb:EIP7514] [customized]

Diff for: lib/lambda_ethereum_consensus/fork_choice/handlers.ex

+7-3
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,14 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
182182
# Add new block and state to the store
183183
BlockStates.store_state(block_root, state)
184184

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+
185189
store
186190
|> Store.store_block(block_root, signed_block)
187191
|> if_then_update(
188-
is_before_attesting_interval and Store.get_current_slot(store) == block.slot,
192+
is_timely and is_first_block,
189193
&%Store{&1 | proposer_boost_root: block_root}
190194
)
191195
# Update checkpoints in store if necessary
@@ -254,7 +258,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
254258
def compute_pulled_up_tip(%Store{} = store, block_root, block, state) do
255259
with {:ok, state} <- EpochProcessing.process_justification_and_finalization(state) do
256260
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)
258262

259263
unrealized_justifications =
260264
Map.put(store.unrealized_justifications, block_root, state.current_justified_checkpoint)
@@ -355,7 +359,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
355359
target = attestation.data.target
356360

357361
# 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)
359363
# Use GENESIS_EPOCH for previous when genesis to avoid underflow
360364
previous_epoch = max(current_epoch - 1, Constants.genesis_epoch())
361365

Diff for: lib/lambda_ethereum_consensus/fork_choice/helpers.ex

+5-5
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ defmodule LambdaEthereumConsensus.ForkChoice.Helpers do
117117
end
118118

119119
defp filter_leaf_block(%Store{} = store, block_root, block, blocks) do
120-
current_epoch = store |> Store.get_current_slot() |> Misc.compute_epoch_at_slot()
120+
current_epoch = Store.get_current_epoch(store)
121121
voting_source = get_voting_source(store, block_root)
122122

123123
# The voting source should be at the same height as the store's justified checkpoint
124124
correct_justified =
125125
store.justified_checkpoint.epoch == Constants.genesis_epoch() or
126-
voting_source.epoch == store.justified_checkpoint.epoch
126+
voting_source.epoch == store.justified_checkpoint.epoch or
127+
voting_source.epoch + 2 >= current_epoch
127128

128129
# If the previous epoch is justified, the block should be pulled-up. In this case, check that unrealized
129130
# justification is higher than the store and that the voting source is not more than two epochs ago
@@ -158,7 +159,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Helpers do
158159
# Compute the voting source checkpoint in event that block with root ``block_root`` is the head block
159160
def get_voting_source(%Store{} = store, block_root) do
160161
block = Blocks.get_block!(block_root)
161-
current_epoch = store |> Store.get_current_slot() |> Misc.compute_epoch_at_slot()
162+
current_epoch = Store.get_current_epoch(store)
162163
block_epoch = Misc.compute_epoch_at_slot(block.slot)
163164

164165
if current_epoch > block_epoch do
@@ -172,8 +173,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Helpers do
172173
end
173174

174175
def previous_epoch_justified?(%Store{} = store) do
175-
current_slot = Store.get_current_slot(store)
176-
current_epoch = Misc.compute_epoch_at_slot(current_slot)
176+
current_epoch = Store.get_current_epoch(store)
177177
store.justified_checkpoint.epoch + 1 == current_epoch
178178
end
179179

Diff for: lib/lambda_ethereum_consensus/state_transition/math.ex

+5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ defmodule LambdaEthereumConsensus.StateTransition.Math do
33
Math functions
44
"""
55

6+
@uint64_max 2 ** 64 - 1
7+
@uint32_max 2 ** 32 - 1
8+
69
@doc """
710
Return the largest integer ``x`` such that ``x**2 <= n``.
811
"""
912
@spec integer_squareroot(Types.uint64()) :: Types.uint64()
13+
def integer_squareroot(@uint64_max), do: @uint32_max
14+
1015
def integer_squareroot(n) when is_integer(n) do
1116
compute_root(n, n, div(n + 1, 2))
1217
end

Diff for: lib/types/store.ex

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ defmodule Types.Store do
9292
div(time - genesis_time, ChainSpec.get("SECONDS_PER_SLOT"))
9393
end
9494

95+
def get_current_epoch(store) do
96+
store |> get_current_slot() |> Misc.compute_epoch_at_slot()
97+
end
98+
9599
def get_ancestor(%__MODULE__{} = store, root, slot) do
96100
block = Blocks.get_block!(root)
97101

0 commit comments

Comments
 (0)