The Building Blocks of Stacks

Sidra
GeeksTrends
Published in
5 min readJan 16, 2020

--

Fig-1 Stacks Architecture

In my previous article, I have explained why Stacks was developed in the first place. DARPA designed the internet during the world war. Communication links were designed to be fault-tolerant. So, in any case, it should find a way to transfer the packet to the destination. This resulted in the transfer rate being slow. To overcome this problem client-server architecture was designed. To achieve speed loopholes were left in the system. Internet infrastructure is decentralized by design with centralized entities on top. E.g public key infrastructure, DNS. Stacks has been working to reinvent the internet by removing any trusted third party.

Traditional App’s Vs Stacks App

Apps like facebook, whatsapp, Snapchat works on the application layer. They utilize internet API’s to share data. Traditional Applications allow the user to login to the system. Retrieve or store information from the database on the basis of identity provided by the application.

The idea behind Stacks App is user should be the sole owner of the data and his digital identity. Stacks is ensuring all of this by providing:

Digital Identity To allow the user to own a digital identity a decentralized identity was developed. Stacks has implemented a virtual chain to map the digital property of the user. E.g domain name to public keys of the user.

Discovering User Data A global indexer is implemented for retrieving and storing of data into storage backends.

A unique way of using the underlying blockchains

Stacks has utilized the existing blockchain in a very unique way. It has used bitcoin blockchain as an append-only log that models system state and changes on it. It used abstract features such as security, consensus, and network effect of the underlying blockchain. The advantage of this mapping is that there are no central servers to maintain user identity and the naming system is maintained by the user.

Challenges Name coin faced while bootstrapping their own blockchain network

Stacks has implemented an underlying blockchain in a unique manner. Before Stacks common way of making your own blockchain was to fork an existing blockchain and add additional functionality.

Namecoin an alternative to domain name system bootstrapped their own blockchain. They ran into problems. They have documented those challenges in their whitepaper. Here is a brief summary of it

Security Name coin found out that miners would often pool their resources together and launch 51% attack. It is attractive to fork the blockchain and introduce new features however there are major security concerns.

Network reliability and throughput Software bugs may halt the registration process of the domain name. If someone sends a transaction with too many fields it caused the miner to shutdown. Another issue is low throughput. One big mining pool can become a black hole and control which transactions get passed.

Selfish mining It was noticed miners were allowing some transactions to get mined in bulks and some were rejected.

Consensus breaking changes When hard forks were needed and there was a major software up-gradation require. Many miners never came back to mine in the network.

Deep Dive into Stacks Ecosystem

Stacks has designed its architecture after learning from name coin challenges. Now let’s dive deep into the internal working of stacks. It has three important layers.

  1. Data Plane

The data plane or Blockchain layer is the lowest layer responsible for maintaining the mapping between human-readable names (DNS records) and network resources(identity information). Data plane can be divided into two layers. It consists of a virtual chain and an underlying blockchain.

Fig-2: Data plane division

Layer 1 — Underlying blockchain: Bitcoin-like blockchain that stores the global consensus on the system state. Currently, stacks use bitcoin blockchain. Security is maintained using bitcoin blockchain abstract functionality such as mining, consensus algorithm. Once a blockchain has been defined it is nearly impossible to change the operations. For additional functionality virtual chains are used like BNS. Bitcoin treats bitcoin blockchain as an append-only blockchain where the state of the virtual chain is maintained by a global consensus mechanism.

Layer 2 — VirtualChain: To a novice, it seems like Stacks is actually helping you store transactions in actual blockchain but it is the virtual chain. Stacks has designed its architecture around “virtual chains”, peers only need to reach a consensus on the shared “virtual chain” they’re interested in.

There can be many virtual chains on top of any blockchain for which there exists a driver. The virtual chain clients only need to execute their own virtual chain transactions. For example, stacks only process stacks virtual chain transactions.

A virtual chain contains an arbitrary type of state machine. For example, the DNS state machine can be different than an Identity state machine. The virtual chain can be used with any underlying blockchain. The reliability and security properties will be derivatives of the underlying blockchain. Virtuachain also binds the names to their values. The Hash of the zone file is stored in this layer. Stacks uses DNS-like zone files for indicating the final storage location for data.

Fig-5: Working of a single Virtual chain

2. Peer network

Any distributed system requires an index to the data stored by it. For this purpose, Stacks uses peer to peer network called Atlas.

The peer network (Atlas) is used to store pointers to the actual storage. It’s a content-addresses storage system whose chunks’ hashes are announced on a public blockchain. Stacks has separated discovering resources(i.e routed to data) from actual data of the user. By using this way multiple storage providers can coexist. It contains zone file hashes that map to the particular domain names of the user and public key. A zone file stores URLs to an owner Gaia hubs.

3. Storage (Gaia)

The user’s data is stored in the Gaia hub, and every user’s Gaia hub is associated with his/her stacks id. Users can decide who views and writes data in their Gaia hub. Data in the user’s Gaia hub is encrypted with their public key. By default, users are provided with default Gaia hub storage but they can migrate their data to their desired cloud or local storage. Applications built on top of the stacks use the user’s Gaia hub to store their data, So the data of every user is stored in their Gaia hub instead of centralized storage.

Conclusion

Blockchain's purpose is to make data consistent. stacks have utilized existing blockchain infrastructure in an efficient way. Giving developers an ecosystem to make decentralized apps. Now, it depends on developers and people what they build on top of it.

Resources:

https://blockstack.org/whitepaper.pdf

https://medium.com/coinmonks/blockstack-a-decentralized-naming-and-storage-system-using-blockchain-445ff60190f7

https://docs.blockstack.org/core/faq_technical.html

https://github.com/blockstack/virtualchain/blob/master/README.md

https://github.com/blockstack/virtualchain

https://docs.blockstack.org/core/naming/introduction.html

--

--

Sidra
GeeksTrends

Blockchain Developer, Blockchain Researcher, Web3 Technical Writer