nervosnetwork / fiber Goto Github PK
View Code? Open in Web Editor NEWChannel network built on Nervos CKB.
License: MIT License
Channel network built on Nervos CKB.
License: MIT License
Refer to protocol design v0.4
The points i try to optimize are as follows:
Simplify on-chain interactions when unilateral closing channel
There are 5 stages in design v0.4: opening -> closing -> clearing -> finalized -> transfer-assets. When unilateral closing channel, 4 types of transactions and at least 4 transactions need be constructed and submitted.
I think it's possible to optimize it to: opening -> closing -> settlement, simplify the interaction flow.
Reduce on-chain data usage
Here are the details:
- inputs
- capacity provide cell
- capacity: 100 CKB
- lockscript: A
- capacity provide cell
- capacity: 200 CKB
- lockscript: B
- other cells to provide channel cell capacity and tx fee
- outputs
- channel cell
- typescript: PCT
- args: channel-id
- lockscript: anyone-can-unlock
- data
- fixed
- pubkey_hashes: [pubkey_hash of A, pubkey_hash of B]
- closing_period: 1000
- dynamic
- state: OPENING
- version: 0
- balances: [100 CKB, 200 CKB]
- remaining_update_times: [5, 5]
- asset cell
- capacity: 300 CKB
- lockscript: PCL
The differences from v0.4:
asset
field. Because we already have asset cell, i think it's better to get asset-info from asset cell.challenge_period
and clear_period
to closing_period
, closing_period
>= max(challenge_period
, clear_period
).update_time_limit
and update_times
to remaining_update_times
.-header_deps
- header_contains_htlc0_proof_cell
- cell_deps
- htlc0_proof_cell
- inputs
- old channel cell
- data
- dynamic
- state: OPENING
- version: 0
- balances: [100 CKB, 200 CKB]
- remaining_update_times: [5, 5]
- outputs
- new channel cell
- data
- dynamic
- state: CLOSING
- version: 100
- balances: [160 CKB, 100 CKB]
- htlcs_merkle_root
- proved_htlcs: 0x01
- remaining_update_times: [4, 5]
- witnesses
- UnilateralCloseChannel
- data
- channel_id
- version: 100
- balances: [50 CKB, 100 CKB]
- htlcs_merkle_root
- htlc0_merkle_proof
- to: 0
- amount: 110 CKB
- lock
- preimage_timeout: 100
- signatures
- submitter_signature of A
The differences from v0.4:
proved_htlcs
records which htlcs have been proved by proof_cell, and the data type is bitmap(e.g. we have 8 htlcs, and htlcs[0, 2] have been proved, then the proved_htlcs
is one byte 0x05).-header_deps
- header_contains_htlc1_proof_cell
- cell_deps
- htlc1_proof_cell
- inputs
- old channel cell
- data
- dynamic
- state: CLOSING
- version: 100
- balances: [160 CKB, 100 CKB]
- htlcs_merkle_root
- proved_htlcs: 0x01
- remaining_update_times: [4, 5]
- outputs
- new channel cell
- data
- dynamic
- state: CLOSING
- version: 100
- balances: [160 CKB, 120 CKB]
- htlcs_merkle_root
- proved_htlcs: 0x03
- remaining_update_times: [4, 4]
- witnesses
- htlc1_merkle_proof
- to: 1
- amount: 20 CKB
- lock
- preimage_timeout: 100
- submitter_signature of B
The differences from v0.4:
- inputs
- assets cell
- capacity: 300 CKB
- lock: PCL
- old channel cell
- since: after closing period
- data
- dynamic
- state: CLOSING
- version: 100
- balances: [160 CKB, 120 CKB]
- htlcs_merkle_root
- proved_htlcs: 0x03
- remaining_update_times: [4, 4]
- outputs
- asset cell 0
- capacity: 180 CKB
- asset cell 1
- capacity: 120 CKB
- witnesses
- htlc2_merkle_proof
- to: 1
- amount: 20 CKB
- lock
- preimage_timeout: 100
The differences from v0.4:
There are 2 reasons that I think a unidirectional channel may be better than bidirectional channel in real life.
With a modification from bidirectional channel to unidirectional channel, we'll lose the ability to reuse a channel to do both pay and receive, but what we get are:
Then the use case will be:
modification details:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.