Giter Site home page Giter Site logo

gauc073 / plasma-contracts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from omgnetwork/plasma-contracts

0.0 0.0 0.0 1.04 MB

Root chain contracts for Plasma

License: Apache License 2.0

Python 42.49% Dockerfile 0.05% JavaScript 57.21% Makefile 0.25%

plasma-contracts's Introduction

Plasma Contracts

Root chain contracts for Plasma M(ore)VP, work in progress.

Build Status

Contents

This version of the contract implements Plasma MVP (Buterin, Poon, Knott). This implementation is a PoA scheme with one operator and multiple watchers (users). Detailed description of our child chain design is in Tesuji document.

Implementation differs from MVP in few regards:

  • Added protection against chain re-orgs (omgnetwork/plasma-mvp#51).
  • Added collected fee exiting for PoA operator.
  • Added ERC20 handling.
  • Merkle tree used is of variable depth.
  • Transaction fee is implicit, not explicit.

Plasma MVP, confirmations, and MoreVP

While this implementation contains confirmations, this is a temporary state as we are going to replace confirmations with the exit game defined in MoreVP (Fichter, Jones) in the future. Reasons include:

  • Bad UX, need to propagate confirm sigs somehow.
  • Receiver can lie about receiving money; to prove sending, sender needs to publish confirmation to Ethereum.
  • Additional signature check per tx is needed.
  • No good way of doing partially signed transactions / atomic swaps.

Re-org protection

See here.

Protection of deposits against malicious operator, pending

Normally funds are protected by M(ore)VP mechanisms. There is an attack vector where operator spots large deposit in Ethereum mempool and produces a block to steal. If malicious block is mined before the deposit, deposit can be stolen. We are intending to use elevated exit priority for deposits so they always wait at most Minimal Finalization Period, while exit from fraudulent block will have to wait for Minimal Finalization Period + Required Exit Period.

Building and running tests

Installing dependencies needed for compilation:

make init

Installing dependencies needed to run tests:

make dev

Building and running tests:

make test

Running slow (overnight) tests:

make runslow | tee raport.txt

Deploying with truffle

Installation

Requires node.js >= 8

Install dependencies:

npm install

Deploying

Deploying the contracts requires two accounts:

  1. DEPLOYER The account that actually deploys the contracts
  2. AUTHORITY The Authority account calls RootChain.init() and is the account used by the Child chain (or operator). By default a new AUTHORITY account is created when deploying, and will be funded with some ETH from the DEPLOYER account. If you prefer you can use an existing AUTHORITY account, but it must not have made any transaction prior to calling RootChain.init() i.e. its nonce must be 0.

Normally you will deploy the contracts using an Ethereum client that you run yourself, such as Geth or Parity. However, you can also use a provider such as Infura. In this case you'll need to know the private keys for the DEPLOYER and AUTHORITY accounts. See truffle-config.js for an example.

Configuration

Certain configuration values need to be set, depending how you're deploying. These values can be set in the environment or in a file called .env

  • MIN_EXIT_PERIOD Minimum exit period in seconds. Required.
  • SOLC_VERSION Solidity compiler version. Defaults to 0.4.25
  • ETH_CLIENT_HOST Host of Ethereum client. Defaults to 127.0.0.1
  • ETH_CLIENT_PORT Port of Ethereum client. Defaults to 8545
  • DEPLOYER_ADDRESS Address of the DEPLOYER account. Defaults to accounts[0]
  • DEPLOYER_PASSPHRASE Passphrase of the DEPLOYER account.
  • AUTHORITY_PASSPHRASE Passphrase of the AUTHORITY account.
  • AUTHORITY_ADDRESS_INITIAL_AMOUNT The amount the fund the AUTHORITY account with (in wei). Defaults to 1 ETH.
  • USE_EXISTING_AUTHORITY_ADDRESS Set to true if you want to use an existing AUTHORITY account instead of creating a new one. You must also set AUTHORITY_ADDRESS

Run truffle, passing in the network e.g.

npx truffle migrate --network local

Truffle will compile and deploy the contracts. If all goes well it will output the results:

{
    "contract_addr":"0xb6d73FCDD7F3E053990518eAe1306D7893EEFE12",
    "txhash_contract":"0x1595b181ece865ccc9e3a025931be0566dd6e7bec739d79faafb1d5215b01c71",
    "authority_addr":"0xF0B750F59Fff5C2be61870Dc0DA58e5e8d8F4232"
}

plasma-contracts's People

Contributors

paulperegud avatar boolafish avatar pik694 avatar kevsul avatar pgebal avatar pthomalla avatar pnowosie avatar pdobacz avatar smartcontracts avatar davidknott avatar kasima avatar jbunce avatar wizardofaus 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.