Introduction to Flow Blockchain

Rahul Ravindran

‍Flow is a fast, decentralized, and developer-friendly blockchain, designed as the foundation for a new generation of games, apps. Every other decentralized blockchain’s plans for scaling depend on some kind of sharding or side chains. Flow takes an interesting approach to scaling by reducing work done at each node.

If you want a quick summary, checkout our video:

Flow was launched in 2019 by Dapper Labs, the company behind famous NFT projects like Cryptokitties and NBA Top shots. It is based on a unique, multi-role architecture, and designed to scale without sharding, allowing for massive improvements in speed and throughput while preserving a developer-friendly, ACID-compliant environment.

Flow empowers developers to build thriving crypto- and crypto-enabled businesses. Applications on Flow can keep consumers in control of their own data; create new kinds of digital assets tradable on open markets accessible from anywhere in the world; and build open economies owned by the users that help make them valuable.

Smart contracts on Flow can be assembled like Lego blocks to power apps serving billions of people, from basketball fans to businesses with mission-critical requirements.

The core insight that led to architecture of Flow is that can be separate non-deterministic processes from deterministic ones and assign each to different types of nodes based on their technical capabilities to dramatically increase the blockchain throughput and solve several user- and developer experience problems with existing networks at the same time. This realization was that tasks within a blockchain can be divided into two types:

  • Non-deterministic (or “subjective”) tasks, such as determining the presence and order of transactions in the blockchain
  • Deterministic (or “objective”) tasks, such as computing the result of those ordered transactions once it has been determined

Non-deterministic tasks require a coordinated consensus process (like Proof of Work or Proof of Stake). Deterministic tasks, on the other hand, always have a single, objectively-correct outcome. The critical insight behind Flow’s architecture was that the single biggest bottleneck to blockchain performance is the deterministic task of executing transactions after they’ve already been included into a block, and not the subjective process that requires consensus, i.e. the formation of the block itself.

Problems with Sharding

Most proposals aim to improve the scalability of blockchains by fragmenting them into inter-connected networks: commonly shards, although sidechains have the same issues. These approaches remove serializability (“ACID”) guarantees common in database systems.

Loss of ACID guarantees makes building an app that needs to access data across fragments far more difficult and error-prone. Interactions between smart contracts become very complicated, and even individual large-scale applications would have to resort to complex mechanics to scale across shards due to latency issues and higher transaction failure rates. The combination dramatically limits the kinds of applications possible on the network as well as their network effects. **Sharding effectively saddles the hardest part of scaling the blockchain onto application developers rather than solving it at the protocol level.

‍**A simple user action (purchasing a hat for a CryptoKitty using a stablecoin like TUSD) can take twelve transactions and seven blocks on a sharded blockchain. In an unsharded, ACID-compliant environment like Flow, the same action, and many more complex than it, can be handled by one atomic transaction in a single block.

Worse than the additional time and cost is the increased attack surface and complexity: it will be much harder to design, test, and harden the smart contract code on a sharded blockchain.

Key Innovations

Flow was explicitly designed to support games and consumer applications on day one, with the throughput necessary to scale to millions of active users.These goals necessitated a number of significant technical innovations:
– A pipelined architecture that separates the jobs typically done by a single miner or validator across five different node types, significantly reducing redundant effort and improving efficiency.
– A new cryptographic technique we call Specialized Proofs of Confidential Knowledge (SPoCKs) to address the Verifier’s Dilemma. – A single shared state for all smart contracts, ensuring that each transaction has full ACID guarantees. This unlocks rich interactions between smart contracts (“Composability”) and creates strong network effects for apps built on Flow.

Originally conceived by the team behind CryptoKitties, Flow today is a decentralized network supported and built on by a growing community of brands and Web3 builders.

Multi-Node Architecture

In a traditional blockchain, every node stores the entire state (account balances, smart contract code, etc.) and performs all of the work associated with processing every transaction in the chain. This is analogous to having a single worker build an entire car.

From manufacturing to CPU design, pipelining is a common technique for dramatically scaling up productivity. Flow applies pipelining to blockchains by separating the jobs of a validator node into four different roles: Collection, Consensus, Execution, and Verification. This separation of labor between nodes is vertical (across the different validation stages for each transaction) rather than horizontal (across different transactions, as with sharding).

In other words, every validator node still participates in the validation of every transaction, but they do so only at one of the stages of validation. They can therefore specialize for — and greatly increase the efficiency of — their particular stage of focus.

There are four pillars that make Flow unique among existing blockchains:

  • Multi-role architecture: Flow’s design is unique, allowing the network to scale to serve billions of users without sharding or reducing decentralization of consensus.
  • Resource-oriented programming: smart contracts on Flow are written in Cadence, an easier and safer programming language for crypto assets and apps.
  • Developer ergonomics: from upgradeable smart contracts and built-in logging support to the Flow Emulator, this network is designed for results.
  • Consumer onboarding: Flow was designed for mainstream consumers, with payment onramps catalyzing a safe and low-friction path from fiat to crypto.

Consensus Mechanism

Consensus and Verification Nodes together are the foundation of security in the Flow network and leverage cryptoeconomic incentives to hold the rest of the network accountable. These validators can optimize for security and decentralization: the roles of Consensus and Verification are streamlined to allow high levels of participation, even by individuals with consumer-grade hardware running on home internet connections. Consensus nodes run a variant of HotStuff, one of the most proven proof of stake algorithms.

Execution and Collection Nodes, on the other hand, do work that is fully deterministic – making them less vulnerable to attack. The work of these nodes is also verified and held accountable by the other node types. These node roles can therefore safely optimize for security and scalability, allowing the network to scale. Operating these nodes requires dedicated server hardware in a professionally managed data center.

Flow pipelines the work of a blockchain miner or validator across four different roles that all require staking; a separation of concerns that significantly reduces redundant effort:

  • Consensus Nodes decide the presence and order of transactions on the blockchain
  • Verification Nodes are responsible for keeping the Execution Nodes in check
  • Execution Nodes perform the computation associated with each transaction
  • Collection Nodes enhance network connectivity and data availability for dapps

Smart Contract Development

Smart contracts in Flow are written in a programming language called Cadence. Cadence is the first ergonomic, resource-oriented smart contract programming language. The syntax of the language is quite like javascript

While existing programming environments can be used to keep track of asset ownership, they are typically used in scenarios where they are reflecting ownership rather than defining it directly. Public blockchains are unique in that they are explicitly designed to manage ownership of digital assets with scarcity and full access control. Digital assets on public blockchains behave like physical assets: they cannot be copied or counterfeited, only moved.

As the first high-level resource-oriented programming language, Cadence has a comfortable, ergonomic syntax making it very easy to read. It uses a strong, static type system to minimize runtime errors, and allows all methods, interfaces, and transactions to include pre- and post-conditions to enforce expected behaviour. This has resulted in a language that is easier to learn, significantly easier to audit, and ultimately much more productive than any current alternatives. You can start learning Cadence on Flow Playground: play.onflow.org

Open source tooling

The Flow team has open sourced a series of tools to help developers get started:

Flow Go SDK: the Go SDK is a great tool for developers looking for backend integration with scalability in mind. Go is one of the most popular backend programming languages when performance is a top priority, and has been the go-to choice for Dapper Labs.

Flow JavaScript SDK: for frontend developers, our JavaScript SDK will allow you to easily integrate and interact with Flow. Develop without using ABIs, construct composable interactions and create dapps that delight your users. We think you’re going to love building with our JavaScript SDK.

Visual Studio Code Extension: interact with Flow and use the Cadence language natively in Visual Studio Code. Statically check your Cadence code for errors and test your smart contracts without leaving the comfort of this industry-leading IDE.

Flow Playground GUI: the hosted, in-browser development environment where users can learn and try out Cadence smart contract language without any setup needed. We make it easy for any new developer to get a taste of Cadence, the powerful new language for smart contract development.

Standards Proposals: FTs (Fungible tokens) and NFTs (Non-fungible tokens) are the Flow equivalent of Ethereum’s ERC-20 and ERC-721 tokens, respectively.

Upgradable Smart Contracts

One of the most important promises made by smart contract platforms is that users can trust the smart contract code instead of trusting the smart contract authors. This aspect of blockchains unlocks use cases that we are only beginning to explore, the most impactful of which might be the concept of open services and composability.

In their first incarnation, smart contract platforms were designed such that contract code could never be changed after it is released. This is the most straightforward method to achieve the goal: If the code can’t be changed, even by the original authors, you clearly don’t need to trust the authors after the code is launched.

Unfortunately, software is hard to get right the first time. There are no shortage of examples of smart contracts that – even with incredibly talented teams and motivated communities – had subtle problems that led to a massive loss of funds.

Many developers have expressed the desire to fix or improve a smart contract after it has been deployed, and several have gone to a lot of time and trouble to build some mechanism into their smart contract to allow for upgrades or migrations. But having each developer “roll their own” mechanism for upgradability adds complexity, and makes those smart contracts harder to trust.

On Flow, we allow smart contracts to be deployed to the mainnet in a “beta state”, where the code can be incrementally updated by the original authors. Users will be alerted to the unfinished nature of this code, and can choose to wait until the code is finalized before trusting it. Once authors are confident that their code is safe, they can irrevocably release their control on the contract, and it becomes perfectly immutable for the rest of time.

This system balances the needs of users to be informed about what kind of code they are dealing with – whether or not an application or smart contract is truly trustless – while allowing developers the flexibility to tweak their code for a limited time after shipping.

Conclusion

Flow was designed as a solution to the “slow finality” of the Blockchain without sharding. It had achieved this without compromising the safety and serialization of the Blockchain. The Flow team partnered with the NBA, and this partnership has increased the popularity of the Flow network. Flow has made it possible to build an application that users can enjoy worldwide.

0 Comments

Leave a Reply

More great articles

Defi Ecosystem Explained

DeFi is short for Decentralized Finance. DeFi is the ecosystem of fintech apps built on top of blockchain protocols and…

Read Story

The Fascinating history of NFTs

A NFT (non-fungible token) is data added to a file that creates a unique signature. It can be an image…

Read Story

Deep diving into Cyrptopunk Source Code

Cryptopunks is a very popular NFT collection, with the top Cryptopunk selling for more than $11M. The CryptoPunks are 10,000…

Read Story

Never miss a minute

Get great content to your inbox every week. No spam.
[contact-form-7 id="6" title="Footer CTA Subscribe Form"]
Arrow-up