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.â
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.
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