Starknet: A layer 2 scaling solution for Ethereum

Introduction

The three key desirable features of a blockchain are- decentralization, scalability, and security. Most blockchains successfully achieve two out of these three as it is difficult to check all of these features, this is referred to as the blockchain trilemma.

Ethereum being a layer-1 possesses 2 of these qualities as it is decentralized and secure but impeded by scalability issues.

This article aims to help readers understand the blockchain trilemma, scaling solutions for this problem, approach utilized by StarkNet to scale Ethereum.

Blockchain Trilemma

Blockchain is a remarkable technology as it’s proving its utility in various industries ranging from art to finance, the underlying structure of a decentralized network comes with its challenges when compared to centralized networks. As early as the 1980s, computer scientists developed what’s called the CAP theorem to articulate the most major of these challenges. According to the CAP theorem, decentralized data stores - of which blockchain is an iteration – can only provide two of three guarantees simultaneously: C = consistency, A = Availability, and P = Partition tolerance (CAP).

In the context of modern distributed systems, this theorem has evolved into the Blockchain Trilema — the popular belief that public blockchain must sacrifice either security, decentralization, or scalability.

Decentralization

Ethereum and similar blockchain networks are decentralized by design. It is structured such that there’s no such person or organization in charge – no one entity can control or censor the data that transact through the network. However, achieving optimal decentralization tends to decrease network throughput — As there’s an increase in participants agreeing on the validity of data, transaction times can be slow due to the way information needs to be shared and processed.

Security

Blockchain is inherently secure but is not entirely immune to vulnerability (hacking). If a hacker is able to secure control of more than half of the network (51%), they are able to alter a blockchain and manipulate transactions to hijack the network.

Scalability

In regard to blockchain protocol refers to the blockchain's ability to support high transactional throughput and future growth. This means that as use cases and adoption accelerate, the performance of the blockchain won’t suffer or decline. Blockchains that perform poorly as adoption increases are said to lack scalability. The Blockchain Trilemma tells us that greater scalability is possible, but security, decentralization, or both, will suffer as a consequence.

So how can we resolve the Blockchain Trilemma and achieve decentralization, security, and scalability simultaneously? There are two possible approaches to achieve these; Layer 1 and Layer 2 solutions.

Solving the Blockchain Trilemma: Layer 1

There are currently a number of processes Ethereum aims to improve scalability, we’d explore them briefly:

  1. Consensus Protocol Improvements

In order to successfully scale Ethereum there had to be a transition of the network from the Proof of work (PoW) to the Proof of stake (PoS) consensus protocol. The PoW consensus mechanism involves intensive computation as miners have to solve cryptographic algorithms using their computers. Sharding is one of the main factors that influenced Ethereum to transition to the PoS consensus model because sharding alongside PoW endangers the network as it makes it susceptible and vulnerable to attack. PoS on the other hand, where validators explicitly stake into a smart contract on Ethereum, works perfectly with Sharding as validators will be algorithmically chosen to propose the creation of new blocks. Whereas Validators who have not been chosen to make a new shard block will be responsible to attest another validator's new block proposal and confirming its validity. But what exactly is Sharding?

  1. Sharding

One of the upcoming upgrades to be implemented onto the Ethereum network, sharding basically breaks transactions into smaller datasets called “shards”. These shards are simultaneously processed in parallel to the network, allowing for sequential work on numerous transactions simultaneously. Further, instead of having each network node hold a copy of every block from its genesis block to the present, this information could be split and held by different nodes, with each remaining consistent with itself. Shards provide proofs to the mainchain and interact with one another to share addresses, balances, and general states using cross-shard communication protocols.

Ethereum plans to have 64 shards chains. The beacon chain which is the consensus layer plays a critical role in the PoS sharding mechanism as it will be responsible for receiving and sending information to and from shard chains and will algorithmically choose validators to propose the creation of new blocks. Ethereum requires at least 128 validators, known as a “committee”, to attest each shard block. Each committee has a time frame (‘slot’) to propose and validate a new shard block. Only one valid block is created per slot. A period of 32 slots is called an ‘epoch’. Once reached, the committee is disbanded and reformed with new participants.

The validators who proposed the new block will be rewarded in ETH once the new shard block proposal gets enough attestation to confirm the “inclusion of the block in the beacon chain”

The advantages of sharding include;

  1. It increases the security of the network by promoting decentralization

  2. Allows validators to store or run data for only the shard chain that is validating and not the entire network

  3. Shard chains will allow the network to process more transactions versus single nodes

Overall, sharding gives Ethereum more capacity to store and access data.

Solving the Blockchain Trilemma: Layer 2

Layer 2 refers to a network that is built on top of an underlying blockchain protocol to improve its scalability and efficiency. Ethereum is a Layer 1 protocol and the StarkNet Protocol is a Layer 2 solution built to scale Ethereum. Layer 2s are important because;

  1. They help increase transactions per second which in turn improves user experience and reduces network congestion on the Mainnet Ethereum.

  2. Transactions are rolled up into a single transaction to Mainnet Ethereum, reducing gas fees for users and making Ethereum more accessible to people.

  3. Any updates to scalability should not be at the expense of decentralization or security – Layer 2 builds on top of Ethereum

  4. There are application-specific layer 2 networks that bring their own set of efficiencies with assets at scale

An example of layer 2 scaling solutions is Rollups, which will be explored in detail. Other examples are Sidechains, Plasma Chains, and State Channels.

Rollups

perform transactions off-chain i.e outside layer 1 and then post data to layer 1 where consensus is reached.

There are two types of rollups with different security models:

  1. Optimistic rollups: assume transactions are valid by default and only run the computation, via a fraud-proof, in the event of a challenge.

  2. Zero-knowledge rollups: runs computation off-chain and submits a validity proof (Zk-proofs) on-chain (Layer 1).

ZK-Proofs

Zk-proofs submitted by Layer 2 blockchain are of two forms — ZK-SNARKS (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge) or ZK-STARK (Zero-Knowledge Scalable Transparent Argument of Knowledge).

Both “ZK-SNARK” and “ZK-STARK” are Zero-Knowledge proofs. They both prove transactions on Layer 2 Blockchain without disclosing any underlying information except that they are correct.

Briefly, Zero - Knowledge Proofs — refers to the process whereby verifiers can verify the integrity of the information without it actually being disclosed.

The significant difference between SNARK AND STARK lies in the letter “T” in STARKS, which stands for “Transparency”.

Zk-SNARKS — need pubic parameters for proving and verifying validity proofs. The public parameters are provided by creating a public string called Common Reference String (CRS). The security of the SNARK system depends on the CRS setup for generating the public parameters. To ensure it is secure, a few trusted parties are used to securely generate the public parameters. This reduces the risks of the parameter falling into the possession of malicious actors who might generate false proofs.

Zk-STARKS — are “transparent”, as they function without the trusted setup for creating a Common Reference String (CRS), instead, Zk-STARKs rely on publicly verifiable randomness to set up parameters for generating and verifying proofs.

Comparing these two

Zk-Snarks have a huge advantage when it comes to proof sizes and throughputs, but they have two major weaknesses. They require a trusted setup and are not quantum resistant.

Zk-Starks are more reliable as it does not require a trusted setup and is quantum resistant but generate large proofs.

Although Zk-Starks have the drawback of large proof sizes, they are created to be quantum resistant and do not require a trusted setup, hence are more reliable. Proof generation is also up to 20x faster, thus allowing for proof generation, on smaller devices.

Putting it all together

StarkNet

StarkNet — A permissionless decentralized Zk-Stark-validity-rollup. It operates over Ethereum, enabling any Dapp to achieve unlimited scale for its computation without compromising Ethereum’s composability and security. it utilizes Zero-Knowledge rollups (Zk-rollups) which can process thousands of transactions in a batch and then only post some minimal summary data to Mainnet Ethereum. The summary data defines the changes that should be made to the Ethereum state and some cryptographic proof that those changes are correct.

StarkNet is the first Zk-rollup to offer a general-purpose smart contract platform on a fully composable network. This enables anyone and everyone to be able to develop and deploy their own application on the network, users may send transactions and interact with smart contracts. The development of smart contracts on the network is accompanied by the introduction of a new programming language called Cairo — a special-purpose programming language for creating provable programs for general computation.

In conclusion, StarkNet helps scale Ethereum by providing a building ecosystem on top of Ethereum, where multiple transactions can be carried out, batched, and in turn settled back on Ethereum with the associated validity proofs. This provides developers with the opportunity to build verifiable applications which make interaction, and activities of users efficient which in turn brings about the massive adoption of Blockchain by the general public.