Soft fork BIP101

theZerg

Moderator
Staff member
Aug 28, 2015
1,012
2,327
Here's a way to soft fork BIP 101. The purpose of this post is both to show that it really can be done, and to show that the mechanisms required to make SW (segregated witness) a soft fork are so powerful that practically anything can be a soft fork.

Define a Merkle tree that contains hashes of extension blocks (and all the other things we may want to hang off the blockchain). This Merkle tree root is posted in the coinbase txn, or other locations as proposed by SW.

Define a new address range, call it 2XXXX rather then Bitcoin's 1XXXX addresses. All 2XXXX address operations will go into the extension block. The extension block starts at 8MB and expands following BIP101.

If someone pays from a 1XXX address to a 2XXX address, create a transaction using the OP_ANYONECANPAY that is placed on the "main" 1MB limited block, and simultaneously create another transaction that fully specifies the payment 1XXX -> 2XXX. This transaction is placed in the extension block. (Just like in SW the miners "know" that ANYONECANPAY no longer actually means that anyone can grab the money)

Now 2XXX addresses can pay other 2XXX addresses on the extension blocks for as long as necessary.

And when a 2XXX block pays a 1XXX block a miner can put this back on the "main" 1MB blockchain by claiming one or more of the ANYONECANPAY txouts. It doesn't matter which one.

Just like in SW, as long as over 51% of the miners respect the new definition of ANYONECANPAY, it works fine.

EDIT: you could also completely rework the 2XXX transaction and block format, solving a lot of issues like malleability, adding txout block hashes (for efficient fraud proofs), and SW. Ofc, that would take more time...
 
Last edited:
  • Like
Reactions: Terry999

Gavin Andresen

New Member
Dec 9, 2015
19
126
Adam Back proposed this scheme to me and Greg and Pieter at the Financial Cryptography conference in January.

None of us liked it-- I didn't like it because it's a messy, overly-complicated solution, and simplicity and security go together. I don't remember why Greg and Pieter didn't like it (might be because it does nothing to fix bandwidth / block relay problems).
 

davecgh

Member
Nov 30, 2015
28
51
Personally I think the entire fascination with only doing soft forks is a mistake. There are several problems with them and the SW proposal along with this one shows one of them. You can change almost any rule you want all the while tricking old nodes into accepting something they think is valid when they, in reality, have no way to actually know if it is or not.

Hard forks should not be feared, and I'd much rather see them called "Planned Upgrades". The name hard fork makes them sound a whole lot more scary than they actually are.
 
Last edited:

Zangelbert Bingledack

Well-Known Member
Aug 29, 2015
1,485
5,585
While we're at it, I'd like to see clearer terminology that doesn't conflate intentional forking with unintentional forking (whether hard or soft). "Planned upgrade" probably works, though this phrasing (as well as the word "intentional") introduces value judgment since of course one person's intentional fork or planned upgrade could be someone else's unintentional fork or hostile downgrade. But it is good to at least clarify that someone intended/planned it versus it being a universally unwanted behavior.

There's also a problem with the noun usage: "fork" is loosely used to refer to both the action of forking and each one of the prongs/branches created by the fork. "Bitcoin's fork resulted in two forks." It's very confusing language. How about, "Bitcoin's fork resulted in two branches" or "Bitcoin's fork resulted in two prongs"?
 

solex

Moderator
Staff member
Aug 22, 2015
1,558
4,693
Another way to think about this is to consider the data separately from the software, and software version compatibility. In Bitcoin we have:
  • Data -> Blockchain (including the UTXO set)
  • Software -> Clients (Core, XT, btcd, etc)
A fork of the data is bad (orphan block sequences), while a fork in the software is good. In fact it is very good as long as the different clients share at minimum the same essential rules (e.g. libconsensus). This enables competition and gains the benefits of Darwinian natural selection, i.e.. "fitter" clients better able to serve the Bitcoin ecosystem.

Clients have versions and this is where compatibility becomes important and is at the root of Bitcoin's soft/hard fork concepts.
  • Backward compatibility (later versions processing data from old versions)
  • Forward compatibility (old versions gracefully handling data from later versions).
Backward compatibility is common and generally expected by software customers. A new version of Microsoft Word would get serious blowback from users if it could not read old documents from previous versions.

Forward compatibility is a bit more subtle and Wikipedia explains it well:
Assume that Version 1 of a word processor only allows text, and no graphics. It saves files with only information about the text typed, and the font, color, and size of the text. Let's say that the program adds the mark [VERSION1 END] to denote the end of the file. However, next year Version 2 is released that accepts graphics. However, the new word processor saves all of the text at the beginning of the file, puts the [VERSION1 END] mark, and then stores the picture data next, and puts a [VERSION2 END] mark after the picture data. The Version 1 word processor would still be able to read the text data up to the [VERSION1 END] mark, but would ignore the picture data afterward.
https://en.wikipedia.org/wiki/Forward_compatibility#Document_formats

So, a "soft-fork" in Bitcoin aims to create a new instance of forward compatibility where old versions can handle data from a new version, usually by ignoring it without crashing. There are hooks for this as Satoshi put version numbers on blocks and transactions, and created some dummy OP codes. However, beyond that the old software has no knowledge of what the new software is doing. The new software is also subject to design compromises in order to create forward compatibility in prior versions.

The benefit of a soft-fork is that users are not forced to upgrade, but the downside is that their software has incomplete functionality (in the Wikipedia example the version 1 WP can't show graphics present in a document). There is a grayscale. Sometimes the change is minor and the aggravation of making everyone upgrade, a "hard-fork", outweighs the benefit of everyone's software having full functionality. Sometimes the change is major and the old software then lacks so much functionality that users really should be upgrading.

Segregated Witness is borderline in this regard, and is arguably a major enough change that all users should be upgrading. A soft-fork for BIP101 is also major enough that everyone should instead upgrade as preserving forward compatibility is simply not worth it.
 
Last edited:
  • Like
Reactions: Terry999

theZerg

Moderator
Staff member
Aug 28, 2015
1,012
2,327
Ok, when I posted this yesterday my main purpose was that I thought that it was important to discuss because it positions BIP101 on equal footing with SW -- no hard fork required.

However, as I've been thinking about it I've realized that this is a way to soft-fork in a scaling idea that I originally thought could only be applicable to an alt-coin I which call distributed trustless merkle trees. The advantage is that this proposal actually scales beyond the capabilities of any portion of the network or of a single computer -- in other words, every wire or CPU does not have to see every transaction. So it solves scalability forever. Within that context, I've changed my mind -- yes its a bit more "messy" then BIP101 but its also much more powerful. If we are going to use the power of ANYONECANPAY, we should use it for this.

I was working on a more formal writeup last summer without much focus because I am not that interested in alt-coins until it becomes clear that Bitcoin will never be allowed to scale. Here is the proposal informally:

Let me propose that the extended block be replaced with 10 extended blocks each containing addresses prefixed with 20 to 29. And block with prefix address 20, directly contains addresses 200 and could contain sub-blocks (in theory) consisting of addresses 201 to 209, recursively. So we have a merkle block tree, and POW in the bitcoin blockchain is inherited by all blocks in that tree. Subblocks have their own coinbase txn that pays 0 reward but defines where the transaction fees go.

Paying between 2 addresses with the same prefix is just a transaction within a single block. Paying across address prefixes would require a transaction in the common parent, and in the "legacy" (today's blockchain) case we use the ANYONECANPAY "trick" and put the transaction in the children too (as described in my original post).

An individual's wallet could choose to limit itself to a particular set of leaf blocks (typically 1) and all parent blocks simply by generating the appropriately prefixed recipient addresses just like we generate vanity addreses today.

The security model is the same as Bitcoin for all blocks that the individual's wallet chooses to download the block's complete history.

Let us assume 3 main payment models in the world -- P2P, fan-in (starbucks), and fan-out (ad networks). Individuals use P2P and send into fan-in models. I believe that P2P use is highly localized -- its a scaled network of friends, family, and localized "yard-sale" like transactions. In these cases, if the sub-blocks were more-or-less geographically localized (this may happen naturally, or it may happen with some "help" via explicit coding in the client), most of the P2P transactions would occur within a block (remember that a single block can handle the ENTIRE bitcoin economic activity happening today). Companies with fan-in or fan-out models could keep track of and hold balances in many or all the address blocks, and in the fan-in case, the QR code could be extended to offer several recipient address choices, allowing the sender to choose an address block that he has a balance in. With these strategies, most of the transactions can occur in sub-blocks. This is not a requirement -- we will allow transactions to cross blocks as described next -- but companies might do so for efficiency reasons. With a lot of sub-blocks there could be heavy demand for cross-block transactions, resulting in higher fees to use space in blocks closer to the root (today's bitcoin blockchain) block.

But there will be times when a transaction must cross blocks. If txouts included the source block hash in the transaction (Ranvier's fraud proofs), it would be the individual's choice as to how deeply he wants to validate the coin history in a block history that his client is not tracking. He could rely entirely on miners for validation and therefore be essentially a SPV-client for txouts coming from those addresses, he could trace N weeks back in the blockchain, or he could have a trust relationship with a 3rd party service that is tracking the entire blockchain (well, blocktree). This is no worse of a security model than today's SPV clients.

Originally I thought that Mining pools would need to track all blocks. Let's assume this is the case for now... the advantages are that this tracking is naturally decomposable -- the mining pool can split tracking of particular address blocks to separate servers (located near where most transactions on that block originate to eliminate network use) and each server submits the block hash to its parent server to be assembled into a merkle tree of blocks that ultimately is placed in the bitcoin blockchain. This requires a trust relationship between the mining pool and the servers assembling blocks -- or to put it another way, the mining pool has to run multiple servers to handle the transaction load. This is no worse than the centralization that happens today -- the mining pool handles all blocks.

However, now I don't think that mining pools need to handle all the blocks in the tree. They could simply not mine some of the sub-blocks and not add them into the merkle block tree. This would reduce the rate of transaction commitment in those sub-blocks. How can users encourage a sub-block to be regularly mined? Offer more in transaction fees! So we get a fee market. You could even offer an ANYONECANPAY transaction to explicitly encourage mining.

Miners do not need to see any of the data in the sub-blocks. They only need to see the original bitcoin block, since it contains a merkle tree of the hashes of (essentially pointers to) the sub-blocks. This means that bandwidth to the hashing factories remains what it is today.

Finally, mining pools may not need to generate all the sub-blocks themselves. They could choose to accept a sub-block without validating it. If they do so, there is a danger that this subblock will be invalid and rejected by the rest of the network. In this case, the rest of the network could present a succinct fraud proof which the mining pool could validate without having to sync the entire sub-block chain. But there are several incentives for the submission of valid subblocks:
1. transaction fees go to the sub-block coinbase addresses -- presumably some of these are the sub-block validator's addresses, and some amount could also pay out to the mining pool to encourage it to include this sub-block rather than a competitor's.
2. the sub-block validator could "mine" the sub-block. In other words, the validator could use POW to prove to a mining pool that it has significant investment in the block.

With these last 2 observations, you end up with the trustless part in the "distributed trustless merkle tree". However this trustless "feature" does not seem that important in today's network, given the fact that mining pools are ALREADY quite centralized. The proposal above makes them no more so, and in fact may help to decentralize them by allowing trustless sub-block assembly. The most important feature is the "permissionless" aspect -- anyone can create a new mining pool and compete with the existing ones.

TLDR:

1. Infinite scalability
2. User clients do not require more bandwidth than today. They can be "full nodes" for regional transaction and SPV nodes (or full nodes if they want) for others.
3. Competition for cross block space creates transaction fees -> fee market
4. Encouraging mining pools to include sub-blocks creates transaction fees -> fee market
5. Miners (hashers) do not need higher bandwidth than today
6. Mining pools can distribute the validation work across multiple servers
7. Mining pools can choose to include sub-blocks from 3rd party providers and there are mechanisms to ensure that these sub-blocks are valid.
8. User clients with a lot of activity (corporations, exchanges, etc) can validate any/all regions and can naturally distribute this validation to a network of machines.
 
Last edited:

solex

Moderator
Staff member
Aug 22, 2015
1,558
4,693
@theZerg
It is great to see this idea explained and documented, especially as it gives hope that even if the Bitcoin protocol has become ossified so soon, that it can still be made to scale to become the global currency and payments system of the future.
 

Peter R

Well-Known Member
Aug 28, 2015
1,398
5,595
I was thinking last night: is it possible to soft fork any change if one allows for as much complexity and mess as required? I could imaging that even an increase to the number of coins would be possible with a soft fork (of course the old nodes would not recognize the new coins).

Just thinking out loud...
 
  • Like
Reactions: Terry999

Zangelbert Bingledack

Well-Known Member
Aug 29, 2015
1,485
5,585
I wouldn't be surprised. However, the "soft forks don't require consensus" schtick is just the latest in a long line of ad hoc stances that change to suit the needs of Core/Blockstream while trying to maintain a facade of objectivity. This manipulative and audacious framing should be exposed wherever it is tried, as soon as it is tried.
 

Emperor Bob

New Member
Aug 19, 2015
18
37
I could imaging that even an increase to the number of coins would be possible with a soft fork (of course the old nodes would not recognize the new coins).
Yeah, you could do an extension-block approach where the extension block has its own reward. The problem is that since old-coins are distinct from new coins, they won't have the same value on an exchange. So that's not quite inflation (just adding a separate currency inside the system with a separate inflation schedule, and adding the ability to convert 1-1 from the old one).

Much more fun (and devious) is Freicoin-style demurrage as a soft fork. Make it a protocol rule that there's a minimum miner fee, proportional to age times total value. Worried about miner -> spender kickbacks? Add a rule that says the fees from demurrage are split equally amongst miners of the last 10 blocks. Still softfork-compatible.

If that's not good enough, make the output value be stored in extraneous data in the output (OP_RETURN or the like). All old-style outputs (including the coinbase reward) must have value == 0. If you don't like whatever rules govern the new value storage format, too bad, none of your transactions will confirm (unless you're just burning your money and giving it to miners). If you want to keep using Bitcoin, you have to opt into inflation.

It's pretty obvious to me that a soft-fork has no guarantee of preserving any property of Bitcoin. It has one, and only one, advantage (speed of rollout). That makes it appropriate for bug fixes, but not much else.
 
Last edited:

Roger_Murdock

Active Member
Dec 17, 2015
223
1,453
Yeah, you could do an extension-block approach where the extension block has its own reward. The problem is that since old-coins are distinct from new coins, they won't have the same value on an exchange. So that's not quite inflation (just adding a separate currency inside the system with a separate inflation schedule, and adding the ability to convert 1-1 from the old one).
I'm not sure about that. Consider that the soft fork could require that ALL transactions (other than perhaps the initial coinbase transaction for new "main blocks") occur in the extension blocks. And in fact, the rule set governing the extension blocks could blacklist all new "main chain" coinbase transactions such that the only spendable outputs are pre-softfork outputs and those from the extension block coinbase transactions. As I said in another comment:

Basically you can have all the REAL action vis-a-vis updating the ledger happening in the extension block by applying whatever rule set you want to it. Essentially, the “main blocks” become these sort of “pod-person” blocks that look superficially “valid” to old nodes, but whose true internal workings are totally inscrutable and alien.
So I'm imagining that address balances would eventually become this sort of hopeless mix of outputs that trace their origin back to "real" (i.e., pre-softfork "main block") coinbase transactions and those that came from the "fake" (i.e., extension block) coinbase transactions. I'm not 100% sure if, in this scenario, it would actually even be possible to uniquely attribute specific outputs to one origin of the other. But even if the different types of outputs here could be differentiated, I'm not sure the market would differentiate between them in the bizarro-world scenario we're imagining where this type of shenanigans is actually being tolerated.

(And yes, I know I'm bumping an eight-month-old thread here, but I just saw it.)
 
Last edited:
  • Like
Reactions: Terry999 and solex