Skip to content

Commit 34db0e9

Browse files
authored
Link to latest code -- also shorter/better explanations (bitcoin#1666)
* Update to CUSF activation client +shorter +clearer * remove superfluous images * link to CUSF client, shorter and clearer BIP text
1 parent 22660ad commit 34db0e9

File tree

6 files changed

+112
-175
lines changed

6 files changed

+112
-175
lines changed

bip-0300.mediawiki

+79-110
Large diffs are not rendered by default.

bip-0301.mediawiki

+33-64
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
==Abstract==
1717

18-
Blind Merged Mining (BMM) allows miners to mine a Sidechain/Altcoin, without running its node software (ie, without "looking" at it, hence "blind").
18+
Blind Merged Mining (BMM) allows SHA-256d miners to collect transaction fee revenue from other blockchains, without running any new software (i.e., without "looking" at those alt-chains, hence "blind").
1919

20-
Instead, a separate sidechain user runs their node and constructs the block, paying himself the transaction fees. He then uses an equivalent amount of money to "buy" the right to find this block, from the conventional layer1 Sha256d miners.
20+
Instead, this block-assembly work is done by alt-chain users. They choose the alt-chain block, and what txns go in it, the fees etc. Simultaneously, these users "bid" on L1 to win the right to be the sole creator of the alt-chain block. BIP-301 ensures that L1 miners only accept one bid (per 10 minutes, per L2 category), instead of taking all of them (which is what they would ordinarily do).
2121

2222

2323
==Motivation==
@@ -32,9 +32,9 @@ However, traditional MM has two drawbacks:
3232

3333
==Notation and Example==
3434

35-
Note: We use notation side:\* and main:\* in front of otherwise-ambiguous words (such as "block", "node", or "chain"), to sort the mainchain version from its sidechain counterpart. We name all sidechain users "Simon", and name all mainchain miners "Mary".
35+
We use notation side:\* and main:\* in front of otherwise ambiguous words (such as "block", "node", or "chain"), to distinguish the mainchain version from its sidechain/alt-chain counterpart. We name all sidechain users "Simon", and name all mainchain miners "Mary".
3636

37-
Example: imagine that a sidechain block contains 20,000 txns, each paying a $0.10 fee; therefore, the block is worth $2000 of fee-revenue. As usual: the sidechain's coinbase txn will pay this $2000 to someone (in this case, "Simon"). Under Bip301, Simon does no hashing, but instead makes one layer1 txn paying $1999 to the layer1 miners ("Mary").
37+
Furthermore, here is an example of BIP-301 in use. Imagine that a side:block contains 20,000 txns, each paying a $0.10 fee; therefore, the side:block is worth $2000 of fee revenue. In BIP-301, the sidechain's coinbase txn will pay this $2000 to "Simon". Simon does no hashing, but instead makes one L1 txn paying $1999 to the L1 miners ("Mary"). Thus, Mary ends up with all of the fee revenue, even though she didn't do anything on the sidechain.
3838

3939

4040
{| class="wikitable"
@@ -71,119 +71,88 @@ Example: imagine that a sidechain block contains 20,000 txns, each paying a $0.1
7171
|}
7272

7373

74-
Bip301 makes this specialization-of-labor trustless on layer1. If Mary takes Simon's money, then she must let Simon control the side:block.
74+
BIP-301 makes this specialization-of-labor trustless on L1. If Mary takes Simon's money, then she must let Simon control the side:block.
7575

7676

7777

7878
==Specification==
7979

80+
Each candidate for next side:block is defined by its unique side:blockhash "h*". (Even if the entire rest of the L2 block is identical, different Simons will have different side:coinbases and therefore different h*.)
8081

81-
Bip301 consists of two messages: "BMM Accept" and "BMM Request". These govern something called "h*".
82+
BIP-301 consists of two messages: "BMM Accept" and "BMM Request".
8283

83-
So we will discuss:
84+
# "BMM Accept" -- A coinbase output in L1, which contains h*. Mary can only choose one h* to endorse.
85+
# "BMM Request" -- A transaction where Simon offers to pay Mary, if (and only if) Mary's L1 block contains Simon's h*.
8486
85-
# h* -- The sidechain's hashMerkleRoot, and why it matters.
86-
# "BMM Accept" -- How h* enters a main:coinbase. When Mary "accepts" a BMM Request, Mary is ''endorsing a side:block''.
87-
# "BMM Request" -- Simon offering money to Mary, if (and only if) she will Endorse a specific h*. When Simon broadcasts a BMM Request, Simon is ''attempting a side:block''.
88-
89-
90-
=== h* ===
91-
92-
h* ("h star") is the sidechain's Merkle Root hash.
93-
94-
In Bip301, a sidechain's coinbase txn acts as a header (it contains the hash of the previous side:block, and previous main:block). Thus, the MerkleRoot contains everything important.
95-
96-
Note: in Bip301 sidechains, "headers" and "block hashes" do not have significant consensus meaning and are in the design mainly to help with IBD. (In the mainchain, in contrast, headers and block hashes determine the difficulty adjustments and cumulative PoW.)
97-
98-
<img src="bip-0301/sidechain-headers.png?raw=true" align="middle"></img>
99-
100-
101-
Above: h* is located in the main:coinbase. h* contains all side:txns, including the side:coinbase. The side:coinbase contains many "header-like" fields, such as the hash of the previous side:block.
102-
103-
Mary controls the main:coinbase, so she may select any h*. Her selection will determine which side:block is "found".
87+
As a miner, Mary controls the main:coinbase, so she may select any h*. Her selection determines which side:block is "found" -- and which associated BMM Request she can collect.
10488

10589

10690
=== BMM Accept ===
10791

108-
To "Accept" the BMM proposal (and to accept Simon's money), Mary must endorse Simon's block.
92+
To "Accept" a BMM proposal (endorsing Simon's side:block, and allowing Mary to accept Simon's money later in the block), Mary places an OP_RETURN output into the main:coinbase as follows:
10993

11094
<pre>
111-
For each side:block Mary wishes to endorse, Mary places the following into a main:coinbase OP_RETURN:
11295
1-byte - OP_RETURN (0x6a)
11396
4-bytes - Message header (0xD1617368)
97+
1-byte - Sidechain number (0-255)
11498
32-bytes - h* (obtained from Simon)
11599
</pre>
116100

117-
[https://github.com/drivechain-project/mainchain/blob/8901d469975752d799b6a7a61d4e00a9a124028f/src/validation.cpp#L3530-L3572 Code details here].
101+
[https://github.com/LayerTwo-Labs/bip300301_messages/blob/master/src/lib.rs#L252-L264 Code details here].
118102

119103
If these OP_RETURN outputs are not present, then no Requests were accepted. (And, Mary would get no money from Requests.)
120104

121-
It is possible for Mary and Simon to be the same person.They would trust each other completely, so the BMM process would stop here. There would only be Accepts; Requests would be unnecessary.
105+
It is possible for Mary and Simon to be the same person. They would trust each other completely, so the BMM process would stop here. There would only be Accepts; Requests would be unnecessary.
122106

123107
When Simon and Mary are different people, Simon will need to use BMM Requests.
124108

125109
=== BMM Request ===
126110

127-
Simon will use BMM Requests to buy the right to find a sidechain block, from Mary.
111+
Simon will use BMM Requests to buy the "right" to find a sidechain block, from Mary.
112+
113+
For each side:block that Simon wants to attempt, he broadcasts a txn containing the following as an OP_RETURN:
128114

129115
<pre>
130-
For each side:block that Simon wants to attempt, he broadcasts a txn containing the following:
131-
3-bytes - Message header (0x00bf00)
132-
32-bytes - h* (side:MerkleRoot)
133-
1-byte - nSidechain (sidechain ID number)
134-
4-bytes - prevMainHeaderBytes (the last four bytes of the previous main:block)
116+
1-byte - OP_RETURN (0x6a)
117+
3-bytes - Message header (0x00bf00)
118+
1-byte - Sidechain number (0-255)
119+
32-bytes - h* (obtained from L2 node)
120+
32-bytes - prevMainBlock (the blockhash of the previous main:block)
135121
</pre>
136122

137-
We make use of the [https://github.com/drivechain-project/mainchain/blob/8901d469975752d799b6a7a61d4e00a9a124028f/src/primitives/transaction.h#L224-L331 extended serialization format]. (SegWit used ESF to position scriptWitness data within txns; we use it here to position the five fields above.)
138-
139-
140-
The Message header identifies this txn as a BMM transaction. h* is chosen by Simon to correspond to his side:block. nSidechain is the number assigned to the sidechain when it was created. preSideBlockRef allows Simon to build on any preexisting side:block (allowing him to bypass one or more invalid blocks, details below). prevMainHeaderBytes are the last four bytes of the previous main:block (details below).
123+
h* is chosen by Simon to correspond to the side:block he wants to mine on the alt-chain. nSidechain is the number assigned to the sidechain/alt-chain when it was created.
141124

142125
This txn is invalid if it fails any of the following checks:
143126

144127
# Each "BMM Request", must match one corresponding "BMM Accept" (previous section).
145-
# Only one BMM Request is allowed in each main:block, per sidechain. In other words, if 700 users broadcast BMM Requests for sidechain #4, then the main:miner singles out one BMM Request to include.
146-
# The 4-bytes of prevMainHeaderBytes must match the last four bytes of the previous main:blockheader. Thus, Simon's txns are only valid for the current block, in the block history that he knows about (and therefore, the current sidechain history that he knows about).
128+
# Only one BMM Request is allowed in each main:block, per nSidechain. In other words, if 700 users broadcast BMM Requests for sidechain #4, then the main:miner must single out one BMM_Request_4 to include in this L1 block.
129+
# The 32-bytes of prevMainBlock must match the previous main:blockhash. Thus, Simon's txns are only valid for the current block, in the block history that he knows about.
147130
148131

149-
Most BMM Request txns will never make it into a block. Simon will make many BMM Requests, but only one will be accepted. Since only one BMM Request can become a bona fide transaction, Simon may feel comfortable making multiple offers all day long. This means Mary has many offers to choose from, and can choose the one which pays her the most.
132+
Most BMM Request txns will never make it into a block. Simon will make many BMM Requests, but only one will be accepted. Since only one BMM Request can enter the L1 block, Simon may feel comfortable making multiple offers all day long. This means Mary has many offers to choose from, and can choose the one that pays her the most.
150133

151134
This BIP allows BMM Requests to take place over Lightning. One method is [https://www.drivechain.info/media/bmm-note/bmm-lightning/ here]. (BMM Accepts cannot be over LN, since they reside in main:coinbase txns.)
152135

153-
==Backward compatibility==
154-
155-
As a soft fork, older software will continue to operate without modification. To enforce BMM trustlessly, nodes must watch "pairs" of transactions, and subject them to extra rules. Non-upgraded nodes will notice that this activity is present in the blockchain, but they will not understand any of it.
156136

157-
Much like P2SH or a new OP Code, these old users can never be directly affected by the fork, as they will have no expectations of receiving payments of this kind. (As a matter of fact, the only people receiving BTC here, all happen to be miners. So there is less reason than ever to expect compatibility problems.)
137+
==Backward compatibility==
158138

159-
As with all previous soft forks, non-upgraded users are indirectly affected, in that they are no longer performing full validation.
139+
This soft fork can be deployed without modifying Bitcoin Core at all (ie, via [https://bip300cusf.com/ CUSF]).
160140

161141

162142
==Deployment==
163143

164-
This BIP will be deployed via UASF-style block height activation. Block height TBD.
165-
166-
167-
==Reference Implementation==
168-
169-
See: https://github.com/drivechain-project/mainchain
170-
171-
Also, for interest, see an example sidechain here: https://github.com/drivechain-project/sidechains/tree/testchain
144+
This BIP deploys when/if >51% hashrate runs [https://github.com/LayerTwo-Labs/bip300301_enforcer/ the enforcer client].
172145

146+
Ideally, a critical mass of users would also run the enforcer client -- this would strongly dissuade miners from ever de-activating it.
173147

174-
==References==
175-
176-
* http://www.drivechain.info/literature/index.html
177-
* http://www.truthcoin.info/blog/blind-merged-mining/
178-
* http://www.truthcoin.info/images/bmm-outline.txt
179148

149+
==Reference Implementation==
180150

181-
==Thanks==
151+
The enforcer is [https://github.com/LayerTwo-Labs/bip300301_enforcer/ here].
182152

183-
Thanks to everyone who contributed to the discussion, especially: ZmnSCPxj, Adam Back, Peter Todd, Dan Anderson, Sergio Demian Lerner, Matt Corallo, Sjors Provoost, Tier Nolan, Erik Aronesty, Jason Dreyzehner, Joe Miyamoto, Chris Stewart, Ben Goldhaber.
153+
Also, several example L2s using BIP-301 are [https://releases.drivechain.info/ here].
184154

185155

186156
==Copyright==
187157

188158
This BIP is licensed under the BSD 2-clause license.
189-

bip-0301/images.txt

-1
This file was deleted.

bip-0301/m1-gui.jpg

-111 KB
Binary file not shown.

bip-0301/sidechain-headers.png

-42 KB
Binary file not shown.

bip-0301/witness-vs-critical.png

-262 KB
Binary file not shown.

0 commit comments

Comments
 (0)