This is a (rough draft) clean rewrite of BIP300 (Drivechain) consensus-level code.
Instead of a separate sidechain database (which may be prone to hard-to-review/test consistency issues), instead the unusable 8 MSB of the UTXO index are reserved for non-UTXO database entries, and the existing UTXO db and caching layer is shared. This can be refactored in the future, but I think it is the cleanest and most reviewable approach initially - open to other ideas, though. There’s also some ugliness in the undo data to handle restoring the new data, but it’s abstracted and shouldn’t be too hard to reason about.
Using these new primitives, Drivechains can be reimplemented with a UTXO-like model. Note that there is zero activation logic in the current PR: the protocol changes are always active. Therefore, this will not work (at least not safely) on Bitcoin today, and cannot be deployed without significant additional changes to handle an activation.
A new SERIALIZE_TRANSACTION_FOR_WEIGHT
serialization flag is also added, that is meant only for weight counting. This allows for adjusting weight (upward) to fit additional resource requirements by new functionality. In this case, several Drivechain “messages” are expected to have a larger burden than their OP_RETURN
encoding would otherwise weigh. However, the specific adjustments are not implemented in this draft.
As a consensus change, this can only be implemented with community support. Many people seem to have opinions, but please keep them to other forums. Despite providing and continuing this implementation, I myself do not thereby endorse or otherwise comment on the proposal itself.
Therefore, not looking for concept ACKs/NACKs (ie, about Drivechains), just Approach ACKs / constructive criticism (ie, about how I’m implementing it).