Skip to content

Commit 3ab8d29

Browse files
authored
chore: bump deps (#713)
1 parent 692da2a commit 3ab8d29

File tree

14 files changed

+88
-96
lines changed

14 files changed

+88
-96
lines changed

lib/beacon_api/utils.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ defmodule BeaconApi.Utils do
44
"""
55
alias LambdaEthereumConsensus.ForkChoice.Helpers
66

7-
@doc """
8-
Checks if the value is 32 bytes and starting with "0x"
9-
"""
10-
@spec is_bytes32?(binary) :: boolean
11-
def is_bytes32?(value) when is_binary(value) do
12-
String.starts_with?(value, "0x") and byte_size(value) == 66
13-
end
14-
157
@spec parse_id(binary) :: Helpers.block_id()
168
def parse_id("genesis"), do: :genesis
179
def parse_id("justified"), do: :justified

lib/lambda_ethereum_consensus/beacon/pending_blocks.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ defmodule LambdaEthereumConsensus.Beacon.PendingBlocks do
3131
GenServer.cast(__MODULE__, {:add_block, signed_block})
3232
end
3333

34-
@spec is_pending_block(Types.root()) :: boolean()
35-
def is_pending_block(block_root) do
36-
GenServer.call(__MODULE__, {:is_pending_block, block_root})
34+
@spec pending_block?(Types.root()) :: boolean()
35+
def pending_block?(block_root) do
36+
GenServer.call(__MODULE__, {:pending_block?, block_root})
3737
end
3838

3939
##########################
@@ -56,7 +56,7 @@ defmodule LambdaEthereumConsensus.Beacon.PendingBlocks do
5656
end
5757

5858
@impl true
59-
def handle_call({:is_pending_block, block_root}, _from, state) do
59+
def handle_call({:pending_block?, block_root}, _from, state) do
6060
{:reply, Map.has_key?(state.pending_blocks, block_root), state}
6161
end
6262

lib/lambda_ethereum_consensus/fork_choice/handlers.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
116116
end
117117

118118
defp check_valid_indexed_attestation(target_state, indexed_attestation) do
119-
if Predicates.is_valid_indexed_attestation(target_state, indexed_attestation),
119+
if Predicates.valid_indexed_attestation?(target_state, indexed_attestation),
120120
do: :ok,
121121
else: {:error, "invalid indexed attestation"}
122122
end
@@ -137,13 +137,13 @@ defmodule LambdaEthereumConsensus.ForkChoice.Handlers do
137137
state = BlockStates.get_state!(store.justified_checkpoint.root)
138138

139139
cond do
140-
not Predicates.is_slashable_attestation_data(attestation_1.data, attestation_2.data) ->
140+
not Predicates.slashable_attestation_data?(attestation_1.data, attestation_2.data) ->
141141
{:error, "attestation is not slashable"}
142142

143-
not Predicates.is_valid_indexed_attestation(state, attestation_1) ->
143+
not Predicates.valid_indexed_attestation?(state, attestation_1) ->
144144
{:error, "attestation 1 is not valid"}
145145

146-
not Predicates.is_valid_indexed_attestation(state, attestation_2) ->
146+
not Predicates.valid_indexed_attestation?(state, attestation_2) ->
147147
{:error, "attestation 2 is not valid"}
148148

149149
true ->

lib/lambda_ethereum_consensus/fork_choice/helpers.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Helpers do
128128
# If the previous epoch is justified, the block should be pulled-up. In this case, check that unrealized
129129
# justification is higher than the store and that the voting source is not more than two epochs ago
130130
correct_justified =
131-
if not correct_justified and is_previous_epoch_justified(store) do
131+
if not correct_justified and previous_epoch_justified?(store) do
132132
store.unrealized_justifications[block_root].epoch >= store.justified_checkpoint.epoch and
133133
voting_source.epoch + 2 >= current_epoch
134134
else
@@ -171,7 +171,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Helpers do
171171
end
172172
end
173173

174-
def is_previous_epoch_justified(%Store{} = store) do
174+
def previous_epoch_justified?(%Store{} = store) do
175175
current_slot = Store.get_current_slot(store)
176176
current_epoch = Misc.compute_epoch_at_slot(current_slot)
177177
store.justified_checkpoint.epoch + 1 == current_epoch

lib/lambda_ethereum_consensus/state_transition/accessors.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do
110110
compute_fn = fn ->
111111
validators
112112
|> Aja.Vector.with_index()
113-
|> Aja.Vector.filter(fn {v, _} -> Predicates.is_active_validator(v, epoch) end)
113+
|> Aja.Vector.filter(fn {v, _} -> Predicates.active_validator?(v, epoch) end)
114114
|> Aja.Vector.map(fn {_, index} -> index end)
115115
end
116116

@@ -160,7 +160,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do
160160
participating_indices =
161161
state.validators
162162
|> Aja.Vector.zip_with(epoch_participation, fn v, participation ->
163-
not v.slashed and Predicates.is_active_validator(v, epoch) and
163+
not v.slashed and Predicates.active_validator?(v, epoch) and
164164
Predicates.has_flag(participation, flag_index)
165165
end)
166166
|> Aja.Vector.with_index()
@@ -194,7 +194,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do
194194

195195
Cache.lazily_compute(:total_active_balance, {epoch, root}, fn ->
196196
state.validators
197-
|> Stream.filter(&Predicates.is_active_validator(&1, epoch))
197+
|> Stream.filter(&Predicates.active_validator?(&1, epoch))
198198
|> Stream.map(fn %Validator{effective_balance: effective_balance} -> effective_balance end)
199199
|> Enum.sum()
200200
|> max(ChainSpec.get("EFFECTIVE_BALANCE_INCREMENT"))
@@ -232,7 +232,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do
232232
validators
233233
|> Stream.with_index()
234234
|> Stream.filter(fn {validator, _index} ->
235-
Predicates.is_eligible_validator(validator, previous_epoch)
235+
Predicates.eligible_validator?(validator, previous_epoch)
236236
end)
237237
|> Stream.map(fn {_validator, index} -> index end)
238238
|> Enum.to_list()
@@ -284,7 +284,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do
284284
@spec get_active_validator_count(BeaconState.t(), Types.epoch()) :: Types.uint64()
285285
def get_active_validator_count(%BeaconState{} = state, epoch) do
286286
Cache.lazily_compute(:active_validator_count, {epoch, get_state_epoch_root(state)}, fn ->
287-
Aja.Enum.count(state.validators, &Predicates.is_active_validator(&1, epoch))
287+
Aja.Enum.count(state.validators, &Predicates.active_validator?(&1, epoch))
288288
end)
289289
end
290290

lib/lambda_ethereum_consensus/state_transition/epoch_processing.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ defmodule LambdaEthereumConsensus.StateTransition.EpochProcessing do
145145
validators
146146
|> Stream.with_index()
147147
|> Stream.map(fn {v, i} ->
148-
{{v, i}, Predicates.is_eligible_for_activation_queue(v),
149-
Predicates.is_active_validator(v, current_epoch) and
148+
{{v, i}, Predicates.eligible_for_activation_queue?(v),
149+
Predicates.active_validator?(v, current_epoch) and
150150
v.effective_balance <= ejection_balance}
151151
end)
152152
|> Stream.filter(&(elem(&1, 1) or elem(&1, 2)))
@@ -163,7 +163,7 @@ defmodule LambdaEthereumConsensus.StateTransition.EpochProcessing do
163163
with {:ok, new_state} <- result do
164164
new_state.validators
165165
|> Stream.with_index()
166-
|> Stream.filter(fn {v, _} -> Predicates.is_eligible_for_activation(state, v) end)
166+
|> Stream.filter(fn {v, _} -> Predicates.eligible_for_activation?(state, v) end)
167167
|> Enum.sort_by(fn {%{activation_eligibility_epoch: ep}, i} -> {ep, i} end)
168168
|> Enum.slice(0..(churn_limit - 1))
169169
|> Enum.reduce(new_state.validators, fn {v, i}, acc ->
@@ -223,21 +223,21 @@ defmodule LambdaEthereumConsensus.StateTransition.EpochProcessing do
223223
{:ok, unslashed_participating_indices} =
224224
Accessors.get_unslashed_participating_indices(state, timely_target_index, previous_epoch)
225225

226-
state_is_in_inactivity_leak = Predicates.is_in_inactivity_leak(state)
226+
state_in_inactivity_leak? = Predicates.in_inactivity_leak?(state)
227227

228228
state.inactivity_scores
229229
|> Stream.zip(state.validators)
230230
|> Stream.with_index()
231231
|> Enum.map(fn {{inactivity_score, validator}, index} ->
232-
if Predicates.is_eligible_validator(validator, previous_epoch) do
232+
if Predicates.eligible_validator?(validator, previous_epoch) do
233233
inactivity_score
234234
|> Misc.increase_inactivity_score(
235235
index,
236236
unslashed_participating_indices,
237237
inactivity_score_bias
238238
)
239239
|> Misc.decrease_inactivity_score(
240-
state_is_in_inactivity_leak,
240+
state_in_inactivity_leak?,
241241
inactivity_score_recovery_rate
242242
)
243243
else
@@ -323,7 +323,7 @@ defmodule LambdaEthereumConsensus.StateTransition.EpochProcessing do
323323

324324
state.validators
325325
|> Aja.Vector.zip_with(epoch_participation, fn v, participation ->
326-
{not v.slashed and Predicates.is_active_validator(v, epoch) and
326+
{not v.slashed and Predicates.active_validator?(v, epoch) and
327327
Predicates.has_flag(participation, flag_index), v.effective_balance}
328328
end)
329329
|> Aja.Vector.filter(&elem(&1, 0))

lib/lambda_ethereum_consensus/state_transition/operations.ex

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
223223
) do
224224
cond do
225225
# Verify consistency of the parent hash with respect to the previous execution payload header
226-
Types.BeaconState.is_merge_transition_complete(state) and
226+
Types.BeaconState.merge_transition_complete?(state) and
227227
payload.parent_hash != state.latest_execution_payload_header.block_hash ->
228228
{:error, "Inconsistency in parent hash"}
229229

@@ -364,10 +364,10 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
364364
|> Stream.take(bound)
365365
|> Stream.map(fn {{validator, balance}, index} ->
366366
cond do
367-
Validator.is_fully_withdrawable_validator(validator, balance, epoch) ->
367+
Validator.fully_withdrawable_validator?(validator, balance, epoch) ->
368368
{validator, balance, index}
369369

370-
Validator.is_partially_withdrawable_validator(validator, balance) ->
370+
Validator.partially_withdrawable_validator?(validator, balance) ->
371371
{validator, balance - max_effective_balance, index}
372372

373373
true ->
@@ -400,7 +400,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
400400
proposer = state.validators[header_1.proposer_index]
401401

402402
cond do
403-
not Predicates.is_indices_available(validators_size, [header_1.proposer_index]) ->
403+
not Predicates.indices_available?(validators_size, [header_1.proposer_index]) ->
404404
{:error, "Too high index"}
405405

406406
not (header_1.slot == header_2.slot) ->
@@ -412,7 +412,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
412412
not (header_1 != header_2) ->
413413
{:error, "Headers are same"}
414414

415-
not Predicates.is_slashable_validator(proposer, Accessors.get_current_epoch(state)) ->
415+
not Predicates.slashable_validator?(proposer, Accessors.get_current_epoch(state)) ->
416416
{:error, "Proposer is not slashable"}
417417

418418
not ([proposer_slashing.signed_header_1, proposer_slashing.signed_header_2]
@@ -458,7 +458,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
458458
{:ok, BeaconState.t()} | {:error, String.t()}
459459
def process_deposit(state, deposit) do
460460
with {:ok, deposit_data_root} <- Ssz.hash_tree_root(deposit.data) do
461-
if Predicates.is_valid_merkle_branch?(
461+
if Predicates.valid_merkle_branch?(
462462
deposit_data_root,
463463
deposit.proof,
464464
Constants.deposit_contract_tree_depth() + 1,
@@ -487,19 +487,19 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
487487
validator_size = Aja.Vector.size(state.validators)
488488

489489
cond do
490-
not Predicates.is_slashable_attestation_data(attestation_1.data, attestation_2.data) ->
490+
not Predicates.slashable_attestation_data?(attestation_1.data, attestation_2.data) ->
491491
{:error, "Attestation data is not slashable"}
492492

493-
not Predicates.is_valid_indexed_attestation(state, attestation_1) ->
493+
not Predicates.valid_indexed_attestation?(state, attestation_1) ->
494494
{:error, "Attestation 1 is not valid"}
495495

496-
not Predicates.is_valid_indexed_attestation(state, attestation_2) ->
496+
not Predicates.valid_indexed_attestation?(state, attestation_2) ->
497497
{:error, "Attestation 2 is not valid"}
498498

499-
not Predicates.is_indices_available(validator_size, attestation_1.attesting_indices) ->
499+
not Predicates.indices_available?(validator_size, attestation_1.attesting_indices) ->
500500
{:error, "Index too high attestation 1"}
501501

502-
not Predicates.is_indices_available(validator_size, attestation_2.attesting_indices) ->
502+
not Predicates.indices_available?(validator_size, attestation_2.attesting_indices) ->
503503
{:error, "Index too high attestation 2"}
504504

505505
true ->
@@ -521,7 +521,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
521521

522522
defp slash_validator(slashed_any, state, i) do
523523
if Aja.Vector.at!(state.validators, i)
524-
|> Predicates.is_slashable_validator(Accessors.get_current_epoch(state)) do
524+
|> Predicates.slashable_validator?(Accessors.get_current_epoch(state)) do
525525
case Mutators.slash_validator(state, i) do
526526
{:ok, state} -> {:cont, {true, state}}
527527
{:error, _msg} -> {:halt, {false, nil}}
@@ -542,10 +542,10 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
542542
validator = state.validators[validator_index]
543543

544544
cond do
545-
not Predicates.is_indices_available(Aja.Vector.size(state.validators), [validator_index]) ->
545+
not Predicates.indices_available?(Aja.Vector.size(state.validators), [validator_index]) ->
546546
{:error, "Too high index"}
547547

548-
not Predicates.is_active_validator(validator, Accessors.get_current_epoch(state)) ->
548+
not Predicates.active_validator?(validator, Accessors.get_current_epoch(state)) ->
549549
{:error, "Validator isn't active"}
550550

551551
validator.exit_epoch != Constants.far_future_epoch() ->
@@ -860,7 +860,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Operations do
860860
end
861861

862862
defp check_valid_indexed_attestation(state, indexed_attestation) do
863-
if Predicates.is_valid_indexed_attestation(state, indexed_attestation) do
863+
if Predicates.valid_indexed_attestation?(state, indexed_attestation) do
864864
:ok
865865
else
866866
{:error, "Invalid signature"}

0 commit comments

Comments
 (0)