Libbitcoinkernel: Untangling Bitcoin's Code for Easier Development

Learn about libbitcoinkernel, a project that untangles Bitcoin's code to make it easier for developers to experiment with changes. This project aims to extract security-critical code and improve development efficiency.

Posted 9 months ago in Blockchain

A group of developers working together on open source code.

Meet libbitcoinkernel—a long-running project to help devs avoid inadvertently changing mission-critical code when building on Bitcoin.

"Libbitcoinkernel" is a far-reaching, in-progress face-lift of Bitcoin's code that's been flying under the radar, but is likely to make it easier for developers to experiment with changes to Bitcoin. The goal of the ambitious project is to untangle Bitcoin Core's code—the main software underlying Bitcoin—so that much of the "security-critical" code is sliced out from the rest of it. By doing so, it could unclog the path to new Bitcoin improvements.

Untangling this code makes developers’ lives easier and the changes are likely to (eventually) ripple out to users as well. The faster developers can write up new features—whether privacy, security, or easier-to-use wallet tools—the faster users can take advantage of them.

Libbitcoinkernel has a long-winded and esoteric name because the idea is it will ultimately be a library that developers can use. But even if it’s specifically geared towards developers, it could have wider consequences for the BTC universe.

"The thing that really drew me towards dedicating time to Libbitcoinkernel was when I realized that it could be a technical solution to some of Bitcoin Core’s social hurdles," Bitcoin developer Carl Dong told t. He's the one who initially spearheaded the project. Dong has since, letting Spiral-backed developer Sebastian Kung, veteran Bitcoin Core contributor Cory Fields, and others take the reins.

Kung told that he believes Libbitcoinkernel is one of the most impactful projects to be working on in Bitcoin right now. Understanding Libbitcoinkernel starts with understanding “consensus” code. Consensus code is security critical code in Bitcoin Core, Bitcoin’s main underlying node software. This is the code that keeps all the nodes in the network in agreement with one another. If half the network follows some rules, while the other half follows slightly different rules, this could lead to an unintentional “hard fork,” where the network effectively splits into two. “That’s the nightmare scenario that keeps Bitcoin developers up at night,” Dong said in a explaining his work on Libbitcoinkernel.

The issue is, the consensus code is tangled up with all the rest of Bitcoin Core’s code. This is a pain for developers trying to make changes because it’s not always easy for them to detect when they’re touching a security-critical piece of code. And even if they do know, it can take some time to work around it.

The goal of Libbitcoinkernel is to slowly extract all this code into a separate library, so developers working on other sections of the code don’t have to nervously tip toe around it. If developers can spend less time on trying to make sure they aren’t accidentally poking any landmines in the consensus code, they can spend more time on more interesting BTC features or bug fixes.

“This allows developers to give more focused review on the critical consensus code while worrying less about the rest of Bitcoin Core. It also allows developers to talk about the body of consensus code as a well-defined entity for the first time,” Kung told .

There's also a second more long-term goal that can be achieved with the help of Libbitcoinkernel. Bitcoin Core is the main implementation of Bitcoin's code. Users run it to connect to the Bitcoin network and to verify transactions. But what if there were other choices besides Bitcoin Core? If this was an option, developers would have a way to experiment with new features more easily.

“Implementations can also prioritize features differently to serve their target users better,” Dong explained. Second, multiple Bitcoin implementations could increase resiliency of the network—if one implementation is floored by a non-consensus related bug, the other implementation might be unaffected by the same bug, keeping Bitcoin intact. This could bolster Bitcoin’s decentralization, which is, well, BTC's entire M.O.

But multiple clients is easier said than done. Without Libbitcoinkernel, many BTC developers expressed concerns about having multiple implementations. The reasoning goes back to the tangled up consensus code. Say “Bitcoin B” tries to copy Bitcoin Core’s code. If Bitcoin B developers make a single misstep reimplementing this code, the network could split into two in an unintentional hard fork.

Libbitcoinkernel could change this. By extracting the consensus code into a separate library, the Bitcoin Core and Bitcoin B can use the same consensus code. There’s no longer any need to worry about consensus subtle discrepancies wrecking havoc between the two implementations. "Having a reusable consensus library would allow people to build alternative Bitcoin implementations, which were previously thought to be too dangerous because of the now-eliminated potential consensus incompatibilities," Dong said.

Extracting the consensus code from the rest is not a new idea. Early on in Bitcoin’s history, some of the consensus code was extracted, but the project was left unfinished. Then a 2016 attempt at resurrecting the project perhaps “crumbled under the weight of its own ambition,” as Dong put it. With that in mind, Dong and Kung have been taking a more iterative approach in extracting the consensus code from the rest, one which “respects the sheer size of work.” With that, the project has become a years-long, multi-step project, which ultra-curious readers can track , the open source developer Mecca. The project’s developers have contributed tens of pull requests—proposed changes to Bitcoin Core—and there’s still much more to do. Developers expect the full project will take a number of release cycles. “This project is a marathon,” Dong said, “and a long one at that.” Stay on top of crypto news, get daily updates in your inbox.

Last updated 9/25/2023, 10:55:23 PM


Related Articles

Related Questions

News Letter

Subscribe to the newsletter to stay updated with the latest cryptocurrency news, insightful articles, market trends, and more – delivered directly to your inbox!


Is email too old school? Well you can get your news directly on twitter just by following us