The initial iteration of the Light Ethereum Subprotocol (LES/1) along with its implementation in Geth remains in a preliminary phase, yet it is anticipated to evolve into a more advanced condition in several months where the fundamental functionalities will operate consistently. The light client is architected to work similarly to a full client, but the “lightweight” nature presents certain limitations that DApp developers must acknowledge and consider when crafting their applications.
In the majority of scenarios, a well-constructed application can function even when it is unaware of the type of client it is linked to, but we are exploring the addition of an API extension to communicate various client capabilities to provide a forward-compatible interface. While minor aspects of LES are still being refined, I feel it is crucial to elucidate the most significant distinctions between full and light clients from the viewpoint of application developers.
Current restrictions
Pending transactions
Light clients do not receive pending transactions from the primary Ethereum network. The only pending transactions known to a light client are those that have been initiated and dispatched from that client. When a light client dispatches a transaction, it begins downloading entire blocks until it locates the dispatched transaction in one of the blocks, subsequently removing it from the pending transaction set.
Locating a transaction by hash
At present, you can only locate locally generated transactions by hash. These transactions and their corresponding blocks are stored in the database and can be accessed by hash later. Locating other transactions poses a greater challenge. It is feasible (though not yet implemented) to obtain them from a server and verify that the transaction is indeed included in the block that the server identified. Regrettably, if the server claims that the transaction is nonexistent, the client cannot verify the accuracy of this assertion. It is possible to consult multiple servers in the event the first one does not recognize it, but the client can never be entirely certain about the non-existence of a specific transaction. For many applications, this may not be a concern, yet it is an aspect one should bear in mind if crucial matters could hinge on the presence of a transaction. A coordinated effort to deceive a light client into believing that no transaction is present with a specified hash would likely be challenging to carry out, albeit not wholly impossible.
Performance factors
Request latency
The only data a light client consistently retains in its database is the most recent few thousand block headers. This indicates that obtaining any other information necessitates the client to dispatch requests and receive responses from light servers. The light client endeavors to optimize request allocation and compiles statistical data on the typical response times of each server to reduce latency. Latency serves as the primary performance metric of a light client. It typically falls within the 100-200ms range, applying to every state/contract storage read, block, and receipt set retrieval. If numerous requests are sequentially made to accomplish a task, it may lead to a delayed response time for the user. Executing API functions in parallel whenever feasible can significantly enhance performance.
Searching for events over an extensive block history
Full clients utilize a so-called “MIP mapped” bloom filter to quickly locate events amidst a lengthy list of blocks, making it relatively inexpensive to search for specific events across the complete block history. Unfortunately, employing a MIP-mapped filter is not straightforward for a light client, as searches are only conducted in separate headers, which is significantly slower. Retrieving data from a few days’ worth of block history usually concludes within an acceptable time frame, but currently, you should refrain from searching for anything throughout the entire history as it will take an extraordinarily long period.
Memory, disk, and bandwidth requirements
Here is the positive aspect: a light client does not necessitate a large database since it can retrieve anything upon request. With garbage collection activated (which is scheduled for implementation), the database will operate more like a cache, which means a light client can function with as little as 10Mb of storage space. Note that the current Geth implementation consumes approximately 200Mb of memory, which could possibly be reduced further. Bandwidth requirements are also lower when the client is not heavily utilized. Typically, bandwidth usage is well below 1Mb/hour when idle, with an additional 2-3kb required for an average state/storage request.
Future enhancements
Mitigating overall latency through remote execution
Occasionally, it is unnecessary to transfer data back and forth multiple times between the client and the server to evaluate a function. Executing functions on the server side, collecting all the Merkle proofs proving every piece of state data accessed by the function and then transmitting all the proofs at once can allow the client to re-run the code and validate the proofs. This approach can be applied to both read-only contract functions and any application-specific code that interacts with the blockchain/state as an input.
Indirectly validating elaborate calculations
One of the primary limitations we are striving to improve is the sluggish search speed of log histories. Many of the limitations highlighted above, including the challenge of acquiring MIP-mapped bloom filters, follow a similar pattern: the server (which operates as a full node) can effortlessly compute specific pieces of information, which can be shared with the light clients. However, light clients currently lack a practical means to validate that information since verifying the entirety of the result calculations directly would require substantial processing power and bandwidth, rendering light client use ineffective.
Fortunately, a secure and trustless resolution exists for the generalized task of indirectly confirming remote calculations based on an input dataset both parties presume to be accessible, even if the receiving party does not possess the actual data, just its hash. This aligns perfectly with the circumstances in our case where the Ethereum blockchain can itself be utilized as an input for such a verified calculation. This implies that light clients can acquire functionalities akin to those of full nodes, allowing them to request a light server to remotely carry out an operation on their behalf that they otherwise could not perform independently. The specifics of this capability are still undergoing development and lie beyond the scope of this document, yet the overarching concept of the verification method is articulated by Dr. Christian Reitwiessner in this Devcon 2 talk.
Complex applications engaging with extensive contract storage can also gain advantages from this strategy by assessing accessor functions entirely on the server side, eliminating the need to download proofs and re-evaluate functions. Theoretically, it would also be feasible to apply indirect verification for filtering events that light clients could not monitor otherwise. However, in most situations, generating accurate logs remains simpler and more efficient.
