or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
🔮💸🌊 Plasma Cashflow
⚠️⚠️⚠️ WORK IN PROGRESS ⚠️⚠️⚠️
Introduction
Plasma Cashflow is an adaptation of Plasma Cash, draws from Plasma Debit, and is based around Plasma Cash defragmentation.
This document describes the process of depositing, transacting, and exiting the Plasma Cashflow chain. Throughout this process it will provide details regarding how each component can be implemented.
🏦 Deposit
The Plasma contract will live on the Ethereum mainnet. Tokens can be transferred to be owned by this contract. Upon transfer the Plasma contract will issue new tokens on the Plasma chain.
Issuance of Plasma chain tokens is done in two steps:
🔀 Transact
Transaction Format
Send
Send transactions can specify a number of transaction input ranges & send them to a single recipient. Note that all of the input ranges must be contiguous & owned by the same address.
Swap
Swap transactions are comprised of a number of unsigned send transactions. All owners of all tokens must have signed the swap signatures.
Defragmentation
Any number of contiguous tokens owned by the same private key can be exited without extra storage required. Exiting tokens
(100-500)
is the same gas cost on Ethereum as exiting tokens(100-5000000)
. However, when tokens are not contiguous each segment adds significant gas usage. For example, exiting(0-500)
and(1000-1500)
is two times more expensive than exiting(0-1000)
.Defragmentation refers to the process of shifting tokens which are owned by a particular owner such that they are contiguous. Strategies can be developed (client-side) to 1) increase the number of contiguous tokens, and 2) avoid creating unnecessary fragmentation of tokens ownership.
To reduce fragmentation we must reduce the number of adjacent tokens. However, while transacting we will often increase the number of adjacencies. The growth of adjacencies can be modeled with:
An example of this can be seen here:
We can also use atomic swaps to route payments as a way to avoid creating more adjacencies. eg:
Validity Proofs
Like in Plasma Cash, token histories grow linearly with the number of blocks. This means that validating a particular token can get extremely expensive. Some ways to address these concerns are zkSNARKs, Plasma XT-style checkpointing, and block validity bonds
⬛ Plasma Blocks
Transaction Tree Structure
As with Plasma Cash, transactions are periodically merklized and then committed on chain. However, the structure of the merkle tree has been updated for simplicity and efficiency gains.
The tree is structured as a merkle-sum-tree where the leaf nodes are separated into ranges which have either been effected by a transaction or remained untouched. Then within each leaf, there is a list of transactions which effect that leaf's range. The merkle-sum-tree guarantees that these ranges are positioned correctly & include all tokens.
Constructing a transaction tree
The following is how one might construct a transaction tree:
start
field. From this, produce the minimal list of ranges which have been altered by the transactions, while making sure to cover every token. For instance:🚪 Exit
Exits can be submitted to the Plasma contract. They must simply specify a range of tokens they wish to exit, an owner & pay a bond to pay for challenges.
Exit spent token, exit double spend, & exit invalid history
Same as Plasma Cash (see the spec here); however, challenges must provide a particular token within the range attempting to be exited that is invalid. Proving one token is invalid cancels the entire exit.
Atomic Swap Force Include
In order to handle atomic swaps, we must add the ability to force include swap transactions. This game is required when an operator is withholding blocks & users are not able to determine if their swap transaction was included. Users can thereby force the withheld atomic swap transaction to be posted to the main chain. This lets them enough information to exit their new tokens as well as cancel any invalid exits.
Signatures from phase 1 of the atomic swap transaction are required for force includes to be accepted. This prevents a malicious atomic swap counter-party from griefing by submitting undesired atomic swap force includes.
Force include procedure
User submits a swap transaction to the mainchain. It must have attached to it all Phase 1 signatures. An exit bond must be paid for every token in the swap. If it is a 3-party atomic swap, then 3 exit bonds must be paid.
The force include will go through and cancel any exits of subsequent tokens unless someone shows 1) the atomic swap was already included, or 2) there is a spend of one of the inputs to the atomic swap already.
If the force include goes through without fail, then any exits of tokens that are between the force included swap & the previous token the swap references are canceled.
Token Withdraws
If an exit succeeds, a record of the token ranges which have been withdrawn is made. These tokens can never be transacted again.
Exit Withdrawn Token Challenge
If a user attempts to exit tokens which have already been withdrawn, they may be challenged, pointing to the record of withdrawn tokens.
[TODO] Smart Contract
Constants
Storage
Functions