Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/lambda_ethereum_consensus/state_transition/accessors.ex
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,7 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do
|> Enum.reduce_while({MapSet.new(), 0}, fn committee_index, {attesters, offset} ->
case get_beacon_committee(state, data.slot, committee_index) do
{:ok, committee} ->
committee_attesters =
committee
|> Stream.with_index(offset)
|> Stream.filter(fn {_validator, pos} -> participated?(aggregation_bits, pos) end)
|> Stream.map(fn {validator, _} -> validator end)
|> MapSet.new()
committee_attesters = compute_committee_attesters(committee, aggregation_bits, offset)

{:cont, {MapSet.union(attesters, committee_attesters), offset + length(committee)}}

Expand All @@ -616,6 +611,14 @@ defmodule LambdaEthereumConsensus.StateTransition.Accessors do
end
end

defp compute_committee_attesters(committee, aggregation_bits, offset) do
committee
|> Stream.with_index(offset)
|> Stream.filter(fn {_validator, pos} -> participated?(aggregation_bits, pos) end)
|> Stream.map(fn {validator, _} -> validator end)
|> MapSet.new()
end

@spec get_committee_attesting_indices([Types.validator_index()], Types.bitlist()) ::
[Types.validator_index()]
def get_committee_attesting_indices(committee, bits) do
Expand Down
Loading