lambdaclass / lambda_ethereum_consensus

Elixir implementation of an Ethereum consensus client, which offers high reliance & fault tolerance
Apache License 2.0
101 stars 33 forks source link

Leave and Join subnets on epoch duties calculation #1279

Open rodrigo-o opened 3 months ago

rodrigo-o commented 3 months ago

During #1274, duties calculations have been simplified and shared across all Validators in the node. During this refactor a previous step has been removed, during duties recalculation (at the end of an epoch) this function was executed in each validator:

  defp move_subnets(%{attester: old_duties}, %{attester: new_duties}) do
    old_subnets = old_duties |> get_subnet_ids() |> MapSet.new()
    new_subnets = new_duties |> get_subnet_ids() |> MapSet.new()

    # leave old subnets (except for recurring ones)
    MapSet.difference(old_subnets, new_subnets) |> leave()

    # join new subnets (except for recurring ones)
    MapSet.difference(new_subnets, old_subnets) |> join()
  end

This hasn't been added in #1274 but the Validators work (specifically attestation) doesn't appear to be affected. We need to check this is actually the case and make sure it wasn't needed in the first place.

rodrigo-o commented 2 months ago

Right now we are missing some of the attestations and sync committee messages that should be collected, this appears to be happening due to a late subscription to the gossip topic, we need to make sure subnets are joined and subscribed in a timely fashion.

Edit: This was moved to it's own issue #1300, to left this issue open for future research, there is no bug right now affecting this issue and it will be just a nice-to-have except we found anything related to the leave and join per slot instead of at the start of an epoch.