|
|
|
@@ -16,7 +16,7 @@ LBRY offers a significant improvement over both options. It uses a blockchain to
|
|
|
|
|
|
|
|
|
|
### Status
|
|
|
|
|
|
|
|
|
|
LBRY has been in public use since June 2016. As of February 2019, approximately 750,000 pieces of digital content have been published via the protocol. Tens of thousands of users access hundreds of thousands of pieces of content each month, downloading and uploading terabytes of data. Graphical browsers and wallets are available for all major operating systems and can be downloaded on at [lbry.com/get](https://lbry.com/get).
|
|
|
|
|
LBRY has been in public use since June 2016. As of May 2020, over 3.3 million pieces of digital content have been published via the protocol. Millions of users access this content each month, downloading and uploading terabytes of data. Graphical browsers and wallets are available for all major operating systems and can be downloaded at [lbry.com/get](https://lbry.com/get).
|
|
|
|
|
|
|
|
|
|
### Overview
|
|
|
|
|
|
|
|
|
@@ -75,7 +75,7 @@ Our blockchain serves three key purposes:
|
|
|
|
|
|
|
|
|
|
### Stakes
|
|
|
|
|
|
|
|
|
|
A _stake_ is a a single entry in the blockchain that commits credits toward a name. The two types of stakes are [_claims_](#claims) and [_supports_](#supports).
|
|
|
|
|
A _stake_ is a single entry in the blockchain that commits credits toward a name. The two types of stakes are [_claims_](#claims) and [_supports_](#supports).
|
|
|
|
|
|
|
|
|
|
All stakes have these properties:
|
|
|
|
|
|
|
|
|
@@ -179,7 +179,7 @@ The _root hash_ is the hash of the root node. It is stored in the header of each
|
|
|
|
|
|
|
|
|
|
Multiple claims can exist for the same name. They are all stored in the leaf node for that name. See [Claim Ordering](#claim-ordering)
|
|
|
|
|
|
|
|
|
|
For more details on the specific claimtrie implementation, see [the source code](https://github.com/lbryio/lbrycrd/blob/master/src/claimtrie.cpp).
|
|
|
|
|
For more details on the specific claimtrie implementation, see [the source code](https://github.com/lbryio/lbrycrd/blob/v0.17.3.2/src/claimtrie.cpp).
|
|
|
|
|
|
|
|
|
|
#### Statuses {#stake-statuses}
|
|
|
|
|
|
|
|
|
@@ -303,18 +303,20 @@ lbry://@lbry/meet-lbry
|
|
|
|
|
A claim for this name with this claim ID. Partial prefix matches are allowed (see [URL Resolution](#url-resolution)).
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
lbry://meet-lbry#7a0aa95c5023c21c098
|
|
|
|
|
lbry://meet-lbry#7a
|
|
|
|
|
lbry://@lbry#3f/meet-lbry
|
|
|
|
|
lbry://meet-lbry:7a0aa95c5023c21c098
|
|
|
|
|
lbry://meet-lbry:7a
|
|
|
|
|
lbry://@lbry:3f/meet-lbry
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
*Note: in a previous version of this spec, the `#` character was used to signify the claim ID portion of the url. This character is now deprecated and will stop being supported in the future.*
|
|
|
|
|
|
|
|
|
|
##### Sequence
|
|
|
|
|
|
|
|
|
|
The _n_th accepted claim for this name. _n_ must be a positive number. This can be used to reference claims in the order in which they were made, rather than by the amount of credits backing a claim.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
lbry://meet-lbry:1
|
|
|
|
|
lbry://@lbry:1/meet-lbry
|
|
|
|
|
lbry://meet-lbry*1
|
|
|
|
|
lbry://@lbry*1/meet-lbry
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
##### Amount Order
|
|
|
|
@@ -355,8 +357,8 @@ StreamClaimName ::= NameChar+
|
|
|
|
|
ChannelClaimName ::= '@' NameChar+
|
|
|
|
|
|
|
|
|
|
Modifier ::= ClaimID | Sequence | AmountOrder
|
|
|
|
|
ClaimID ::= '#' Hex+
|
|
|
|
|
Sequence ::= ':' PositiveNumber
|
|
|
|
|
ClaimID ::= ':' Hex+
|
|
|
|
|
Sequence ::= '*' PositiveNumber
|
|
|
|
|
AmountOrder ::= '$' PositiveNumber
|
|
|
|
|
|
|
|
|
|
Query ::= '?' QueryParameterList
|
|
|
|
@@ -372,7 +374,7 @@ PositiveNumber ::= PositiveDigit Digit*
|
|
|
|
|
HexAlpha ::= [abcdef]
|
|
|
|
|
Hex ::= (Digit | HexAlpha)+
|
|
|
|
|
|
|
|
|
|
NameChar ::= Char - [=&#:$@%?/] /* any character that is not reserved */
|
|
|
|
|
NameChar ::= Char - [=&#:*$@%?/] /* any character that is not reserved */
|
|
|
|
|
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@@ -454,7 +456,7 @@ OP_CLAIM_NAME Fruit Apple OP_2DROP OP_DROP OP_DUP OP_HASH160 <address> OP_EQUALV
|
|
|
|
|
|
|
|
|
|
##### OP\_UPDATE\_CLAIM
|
|
|
|
|
|
|
|
|
|
`OP_UPDATE_CLAIM` updates a claim by replacing its metadata. An update transaction has an added requirement that it must spend the output for the existing claim that it wishes to update. Otherwise, it is considered invalid and will not make it into the claimtrie. Thus it must have the following redeem script:
|
|
|
|
|
`OP_UPDATE_CLAIM` updates a claim by replacing its metadata. An update transaction has an added requirement that it must spend the output for the existing claim that it wishes to update. Otherwise, it is considered invalid and will not make it into the claimtrie. Thus, it must have the following redeem script:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
<signature> <pubKeyForPreviousAddress>
|
|
|
|
@@ -510,21 +512,21 @@ The target block time was lowered from 10 minutes to 2.5 minutes to facilitate f
|
|
|
|
|
|
|
|
|
|
#### Difficulty Adjustment
|
|
|
|
|
|
|
|
|
|
The proof-of-work target is adjusted every block to better adapt to sudden changes in hash rate. The exact adjustment algorithm can be seen [here](https://github.com/lbryio/lbrycrd/blob/master/src/lbry.cpp).
|
|
|
|
|
The proof-of-work target is adjusted every block to better adapt to sudden changes in hash rate. The exact adjustment algorithm can be seen [here](https://github.com/lbryio/lbrycrd/blob/v0.17.3.2/src/lbry.cpp).
|
|
|
|
|
|
|
|
|
|
#### Block Hash Algorithm
|
|
|
|
|
|
|
|
|
|
LBRY uses a combination of SHA-256, SHA-512, and RIPEMD-160. The exact hashing algorithm can be seen [here](https://github.com/lbryio/lbrycrd/blob/master/src/hash.cpp#L18).
|
|
|
|
|
LBRY uses a combination of SHA-256, SHA-512, and RIPEMD-160. The exact hashing algorithm can be seen [here](https://github.com/lbryio/lbrycrd/blob/v0.17.3.2/src/hash.cpp#L15).
|
|
|
|
|
|
|
|
|
|
#### Block Rewards
|
|
|
|
|
|
|
|
|
|
The block reward schedule was adjusted to provide an initial testing period, a quick ramp-up to max block rewards, then a logarithmic decay to 0. The source for the algorithm is [here](https://github.com/lbryio/lbrycrd/blob/master/src/main.cpp#L1594).
|
|
|
|
|
The block reward schedule was adjusted to provide an initial testing period, a quick ramp-up to max block rewards, then a logarithmic decay to 0. The source for the algorithm is [here](https://github.com/lbryio/lbrycrd/blob/v0.17.3.2/src/validation.cpp#L1025).
|
|
|
|
|
|
|
|
|
|
#### Addresses
|
|
|
|
|
|
|
|
|
|
The address version byte is set to `0x55` for standard (pay-to-public-key-hash) addresses and `0x7a` for multisig (pay-to-script-hash) addresses. P2PKH addresses start with the letter `b`, and P2SH addresses start with `r`.
|
|
|
|
|
|
|
|
|
|
All the chain parameters are defined [here](https://github.com/lbryio/lbrycrd/blob/master/src/chainparams.cpp).
|
|
|
|
|
All the chain parameters are defined [here](https://github.com/lbryio/lbrycrd/blob/v0.17.3.2/src/chainparams.cpp).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Metadata
|
|
|
|
@@ -533,9 +535,9 @@ Metadata is structured information about a stream or channel separate from the c
|
|
|
|
|
|
|
|
|
|
Metadata is stored in a serialized binary format using [Protocol Buffers](https://developers.google.com/protocol-buffers/). This allows for metadata to be:
|
|
|
|
|
|
|
|
|
|
- **Extensibile**. Metadata can encompass thousands of fields for dozens of types of content. It must be efficient to both modify the structure and maintain backward compatibility.
|
|
|
|
|
- **Extensible**. Metadata can encompass thousands of fields for dozens of types of content. It must be efficient to both modify the structure and maintain backward compatibility.
|
|
|
|
|
- **Compact**. Blockchain space is expensive. Data must be stored as compactly as possible.
|
|
|
|
|
- **Interoperabile**. Metadata will be used by many projects written in different languages.
|
|
|
|
|
- **Interoperable**. Metadata will be used by many projects written in different languages.
|
|
|
|
|
|
|
|
|
|
The serialized metadata may be cryptographically signed to indicate membership in a channel. See [Channels](#channels) for more info.
|
|
|
|
|
|
|
|
|
@@ -628,7 +630,7 @@ The purpose of channels is to allow content to be clustered under a single pseud
|
|
|
|
|
|
|
|
|
|
#### Signing
|
|
|
|
|
|
|
|
|
|
A claim is considered part of a channel when the metadata in it's value is signed by the channel's private key. Here's the structure of a signed value:
|
|
|
|
|
A claim is considered part of a channel when the metadata in its value is signed by the channel's private key. Here's the structure of a signed value:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
field | size | description
|
|
|
|
@@ -674,7 +676,6 @@ format | description
|
|
|
|
|
The blockchain treats metadata as an opaque series of bytes. Clients should not trust the metadata they read from the blockchain. Each client is responsible for correctly encoding and decoding the metadata, and for validating its structure and signatures. This allows evolution of the metadata definition without changes to blockchain consensus rules.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Data
|
|
|
|
|
|
|
|
|
|
Files published using LBRY are stored in a distributed fashion by the clients participating in the network. Each file is split into many small pieces. Each piece is encrypted and [announced](#announce) to the network. The pieces may also be uploaded to other hosts on the network that specialize in rehosting content.
|
|
|
|
@@ -748,7 +749,6 @@ The `version` field is always 1. It is intended to signal structure changes in f
|
|
|
|
|
Every stream must have at least two blobs - the manifest blob and a content blob. Consequently, zero-length streams are not allowed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### Stream Encoding
|
|
|
|
|
|
|
|
|
|
A file must be encoded into a stream before it can be published. Encoding involves breaking the file into chunks, encrypting the chunks into content blobs, and creating the manifest blob. Here are the steps:
|
|
|
|
@@ -760,7 +760,7 @@ A file must be encoded into a stream before it can be published. Encoding involv
|
|
|
|
|
##### Content Blobs
|
|
|
|
|
|
|
|
|
|
1. Break the file into chunks of at most 2097151 bytes.
|
|
|
|
|
1. Generate a random 32-byte initialization vector (IV) for each chuck.
|
|
|
|
|
1. Generate a random 32-byte initialization vector (IV) for each chunk.
|
|
|
|
|
1. Pad each chunk using PKCS7 padding.
|
|
|
|
|
1. Encrypt each chunk with AES-CBC using the stream key and the IV for that chunk.
|
|
|
|
|
1. An encrypted chunk is a blob.
|
|
|
|
@@ -780,14 +780,13 @@ An implementation of this process is available [here](https://github.com/lbryio/
|
|
|
|
|
|
|
|
|
|
Decoding a stream is like encoding in reverse, and with the added step of verifying that the expected blob hashes match the actual data.
|
|
|
|
|
|
|
|
|
|
1. Verify that the hash of the manifest blob and matches the stream hash.
|
|
|
|
|
2. Parse the JSON in manifest blob.
|
|
|
|
|
1. Verify that the hash of the manifest blob matches the stream hash.
|
|
|
|
|
2. Parse the JSON in the manifest blob.
|
|
|
|
|
3. Verify the hashes of the content blobs.
|
|
|
|
|
4. Decrypt and remove the padding from each content blob using the stream key and IVs in the manifest.
|
|
|
|
|
5. Concatenate the decrypted chunks in order.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Announce
|
|
|
|
|
|
|
|
|
|
After a stream is encoded, it must be _announced_ to the network. Announcing is the process of letting other nodes on the network know that a client has content available for download. LBRY tracks announced content using a distributed hash table.
|
|
|
|
@@ -847,8 +846,6 @@ Upload sends a blob to the server. If uploading many blobs, the client should us
|
|
|
|
|
The protocol methods and message types are defined in detail [here](https://github.com/lbryio/lbry.go/blob/master/blobex/blobex.proto).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Reflectors and Data Markets
|
|
|
|
|
|
|
|
|
|
In order for a client to download content, there must be hosts online that have the content the client wants, when the client wants it. To incentivize the continued hosting of data, the blob exchange protocol supports data upload and payment for data. _Reflectors_ are hosts that accept data uploads. They rehost (reflect) the uploaded data and charge for downloads.
|
|
|
|
@@ -864,25 +861,25 @@ The current version of the protocol does not support sophisticated price negotia
|
|
|
|
|
|
|
|
|
|
Here is a step-by-step example to illustrate how competing claims activate and are ordered. All stakes are for the same name.
|
|
|
|
|
|
|
|
|
|
**Block 13:** Claim A for 10LBC is accepted. It is the first claim, so it immediately becomes active and controlling.
|
|
|
|
|
**Block 13:** Claim A for 10 LBC is accepted. It is the first claim, so it immediately becomes active and controlling.
|
|
|
|
|
<br>State: A(10) is controlling
|
|
|
|
|
|
|
|
|
|
**Block 1001:** Claim B for 20LBC is accepted. Its activation height is `1001 + min(4032, floor((1001-13) / 32)) = 1001 + 30 = 1031`.
|
|
|
|
|
**Block 1001:** Claim B for 20 LBC is accepted. Its activation height is `1001 + min(4032, floor((1001-13) / 32)) = 1001 + 30 = 1031`.
|
|
|
|
|
<br>State: A(10) is controlling, B(20) is accepted.
|
|
|
|
|
|
|
|
|
|
**Block 1010:** Support X for 14LBC for claim A is accepted. Since it is a support for the controlling claim, it activates immediately.
|
|
|
|
|
**Block 1010:** Support X for 14 LBC for claim A is accepted. Since it is a support for the controlling claim, it activates immediately.
|
|
|
|
|
<br>State: A(10+14) is controlling, B(20) is accepted.
|
|
|
|
|
|
|
|
|
|
**Block 1020:** Claim C for 50LBC is accepted. The activation height is `1020 + min(4032, floor((1020-13) / 32)) = 1020 + 31 = 1051`.
|
|
|
|
|
**Block 1020:** Claim C for 50 LBC is accepted. The activation height is `1020 + min(4032, floor((1020-13) / 32)) = 1020 + 31 = 1051`.
|
|
|
|
|
<br>State: A(10+14) is controlling, B(20) is accepted, C(50) is accepted.
|
|
|
|
|
|
|
|
|
|
**Block 1031:** Claim B activates. It has 20LBC, while claim A has 24LBC (10 original + 14 from support X). There is no takeover, and claim A remains controlling.
|
|
|
|
|
**Block 1031:** Claim B activates. It has 20 LBC, while claim A has 24 LBC (10 original + 14 from support X). There is no takeover, and claim A remains controlling.
|
|
|
|
|
<br>State: A(10+14) is controlling, B(20) is active, C(50) is accepted.
|
|
|
|
|
|
|
|
|
|
**Block 1040:** Claim D for 300LBC is accepted. The activation height is `1040 + min(4032, floor((1040-13) / 32)) = 1040 + 32 = 1072`.
|
|
|
|
|
**Block 1040:** Claim D for 300 LBC is accepted. The activation height is `1040 + min(4032, floor((1040-13) / 32)) = 1040 + 32 = 1072`.
|
|
|
|
|
<br>State: A(10+14) is controlling, B(20) is active, C(50) is accepted, D(300) is accepted.
|
|
|
|
|
|
|
|
|
|
**Block 1051:** Claim C activates. It has 50LBC, while claim A has 24LBC, so a takeover is initiated. The takeover height for this name is set to 1051, and therefore the activation delay for all the claims becomes `min(4032, floor((1051-1051) / 32)) = 0`. All the claims become active. The totals for each claim are recalculated, and claim D becomes controlling because it has the highest total.
|
|
|
|
|
**Block 1051:** Claim C activates. It has 50 LBC, while claim A has 24 LBC, so a takeover is initiated. The takeover height for this name is set to 1051, and therefore the activation delay for all the claims becomes `min(4032, floor((1051-1051) / 32)) = 0`. All the claims become active. The totals for each claim are recalculated, and claim D becomes controlling because it has the highest total.
|
|
|
|
|
<br>State: A(10+14) is active, B(20) is active, C(50) is active, D(300) is controlling.
|
|
|
|
|
|
|
|
|
|
### URL Resolution Examples
|
|
|
|
@@ -899,7 +896,7 @@ _--_ | apple | 690eea | 10
|
|
|
|
|
@Bryan | _--_ | 0da517 | 1
|
|
|
|
|
@Chris | _--_ | b3f7b1 | 1
|
|
|
|
|
@Chris | banana | fc861c | 1
|
|
|
|
|
@Arthur | apple | 37ee1 | 20
|
|
|
|
|
@Arthur | apple | a37ee1 | 20
|
|
|
|
|
@Bryan | cherry | a18bca | 10
|
|
|
|
|
@Chris | _--_ | 005a7d | 100
|
|
|
|
|
@Arthur | cherry | d39aa0 | 20
|
|
|
|
@@ -912,16 +909,15 @@ URL | Claim ID
|
|
|
|
|
`lbry://banana` | 714a3f
|
|
|
|
|
`lbry://@Chris` | 005a7d
|
|
|
|
|
`lbry://@Chris/banana` | _not found_ (the controlling `@Chris` does not have a `banana`)
|
|
|
|
|
`lbry://@Chris:1/banana` | fc861c
|
|
|
|
|
`lbry://@Chris:#fc8/banana` | fc861c
|
|
|
|
|
`lbry://@Chris*1/banana` | fc861c
|
|
|
|
|
`lbry://@Chris:fc8/banana` | fc861c
|
|
|
|
|
`lbry://cherry` | bfaabb
|
|
|
|
|
`lbry://@Arthur/cherry` | d39aa0
|
|
|
|
|
`lbry://@Bryan` | 0da517
|
|
|
|
|
`lbry://banana$1` | 714a3f
|
|
|
|
|
`lbry://banana$2` | fc861c
|
|
|
|
|
`lbry://banana$3` | _not found_
|
|
|
|
|
`lbry://@Arthur:1` | b7bab5
|
|
|
|
|
|
|
|
|
|
`lbry://@Arthur*1` | b7bab5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Additional Resources
|
|
|
|
@@ -931,7 +927,6 @@ URL | Claim ID
|
|
|
|
|
- [lbry.com](https://lbry.com) is an application built on top of LBRY. It's one example of the type of end-to-end experience that is possible to create using this technology.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<pre class="pdf-hide" style="font: 10px/5px monospace;overflow:hidden;text-align: center;margin: 10rem 0">
|
|
|
|
|
|
|
|
|
|
++
|
|
|
|
|