Note: The following are my thoughts as a developer of Komodo Core. This is not a guarantee the work will be done in this manner, or even be done at all. This is me “typing out loud”.
The Komodo Core code has diverged quite a bit from the Bitcoin codebase. Of course, Komodo is not a clone. There is quite a bit of functionality added to Komodo which requires the code to be different.
However, there are areas where Komodo could benefit from merging in the changes that Bitcoin has since made to their code base. Some of the biggest benefits are:
- Modularization – Functionality within the code base is now more modular. Interfaces are better defined, and some of the ties between components have been eliminated.
- Reduction in global state – Global state makes certain development tasks difficult. Modularization, testing, and general maintainability are increased when state is pushed down into the components that use them instead of exposed for application-wide modification.
- Testability – When large processes are broken into smaller functions, testing individual circumstances (i.e. edge cases) becomes less cumbersome, and sometimes trivial.
- Maintainability – With improvements in the points above, modifications to the code base are often more limited in scope and easier to test. This improves developer productivity and code base stability.
Plan of Attack
“Upgrading” Komodo to implement the changes to the Bitcoin code base sounds great. But to do a simple git merge
will not work. The extent of the changes is too great.
My idea is to merge in these changes in smaller chunks. Looking at the NodeContext
object (a basic building block of a Bitcoin application), we can divide functionality into 3 large pieces.
- P2P – The address manager, connection manager, ban manager, and peer manager
- Chain – The chain state, persistence, and mempool
- Glue – Smaller components that wire things together. Examples are the fee estimator, task scheduler, config file and command line argument processing, client (i.e. wallet) connectivity and functionality.
Building a NodeContext
object will be the first step. Each piece will have access to an object of this type. This will provide the state of the system, as well as be where components update state when necessary.
The “glue” components often require resources from both “p2p” and “chain” components. Hence they should probably be upgraded last.
The task of upgrading the “chain” piece is probably smaller in scope than upgrading “p2p”. I will attempt to attack that first.
The “p2p” pieces do not seem to be too difficult. Most of the work seems to be in wrapping much of the functionality of main.cpp
and bitcoind.cpp
into appropriate classes. The communication between components are now better defined behind interfaces. The pimpl
idiom is also in use in a few places.
Note: Bitcoin 0.22 requires C++17. For more information, click here.