Skip to content

Commit

Permalink
Added sync_committee_aggregator? function
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-o committed Aug 26, 2024
1 parent 3c9803d commit 324474d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/lambda_ethereum_consensus/validator/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,19 @@ defmodule LambdaEthereumConsensus.Validator.Utils do
"Invalid epoch #{epoch}, should be in the current or next sync committee period"
end
end

# `is_sync_committee_aggregator` equivalent
@spec sync_committee_aggregator?(Types.bls_signature()) :: boolean()
def sync_committee_aggregator?(signature) do
modulo =
ChainSpec.get("SYNC_COMMITTEE_SIZE")
|> div(Constants.sync_committee_subnet_count())
|> div(Constants.target_aggregators_per_sync_subcommittee())
|> max(1)

SszEx.hash(signature)
|> binary_part(0, 8)
|> :binary.decode_unsigned(:little)
|> rem(modulo) == 0
end
end

0 comments on commit 324474d

Please sign in to comment.