Giter Site home page Giter Site logo

w3f-grants-archive / plasm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from astarnetwork/astar

0.0 1.0 0.0 4.04 MB

Plasma x Substrate Blockchain.

Home Page: https://stakedtechnologies.github.io/plasmdocs/

License: GNU General Public License v3.0

Rust 95.78% Shell 3.91% Makefile 0.16% Dockerfile 0.15%

plasm's Introduction

plasm

Build Status

Plasm is a Substrate Runtime Module Library which allows developers to add Plasma functions to their Substrate chain easily and seamlessly. Since Plasm is an SRML, developers can also make both plasma parent chains and plasma child chains with Substrate.

WARNING: This is a proof-of-concept prototype. This implementation is NOT ready for production use.

Whitepaper

Comunity

Table of Contents

Introduction

Plasm is a Substrate Runtime Module Library which allows developers to add Plasma functions to their Substrate chain. By adding a Plasm Substrate Runtime Module Library, you can get scalable blockchains within a few minutes.

Some people might not know Substrate Runtime Module Library. Basically speaking, Substrate consists of 2 components, Substrate Core and Substrate Runtime Module Library aka SRML. We can customize Substrate Core with SRML and make an original Substrate chain.

Other people might not know Plasma. Plasma is a layer2 scaling solution which makes it possible for scalable computation by structuring economic incentives to operate the blockchain autonomously without the operator’s management. Ideally, it brings infinite scalability into your blockchain.

Based on the above, Plasm has some features.

  • The first Rust implementation of Plasma SRML.
  • Plasm is a simple but versatile SRML and makes it easier for developers to make a Plasma chain with Substrate.
  • Plasm deals with many types of “Plasmas” in the future. Currently, we are providing UTXO models.
  • Substrate chain can be both a plasma parent chain and a plasma child chain.

Since we are making an SRML, we can also make a Plasma chain with Substrate. Once Polkadot is launched, we will connect our root chain to Polkadot, and we aim to be one of the parachains. vision In addition, Plasm makes it easier even for other developers to make a Plasma chain.

Demo

You can see our demo

  • Version1: 2019/04/25 CLI Demo
  • Version2: 2019/05/22 UI Demo No explanations yet. I will add asap.

Plasm ver0.2.0

Plasm ver0.2.0 is a prototype which has the following functions.

  • Plasma MVP implementation
    • Plasm-Parent provides the parent chain’s specification. Mainly, Plasm-Parent has the logic of each exit game.
    • Plasm-Child provides the child chain’s specification.
    • Plasm UTXO/Merkle provides the data structure which manages transactions.
  • Plasma Client implementation
    • Plasm Util is a wrapper function to call the endpoint of blockchains.
    • Plasm Operator is monitoring a parent chain and a child chain to make the deposit/exit successful.
    • Plasm CLI is a CLI tool to call the endpoint.
    • Plasm Wallet is an application to send, withdraw and receive tokens.

As a next step, let’s make a wallet demo application on your laptop and see what’s happening.

Step1

Clone Plasm from our GitHub.

$ git clone https://github.com/stakedtechnologies/Plasm.git
$ cd Plasm
$ git checkout v0.2.0

Step2

Build Plasm Node. After a successful build, you can run Plasma nodes.

$ cargo build
$ ./target/debug/plasm-node --dev

Step3

Open another terminal and clone Plasm-Client from our GitHub.

$ git clone https://github.com/stakedtechnologies/plasm-client.git
$ cd plasm-client
$ git checkout v0.2.0

Step4

Start Plasm Operator. The operator is monitoring both the parent chain and the child chain. When the parent chain deposits tokens to the child chain or the child chain exits tokens to the parent chain, the operator writes the root hash of the child chain on the parent chain.

$ cd packages/operator
$ cp ../../env.sample .env
$ yarn install
$ yarn start

Screen Shot 2019-06-08 at 1 02 33

If you can see the output below, this project has been successful.

Screen Shot 2019-06-08 at 1 05 04

Yeah, you made it, but what actually happened? Let me clarify! (You can skip if you want. This is complicated, so we will publish another article focused on this topic.)

Plasm-Operator gets an event which the plasma child/parent chain issues and processes the following steps. Parent chain’s events

  • When an operator receives a Submit event, she finalizes the status of the child chain.
  • When an operator receives a Deposit event, she sends tokens to the issuer.
  • When an operator receives an ExitStart event, she deletes the UTXO which was used for exiting on the child chain. Child chain’s events. When an operator receives a Submit event, she submits the root hash to the parent chain. The Submit event on a child chain is issued regularly. (You can decide this logic. For this time, 1 time in 5 blocks.)

Step5

Open another terminal and move to plasm-client root directory. Then, start Plasm Wallet UI Demo Application.

$ cd packages/wallet
$ yarn install
$ yarn dev

Screen Shot 2019-06-08 at 1 07 31

After that, let’s go to localhost:8000 on your browser. We will create 2 different accounts and send/receive tokens by using the wallet application I mentioned above.

Step6: Account Registration

First, you need to register your demo account. Since a default operator is Alice, you should add //Alice ①. Then, create an account ②. You can check Alice’s balance ③.

Screen Shot 2019-06-08 at 1 09 00

To send tokens from Alice to Bob, Alice to Tom and Bob to Tom, generate Bob’s and Tom’s account as well.

Screen Shot 2019-06-08 at 1 09 44

Step7: Token Transfer on Parent Chain

As a next step, we will send tokens from Alice to Bob and Alice to Tom on the parent chain.

Screen Shot 2019-06-08 at 1 11 01

Screen Shot 2019-06-08 at 1 11 22

Enter the account name and decide the amount of token. Then, click the “Send” button. Keep your eye on the “ParentBalance” next to the account name. After a successful transaction, you will notice that Bob’s amount is increasing. Currently, we collect the exchange fee from the sender on the parent chain. So, Bob and Tom need to have some tokens on the parent chain.

Step8: Deposit (Deposit tokens from Parent Wallet to Child Wallet.)

Screen Shot 2019-06-08 at 1 12 40

Third, we will send tokens from the parent chain to the child chain. For this time, Bob deposits 5,000,000 tokens to the child chain. Just keep in mind, it takes time to increase ChildBalance because the operator checks the event and executes a transaction.

Screen Shot 2019-06-08 at 1 13 36

Step9: Token Transfer on Child Chain

Screen Shot 2019-06-08 at 1 14 10

Fourth, let’s send some tokens from Bob to Tom on the child chain.

Screen Shot 2019-06-08 at 1 15 04

Bob has 5,000,000 tokens. He sent 1,000,000 tokens out of 5,000,000 to Tom.

Step10: Exit Part1(Exit tokens from ChildWallet to ParentWallet.)

Screen Shot 2019-06-08 at 1 16 22

Exit tokens from Tom’s account on the child chain to his account on the parent chain. If you type your account name, you can find UTXO lists you have. A child chain has all transaction histories you made and tokens are exited based on UTXO.

Screen Shot 2019-06-08 at 1 16 49

Press the ExitStart button so that you can exit your tokens to the parent chain.

Screen Shot 2019-06-08 at 1 17 32

BUT, you have to wait about 60 seconds. It is a Plasma challenge period which we decided. Full node holders can challenge the legitimacy of exits in it.

Step11: Exit Part2(ExitFinalize ChildWallet to ParentWallet.)

Click ExitFinalize.

Screen Shot 2019-06-08 at 1 18 32

Then,

Screen Shot 2019-06-08 at 1 19 16

Finally, the exit is successful. Well done!! This is a simple demo, but it’s one giant leap for the Polkadot/Substrate community!!

Future Works

ver0.2.0rc1 : Actually, we just have one node in this tutorial because we used balances SRML, the default setting. We will divide this node into a parent node and a child node using PlasmUtxo SRML.

ver0.5.0 : Connect our root chain to Polkadot Testnet.

v0.7.0 : Plasma Cash implementation

v1.0.0 : Plasma Chamber implementation

Another Important Task : Improve ExitGame implementation

Build Nodes on Docker

Parent(Root) Node

> docker run -p 9944:9944 stakedtechnologies/plasm-node

Child Node

> docker run -p 9955:9944 stakedtechnologies/plasm-child-node

Build Nodes for Developer

Parent(Root) Node

> cd plasm
> ./build
> cargo build
> ./target/debug/plasm-node --base-path /tmp/parent --port 30333 --ws-port 9944 --dev

Child Node

> cd plasm/child
> ./build
> cargo build
> ./target/debug/plasm-child-node --base-path /tmp/child --port 30334 --ws-port 9955 --dev

Build Nodes on Docker

Parent(Root) Node

> docker run -p 9944:9944 stakedtechnologies/plasm-node

Child Node

> docker run -p 9955:9944 stakedtechnologies/plasm-child-node

Build Nodes for Developer

Parent(Root) Node

> cd plasm
> ./build
> cargo build
> ./target/debug/plasm-node --base-path /tmp/parent --port 30333 --ws-port 9944 --dev

Child Node

> cd plasm/child
> ./build
> cargo build
> ./target/debug/plasm-child-node --base-path /tmp/child --port 30334 --ws-port 9955 --dev

Example Trait

Please check here.

Please Contacts

Maintainers


Plasm is licensed under the GPL, Version3.0 by Staked Technologies Inc.

plasm's People

Contributors

satellitex avatar sotawatanabe avatar taskooh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.