Developers often use words like “monolithic,” “blob” and “tangled” to describe the code underpinning bitcoin.
These words paint a picture of how difficult the code can be to comprehend and, in turn, work with, and it’s not exactly a comforting thought for a network supporting $61 billion in investor dollars. That’s not to say bitcoin doesn’t work – it does – but the state of the codebase does leave something to be desired, both for users who might desire more flexibility and the developers who want to improve it.
So, although changes like the code optimization Segregated Witness (SegWit) and the philosophy of so-called “hard fork” upgrades have attracted the most attention of late, several bitcoin developers are working under the radar to untangle bitcoin’s messy architecture.
Chaincode’s Russell Yanofsky, for one, is attempting to tackle one part of the problem with something called “process separation” in the Bitcoin Core code, the most used of the software options.
Yanofsky told CoinDesk:
“Bitcoin is an older codebase. It’s changed a lot over time. There are lots of parts of it where, if we were writing everything from scratch, we’d probably do things differently. But since we have this legacy of code, we have to find ways to maintain it.”
Ditch the monolith
To begin to understand Yanofksy’s process separation technique, you must first understand that the Bitcoin Core software is made up of many different pieces and two so-called “processes” that are lumped together in, some would argue, a random way.
The first process is called “bitcoind” and, according to Yanofsky, is made up of a few things: the peer-to-peer code, which connects the nodes in the network; the validation code, which checks whether transactions and blocks that a node receives are valid; and the wallet code, which stores a user’s private keys.
The second process, “bitcoin-qt,” runs all of those things with the addition of a user interface so users with little tech experience can run a full node without using the command line.
Yanofsky thinks it would be better to separate some of these aspects of the code. To that end, he’s creating a new process, “bitcoin-walletd,” which splits off the wallet code from bitcoind. And he’s removing all of the code from bitcon-qt except the user interface.
His slides from a BitDevs presentation in New York City this week show the difference in structure:
At a high level, it may seem as if the various bitcoin processes are already completely separated, but in coding terms they aren’t. So now, Yanofsky is essentially building barriers between the different components.
In this way, once the code is finished, the wallet portion will not be able to touch other parts of the code.
Mix and match
So, what would this mean for users? More flexibility, mostly.
Users can move things around like a puzzle, mixing and matching the pieces Yanofsky is splitting up. For example, with the wallet not tied to the node, users could take the wallet and use it with any bitcoin node.
“Maybe if you’re using an older wallet that doesn’t support new features and you don’t want to get rid of it – or you don’t want to transfer your money out,” the option to bring the wallet over to a different node might be useful, he said.
In much the same way, users might want to use the user inteface of bitcoin-qt with different bitcoind nodes.
“You could basically have a bitcoin node running on a server someplace. Maybe you just want to run the GUI to just check what its bandwidth usage is or its peer-to-peer connections are,” Yanofsky said.
Creating more options for users, something bitcoin enthusiasts are particularly attentive to, is why Yanofsky is working on the project at all.
While he admits his changes could slow things down a little, or make debugging code more difficult for developers, the project has gotten a GitHub blessing from several Bitcoin Core contributors, including lead maintainer Wladimir J. van der Laan and contributor Daniel Cousen.
And that’s partly because the advantages aren’t only user-facing, Yanofksy said, adding:
“There are user-visible features that come out of it, but there’s also a big architectural and code cleanup component to it.”
While Yanofsky said he’s almost done writing the code for the major upgrade, there’s still a number of things need to happen before it can be officially added to Bitcoin Core.
“The biggest problem with review is getting people’s attention,” he said.
Since a number of open-source bitcoin developers have to review each code change before it can be added, and there is a limited number of developers with the expertise to review code changes, the process could be a long one.
Yanofsky also expects some other changes, such as Cory Fields’ peer-to-peer code additions and wallet code changes from his Chaincode colleague Matt Corallo, will also take precedence over his process separation change.
“Right now the focus is definitely not in this area,” Yanofsky said. “Our biggest priority right now is getting better SegWit support. This feature will have to wait its turn.“
But while it’s not on the priority list just yet, the work still promises to be an important change, as highlighted by Blockstream CTO Greg Maxwell’s comment on the Yanofsky’s Github:
“I think we should have done something like this a long time ago.”
Disclosure: CoinDesk is a subsidiary of Digital Currency Group, which has ownership stake in Blockstream.
Lego image via Shutterstock
The leader in blockchain news, CoinDesk is an independent media outlet that strives for the highest journalistic standards and abides by a strict set of editorial policies. Interested in offering your expertise or insights to our reporting? Contact us at [email protected].