You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Bip300, txns are not signed via cryptographic key. Instead, they are "signed" by the accumulation of hashpower over time.
18
+
In Bip300, txns are not signed via cryptographic key. Instead, they are "signed" by hashpower, over time. Like a big multisig, 13150-of-26300, where each block is a new "signature".
19
19
20
20
Bip300 emphasizes slow, transparent, auditable transactions which are easy for honest users to get right and very hard for dishonest users to abuse. The chief design goal for Bip300 is ''partitioning'' -- users may safely ignore Bip300 txns if they want to (or Bip300 entirely).
21
21
@@ -27,7 +27,7 @@ See [http://www.drivechain.info/ this site] for more information.
27
27
28
28
As Reid Hoffman [https://blockstream.com/2015/01/13/en-reid-hoffman-on-the-future-of-the-bitcoin-ecosystem/ wrote in 2014]: "Sidechains allow developers to add features and functionality to the Bitcoin universe without actually modifying the Bitcoin Core code...Consequently, innovation can occur faster, in more flexible and distributed ways, without losing the synergies of a common platform with a single currency."
29
29
30
-
Coins such as Namecoin, Monero, ZCash, and Sia, offer features that Bitcoiners cannot access -- not without selling their BTC to invest in a rival monetary unit. According to [https://coinmarketcap.com/charts/#dominance-percentage coinmarketcap.com], there is now more value *outside* the BTC protocol than within it. According to [https://cryptofees.info/ cryptofees.info], 10x more txn fees are paid outside the BTC protocol, than within it.
30
+
Today, coins such as Namecoin, Monero, ZCash, and Sia, offer features that Bitcoiners cannot access -- not without selling their BTC to invest in a rival monetary unit. According to [https://coinmarketcap.com/charts/#dominance-percentage coinmarketcap.com], there is now more value *outside* the BTC protocol than within it. According to [https://cryptofees.info/ cryptofees.info], 15x more txn fees are paid outside the BTC protocol, than within it.
31
31
32
32
Software improvements to Bitcoin rely on developer consensus -- BTC will pass on a good idea if it is even slightly controversial. Development is slow: we are now averaging one major feature every 5 years.
33
33
@@ -37,7 +37,9 @@ BTC can copy every useful technology, as soon as it is invented; scamcoins lose
37
37
38
38
==Specification==
39
39
40
-
Bip300 allows for six new blockchain messages:
40
+
===Overview===
41
+
42
+
Bip300 allows for six new blockchain messages (these have consensus significance):
41
43
42
44
* M1. "Propose New Sidechain"
43
45
* M2. "ACK Proposal"
@@ -48,22 +50,12 @@ Bip300 allows for six new blockchain messages:
48
50
49
51
Nodes organize those messages into two caches:
50
52
51
-
* D1. "Escrow_DB" -- tracks the 256 Hashrate Escrows (Escrows slots that a sidechain can live in).
52
-
* D2. "Withdrawal_DB" -- tracks the withdrawal-Bundles (coins leaving a Sidechain).
53
-
54
-
We will cover:
55
-
56
-
# Adding Sidechains (D1, M1, M2)
57
-
# Approving Withdrawals (D2, M3, M4)
58
-
# Depositing and Withdrawing (M5, M6)
59
-
60
-
=== Adding Sidechains (D1, M1, M2) ===
61
-
62
-
63
-
==== D1 -- "Escrow_DB" ====
53
+
* D1. "The Sidechain List", which tracks the 256 Hashrate Escrows (Escrows are slots that a sidechain can live in).
54
+
* D2. "The Withdrawal List", which tracks the withdrawal-Bundles (coins leaving a Sidechain).
64
55
65
-
The table below enumerates the new database fields, their size in bytes, and their purpose. A sidechain designer is free to choose any value for these.
56
+
==== D1 (The Sidechain List) ====
66
57
58
+
D1 is a list of active sidechains. D1 is updated via M1 and M2.
@@ -133,10 +125,61 @@ The table below enumerates the new database fields, their size in bytes, and the
133
125
| Of the CTIP, the second element of the pair: the Index. See #11 above.
134
126
|}
135
127
136
-
D1 is updated via M1 and M2.
137
128
129
+
==== D2 (The Withdrawal List) ====
130
+
131
+
D2 lists withdrawal-attempts. If these attempts succeed, they will pay coins "from" a Bip300-locked UTXO, to new UTXOs controlled by the withdrawing-user. Each attempt pays out many users, so we call these withdrawal-attempts "Bundles".
132
+
133
+
D2 is driven by M3, M4, M5, and M6. Those messages enforce the following principles:
134
+
135
+
# The Bundles have a canonical order (first come first serve).
136
+
# From one block to the next, every "Blocks Remaining" field decreases by 1.
137
+
# When "Blocks Remaining" reaches zero the Bundle is removed.
138
+
# From one block to the next, the value in "ACKs" may either increase or decrease, by a maximum of 1 (see M4).
139
+
# If a Bundle's "ACKs" reach 13150 or greater, it "succeeds" and its corresponding M6 message can be included in a block.
140
+
# If the M6 of a Bundle is paid out, it is also removed.
141
+
# If a Bundle cannot possibly succeed ( 13500 - "ACKs" > "Blocks Remaining" ), it is removed immediately.
142
+
143
+
144
+
{| class="wikitable"
145
+
! Field No.
146
+
! Label
147
+
! Type
148
+
! Description / Purpose
149
+
|-
150
+
| 1
151
+
| Sidechain Number
152
+
| uint8_t
153
+
| Links the withdrawal-request to a specific hashrate escrow.
154
+
|-
155
+
| 2
156
+
| Bundle Hash
157
+
| uint256
158
+
| A withdrawal attempt. Specifically, it is a "blinded transaction id" (ie, the double-Sha256 of a txn that has had two fields zeroed out, see M6) of a txn which could withdraw funds from a sidechain.
159
+
|-
160
+
| 3
161
+
| ACKs (Work Score)
162
+
| uint16_t
163
+
| The current ACK-counter, which is the total number of ACKs (the PoW that has been used to validate the Bundle).
164
+
|-
165
+
| 4
166
+
| Blocks Remaining (Age)
167
+
| uint16_t
168
+
| The number of blocks which this Bundle has remaining to accumulate ACKs
169
+
|}
170
+
171
+
172
+
173
+
174
+
175
+
176
+
=== The Six New Bip300 Messages ===
177
+
178
+
First, how are new sidechains created?
179
+
180
+
They are first proposed (with M1), and later acked (with M2). This process resembles Bip9 soft fork activation.
138
181
139
-
==== M1 -- "Propose New Sidechain"====
182
+
==== M1 and M2 (Adding a new sidechain)====
140
183
141
184
Examples:
142
185
@@ -159,140 +202,93 @@ M1 is a coinbase OP Return output containing the following:
159
202
32-byte hashID1
160
203
20-byte hashID2
161
204
162
-
M1 is used in conjunction with M2.
163
-
164
-
==== M2 -- "ACK Sidechain Proposal" ====
205
+
M2 is a coinbase OP Return output containing the following:
165
206
166
207
1-byte - OP_RETURN (0x6a)
167
208
4-byte - Message header (0xD6E1C5BF)
168
209
32-byte - sha256D hash of sidechain's serialization
169
210
170
-
====M1/M2 Validation Rules ====
211
+
The new M1/M2 validation rules are:
171
212
172
213
# Any miner can propose a new sidechain at any time. This procedure resembles BIP 9 soft fork activation: the network must see a properly-formatted M1, followed by "acknowledgment" of the sidechain in 90% of the following 2016 blocks.
173
214
# It is possible to "overwrite" a sidechain. This requires more ACKs -- 50% of the following 26300 blocks must contain an M2. The possibility of overwrite, does not change the security assumptions (because we already assume that users perform extra-protocolic validation at a rate of 1 bit per 26300 blocks).
174
215
175
216
176
-
=== Approving Withdrawals (D2, M3, M4) ===
217
+
==== M3 and M4 (Withdrawing Coins) ====
177
218
178
219
Withdrawals in Bip300 (ie, "M6"), are very significant. So, we will first discuss how these are approved/rejected -- a process involving M3, M4, and D2.
179
220
180
-
==== What are Bundles? ====
181
-
182
-
All Bip300 withdrawals take the form of “Bundles” (formerly known as “WT^s”) -- named because they "bundle up" many individual withdrawal-requests into one single rare layer1 transaction.
183
-
184
-
This bundle either pays all of the withdrawals out, or else it fails (and pays nothing out). Bip300 / layer 1 does not assemble Bundles (the sidechain developer does this in a manner of their choosing).
185
-
186
-
Bundles are identified by a 32-byte hash, which aspires to be the TxID of M6. Unfortunately, the Bundle-hash and M6-TxID cannot match exactly, since the first input to M6 is a CTIP which is constantly changing. So, we must accomplish a task, which is conceptually similar to AnyPrevOut (BIP 118). We define a "blinded TxID" as a way of hashing a txn, in which some bytes are first overwritten with zeros. In our case, these bytes are the first input and the first output.
187
-
188
-
D2 controls Bundles, and is driven by M3, M4, M5, and M6.
189
-
190
-
191
-
==== D2 -- "Withdrawal_DB" ====
192
-
193
-
194
-
{| class="wikitable"
195
-
! Field No.
196
-
! Label
197
-
! Type
198
-
! Description / Purpose
199
-
|-
200
-
| 1
201
-
| Sidechain Number
202
-
| uint8_t
203
-
| Links the withdrawal-request to a specific hashrate escrow.
204
-
|-
205
-
| 2
206
-
| Bundle Hash
207
-
| uint256
208
-
| A withdrawal attempt. Specifically, it is a "blinded transaction id" (ie, the double-Sha256 of a txn that has had two fields zeroed out, see M6) of a txn which could withdraw funds from a sidechain.
209
-
|-
210
-
| 3
211
-
| ACKs (Work Score)
212
-
| uint16_t
213
-
| The current ACK-counter, which is the total number of ACKs (the PoW that has been used to validate the Bundle).
214
-
|-
215
-
| 4
216
-
| Blocks Remaining (Age)
217
-
| uint16_t
218
-
| The number of blocks which this Bundle has remaining to accumulate ACKs
219
-
|}
220
-
221
-
A hash of D2 exists in each coinbase txn, and has consensus-significance.
221
+
===== What are Bundles? =====
222
222
223
-
==== D2 Validation Rules ====
223
+
All Bip300 withdrawals take the form of “Bundles” -- named because they "bundle up" many individual withdrawal-requests into one single rare layer1 transaction.
224
224
225
-
# The D2 hash commitment must be in each block (unless D2 is blank).
226
-
# The Bundles must be listed in a canonical order (so that the hashes match).
227
-
# From one block to the next, "Age" fields must increase by exactly 1 (ie, Blocks Remaining decreases by 1).
228
-
# Bundles are stored in D2 until they fail (which occurs at "Age" = "MaxAge"), or they succeed (Bundle is paid out).
229
-
# From one block to the next, the value in the ACKs field (ACK-counter) can increase or decrease by a maximum of 1 (see below).
225
+
This bundle either pays all of the withdrawals out, or else it fails (and pays nothing out). Bip300 / layer 1 does not assemble Bundles (the sidechain developer does this, in a manner of their choosing).
230
226
231
-
If a Bundle succeeds (in D2), it "becomes" an M6 message and is included in a block.
227
+
Bundles are identified by a 32-byte hash, which aspires to be the TxID of M6. Unfortunately, the Bundle-hash and M6-TxID cannot match exactly, since the first input to M6 is a CTIP which is constantly changing. So, we must accomplish a task, which is conceptually similar to AnyPrevOut (BIP 118). We define a "blinded TxID" as a way of hashing a txn, in which some bytes are first overwritten with zeros. In our case, the precise "overwritten bytes" are: the first input and the first output.
232
228
233
-
So, first: how do we add a Bundle to D2?
229
+
===== M3 (Propose a Bundle) =====
234
230
235
-
==== M3 -- "Propose Bundle" ====
236
-
237
-
238
-
Nodes will add an entry to D2 if there is a coinbase output with the following:
231
+
M3 is a coinbase OP Return output containing the following:
239
232
240
233
1-byte - OP_RETURN (0x6a)
241
234
4-byte - Commitment header (0xD45AA943)
242
235
32-byte - The Bundle hash, to populate a new D2 entry
243
236
244
237
245
-
==== M3 Validation Rules ====
238
+
The new validation rules pertaining to M3 are:
246
239
247
-
# If the network detects a properly-formatted M3, it must add an entry to D2 in the very next block. The starting Blocks Remaining value is 26,299. The starting ACKs count is 1.
240
+
# If the network detects a properly-formatted M3, it must add an entry to D2 in the very next block. The starting "Blocks Remaining" value is 26,299. The starting ACKs count is 1.
248
241
# Each block can only contain one M3 per sidechain.
249
242
250
243
Once a Bundle is in D2, how can we give it enough ACKs to make it valid?
251
244
252
-
==== M4 -- "ACK Withdrawal" ====
245
+
===== M4 (ACK Withdrawals) =====
253
246
254
-
From one block to the next, "ACKs" can only change as follows:
247
+
M4 is a coinbase OP Return output containing the following:
255
248
256
-
* The ACK-counter of any Bundle can only change by (-1,0,+1).
257
-
* Within a sidechain-group, upvoting one Bundle ("+1") requires you to downvote all other Bundles in that group. However, the minimum ACK-counter is zero.
258
-
* While only one Bundle can be upvoted at once; the whole group can all be unchanged at once ("abstain"), and they can all be downvoted at once ("alarm").
249
+
1-byte - OP_RETURN (0x6a)
250
+
4-byte - Commitment header (0xD77D1776)
251
+
1-byte - Version
252
+
n-byte - The vector describing the "upvoted" bundle-choice, for each sidechain.
259
253
260
-
M4 does not need to be explicitly transmitted. It can simply be inferred from the new state of D2. M4 can therefore be improved over time, without affecting consensus.
254
+
Version 0x01 uses one byte per sidechain, and applies in most cases. Version 0x02 uses two bytes per sidechain and applies in unusual situations where at least one sidechain has more than 256 distinct withdrawal-bundles in progress at one time. If a sidechain has no pending bundles, then it is skipped over when M4 is created and parsed.
261
255
262
-
Nonetheless, one option for explicit transmission of M4 is [https://github.com/drivechain-project/mainchain/blob/8901d469975752d799b6a7a61d4e00a9a124028f/src/validation.cpp#L3735-L3790 in our code].
256
+
The upvote vector will code "abstain" as 0xFF (or 0xFFFF); it will code "alarm" as 0xFE (or 0xFFFE). Otherwise it simply indicates which withdrawal-bundle in the list, is the one to be "upvoted". For example, if there are two sidechains, and we wish to upvote the 7th bundle on sidechain #1 plus the 4th bundle on sidechain #2, then the vector would be 0x0704.
263
257
264
-
Often, M4 does not need to be transmitted at all. If there are n Sidechains and m Withdrawals-per-sidechain, then there are (m+2)^n total candidates for the next D2. So, when m and n are low, all of the possible D2s can be trivially computed in advance.
258
+
The M4 message will be invalid (and invalidate the block), if it tries to upvote a Bundle that doesn't exist (for example, trying to upvote the 7th bundle on sidechain #2, when sidechain #2 has only three bundles). If there are no Bundles at all (no one is trying to withdraw from any sidechain), then *any* M4 message present in the coinbase will be invalid. If M4 is NOT present in a block, then it is treated as "abstain".
265
259
266
-
Miners can impose a "soft limit" on m, blocking new withdrawal-attempts until previous ones expire. Even if they fail to do this, a a worst-case scenario of n=200 and m=1,000, honest nodes can communicate the M4 with ~25 KB per block [4+1+1+(200\*(1000+1+1)/8)].
260
+
The ACKed withdrawal will gain one point for its ACK field. Therefore, the ACK-counter of any Bundle can only change by (-1,0,+1).
267
261
268
-
Finally, we give Deposits and Withdrawals.
262
+
Within a sidechain-group, upvoting one Bundle ("+1") requires you to downvote all other Bundles in that group. However, the minimum ACK-counter is zero. While only one Bundle can be upvoted at once; the whole group can all be unchanged at once ("abstain"), and they can all be downvoted at once ("alarm").
269
263
270
-
===Deposits and Withdrawals (M5, M6) ===
264
+
Finally, we describe Deposits and Withdrawals.
271
265
272
-
Both M5 and M6 are regular Bitcoin txns. They are identified, as Deposits/Withdrawals, when they select one of the special CTIP UTXOs as one of their inputs (see D1).
266
+
==== M5 and M6 (User's Deposits and Withdrawals) ====
273
267
268
+
Both M5 and M6 are regular Bitcoin txns. They are identified, as Deposits/Withdrawals, when they select one of the special CTIP UTXOs as one of their inputs (see D1).
274
269
275
270
All of a sidechain’s coins, are stored in one UTXO. (Deposits/Withdrawals never cause UTXO bloat.) So, each Deposit/Withdrawal must select a CTIP, and generate a new CTIP (this is tracked in D1, above).
276
271
277
-
If the from-CTIP-to-CTIP quantity of coins goes '''up''', (ie, if the user is adding coins), then the txn is treated as a Deposit (M5). Else it is treated as a Withdrawal (M6). See [https://github.com/drivechain-project/mainchain/blob/8901d469975752d799b6a7a61d4e00a9a124028f/src/validation.cpp#L668-L781here].
272
+
If the from-CTIP-to-CTIP quantity of coins goes '''up''', (ie, if the user is adding coins), then the txn is treated as a Deposit (M5). Else it is treated as a Withdrawal (M6). See [https://github.com/drivechain-project/mainchain/blob/e37b008fafe0701b8313993c8b02ba41dc0f8a29/src/validation.cpp#L667-L780here].
278
273
279
274
280
-
==== M5. "Make a Deposit" -- a transfer of BTC from-main-to-side ====
275
+
===== M5 (Make a Deposit) -- a transfer of BTC from-main-to-side =====
281
276
282
277
As far as mainchain consensus is concerned, all deposits to a sidechain are always valid.
283
278
284
-
==== M6. "Execute Withdrawal" -- a transfer of BTC from-side-to-main ====
279
+
===== M6 (Execute a Withdrawal) -- a transfer of BTC from-side-to-main =====
285
280
286
281
We come, finally, to the critical matter: where users can take their money *out* of the sidechain.
287
282
288
283
In each block, a Bundle in D2 is considered "approved" if its "ACK-counter" value meets the threshold (13,150).
289
284
285
+
If a Bundle is approved, then its associated M6 can be included in a block.
290
286
291
-
The Bundle must meet all these criteria:
287
+
An M6 must meet all these criteria, else it be invalid:
292
288
293
-
# "Be ACKed" -- The "blinded TxID" of this txn must be a member of the "approved candidate" set in the D2 of this block.
294
-
# "Return Change to Account" -- TxOut0 must pay coins back to the sidechain's CTIP.
295
-
# "Return *all* Change to Account" -- Sum of inputs must equal the sum of outputs. No traditional tx fee is possible.
289
+
# "Be ACKed" -- The "blinded TxID" of the M6 must match an approved Bundle. In other words, an M6 can only be included in a block, after the 3+ month (13150 block) ceremony.
290
+
# "Return Change to Account" -- TxOut0 must be paid back to the sidechain's Bip300 script. In other words, since we select the UTXO with *all* of the money, we must make sure we pay all of the non-withdrawn money back into the sidechain.
291
+
# "Return *all* Change to Account" -- Sum of all inputs must equal the sum of all outputs. No traditional tx fee is possible. (The txn fee is paid via an OP TRUE output in the Bundle -- this allows the withdraw-ers to set the fee via the Bundle, and ACK it over 3 months like everything else.)
296
292
297
293
298
294
==Backward compatibility==
@@ -304,25 +300,20 @@ As a soft fork, older software will continue to operate without modification. No
304
300
305
301
==Deployment==
306
302
303
+
This BIP will be deployed via UASF-style block height activation.
307
304
308
-
This BIP will be deployed by "version bits" BIP9 with the name "hrescrow" and using bit 4.
0 commit comments