Let's talk, peer to peer

If you haven't already read my two articles, they will provide some details that are assumed to be understood in the this article.

Photo by Shane Rounce on Unsplash

We talked before about how the client/server model has some significant shortcomings when it comes to light clients. In short, if there are a lot more light clients (the clients) than full nodes (the servers) and the full nodes have no incentive to respond to light client requests, then the few altruistic full nodes that do act as the servers in this scenario would get overwhelmed and we end up kind of where the current Ethereum light client world is today (i.e. lightly used and even more lightly served because Infura/Alchemy just work better). What if there's a better way?

Peer to Peer (p2p)

What is peer to peer anyway?

That potentially better way is called peer-to-peer. It may sound familiar if you've been around the internet at all the past 25 years. It was what Napster promised (not really) and then BitTorrent and similar file-sharing protocols now leverage. But what it is really? Just what it sounds like, two or more machines, nodes, computers, whatever interacting as peers. In the client/server model, the server produces the data and the client consumes, but in peer to peer networks, all nodes both produce and consume. In the world of Ethereum, all full nodes already participate in a peer to peer network, sharing blocks with each other, broadcasting transactions around the network, all checking each other's work, in other words, doing the hard work of consensus.

Can’t we all just be friends?

So can light clients get in on this peer to peer game? Let's explore some of the technical challenges that make this hard.

  1. Storage/Compute - We've talked about this before but store a full copy of the Ethereum chain state and history takes hundreds of gigabytes and lots of bandwidth to process. While a top-end mobile phone might be able to a full node, or at least maybe a validator, it's probably all the phone could do and it would chew up your data plan if you're on a metered service. In other words, not a light client thing.

  2. Networks - I'm going to try and avoid the deep technical mumbo jumbo here but when it comes to running an application in a peer to peer environment, it's important that you can connect to any other peer. Otherwise, you can't participate in the network on an equal footing. This is where things get messy for those of us running nodes on "consumer hardware" (i.e. phone/laptops). Almost all consumer hardware connects to the internet via WiFi or cellular and as such sits behind a router. There are lots of reasons for this but the one that concerns us most is that routers generally ensure that you only talk to servers that you intend to and that servers that you haven't already talked to can't just randomly reach you. To use the analogy of mobile phones, if your phone/laptop is behind a router, you can’t accept incoming calls from unknown numbers. Routers ensure that you can make outbound calls to whoever you want because they assume that if you dial a number (or type in a URL), you're intending to contact whoever is on the other end of that number. But, they don't let any random person (or server) call you since if our computers accepted random incoming connections from the internet, we'd be in a very bad place where anyone at any time could connect to our machine and well, that means viruses, ransomware, denial of service attacks, and all the other bad things that are out on the internet. But, this is a problem for peer-to-peer networks where you need to be able to connect to lots of peers both incoming and outgoing in order to ensure that you can participate in the blockchain in a meaningful manner. Otherwise, let's just trust Infura because it's more secure than letting our phones get overrun by incoming connections from all the bad guys on the internet.

From ethernodes.org

Who are the peers then?

Given these two challenges, how does a peer to peer blockchain even work right, if we can't call each other (because of firewalls, routers, and the concerns about getting hacked) and we can't run the nodes on our own hardware (because the system requirements are so high), who are the peers on our blockchains?

Well, mostly, people running full nodes on cloud servers with professional operational security ensuring that the nodes stay running all the time and are properly secured so they don't get hacked or "DDos"ed. But, if you look at the chart, there's also a minority running "at home" or "on cellular." Those are dedicated souls but wouldn’t it be glorious if we could somehow bring light clients into this picture and increase the percentage of people participating trustlessly with Ethereum on a p2p basis?

Let's go through the portal and see what's possible!

Loading...
highlight
Collect this post to permanently own it.
Subscribe to Web3 Ninjitsu and never miss a post.
  • Loading comments...