The first version of the Light Ethereum subprotocol (LES/1) and its implementation on Geth are still in progress. not Although it is experimental, it is expected to reach more levels. mature Just say that basic functionality will be performed reliably in a few months. Light clients are designed to function much the same as full clients, but “lightness” has some inherent limitations that DApp developers cannot fulfill. must understand Take this into consideration when designing your application..
In most cases, a properly designed application can function without knowing what kind of client it is connected to, but we are considering adding API extensions to convey various client functions to provide a future-proof interface. While minor details about LES are still being worked out, I think the time has come to clarify the most important differences between full and light clients from an application developer perspective.
Current restrictions
pending transaction
Light clients do not receive pending transactions from the underlying Ethereum network. The only pending transactions that a light client is aware of are those generated and sent by that client. When a light client sends a transaction, it starts downloading the entire block until it finds the transaction it sent in one of the blocks, then removes that transaction from the set of pending transactions.
Find Transactions by Hash
Currently only locally generated transactions can be found through hashes. These transactions and their containing blocks are stored in a database and can be found later by hash. Finding other deals is a little trickier. (Although it is not implemented yet) You can download it from the server and check if the transaction is actually included in the block if the server finds it. Unfortunately, the client cannot verify the validity of this answer if the server says that the transaction does not exist. If the first server doesn’t know about it, you can ask multiple servers, but the client can never be sure that a given transaction doesn’t exist. For most applications this may not be a problem, but it is something to keep in mind if something important may depend on the existence of a transaction. A coordinated attack that tricks a light client into thinking a transaction does not exist at a particular hash would probably be difficult to execute, but not completely impossible.
Performance considerations
request waiting time
The only thing a light client always has in the database are the last few thousand block headers. This means that to retrieve something else, the client must send a request and receive a response from the light server. The light client attempts to optimize the request. distribution To reduce latency, we collect statistical data about the typical response time of each server. Latency is a key performance parameter for light clients. This is typically around 100-200ms and applies to all state/contract store reads, block and receipt set retrieval. If many requests are made sequentially to perform a task, your user response time may be slow. Running API functions in parallel whenever possible can significantly improve performance.
Search for events in long block history
Full clients can use so-called “MIP mapping” bloom filters to quickly find events in long lists of blocks, making it reasonably cheap to search for specific events across the full block history. Unfortunately, using MIP mapping filters is not easy to do in light clients. This is because the search is performed only on individual headers, making it much slower. Retrieving several days’ worth of block history will generally return after an acceptable amount of time, but You shouldn’t search for anything in the entire record at this time. Because it takes a very long time.
Memory, disk, and bandwidth requirements
The good news is: Light clients don’t need large databases because they can retrieve anything on demand. When garbage collection is enabled (to be implemented) The database works like this: It can be run using cache and light clients. At least 10Mb of storage space. The current Geth implementation uses: 200Mb of memory, maybe it could be reduced further. Bandwidth requirements are also lower when clients are not heavily used. The bandwidth used is typically much lower. 1Mb/hour when running idle, plus 2-3kb per average state/storage request.
Future improvements
Reduce overall latency with remote execution
In some cases, it is not necessary to pass data back and forth between the client and server multiple times to evaluate functionality. On the server side, we run the function, then collect all Merkle proofs that prove all state data accessed by the function, and return all the proofs at once, so the client can run the code again and check the proofs. This method can be used for any application-specific code that acts as an input on the blockchain/state, not just read-only functions in contracts.
Indirectly verify complex calculations
One of the main limitations we are working to improve Log history search speed is slow. Many of the limitations mentioned above, including the difficulty of obtaining MIP-mapped bloom filters, follow the same pattern. This means that servers (full nodes) can easily calculate certain information that can be shared with light clients. However, light clients currently have no practical way to verify the validity of that information. This is because directly viewing the entire calculation of the results would require too much processing power and bandwidth, making using a light client pointless.
Fortunately, there are safe and unreliable solutions to common problems. Day Even if the receiving party does not have the actual data, just the corresponding hash, it indirectly verifies the remote computation based on an input data set that is assumed to be available to both parties. This is exactly the case Scenarios in which the Ethereum blockchain itself can be used as input for verified computations include: This means that a light client can have functionality close to a full node because it can ask a light server to remotely evaluate tasks it cannot perform on its own. The details of this feature are still being researched and are beyond the scope of this document. However, the general idea of how to check is explained in this article by Dr. Christian Reitwiessner. Devcon 2 Talk.
Complex applications that access a huge contract repository may benefit from this approach without having to fully evaluate accessor functions on the server side, download proofs, and reevaluate functions. In theory, it is also possible for light clients to use indirect verification to filter out events that they cannot otherwise observe. However, in most cases it is still simpler and more efficient to generate appropriate logs.