Ethereum Smart Contract Development
上QQ阅读APP看书,第一时间看更新

Middleware

Mist and DApps are mainly part of the frontend stack of Ethereum. Let us now move into backend mechanisms. First, we start with the middleware. The middleware of Ethereum has a flat hierarchy, as there is no central authority, such as a server. It consists of three prime components of equal importance:

  • Swarm: Ethereum's decentralized storage, mainly for static files
  • Whisper: The walkie-talkie of DApps, that is an identity based messaging system
  • EVM: An isolated, on-the-fly, human-to-machine code translator, that is in a sandboxed runtime environment

How does an app run without a server? We can figure this out by understanding that the servers in a web 2.0 framework do quite a lot more than they were intended to do in order to keep the client device light. Not only do they serve static web pages, they store private information, administer user authentication, and compute all the complex analytics. All the client side does is to load and display the message to the user. A server-less architecture in web 3.0, on the other hand, allows a much more modular approach, in which different computing devices and different protocols handle specific tasks; some on the client side and some in specialized nodes deployed on a peer-to-peer network. Therefore, all the data logic comprising logs about what is getting saved, who is saving it and resolving conflicts are handled by smart contracts on the blockchain; static files are served via swarm and real-time communication is taken care of by whisper, as shown in Figure 2.7. The client device keeps the user authentication and runs the application interface, that is, the mist wallet plus the browser:

Figure 2.7: Server less architecture, Source: blog.ethereum.org

Figure 2.8 illustrates how these modules work in unison with DApps and the underlying blockchain in a server less architecture. Such a setup also encourages innovation. As the interfaces are detached from the data, anybody can develop a new interface for the same application, creating a more vibrant and competitive ecosystem:

Figure 2.8: Decentralized architecture, Source: Ethereum stack exchange