gridplus / cryptobridge-contracts Goto Github PK
View Code? Open in Web Editor NEWSmart contracts for trustless bridges
License: MIT License
Smart contracts for trustless bridges
License: MIT License
Hi @alex-miller-0! I was thinking of including your parity bootstrapping script in a new project, and I wanted to make sure it was posted under a compatible license. After a (very) quick glance it seems you haven't indicated how this code is licensed.
Assuming there's no license expressed in this repo, this technically means that nobody is able to use the code here, as no license for use has been granted. ChooseALicense.com has a great explanation of this.
This is a bounty associated with the Relay.sol
contract. Currently, there are three functions that make up a full withdrawal:
prepWithdraw makes a Merkle-Patricia proof given transaction data and saves a temporary Withdrawal
struct to storage. This is the most expensive function because it stores several pieces of data.
proveReceipt takes receipt data and forms a Merkle-Patricia proof. If successful, it saves the receiptsRoot
for the block to storage.
withdraw forms a standard Merkle proof given [modified] headers (they are modified by the cryptobridge client to contain a subset of the Ethereum header data). If successful, this triggers an ERC20 transfer and deletes the temporary Withdrawal
struct associated with the sender.
This process takes about 500,000 gas and requires three transactions on the withdrawal chain. For the next version, I would like to cut that gas usage by as much as possible and reduce it down to one transaction. This is where you come in.
Requirements:
A successful proposal will do the following:
Hints
Any method to perform the above requirements is fine, but I would suggest looking at passing larger bytes arrays and slicing them with utility functions, perhaps in an external library. This would require a considerable rewrite of prepWithdraw
, which has the arguments pre-sliced. For an example of bytes slicing, you can look at the way logs are sliced in proveReceipt
.
(draft)
Info: trufflesuite/ganache#294
(affects: #13)
After starting the parity-duo with npm run parity 7545 8545
, the two parity processes get killed within a few seconds.
The parity/chains/*/error.log
contain the error message:
IPC error: Operation not permitted (os error 1)
It happens in both:
within parity/boot.js
, locate:
//add this to disable ipc, if you get "IPC error: Operation not permitted (os error 1)"
args.push('--no-ipc')
const parity = spawn('parity', args, { stdio: 'pipe', cwd: PATH });
Background: A relay system has two contracts (one on each of two chains), which have mappings between pairs of tokens. A user with a given token may deposit it into the relay contract on that chain and withdraw its copy on the other chain. The withdrawal is a two step process, with the first part being the formation of a Merkle proof to show the transaction (deposit) was in the transaction tree. This issue only covers this first part.
The function prepWithdrawal
in Relay.sol
takes a set of parameters (token, fromChain, and amount) and forms a transaction. It uses this transaction to make a Merkle proof that it was included in a given transaction root in withdraw
. I am having trouble reconstructing the transaction and forming the proof -- this is where you come in!
To claim the bounty:
prepWithdraw
, withdraw
, and merkleProof
Solidity functions to perform a proper Merkle proof. Use the parameters token
, fromChain
, and amount
to form the transaction data that goes into making the proof. You can pass the transaction root from a given block into the function and match it with the proof.relay.js
using this functionality. At a minimum, it should a) make the deposit to get the transaction hash, b) get the block from the transaction hash and make the Merkle proof in Javascript, c) pass the relevant data to Solidity to make the same proof.These repos may help:
https://github.com/ConsenSys/rb-relay
(affect #11)
Windows 10, bash on Windows, Hyper-V ubuntu instance.
The following error raises with truffle test
P:\sand\cryptobridge\contracts>truffle.cmd test
0xf399c77f9a403c541bbac8dae1e016bf942f09f5
Using network 'development'.
Error: Bridge contract constructor expected 1 arguments, received 0
at C:\Users\laz\AppData\Roaming\npm\node_modules\truffle-core\node_modules\truffle-contract\contract.js:388:19
at new Promise (<anonymous>)
at C:\Users\laz\AppData\Roaming\npm\node_modules\truffle-core\node_modules\truffle-contract\contract.js:372:16
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Truffle "hijacks" the test-system, so it is not obvious how to debug this using a standard IDE debugging setup.
Additionally there is no log-file produced.
Please verify that the existent code actually works as-is on your side, thus additional setup/debugging effort is avoided.
"npm install" has issues if you leave it in the repository.
Work on issue #11 has brought up multiple issues, mainly with documentation, dev-system-setup, and some more or less hidden bugs.
The work on this issues was/is beyond the scope of #11, yet it is important that this work is done. This is a prioritized/sequenced list:
(high severity issue)
Work on #11 has brought up a cascade of problems, which finally do not seem related to Windows.
Setting up an isolated development-environment should be simplified. This way, any interested parties (like contributors, developers or evaluators) can come faster in contact with the cryptobridge-contracts, .
The suggested solution is to provide a minimal docker image, which contains everything and with the right versions, so test/work/evaluation can be started immediately, without loosing time and creativity with dev-system setup & troubleshooting.
(draft)
(affects #11, but is out of its scope. Should be provided in future)
This came up during setup for work on #11. There were missing dependencies and finally problems with installation of termios on windows.
This documentation should be provided by the project, as its beyond the scope of issue #11
(I will at this point retry the setup using this time an Ubuntu Subsystem on Win10. )
(related: #11)
The parity/boot.js
which launches the 2 parity test-instances use npm modules which introduces problems.
Installation on a Windows 10 machine brings up several problems, even if the Bash Shell is used (Windows Linux Subsystem, with Ubuntu 16.04).
The installation on a standard Windows 10 Home machine should be enabled and simplified.
This would possibly mean to either solve existent problems (workarounds or fixes), or (prefered) to replace the incompatible modules which seem to have low usage & maintenance.
Modules:
Usage Statistics:
in comparison (picked quickly a pupolar module)
truffle.js
to e.g. test-client.js
(name-clash on windows)(blocks #11)
Copied from the in-source documentation:
// even one(!) more parameter leads to "CompilerError: Stack too deep,
// try removing local variables.". Applying Packing/Slicing has its
// limits, as it has stack-cost, too (and needs sometimes local vars,
// as it does below).
// Suggestion (essentially a must):
// Overall rewrite of proveReceipt, to use other techniques/concepts,
// thus stack-cost is reduced significantly. After this, at minimum
// one of the 2 other functions (prep / withdraw) will be mergable.
This re-implementation will possibly spawn over to other code-files. It is an absolute necessity, in order to allow the completion of #11.
(affects #11)
The libraries in use should be updated to the latest versions, starting with BytesLib.sol
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.