bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 5쪽 중 4쪽
the gossip protocol can
robustly spread a message throughout the network in O ( log ( n )) time, even with up to 1/3
byzantine nodes. When there is network partition, consensus for a checkpoint may not be able
to reach finalization. However, after the network partition is over, the guardian pool can
proceed to finalize the next checkpoint block. If consensus can then be reached, all the blocks
up to the next checkpoint are considered finalized. Hence the finalization process will progress
eventually.
Messaging Complexity : The aggregated signature gossip protocol runs for L iterations, which
is in the order of O ( log ( n )) . In each iteration, the guardian needs to send message ( , ) to σi ci
all its neighboring guardians. Depending on the network topology, typically it is reasonable to
assume that for an average node, the number of neighboring nodes is a constant (i.e. the
number of neighbors does not grow as the total number of nodes grows). Hence the number
of message a node needs to send/receive to finalize a checkpoint is in the order of O ( log ( n )) ,
which is much better than the O ( n ) complexity in the naive all-to-all signature broadcasting
24
implementation. We do acknowledge that each message between two neighboring guardians
contains an n dimensional signer vector , where each entry of is an integer smaller than ci ci
prime p . However, we note that this vector can be represented rather compactly since most of
its entries are small integers ( ≪ p ) in practice.
To get a more concrete idea of the messaging complexity, let us work out an example. Assume
that we pick a 170-bit long prime number p for the BLS signature, which can provide security
comparable to that of a 1024-bit RSA signature. And there are 1000 guardians in total. Under
this setting, can be represented with about twenty kilobytes without any compression. ci
Since most of the entries of are far smaller than p , can be compressed very effectively to ci ci
a couple kilobytes long. Plus the aggregated signature, the size of each message is typically in
the kilobytes range. Moreover, if we assume on average an guardian connects to 20 other
guardians, then L can be as small as 5 (more than twice of log 20 (1000) = 2.3 ). This means
finalizing one checkpoint just requires a guardian to send/receive around 100 messages
to/from its neighbors, each about a couple kilobytes long. This renders the aggregated
signature gossip protocol rather practical to implement and can easily scale to thousands of
guardian nodes. For further analysis, please also refer to our multi-level BFT technical report.
Reward and Penalty for Validators and Guardians
The token reward and penalty structure is essential to encourage nodes to participate in the
consensus process, and not to deviate from the protocol.
Both the validators and guardians can obtain a token reward. Each block includes a special
Coinbase transaction that deposits newly minted tokens to the validator and guardian
addresses. All the validators can get a share of tokens for each block. For guardians, rewarding
every guardian for each block might not be practical since their number is large. Instead, we
propose the following algorithm to randomly pick a limited number of guardians as the reward
recipient for each block.
Denote the height of the newly proposed block by l , and cp is the most recently finalized
checkpoint. The proposer should have received the aggregated signature and σcp
corresponding signer vector for checkpoint cp . Upon validating , the proposer can ccp (σ , c )cp cp
check the following condition for each guardian whose corresponding entry in vector is not ccp
zero (i.e. that guardian signed the checkpoint)
τ H(pk, σ || B )i cp l−1 ≤
where is the hash of the block with height , and is the same Bl−1 l −1 H :G ×{0, 1} * →G
hash function used in the BLS signature algorithm. If the inequality holds, the proposer adds
the guardian with public key pk i to the Coinbase transaction recipient list. Threshold is τ
chosen properly such that only a small number of guardians are included. The proposer should
also attach to the Coinbase transaction as the proof for the reward. (σ , c )cp cp
The Theta ledger also enforces a token penalty should any malicious behavior be detected. In
particular, if a block proposer signs conflicting blocks for the same height, or if a validator votes
for different blocks of the same height, they should be penalized. Earlier we mentioned that to
become either a validator or a guardian, a node needs to lock up a certain amount of tokens for
a period of time. The penalty will be deducted from their locked tokens. The node that detects
the malicious behavior can submit a special Slash transaction to the blockchain. The proof of
25
the malicious behavior (e.g. signatures for conflicting blocks) should be attached to the Slash
transaction. The penalty tokens will be pulled from the malicious node and awarded to the
node that submitted the first Slash transaction.
In the unlikely event that more than one-third of the validators are compromised, the
malicious validators can attempt to perform the double spending attack by forking the
blockchain from a block that is settled but not yet finalized. However, this is detectable by the
guardian pool, since forking will generate multiple blocks with the same height, but signed by
more than two-third of the validators. In this case, the validators that conducted the double
signing will be penalized, and the entire validator committee will be re-elected. After the
validator committee is reinstated, the blockchain can continue to advance from the most
recent finalized checkpoint.
Turing-Complete Smart Contract Support
This Theta Ledger offers a smart contract runtime environment fully compatible with the
Ethereum Virtual Machine . It provides full-fledged support for Turing-Complete smart 18
contracts. Solidity-based Ethereum smart contracts can be ported to the Theta Ledger with
little effort. Solidity has grown a large developer community and the prospect of allowing 19
that proven talent pool to also contribute to Theta without reinventing the wheel was a prime
consideration in enabling compatibility with the Ethereum Virtual Machine.
Smart contracts enable rich user experiences and new attribution models for video platform
DApps built on the Theta Ledger. For example, video platforms can write smart contracts for
loyalty programs to engage users. Based on users’ activity, or the volume of video segments /
data they have relayed, platform DApps may promote users to a higher tier, which unlocks
certain privileges or exclusive capabilities. As another example, video platforms can issue
virtual items backed by the ledger blockchain (e.g. a virtual rose) for gifting to their favorite
content creators. To expand on such a concept, built on the “non-fungible token” standard, the
virtual items could be rare or entirely unique, such that they are essentially “crypto
collectibles”, which can be kept as trophies or traded for other sought after collectibles, all
without additional permissions from 3rd parties.
Moreover, video platforms are able to write smart contracts that enable more fluid
payment-consumption models, such as pay-as-you-go or per-use models. Instead of
traditional annual or monthly subscriptions, user consumption can be priced at a bite-sized
granularity, such that users only need to pay for what they use. This is a feasible way to allow
low-priced, short-form content to be transacted in an economically sensible way, that accrues
benefits to both the video platform and user. Theta Ledger’s properties of tracking
micropayments and video segments enables such smart contracts to be executed.
Smart contracts can also be designed to the benefit of content creators (e.g. user-generated
content producers, larger production studios) as a way to fairly and transparently distribute
royalties. The traditional royalty settlement processes, with all their complexities and
obscurities, can be accommodated with clear smart contract terms that are mutually agreed
upon by creators and distributors - and made available to users that consume the content.
18
https://github.com/ethereum/wiki/wiki/Ethereum-Virtual-Machine-(EVM)-Awesome-List
19
https://solidity.readthedocs.io/
26
Leveraging smart contracts on the Theta Ledger to enable fully digitized item ownership,
innovative payment-consumption models, and transparent royalty distributions provide an
additional layer of social and economic interactivity that supplements the core functionality of
video/content delivery.
Off-Chain Micropayment Support
As discussed in the introduction section, support for high transaction throughput is a must for
a video streaming focused blockchain. We build the support for off-chain payment directly into
the ledger to facilitate high volumes of transactions.
Resource Oriented Micropayment Pool
We have designed and implemented an off-chain “ Resource Oriented Micropayment Pool ”
that is purpose-built for video streaming. It allows a user to create an off-chain micropayment
pool that any other user can withdraw from using off-chain transactions, and is double-spend
resistant. It is much more flexible compared to off-chain payment channels. In particular, for
the video streaming use case, it allows a viewer to pay for video content pulled from multiple
caching nodes without on-chain transactions. By replacing on-chain transactions with
off-chain payments, the built-in “Resource Oriented Micropayment Pool” significantly
improves the scalability of the blockchain.
The following scenario and diagram provide a comprehensive walkthrough of how the
Resource Oriented Micropayment Pool works in application.
27
Figure 7 . Resource Oriented Micropayment Pool shows viewer Alice making off-chain transactions
to cachers Bob and Carol for video chunks
● Step 1. Micropayment pool creation : As the first step, Alice publishes an on-chain
transaction to create a micropayment pool with a time-lock and a slashable collateral.
CreatePool ( resourceId , deposit , collateral , duration )
A couple things to be noted. To create the pool, Alice needs to specify the “Resource
ID” resourceId that uniquely represents the digital content she intends to retrieve. It
may refer to a video file, or a live stream.
The deposit amount needs to be at least the total value of the resource to be retrieved.
For instance, if the resource is a video file which is worth 10 tokens, then the deposit
has to be at least 10 tokens.
28
The collateral is required to discourage Alice from double spending. If a double
spending attempt from Alice is detected by the validators of the blockchain, the
collateral will be slashed. Later in the blogpost we will show that if collateral> deposit ,
the net return of a double spend is always negative, and hence any rational user will
have no incentive to double spend.
The duration is a time-lock similar to that of a standard payment channel. Any
withdrawal from the payment pool has to be before the time-lock expires.
The blockchain returns Alice the Merkle proof of the CreatePool transaction after it
has been committed to the blockchain, as well as createPoolTxHash , the transaction
hash of the CreatePool transaction.
● Step 2. Initial handshake between peers : Whenever Alice wants to retrieve the
specified resource from a peer (Bob, Carol, or David, etc.). She sends the Merkle proof
of the on-chain CreatePool transaction to that peer. The recipient peer verifies the
Merkle proof to ensure that the pool has sufficient deposit and collateral for the
requested resource, and both parties can proceed to the next steps.
● Step 3. Off-chain micropayments : Alice signs ServicePayment transactions and sends
them to the peers off-chain in exchange for parts of the specified resource (e.g. a
piece of the video file, a live stream segment, etc.). The ServicePayment transaction
contains the following data:
targetAddress, transferAmount , createPoolTxHash , targetSettlementSequence,
Sign ( SK A , targetAddress || transferAmount || createPoolTxHash ||
targetSettlementSequence )
The targetAddress is the address of the peer that Alice retrieves the resource from, and
the transferAmount is the amount of token payment Alice intends to send. The
targetSettlementSequence is to prevent a replay attack. It is similar to the “nonce”
parameter in an Ethereum transaction. If a target publishes a ServicePayment
transaction to the blockchain (see the next step), its targetSettlementSequence needs to
increment by one.
The recipient peer needs to verify the off-chain transactions and the signatures. Upon
validation, the peer can send Alice the resource specified by the CreatePool
transaction.
Also, we note that the off-chain ServicePayment transactions are sent directly
between two peers. Hence there is no scalability bottleneck for this step.
● Step 4. On-chain settlement : Any peer (i.e. Bob, Carol, or David, etc) that received the
ServicePayment transactions from Alice can publish the signed transactions to the
blockchain anytime before the timelock expires to withdraw the tokens. We call the
ServicePayment transactions that are published the “on-chain settlement”
transactions.
Note that the recipient peers needs to pay for the gas fee for the on-chain settlement
transaction. To pay less transaction fees, they would have the incentive to publish
on-chain settlements only when necessary, which is beneficial to the scalability of the
network.
29
We note that no on-chain transaction is needed when Alice switches from one peer to another
to retrieve the resource. In the video streaming context, this means the viewer can switch to
any caching node at any time without making an on-chain transaction that could potentially
block or delay the video stream delivery. As shown in the figure, in the event that Bob leaves,
Alice can switch to Carol after receiving k chunks from Bob, and keep receiving video segments
without an on-chain transaction.
Moreover, the total amount of tokens needed to create the micropayment pool is ( collateral+
deposit ) , which can be as low as twice of the value of the requested resource, no matter how
many peers Alice retrieves the resource from. Using computational complexity language, the
amount of reserved token reduces from O ( n ) to O (1) compared to the unidirectional payment
channel approach, where n is the number of peers Alice retrieves the resource from.
Double Spending Detection and Penalty Analysis
To prevent Alice, the creator of the micropayment pool from double spending, we need to 1) be
able to detect double spending, and 2) ensure that the net value Alice gains from double
spending is strictly negative.
Detecting double spending is relatively straightforward. The validators of the Theta Network
check every on-chain transaction. If a remaining deposit in the micropayment pool cannot
cover the next consolidated payment transaction signed by both Alice and another peer, the
validators will consider that Alice has conducted a double spend.
Next, we need to make Alice worse off if she double spends. This is where the collateral comes
in. Earlier, we mentioned that the amount of collateral tokens has to be larger than the
deposit. And here is why.
In Figure 8 below, Bob, Carol, and David are honest. Alice is malicious. Even worse, she colludes
with another malicious peer Edward. Alice exchanges partially signed transactions with Bob,
Carol, and David for the specified resource. Since Alice gains no extra value for the duplicated
resource, the maximum value she gets from Bob, Carol, and David is at most the deposit
amount. As Alice colludes with Edward, she can send Edward the full deposit amount. She then
asks Edward to commit the settlement transaction before anyone else and return her the
deposit later. In other words, Alice gets the resource which is worth at most the deposit amount
for free, before the double spending is detected. Later when Bob, Carol, or David commit the
settlement transaction, the double spending is detected, and the full collateral amount will be
slashed. Hence, the net return for Alice is
net Alice = deposit collateral
Therefore, we can conclude that for this scenario, as long as collateral > deposit , Alice’s net
return is negative. Hence, if Alice is rational, she would not have any incentive to double spend.
We can conduct similar analysis for other cases. The details are omitted here, but it can be
shown that in all cases Alice’s net return is always negative if she conducts a double spend.
Another case is that Alice is honest, but some of her peers are malicious. After Alice sends a
micropayment to one of those peers, it might not return Alice the resource she wants. In this
case, Alice can turn to another peer to get the resource. Since each incremental micropayment
can be infinitesimally small in theory, Alice’s loss can be made arbitrarily small.
30
Figure 8 . Malicious Actor Detection and Penalty shows malicious actor Alice attempting to
make a double spend and the resulting penalty she receives
31
Ledger Storage System
Using a public ledger to facilitate the micropayments for streaming is challenging, not only
because of high transaction throughput, but also for storage space management. To achieve
the “pay-per-byte” granularity, each viewer could send out a payment every few seconds. With
even a moderate ten thousand concurrent users, it could generate a couple thousands of
transactions per second. Even with the off-chain payment pool which already reduces the
amount of on-chain transactions dramatically, the block and state data could still balloon
rather quickly.
We have designed a storage system that addresses this problem, and can adapt to different
types of machines, be it a powerful server cluster running in data centers, or a commodity
desktop PC.
Storage Microservice Architecture
To harness the processing and storage power of server clusters, the key design decision is to
adopt the popular microservice architecture commonly seen for modern web service backends,
where different modules of the ledger can be configured to run on different machines. In
particular, the consensus module and the storage module can be separated. Potentially the
consensus module can run on multiple machines using the MapReduce framework to process
transactions in parallel.
The Theta Ledger stores both the transaction blocks and the account state history, similar to
Ethereum. The bottom layer of the storage module is a key value store. The Theta Ledger
implements the interfaces for multiple databases, ranging from single machine LevelDB to
cloud based NoSQL database such as MongoDB, which can store virtually unlimited amount of
data. Thus the ledger can run on one single computer, and can also be configured to run on
server clusters.
History Pruning
While the microservice architecture suits the powerful server clusters well, we still face
storage space constraints when running the ledger on a lower-end home PC. We have
designed several techniques to reduce the storage consumption.
Similar to Ethereum, the Theta Ledger stores the entire state for each block, and the state tree
root is saved in the header of the corresponding block. To reduce the space consumed by the
state history, the Theta Ledger implements state history pruning, which leverages a technique
called reference counting illustrated in the figure below.
32
Figure 9 . State history pruning with reference counting
The ledger state (i.e. the token balance of each account, etc.) is stored using a Merkle-Patricia
trie. Figure 9(a) depicts the initial state tree, whose root is denot프로젝트로 돌아가기