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
Copy file name to clipboardExpand all lines: bip-0300.mediawiki
+66-6
Original file line number
Diff line number
Diff line change
@@ -226,7 +226,7 @@ A sidechain fails to activate if:
226
226
227
227
Otherwise, the sidechain activates (Active is set to TRUE).
228
228
229
-
In the block in which the sidechain activates, the coinbase MUST include at least one 0-valued OP_TRUE. This output becomes the initial CTIP for the sidechain.
229
+
In the block in which the sidechain activates, the coinbase MUST include at least one 0-valued OP_DRIVECHAIN output. This output becomes the initial CTIP for the sidechain.
230
230
231
231
232
232
@@ -287,11 +287,15 @@ The upvote vector will code "abstain" as 0xFF (or 0xFFFF); it will code "alarm"
287
287
288
288
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 upvote vector would be { 07, 04 }. And M4 would be [0x6A,D77D1776,00,0006,0003].
289
289
290
-
The version number allows us to shrink the upvote vector in many cases. Version 0x00 requires a full two bytes per sidechain, but it always works. Version 0x01 uses half that (one byte per sidechain), and it works while all sidechains have fewer than 255 disputed withdrawals (ie, 99.99%+ of the time). Version 0x02 uses zero bytes (ie, 6 bytes for the whole M4) and sets this block's M4 equal to the previous block's M4. Version 0x03 upvotes only those withdrawals that are leading their rivals by at least 50 votes.
290
+
The version number allows us to shrink the upvote vector in many cases.
291
+
Version 0x00 omits the upvote vector entirely (ie, 6 bytes for the whole M4) and sets this block's M4 equal to the previous block's M4.
292
+
Version 0x01 uses one byte per sidechain, and can be used while all ACKed withdrawals have an index under 256 (ie, 99.99%+ of the time).
293
+
Version 0x02 uses a full two bytes per sidechain (each encoded in little endian), but it always works no matter how many withdrawl proposals exist.
294
+
Version 0x03 omits the upvote vector, and instead upvotes only those withdrawals that are leading their rivals by at least 50 votes.
291
295
292
296
If a sidechain has no pending bundles, then it is skipped over when M4 is created and parsed.
293
297
294
-
For example, an upvote vector of { 2 , N/A, 1 } would be represented as [0x6A,D77D1776,01,00,00]. It means: "upvote the first bundle in sidechain #1; and the first bundle in sidechain #3" (iff sidechains #2 has no bundles proposed).
298
+
For example, an upvote vector of { 2 , N/A, 1 } would be represented as [0x6A,D77D1776,01,01,00]. It means: "upvote the second bundle in sidechain #1; and the first bundle in sidechain #3" (iff sidechains #2 has no bundles proposed).
295
299
296
300
An upvote vector of { N/A, N/A, 4 } would be [0x6A,D77D1776,01,03].
297
301
@@ -394,7 +398,7 @@ Every time a deposit/withdrawal is made, the old CTIP is spent and a new one is
394
398
395
399
Every M5 is valid, as long as:
396
400
397
-
* It has at least one OP_TRUE output -- this becomes the new CTIP.
401
+
* It has exactly one OP_DRIVECHAIN output -- this becomes the new CTIP.
398
402
* The new CTIP has '''more''' coins in it, than before.
399
403
400
404
@@ -405,15 +409,71 @@ We come, finally, to the critical matter: where users can take their money *out*
405
409
M6 is invalid if:
406
410
407
411
* The blinded hash of M6 does NOT match one of the approved Bundle-hashes. (In other words: M6 must first be approved by 13,150 upvotes.)
408
-
* The first output of M6 is NOT an OP_TRUE. (This OP_TRUE becomes the new CTIP. In other words: all non-withdrawn coins are paid back to the sidechain.)
409
-
* The second output is NOT an OP_RETURN script of exactly 10 bytes, of which 8 bytes are a serialized Bitcoin amount.
412
+
* The first output of M6 is NOT an OP_DRIVECHAIN. (This OP_DRIVECHAIN becomes the new CTIP. In other words: all non-withdrawn coins are paid back to the sidechain.)
413
+
* The second output is NOT a zero-value OP_RETURN script of exactly 10 bytes, of which 8 bytes are a serialized Bitcoin amount.
410
414
* The txn fee of M6 is NOT exactly equal to the amount of the previous bullet point.
415
+
* There are additional OP_DRIVECHAIN outputs after the first one.
411
416
412
417
Else, M6 is valid.
413
418
414
419
(The point of the latter two bullet points, is to allow the bundle hash to cover the L1 transaction fee.)
415
420
421
+
===OP_DRIVECHAIN===
416
422
423
+
This proposal adds a single new opcode, OP_DRIVECHAIN, which has strict semantics for usage.
424
+
OP_NOP5 (0xb4) is redefined as OP_DRIVECHAIN if and only if the entire script is OP_DRIVECHAIN followed by a single-byte push and OP_TRUE (exactly 4 bytes).
425
+
The single-byte push contains the sidechain number.
426
+
Note that this is not a "script number", and cannot be OP_1..OP_16 or any other kind of push; it is also unsigned, and must not be padded even if over sidechain number 127.
427
+
The final OP_TRUE is to ensure this change remains a softfork:
428
+
without it, sidechain numbers 0 and 128 would cause the legacy script interpreter to fail.
429
+
430
+
If an OP_DRIVECHAIN input is spent, the additional rules for M5 or M6 (see above) must be enforced.
431
+
432
+
====Weight adjustments====
433
+
434
+
To account for the additional drivechain checks, each message adds to the block's weight:
435
+
436
+
{|class="wikitable"
437
+
! Message !! Additional weight
438
+
|-
439
+
| M1 || 840
440
+
|-
441
+
| M2 || 336
442
+
|-
443
+
| M3 || 848
444
+
|-
445
+
| M4 || ?
446
+
|-
447
+
| M5 || 340
448
+
|-
449
+
| M6 || 352
450
+
|}
451
+
452
+
<!--
453
+
get: 168 WU for 1 byte
454
+
delete: free?
455
+
create: 168 WU for 33 bytes
456
+
hash: 4 WU??
457
+
search outputs: ?
458
+
permanent "proposal rejected" lookup: infinite??
459
+
read prev block: a lot?? maybe store...
460
+
comparison: 4 WU?
461
+
encode script: ?
462
+
463
+
M1: 3 get, 2 create
464
+
M2: 1 get, 1 delete, 1 create
465
+
M3: 3 get, 1 delete, 2 create, 2 hash
466
+
for each coinbase output: search for prior M3 for this sidechain
467
+
lookup if M3 was ever rejected or paid in the past
468
+
for each prior proposed withdrawl: (included in 1 get+delete+create)
469
+
M4: 1 get
470
+
+ for every proposed withdraw, 1 get, 1 delete, 1 create, 1 add
0 commit comments