Cointime

Download App
iOS & Android

The Goldilocks consensus problem

Imagine that you wanted to build a sufficiently decentralized Twitter — a social network in which no single person or company is in control. How would you build something like that?

A social network is decentralized if it has many servers run by different people. The data would be spread across servers, so you’d need a simple way to answer questions like “What are the latest posts?”. This is where consensus comes in.

We developed a new consensus model for Farcaster, our decentralized social network. Existing models had user experience and decentralization tradeoffs, making scaling a social network difficult. Our model, called a deltagraph, uses blockchains and CRDTs to scale to millions, and hopefully billions, of users.

Why do we need a new consensus model?

Federation and blockchains, which are common models in untrusted networks, have tradeoffs that aren’t ideal for a social network. Federation is simple but leads to centralization, while blockchains prevent this but are slow and expensive.

In a federated system, anyone can run a server. Users pick the one they like, and all servers are loosely connected. In practice, federated services become oligopolies. Email is an example of this, where it’s very difficult to start a new server as a new developer. There are many unwritten rules and gatekeepers that you have to get past.

Without a forcing function, servers in a federated system diverge over time. APIs and data formats become slightly different, intentionally or due to bugs. Developers write workarounds that become implicitly enshrined, making the system more complex and opaque. Federated servers start out simple because there isn’t formal consensus, but this tradeoff creates systemic complexity.

Blockchains have a consensus model to prevent exactly this kind of problem. Unfortunately, the type of consensus they use makes them too slow and expensive for social networks. Twitter users generate over 100,000 updates a second 1, while a modern blockchain is 100x slower under ideal conditions 2. Users must pay for each post they add to the blockchain. It is hard to grow a social network under these constraints.

Would faster blockchains solve this? The tradeoffs that blockchains make to support financial transactions make this unlikely. Consensus must prevent double spending, which limits the strategies that can be used. People invent new ways to financialize things on blockchains which creates demand. The appetite for financial transactions seems insatiable even as supply increases, making it hard to store social data at a reasonable cost.

Social networks face a Goldilocks problem — federated consensus is too weak, and blockchain consensus is too strong.

Solving the Goldilocks problem with CRDTs

Blockchains reach consensus by letting one node decide the transaction order. Other nodes must send transactions to them and wait for a confirmation. This step is slow because it requires coordination over a network, but it is essential to prevent double-spending.

A social network network doesn’t need perfect ordering. Little harm is done if Alice’s posts show up in your feed before Bob’s. Farcaster’s consensus model - the deltagraph - uses CRDTs, which can reach consensus without coordination but do not guarantee a global order.

A deltagraph is made up of deltas, which are the atomic units of change. Deltas are stored on nodes, servers that accept them from users and forward them to other nodes. Alice can say “Hello World” by creating an add-post delta and sending it to a node. She can delete it later by sending a remove-post delta. When a node gets the remove, it will discard the add-post and store the remove-post instead.

What happens if deltas arrive in a different order? A “remove-wins” rule handles this case. The rule says that if a post is removed, it can never be added again. With these rules enforced, you can send deltas as many times as you like and in any order, and they end up in the same state. This is very different from blockchains, where reordering transactions changes outcomes.

The deltagraph organizes deltas into sets and graphs. A set maps to something a user can do, like posting a message. It will store deltas related to that action and enforce rules. The rules are always commutative, associative, and idempotent, and they behave like anonymous delta-state CRDTs 3. A graph is a collection of sets that belong to a user.

Deltas across graphs can be merged without rules because they can’t affect each other. Even if Alice says “Hello world” and Bob replies, the deltas can be processed in any order. Deltagraph consensus is quick because it can run in parallel and without network calls.

Once a node achieves local consensus, it broadcasts deltas to other nodes. Syncing is more complex than blockchains because there is no global order. Two nodes have to compare all their sets to find missing deltas. There’s ongoing research to improve sync speed in deltagraphs.

Deltagraphs are much faster at consensus, but we still have a problem. What happens if someone broadcasts a billion deltas? Nodes would sync this with each other, run out of storage, and the entire network would crash.

Charging rent

Farcaster solves the overload problem by charging rent to store deltas. Users pay a storage fee and can post as many deltas as they like for a year. Nodes store a certain number of deltas for each user, and if the limit is crossed, the oldest deltas are removed.

In a feed-based social network, older messages expiring will have little impact on today’s feed, and users can rent more storage to keep a longer history around.

Deltagraphs apply a ‘last-write-wins’ which means that older deltas expire when the set is full. This rule can be stacked on top of the existing set rules while allowing deltas to be merged in any order. For instance, if Alice has three deltas with increasing timestamps - A1, A2, A3 - and the set can only store two deltas, the two most recent deltas will remain after the set logic runs.

The problem with charging rent is that the deltagraph can’t move money. This is a good thing because it reduces demand for space. We don’t want Alice, who is trying to post a photo of her cat, to compete with Bob, who is trying to day trade. But how do we collect rent?

Farcaster’s deltagraph relies on a blockchain to handle the ordered transactions 4. A user must first make an onchain transaction to create an account and pay rent from their wallet. They can then create a delta, sign it with their wallet, and send it to the deltagraph. The deltagraph tracks onchain events and verifies the delta’s signature before accepting it.

The deltagraph doesn’t have to worry about byzantine fault problems. Thanks to CRDTs, most actions don’t need coordinated consensus, and the few that do are outsourced to a blockchain. It’s only concern is handling p2p layer challenges like denial-of-service and eclipse attacks5.

What’s next for deltagraphs?

The deltagraph isn’t theoretical — Farcaster has been using it for a year and has over 300,000 paying users. The network has 1,000 nodes serving 5 million deltas every day. Our goal is to reach Twitter scale while staying decentralized and providing a great user experience, and we see a clear path ahead.

Deltagraphs augment blockchains, enabling applications that weren’t cost-effective before. This design pattern might unlock other use cases that we haven’t yet considered. Alternate approaches to consensus — CRDTs, verifiable compute, or something else entirely — could be paired with blockchains to decentralize games, marketplaces, and other consumer apps.

Thanks to Shilpa LokareddyDan RomeroGeorgios KonstantopoulosSanjay RaveendranCassie Heart and Polynya for help with drafts.

  1. Twitter data is hard to come by these days. The last known number was 6,000 tweets per second. After adding reactions, follows and accounting for growth, the number is likely ~100,000. 
  2. Decentralized blockchains range from 60 (Ethereum) to 1600 (Solana) today. Source
  3. van der Linde, A., Leitão, J., & Preguiça, N. (2016). Δ-CRDTs: Making δ-CRDTs delta-based
  4. Farcaster’s contracts live on OP Mainnet, but any programmable blockchain would work. 
  5. Heilman, E., Kendler, A., Zohar, A., & Goldberg, S. (2015). Eclipse attacks on bitcoin’s peer-to-peer network
Comments

All Comments

Recommended for you

  • New York Attorney General Reaches $2 Billion Settlement with Genesis

    Letitia James, the New York Attorney General, announced a $2 billion settlement agreement with bankrupt cryptocurrency lending platform Genesis, which will help maximize compensation for investors. As Genesis had previously declared bankruptcy, the settlement agreement requires review and approval by a bankruptcy court. The settlement agreement will establish a victim fund to assist defrauded investors, including at least 29,000 New Yorkers who contributed over $1.1 billion to Genesis through Gemini Earn investments. Additionally, the settlement agreement prohibits Genesis from operating in New York. This is the largest settlement agreement in New York history against a cryptocurrency company.

  • Uniswap Labs and Across Protocol collaborate to propose a new cross-chain intent standard ERC-7683

    According to official sources, Uniswap Labs and Across Protocol have proposed a new cross-chain intent standard, ERC-7683, and established a unified framework for specifying cross-chain operations based on intent. This standard allows for the implementation of a standard API for cross-chain transaction execution systems. The standard provides a common CrossChainOrder structure and a standard ISettlementContract smart contract interface.

  • Nigeria's Securities Regulator: Global Cryptocurrency Exchanges Have Delisted Naira

    The Nigerian securities regulator recently stated that global cryptocurrency exchanges have complied with its directive to delist Naira from their respective P2P platforms. The US SEC cited Kucoin's recent announcement of Naira's delisting and related services as evidence supporting its claims. The acting director of the Nigerian Securities and Exchange Commission called on platforms engaged in activities that harm national interests to stop such activities.

  • Gnosis Price Rises 20% After Thanefield Capital's $30M Token Buyback Offer

    The crypto fund Thanefield Capital has proposed a buyback plan for the Gnosis DAO native token. The proposal aims to deploy $30 million for regular token buybacks within six months. Gnosis co-founder Martin Köppelmann supports the proposal but warns that buybacks should be tied to growth plans. Since the proposal went live, Gnosis' price has risen by over 20%, reaching a high of $320, and is now trading at $308.

  • Nigerian court denies bail request for Binance chief Tigran Gambaryan

    A Nigerian court has rejected the bail application of Tigran Gambaryan, the compliance chief of Binance Finance. Judge Emeka Nwite believes that if the Binance executive's application is approved, he may not continue to appear in court. A Binance spokesperson expressed disappointment and sadness at the ruling. The court will adjourn for cross-examination on May 23.

  • ICBC: Hong Kong subsidiary has built a complete service system including the redemption, circulation and redemption of digital RMB

    Industrial and Commercial Bank of China (ICBC) has officially announced that its overseas subsidiary, ICBC (Asia) located in Hong Kong, has built a complete service system for digital renminbi exchange, circulation, and redemption. At the same time, ICBC Asia has launched a digital renminbi experience activity for local individual customers in Hong Kong.

  • The transaction volume of 6 Hong Kong virtual asset ETFs today was HK$26.1102 million

    According to Hong Kong stock market data, as of the close of trading, the turnover of 6 Hong Kong virtual asset ETFs today was HKD 26.11 million, including:

  • Cointime's Evening Highlights for May 19th

    1.US spot Bitcoin ETFs saw net inflows of $948.3 million this week

  • Will this cycle skip Ethereum?

    Ryan Sean Adams is going to take the perspective of long-term Ethereum bulls, not the obviously wrong dyed in the wool Ethereum is dead haters.

  • This year, there have been more than 90 Bitcoin ecosystem-related financings

    There have been more than 90 financing transactions related to the Bitcoin ecosystem since 2024, setting a new record for the highest number of financing transactions in a single year in Bitcoin's history. Kyle Samani, Managing Partner at Multicoin Capital, pointed out that with the emergence of the Bitcoin Taproot upgrade and the Ordinals protocol, the Bitcoin ecosystem is experiencing a "developer renaissance". For some developers, building financial tools on Bitcoin is more attractive because it is the oldest and most secure blockchain. Multicoin Capital's investment trend is reportedly shifting from Solana to the Bitcoin ecosystem. The venture capital firm has invested in projects such as Solana Labs and StarkWare, but recently participated in the funding of the Bitcoin-native music platform Arch Network and the Bitcoin scaling network Mezo.