Check out the Issue Explorer
Looking to fund some work? You can submit a new Funded Issue here.
This is a bounty associated with the `Relay.sol` contract. Currently, there are three functions that make up a full withdrawal:
1. [prepWithdraw](https://github.com/GridPlus/cryptobridge-contracts/blob/master/contracts/Bridge.sol#L237) 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.
2. [proveReceipt](https://github.com/GridPlus/cryptobridge-contracts/blob/master/contracts/Bridge.sol#L303) takes receipt data and forms a Merkle-Patricia proof. If successful, it saves the `receiptsRoot` for the block to storage.
3. [withdraw](https://github.com/GridPlus/cryptobridge-contracts/blob/master/contracts/Bridge.sol#L378) 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.
A successful proposal will do the following:
1. Reduce the gas consumption by a significant quantity
2. Reduce the number of withdrawal transactions from 3 to 1. If this cannot be done, it must show evidence of that. A reduction from 3 to 2 is also acceptable if there is evidence it cannot be reasonably reduced to 1.
3. Update the test cases in [bridge.js](https://github.com/GridPlus/cryptobridge-contracts/blob/master/test/bridge.js) to call the updated API with new data.
4. Update the [README](https://github.com/GridPlus/cryptobridge-contracts/blob/master/README.md) to reflect API changes
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`.