Skip to content

Commit 3c5961f

Browse files
committed
Finally fixing the issue
1 parent 11c9b72 commit 3c5961f

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

lib/lambda_ethereum_consensus/beacon/clock.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ defmodule LambdaEthereumConsensus.Beacon.Clock do
44
use GenServer
55

66
alias LambdaEthereumConsensus.Libp2pPort
7-
alias LambdaEthereumConsensus.Validator.ValidatorManager
87

98
require Logger
109

lib/lambda_ethereum_consensus/validator/duties.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ defmodule LambdaEthereumConsensus.Validator.Duties do
6969
attester_duties
7070
# Drop the first element, which is the previous epoch's duty
7171
|> Stream.drop(1)
72-
|> Enum.each(fn %{index_in_committee: i, committee_index: ci, slot: slot} ->
73-
Logger.debug(
74-
"[Validator] #{validator_index} has to attest in committee #{ci} of slot #{slot} with index #{i}"
72+
|> Enum.each(fn %{index_in_committee: i, committee_index: ci, slot: slot, should_aggregate?: sa} ->
73+
Logger.info(
74+
"[Validator] #{validator_index} has to attest in committee #{ci} of slot #{slot} with index #{i}, and should_aggregate?: #{sa}"
7575
)
7676
end)
7777

lib/lambda_ethereum_consensus/validator/validator.ex

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ defmodule LambdaEthereumConsensus.Validator do
246246
attestation = produce_attestation(current_duty, state.root, state.validator.privkey)
247247

248248
log_md = [slot: attestation.data.slot, attestation: attestation, subnet_id: subnet_id]
249-
log_debug(validator.index, "publishing attestation", log_md)
249+
debug_log_msg = "publishing attestation on committee index: #{current_duty.committee_index} | as #{current_duty.index_in_committee}/#{current_duty.committee_length - 1} and pubkey: #{LambdaEthereumConsensus.Utils.format_shorten_binary(validator.pubkey)}"
250+
log_debug(validator.index, debug_log_msg, log_md)
250251

251-
# FIXME: Uncommenting this line generates the invalid signature errors upon proposals
252-
# Gossip.Attestation.publish(subnet_id, attestation)
253-
# |> log_info_result(validator.index, "published attestation", log_md)
252+
Gossip.Attestation.publish(subnet_id, attestation)
253+
|> log_info_result(validator.index, "published attestation", log_md)
254254

255255
if current_duty.should_aggregate? do
256256
log_debug(validator.index, "collecting for future aggregation", log_md)
@@ -295,12 +295,15 @@ defmodule LambdaEthereumConsensus.Validator do
295295
end
296296

297297
defp aggregate_attestations(attestations) do
298+
# TODO: We need to check why we are producing duplicate attestations, this was generating invalid signatures
299+
unique_attestations = attestations |> Enum.uniq()
300+
298301
aggregation_bits =
299-
attestations
302+
unique_attestations
300303
|> Stream.map(&Map.fetch!(&1, :aggregation_bits))
301304
|> Enum.reduce(&BitField.bitwise_or/2)
302305

303-
{:ok, signature} = attestations |> Enum.map(&Map.fetch!(&1, :signature)) |> Bls.aggregate()
306+
{:ok, signature} = unique_attestations |> Enum.map(&Map.fetch!(&1, :signature)) |> Bls.aggregate()
304307

305308
%{List.first(attestations) | aggregation_bits: aggregation_bits, signature: signature}
306309
end

lib/lambda_ethereum_consensus/validator/validator_manager.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ defmodule LambdaEthereumConsensus.Validator.ValidatorManager do
6363

6464
# TODO: The use of a Genserver and cast is still needed to avoid locking at the clock level.
6565
# This is a temporary solution and will be taken off in a future PR.
66-
defp notify_validators(msg), do: GenServer.call(__MODULE__, {:notify_all, msg})
66+
defp notify_validators(msg), do: GenServer.call(__MODULE__, {:notify_all, msg}, 20_000)
6767

6868
def handle_cast({:notify_all, msg}, validators) do
6969
validators = notify_all(validators, msg)
@@ -80,6 +80,8 @@ defmodule LambdaEthereumConsensus.Validator.ValidatorManager do
8080
defp notify_all(validators, msg) do
8181
start_time = System.monotonic_time(:millisecond)
8282

83+
Logger.info("[Validator Manager] Notifying all Validators with message: #{inspect(msg)}")
84+
8385
updated_validators = Enum.map(validators, &notify_validator(&1, msg))
8486

8587
end_time = System.monotonic_time(:millisecond)

0 commit comments

Comments
 (0)