Git Product home page Git Product logo

leap-contracts's Introduction

LeapDAO Bridge implementation

CI

Development

Getting started

yarn
yarn test 

Deploying contracts

All the commands support any truffle options like --network or --reset.

Deploying on Rinkeby and Mainnet

To deploy on Rinkeby and Mainnet, make sure to specify your Infura project ID and mnemonic in the .env file. Alternatively, you can change truffle-config.js to use other provider of your choice.

Contracts customization

Contract may be customized via ENV variables:

ENV variable Description Default value
PROPOSAL_TIME Governance proposal cool-off time (in seconds) 1209600 (14 days)
EXIT_STAKE Exit stake (in Wei) 100000000000000000
EXIT_DURATION Exit duration (in seconds) 604800 (7 days)
DEPLOYED_TOKEN Token to be configured in vault
EPOCH_LENGTH Number of initial slots for validators 2
PARENT_BLOCK_INTERVAL Number of Ethereum blocks between Plasma periods 2
TAX_RATE Initial tax rate (0 - 1000 equals 0% - 100%) 50
POA_REWARD Reward rate before supply of 7 million reached 778000000000000000000
GOV_OWNER Owner address of the MinGov.sol contract, should be set to seed initial token supply.

E.g. PROPOSAL_TIME=600 EXIT_DURATION=180 yarn deploy deploys plasma contract with 3 minutes exit duration governed by MinGov with 10 minutes proposal time.

Deploy everything

yarn deploy

This will deploy deploy token, plasma and governance contracts.

Deploy only plasma and governance contracts (reusing token)

yarn deploy:plasma

Good things to know

slotId in MinGov.setSlot is encoded like this:

First 20 bytes last 12 bytes
address(OperatorProxy) slotId

Contracts

In this repository are the solidity smart contracts implementing LeapDAO's plasma leap.

There are 3 smart contracts that get deployed:

  • Bridge

    The bridge is responsible for storing the period chain. It is the source of truth for the plasma chain.

  • Operator

    The operator is the contract that is responsible for submitting new periods to the bridge.

  • ExitHandler

    This contract is responsible for user funds. Explained in more detail below.

Layout

The ExitHandler is actually the final contract in an inheritance chain that goes as follows:

  • Vault

    The vault defines what types of assets are allowed on the plasma chain and is responsible for registration of these assets.

  • DepositHandler

    The deposit handler is in general responsible for how funds get onto the plasma chain.

  • ExitHandler

    The exit handler is in general responsible for how funds leave the plasma chain.

Inheritance chain

LICENSE

Project source files are made available under the terms of the Mozilla Public License (MPLv2). See individual files for details.

leap-contracts's People

Contributors

dependabot[bot] avatar eezcjkr avatar eshavkun avatar federicobond avatar jdkanani avatar johannbarbie avatar koroqe avatar pinkiebell avatar pumpkingwok avatar roleengineer avatar sounak98 avatar sunify avatar troggy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leap-contracts's Issues

setup CI

E.g. Travis/Coveralls or CircleCI

Plasma exit with priority queue

Bounty 8: Plasma exit with priority queue

Currently there are only exits by proving a burn. Add exits using the priority queue.

Scope:

  • exits using the priority queue as described in resources

Resources:

Deliverables:

  • function implementation
  • tests

Gain for Circle:

  • Full MVP support.

Bounties: https://github.com/parsec-labs/PIPs/wiki/Bounties

period reward distribution

  • how to distribute exactly 1 reward per slot per period?
  • how to make sure that if a validator is not online, another guy submits the period? which one?

cleanup

  • package.json scripts
  • dependencies
  • scripts, test helpers etc

full test coverage

Bounty

Full(ish) test coverage.

Scope

  • Achieve 90 % test coverage

Deliverables

More tests.

Gain for the project

Confidence in code.

Roles

bounty gardener: @TheReturnOfJan / 5%
bounty worker: @TheReturnOfJan / 80%
bounty reviewer: name / 15%

add min-gas challenge

add a function where a validator can be slashed for including a transaction with less than the min-gas fee.

move staking out into separate contract.

Bounty 27 : Refactor LeapBridge into Bridge and Operator

We want to separate POS logic into it's own contract to enable later upgrades.

Scope

  • split bridge into core and operator contract
  • have all tests pass with PoS operator contract
  • have all tests pass with single operator contract

Deliverables

Branch is pushed to GitHub that solves the above.

Gain for the project

Helps us incrementally launch on a network.


Bounties: https://github.com/parsec-labs/PIPs/wiki/Bounties

add contract upgradeability

we want to be able to upgrade the contract with protocol changes of the Plasma chain. But the community should have the ability to veto each upgrade. Process envisioned like this:

  1. new contract code is deployed and registered for upgrade.
  2. timer runs down over x days.
  3. if no majority of token holders veto'ed the upgrade, new contract code is enabled.

allow proofs for second input/output

now all proofs only work for transactions with 1 input and output.

desired:

  • enable proofs and slashing for second output in tx
  • add unit tests

[POS] add clipping

  • analyze different grieving attacks during consensus window
  • add clipping if possible.

Add a gap into inherited contracts

Add uint256[50] private ______gap; into inherited contracts to accommodate possible changes/resizings during upgrades (see openzeppelin-eth lib for example)

create a list of attack scenarios on plasma chain

objective is to rationalize the need of 2-phase prepare commit transactions on the child chain (or other mitigations, like the expiration time proposed by @DavidKnott in last plasma call).

assumptions: child chain works without any signed confirmations(as in MVP spec):

Deposit not credited Attack

  • alice deposits funds into plasma contract
  • Validator creates UTXO in next plasma block
  • Validator censors all future transactions by Alice to spend the UTXO
  • Alice initiates exit from plasma
    => all good?

Frustration Attack

  • Alice sends tx with output to Bob
  • Validator withholds tx
  • Alice gets frustrated and initiated exit with value of tx
  • Validator includes tx in next block and challenges Alice's exit

Block Withholding Attack

  • Validator constructs a block with invalid txns (0 input, or wrong sigs)
  • Validator submits block hash
  • Aalidator starts exit of funds
    => no-one can challenge validator, because block data missing

Double Spend by Exit Attack

  • Alice sends tx1 to bob
  • Bob spends from tx1 with tx2
  • Alice initiates an exit with value of tx1
  • Bob challenges Alice's exit with tx2

Valueless UTXO Attack

  • Alice deposits x into plasma
  • Validator includes UTXO with x in next block
  • Alice initiates an exit of x
  • Alice waits 14 days and receives x back
  • Alice starts using UTXO on childchain

MoreVP Episode 2 - add inflight tx exits

Bounty : MoreVP Episode 2

Implement MoreVP for better UX.

Scope

  • implement an ExitHandler contract the conforms to MoreVP on refactoring branch
  • unit tests

Deliverables

Branch is pushed to GitHub that solves the above.

Gain for the project

It's good design.


https://github.com/omisego/research/blob/master/plasma/plasma-mvp/delegated-exits.md

chose a variant that will work for transactions to smart contracts as well


gardener: @johannbarbie 10%
worker: @nanspro 70%
reviewer: 20%

Add test coverage report

Scope:

  • add an npm script to measure Solidity test coverage with solcover (or alternative). It should be made to run separately from regular npm test.
  • add codecov.io integration to travis config. Do not add codecov dependency โ€” it will be used on Travis CI only and Travis already have codecov globally

Deliverables:

  • test coverage can be run locally with a separate command
  • test coverage is being run on travis ci for every commit and results are pushed to codecov.io

Create a separate exit game for inflight deposits

deposits create an event in the bridge contract. what if the operator does not include the transaction in the block or withholds the block?

Scope

  • define a depositInclusionTime โ€” reasonable number of periods to wait for deposit tx to be included. It should be changeable via governance.
  • create startDepositExit(depositId) method for exiting inflight deposits (deposit without tx included in the period). It should create an exit with depositId instead of utxo part of priority.
  • create challengeDepositExit to challenge invalid deposits. Challenger should present a proof of deposit tx inclusion. Provided deposit tx should not be younger than exit + depositInclusionTime
  • make sure leap-node is working correctly with the change, picking up deposits as it should be

Deliverables

  • updated root chain contracts with the feature
  • (probably) new leap-node release with necessary changes
  • (probably) new leap-core release with necessary changes

Gain for the project

  • increased security for users โ€” they will be able to exit their deposits even if the block with deposit tx was withheld (requires #85 for MoreVP exits)

Roles:

bounty gardener: @troggy / 5%
bounty worker: @johannbarbie / 85%
bounty reviewer: @eezcjkr / 10%

setup contracts for the testnet

Bounty

Delivery

  • deploy LEAP token contract on Rinkeby. Make sure it has a good name (no MOCK please ๐Ÿ’ฉ). Mint some coins
  • change migrations to optionally use predefined token instead of deploying new token. This way it is easier to redeploy contracts (when testing manually). Keep the old functionality (new token per run) for integration tests
  • decide on proposal time for governance contract and get peeps opinion on Slack/Tactical.
  • deploy new Minimal Viable Governance contract on Rinkeby
  • deploy plasma contracts on Rinkeby
  • register LEAP token with the bridge
  • transfer ownership of plasma contract to governance
  • do basic smoke testing
  • coordinate with Testnet commander to ensure the contracts are running fine with node software and bridge UI. Fix things if needed. Bounty is concluded once the contracts are in use in the network

Bounty setup

Size: M (8)

gardener: @troggy / 10% of worker share
worker: @troggy / Size M โ€”ย 550 DAI
reviewer: @eezcjkr / 10% of worker share

Create reward payment contract

I've removed the reward payment from bridge. hence we should have another contract where rewards can be claimed based on the data in the bridge.

  • The contract should have minting rights, verify proofs and remembers claimHeight per validator slot.
  • Have a governance parameter rewardTax that determines how much of the claimed reward goes to multi-sig.
  • implement RISS model
  • implement inflation cap as described in token model (first x years: 50%, after that: 10%)

Keep later integration with #101 in mind, so that reward payments are possible as in Bouquet Chain design.

gardener: @johannbarbie 10%
worker: @johannbarbie 70%
reviewer: ??? 20%

unknown outpoints problem

a validator can include any imaginary outpoint, because we use transaction hashes to identify them.

options:

  • interactive proof for non-existing outpoint
  • go back to block-id + position to identify outpoints.

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.