Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Light client p2p interface #2786

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jinfwhuang
Copy link

@jinfwhuang jinfwhuang commented Dec 30, 2021

I created this simple PR to get the conversation going about a p2p approach. As mentioned previously in the thread in #light-client channel in discord, we could very well dismiss this approach after some discussions. Instead, we focus on building a p2p approach based on portal network, and a N-server approach. Regardless, it will be a very useful exercise to think through the input data for the light client.

Copied from the channel's discussion. There are three approaches to the light-client networking:

  1. RPC. Clients find the RPC endpoints out of band. The client could optionally use a N server approach to get data input resilience.
  2. Extend beacon chain p2p interface. Light client p2p interface is part of the consensus p2p layer. This approach is detailed in this PR.
  3. Portal network. A light client joins portal network subnetworks that are particular to beacon chain light clients.

@jinfwhuang jinfwhuang changed the title (WIP) Light client networking protocol (WIP) Light client p2p interface Dec 30, 2021
@dapplion
Copy link
Collaborator

dapplion commented Dec 31, 2021

In current beacon chain gossip channels that include aggregate-able objects, a SelectionProof is required to prevent too many distinct yet valid messages from being propagated.

In a naive implementation of a LightClientUpdate gossip channel, an attacker could craft 2**512 - 1 valid LightClientUpdates with different combinations of the signatures. There must exist some mechanism to limit that.

@jinfwhuang
Copy link
Author

In current beacon chain gossip channels that include aggregate-able objects, a SelectionProof is required to prevent too many distinct yet valid messages from being propagated.

In a naive implementation of a LightClientUpdate gossip channel, an attacker could craft 2**512 - 1 valid LightClientUpdates with different combinations of the signatures. There must exist some mechanism to limit that.

This is a valid concern.

Introducing a mechanism akin to "aggregation selection" might be too intrusive. Unlike validator participants, we don't know the set of light client participants. Light client topics participation should be very loose. The servers should be treated as anonymous nodes, coming and going without getting assigned responsibilities.

One cheeky way to ensure that the channel does get spammed is to introduce a deduplication mechanism. Every LightClientUpdate message is deduped/filtered before they are sent to the pubsub channel. For example, here is one way to dedupe LightClientUpdate objects according to the following rule

def select_update(update1, update2) -> LightClientUpdate:
    assert(update1.attested_header == update2.attested_header)  # Otherwise, they are considered distinct
  
    bit_count1 = sum(update1.sync_committee_aggregate.sync_committee_bits)
    bit_count2 = sum(update2.sync_committee_aggregate.sync_committee_bits)
    if bit_count1 == bit_count2:
        as_big_endian_int(update1.sync_committee_aggregate.sync_committee_bits) > as_big_endian_int(update12sync_committee_aggregate.sync_committee_bits):  # This is the tie breaker
           return update1
    elif bit_count1 > bit_count2:
        return update1
    else:
          return update2

Each node will run this dedupe mechanism. Each node will relay a new update of the the same attested hash only if the update has "improved" from the previous version that it saw.

)
```

The request key is the hash root of a SyncCommittee. This allows a light client to start with any trusted sync-committee root to skip sync to the latest sync-committee.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not bullet proof, as the same SyncCommittee may be selected for multiple sync committee periods.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a great observation. In that case, the key must include information about sync period as well.

@dapplion
Copy link
Collaborator

dapplion commented Mar 5, 2023

Should this PR be closed? Spec already well defined in https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/p2p-interface.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants