• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Root chain contracts for Plasma

OmiseGO Plasma Framework Contracts

Root chain contracts for The OmiseGO Plasma Framework, a layer 2 scaling solution for Ethereum.

Build Status Coverage Status

Contents

These contracts comprise the root chain component of an extensible plasma framework that can support many Minimal Viable Plasma (MVP) (Buterin) style plasma constructions. The framework features the ability to extend:

  • transaction types, influenced by Plasma Group's Generalized Plasma Architecture
  • exit games, which can support any MVP-compatible exit game
  • token vaults, such as ETH and ERC-20

The framework includes a basic payment transaction type for UTXO transfers, with 4 inputs and 4 outputs. These transactions are secured under More Viable Plasma (MoreVP) (Fichter, Jones) exits.

The framework includes two token vaults, supporting ETH, ERC-20, and non-compliant ERC-20 tokens.

Child chain and Watchers

The child chain component of our plasma construction runs under Proof of Authority, with a single operator. The construction is secured by a distributed network of watchers. Detailed description of our child chain design is in Tesuji document.

The OmiseGO implementation of the child chain and watcher can be found in our elixir-omg GitHub repository.

Learn more

You can learn more about OmiseGO and get started developing with our plasma framework at developer.omisego.co.

Getting started

The easiest way to compile and deploy the contracts is with Truffle. Requires node.js >= 8.

All the code is in the plasma_framework directory, so go there first.

cd plasma_framework

Next install the dependencies.

npm install

You can then compile the contracts.

npx truffle compile

Or run the tests

npm run test

Configuration

The migration scripts can be configured in plasma_framework/config.js. Various properties of the contracts can be set here, such as the minimum exit period. See the file itself for more details. By default the development environment is used, but this can be set to production via the DEPLOYMENT_ENV environment variable.

You may also override the default exit period in development with an environment variable MIN_EXIT_PERIOD.

Deploying

Deploying the contracts requires three accounts:

  1. DEPLOYER The account that actually deploys the contracts
  2. AUTHORITY The account that used by the Child chain to submit blocks. It must not have made any transaction prior to calling the scripts i.e. its nonce must be 0.
  3. MAINTAINER The account that can register new vaults, exit games, etc.

Normally you will deploy the contracts using an Ethereum client that you run yourself, such as Geth or Parity. Those Ethereum client would have default accounts on the node itself. For local testing, you can leverage those accounts and deploy with --network local flag. The first three accounts inside the Ethereum client would be the DEPLOYER, MAINTAINER, and AUTHORITY account with the order.

You can also use a remote provider such as Infura that does not have control of the private key and accounts with --network remote flag. In this case you'll need to know the private keys for the DEPLOYER, AUTHORITY and MAINTAINER accounts. See truffle-config.js for an example.

Run truffle, passing in the network e.g.

npx truffle migrate --network local

# or to deploy via a remote provider
npx truffle migrate --network remote

You can also run within the docker with the provided Dockerfile.

# run the following commands under the repo directory instead of under plasma_framework/

# build the docker image
docker build -t omisego/plasma-contract .

# deploy the contract
docker run --rm omisego/plasma-contracts npx truffle migrate --network remote

For more detail of the deploying scripts and the env vars to set, see deploying.md

The MAINTAINER account can also be a multisignature contract. The example we've built uses Gnosis MultiSigWallet. The project has been added as a git submodule (https://github.com/gnosis/MultiSigWallet/tree/v1.6.0):

git submodule init
git submodule update --remote

Their deployment scripts were slightly addapted. We can override them by executing:

cd MultiSigWalletOverride/
make init_multisig

While we're in the directory we can deploy the contract by executing:

truffle migrate <account1,account2,...,accountN> <requiredConfirmations> 

The address of the multisignature contract is exported into:

MultiSigWallet/build/multisig_instance

Building and running the python tests

We suggest running the following commands with an active python virtual environment ex. venv. All the code is in the plasma_framework/python_tests directory, so go there first.

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

Run Load Tests

We have code for load tests but is skipped by default. Currently it needs manual setup to run it locally. You should go to the test/loadTests/ folder to find the test you would like to enable. Remove the .skip part on the test, and change it to .only.

The load test would need a ETH network with super high block gas limit and high initial ETH fund for test accounts. You can do the following with ganache:

ganache-cli -e 10000000000000 -l 0xfffffffffff

Run the following command to run the test afterward:

npx truffle test --network loadTest

How to release a new plasma contracts version

  • Update the CHANGELOG.md
  • Bumps the version in package.json (the patch part)
  • Creates a commit with specified message
  • Tags that commit with the new version
npm version patch -m "Fixed a bug in X"

More Repositories

1

plasma-mvp

OmiseGO's research implementation of Minimal Viable Plasma
Python
564
star
2

ewallet

eWallet Backend for the OmiseGO SDKs.
Elixir
323
star
3

elixir-omg

OMG-Network repository of Watcher and Watcher Info
Elixir
210
star
4

plasma-cash

Python
122
star
5

airdrop

Python
83
star
6

research

43
star
7

omg-js

JavaScript Library for communication with OMG network
JavaScript
42
star
8

optimism-v2

ARCHIVE of monorepo implementing Boba, an L2 Compute solution built on Optimistic Ethereum - active repo is at https://github.com/bobanetwork/boba
Go
40
star
9

ios-sdk

OmiseGO iOS SDK for integrating with eWallet Server.
Swift
31
star
10

ex_ulid

Universally Unique Lexicographically Sortable Identifier (ULID) in Elixir
Elixir
29
star
11

web-wallet

JavaScript
24
star
12

android-sdk

OmiseGO Android SDK for integrating with Wallet API Server.
Kotlin
18
star
13

sample-ios

Sample iOS application for loyalty point server and OmiseGO Wallet Server.
Swift
15
star
14

honted

OmiseGO node on Tendermint.
Elixir
12
star
15

community-points

Community points monorepo
JavaScript
11
star
16

js-starter-kit

Vue
11
star
17

ex_plasma

Elixir library for the OMG Plasma Contracts Transaction Format
Elixir
10
star
18

dev-portal

OmiseGO Developers Portal
JavaScript
8
star
19

salty

Elixir wrapper for enacl and libsodium.
Elixir
8
star
20

plasma-cli

Go
8
star
21

ruby-sdk

OmiseGO Ruby SDK for integration with Wallet Server.
Ruby
8
star
22

pos-client-android

Kotlin
7
star
23

sample-server

OMGShop, a.k.a Sample Server: sample loyalty points with OmiseGO eWallet Server integration.
Ruby
6
star
24

potterhat

Like Babel fish but you can’t put into your ears
Elixir
6
star
25

pos-merchant-android

Kotlin
6
star
26

OIP

OmiseGO Improvement Proposal
6
star
27

sample-android

Sample Android application for loyalty point server and OmiseGO Wallet Server.
Kotlin
6
star
28

omg-childchain-v2

pronounced /Ch-ch/
Elixir
5
star
29

omg-samples

OMG Network code samples
4
star
30

specs

OMG Network Specs, Integration, Performance, Stress Testing
Elixir
4
star
31

goban

Development environment bootstrapper for OmiseGO projects using Vagrant and Ansible.
Shell
4
star
32

omg-js-samples

Code samples for omg-js library
JavaScript
3
star
33

omgx_wallet

web wallet for OMGX
JavaScript
3
star
34

omg-block-explorer

a mysterious place where you can see transactions data.
JavaScript
3
star
35

pos-client-ios

Swift
3
star
36

pos-merchant-ios

Swift
3
star
37

roadmap

2
star
38

quasar-services

JavaScript
1
star
39

boba-mainnet-addresses

[Boba Network]Mainnet Contract Addresses
1
star
40

omg-quasar-js

JavaScript
1
star
41

safe-gnosis

A full service docker compose setup and container building repo
Shell
1
star
42

omg-js-testrunner

Dockerfile
1
star
43

omgx_contracts

OMGX smart contracts
TypeScript
1
star
44

xomg-vagrant

Vagrant setup for elixir-omg
Shell
1
star
45

omgnetwork.github.io

Developer Portal for OMG Network
HTML
1
star
46

e2e

Acceptance Tests for eWallet.
RobotFramework
1
star
47

contractexchanger

Python
1
star
48

mobile-wallet

JavaScript
1
star
49

omgx_contracts-analyzer

ARCHIVED - see /omgnetwork/optimism/packages/omgx for the active repo. Sushi on OMGX - An example of contract changes needed to run a non-trivial system on OMGX
Solidity
1
star