Cosmic Bridge: An Experimental Cosmos-Powered Scalability Layer For Bitcoin

Itamar Rogel
Coinmonks
7 min readOct 1, 2018

--

Discovering Cosmos

Earlier this year, we (Chris Buonocore, Darwin Li, and I) discovered Cosmos at the C4YT (Crypto For Your Thoughts) hackathon in San Francisco. Cosmos is a project that deserves much more hype; we were impressed with its thoughtful design and its vision for blockchain connectivity.

Then, we discovered the icing on the cake: Lotion (note: please don’t put actual lotion on your cake). Lotion leverages Tendermint (the consensus engine at the heart of Cosmos) to allow easy creation of stand-alone blockchain applications with simple Javascript code.

Lotion is a terrific tool for prototyping blockchain apps — and very soon, as it matures and Cosmos itself matures — for creating production-quality blockchain apps. For now, it’s one of the faster ways to experiment & iterate on a general blockchain application.

In the hackathon, we built a paywall and micropayments solution for online media. As a user, you would first load a prepaid “media card” with some Bitcoin, and then you’d be able to use this card to perform bitcoin micropayments on participating publishers’ websites. This enables friction-less content paywalls, that are one mechanism for supporting quality journalism.

Since Bitcoin’s transaction costs render on-chain micropayments impossible, our solution used Lotion to manage a sidechain for the micropayments that could enable payments at the scale of pennies. We provided an end-to-end solution, including the in-browser user experience, the required Bitcoin integration (powered by the terrific bcoin project), and the Cosmos-enabled bookkeeping, all in one product.

Our solution was — in strictly professional terms — pretty sweet! Still, it was narrowly focused on paywalls for media websites, so the Cosmos team suggested we think bigger and more exciting. I know what you’re thinking right now: “What could possibly be more exciting than paywalls?”

Cosmos as a Scalability Layer For Bitcoin

As we thought about the possibilities, we realized that there’s no reason to limit a scalable transaction solution to paywalls, or even to micropayments. Our mind quickly went to the question: Can a Proof-of-Stake blockchain powered by Tendermint be used as a second layer for Bitcoin, providing scalability while still maintaining a blockchain’s desirable properties (immutability, auditability, trustlessness) ?

Wait, What…? Second Layer For Bitcoin?

Perhaps an interjection is due to explain why a second layer for Bitcoin is at all necessary. The issue of Bitcoin scalability and transaction costs is rather deep and have been discussed at length elsewhere, but a quick informal recap is in order. Please do feel free to skip this section if you’re familiar with the issue.

The way the Bitcoin blockchain works, only a certain number of transactions can be performed on the chain in a given time period. As the number of Bitcoin users increases and the demand for performing Bitcoin transactions increases in turn, the demand for performing transactions surpasses the supply — there’s literally not enough ‘room on the chain’ to fit them all in in a timely manner.

As a result, more and more transactions ‘wait in line’ to be included. The line they’re waiting on is called the mempool — a waiting list of transactions that are waiting to be confirmed on the blockchain. Every time a block is mined, it is the block’s miner who chooses which transactions to pluck from the waiting list and include in that block. The Bitcoin protocol allows the creator of a transaction to incentivize miners to include their transaction first — by paying a fee.

The result is easy to guess: People pay higher and higher fees for their transactions, since otherwise they’d get stuck in the waiting list (aka the mempool) for a long period of time. This means that the practical cost of a Bitcoin transaction keeps increasing over time.

As you might guess, costly transactions are not so good for Bitcoin’s adoption: If it becomes expensive to send money over the globe via Bitcoin, people will obviously not use it as much. It also renders some use cases impossible, specifically micropayments: If you need to pay 50 cents for accessing a news article and the transaction alone costs 25 cents, the entire use case is not viable.

Unfortunately, the solution to this scalability challenge is not uniformly agreed upon. The scalability debates were very heated, and have led to the Bitcoin Cash fork of summer 2017. The maintainers of Bitcoin Core (not Bitcoin Cash) nowadays generally agree that the solution for scaling Bitcoin is via a “second layer” — an extra layer on top of the Bitcoin blockchain. Such a layer could allow fast and cheap transactions without incurring a transaction on the chain, with the associated mining costs, waiting list mechanism and so forth. The most accepted second layer solution is called the Lightning Network. It is an innovative, peer-to-peer solution that is already being deployed and we encourage you to check it out if you haven’t already.

Cosmic Bridge Enters The Scene

The need for a second layer in order to scale Bitcoin is fairly well-established, and Lightning is an awesome piece of technology. Our idea with Cosmic Bridge was to explore the use of a proof-of-stake blockchain as a second layer, as blockchains have some desirable properties that peer-to-peer solutions do not. More generally, they simply represent a different set of design choices.

We’ve thus embarked on our journey to create Cosmic Bridge. The idea behind Cosmic Bridge is simple: It allows anyone to set up an independent blockchain (“zone” in Cosmos parlance) that can be used to transact in Bitcoin for virtually free. We call such blockchains “payment zones”.

The way this works (roughly) is by having the set of validators of the Proof-of-Stake chain be the co-signers of a multi-sig wallet on the main bitcoin chain. This wallet holds the total balance of the bitcoin managed by the payment zone. Users can commit any amount of Bitcoin to this wallet — think of it as loading a prepaid debit card — and then transact with their loaded bitcoin on the payment zone, for free. The balances are periodically settled on the main bitcoin chain, so payees ultimately get “hard” bitcoin on the main chain. The default settlement period is one month, so you get the experience of a monthly settlement that credit card users are familiar with.

Development Notes

When we began developing the project, Lotion was still quite early in its development, and we were not sure if we should build on it or use the Cosmos SDK directly. However, Lotion’s development is moving quickly and we realized we’d better leverage it so we can move forward faster.

Lotion allows you to experiment and whip up a blockchain application with very minimal code, so you can prototype and test ideas very quickly. Despite the project being quite new, our experience has been great and Judd Keppel has been graciously helpful whenever we’ve had a question or an issue. We encourage you to try it out — you can create your own blockchain application in a (very) lazy afternoon.

Cosmos as a whole is still a young and fast-evolving stack, so there were definitely the occasional hiccups in setup and deployment, but the experience overall proved pleasant and the solution itself elegant. We have enormous respect to the team behind Cosmos and Tendermint.

Bitcoin integration, and specifically the multi-sig management and proper system testing, posed its own challenges too — we’re still working on some kinks, but bcoin has proved a venerable tool.

Overall, we’re highly appreciative of the projects we’ve built on. They’ve enabled us to experiment and build a MVP with relative ease.

Use Cases

Cosmic Bridge can enable a lot of interesting use cases:

  • Bitcoin debit card and merchant network with free transactions
  • A bitcoin micropayments solution
  • Dark pools of bitcoin liquidity between exchanges or large traders

…. and a lot more.

While the potential use cases are exciting and can be very impactful, the truth of the matter is that when you’re building an infrastructure project, let alone an experimental proof-of-concept, you can’t always predict exactly what use cases you’ll see in the field. You can have some likely use cases in mind, design the solution in a way that provides a base that is as solid as possible, and if all goes well — you will end up surprised by the actual use cases people come up with.

The Future

Seeing surprising use cases pop up is would certainly be a great outcome. We believe that having a blockchain-based second layer for Bitcoin can prove very useful for many scenarios — alongside peer-to-peer solutions like Lightning — because it has a different set of properties which may be more appropriate for some scenarios. With Cosmic Bridge, you get the immutable ledger you know and love, near-zero-cost transactions, and predictable settlement on the main Bitcoin chain. In return, you replace complete trustlessness with trust in a set of well-known validators (note that you trust the collective, not any single validator — and are assured Tendermint’s fault-tolerance properties).

In a way, the above observation about infrastructure projects applies to Cosmos itself as well. Extensible by nature, the thoughtful design with Tendermint and IBC (the Inter Blockchain Communication protocol) enables a variety of use cases, from the now-familiar spooning and anticipated distributed exchange to many others that we cannot yet foresee.

As for Cosmic Bridge, the project is still at the experimental MVP stage so any help is welcome! To learn more about the design and check out the code, please head over to our github repo. (Hint: If you’re looking for a place to start, why not give us a hand in designing and implementing the secure multi-sig coordination protocol between the validators?😃)

Thanks to Chjango Unchained and Chris Buonocore for their contributions to this article! You rock 😎

Get Best Software Deals Directly In Your Inbox

--

--