omgnetwork / plasma-mvp

OmiseGO's research implementation of Minimal Viable Plasma
MIT License
561 stars 158 forks source link

Create an RLP encoding library #170

Closed smartcontracts closed 6 years ago

smartcontracts commented 6 years ago

Issue Type

[ ] bug report
[x] feature request

Current Behavior

We currently differ from the Plasma MVP spec by creating a simplified deposit function at the cost of a more complicated withdrawDeposit addition. This should be removed, but requires that we be able to encode transactions on-chain.

Suggested Fix

Solidity RLP Encoding Library

Description

RLP (Recursive Length Prefix) is a method for encoding arbitrarily nested arrays of binary data. You can learn more about RLP encoding here.

We’re using RLP to decode transactions for our Plasma MVP implementation. However, we’re also maintaining a simplified Plasma contract (as a learning resource) that could be made even simpler with an RLP encoding library written in Solidity.

Requirements

We’re looking for a relatively simple RLP encoding library. It doesn’t need to be hyper-optimized, but optimizations are always appreciated! You should look to the Ethereum RLP wiki page for a detailed spec of how RLP works.

RLP operates on arbitrary binary data. However, we’d like to be able to RLP encode typed objects in Solidity. Therefore, the contract should expose a few key functions:

Note that encodeList does not need to recursively encode the contents of the list (you can assume they’re already encoded).

Motivation for Change

We want to match the original Plasma MVP specification, and therefore need to remove withdrawDeposit.

gitcoinbot commented 6 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 500.0 DAI (500.0 USD @ $1.0/DAI) attached to it.

gitcoinbot commented 6 years ago

@blocksoft-technologies Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

blocksoft-technologies commented 6 years ago

I'm still working...

gitcoinbot commented 6 years ago

After 7 days with no comment / WIP PR, this issue has returned to an open status on Gitcoin.

gitcoinbot commented 6 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 3 months, 3 weeks from now. Please review their action plans below:

1) bakaoh has been approved to start work.

I think it's rather simple to implement as definition at https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP , (port code from python to solidity) I will try to optimize the code using https://github.com/omisego/plasma-mvp/blob/master/plasma/root_chain/contracts/RLP.sol as reference. If everything go well, i may finish this issue this week.

Learn more on the Gitcoin Issue Details page.

bakaoh commented 6 years ago

Please take a look at my first version https://gist.github.com/bakaoh/0746cdbd749439798217b5b022faf906 I didn't test encodeList function cause i don't know how to pass a bytes[] from web3. Also mergeBytes may need some optimize

smartcontracts commented 6 years ago

@bakaoh This is awesome. I think some minor code cleanup/standardization and it's perfect!

bakaoh commented 6 years ago

@kfichter -- where should i put the contract? In https://github.com/omisego/plasma-mvp/tree/master/plasma/root_chain/contracts or a seperate repo?

smartcontracts commented 6 years ago

Right in there is perfect, thank you!

vs77bb commented 6 years ago

@bakaoh Excited to see you here! I've approved you on Gitcoin. Good luck with it 😄

gitcoinbot commented 6 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 500.0 DAI (500.0 USD @ $1.0/DAI) has been submitted by:

  1. @bakaoh

@ceresstation please take a look at the submitted work:


spm32 commented 6 years ago

Awesome job @bakaoh, the bounty has been paid out!

gitcoinbot commented 6 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 500.0 DAI (500.0 USD @ $1.0/DAI) attached to this issue has been approved & issued to @bakaoh.