An open API service indexing awesome lists of open source software.

https://github.com/nuttymoon/chain-shuttle

:bus: A shuttle to batch cross-chain transfers and lower fees
https://github.com/nuttymoon/chain-shuttle

avalanche blockchain evm nodejs solidity

Last synced: 2 months ago
JSON representation

:bus: A shuttle to batch cross-chain transfers and lower fees

Awesome Lists containing this project

README

        

# Chain Shuttle

:bus: A shuttle to batch cross-chain transfers using [ChainBridge](https://github.com/ChainSafe/chainbridge/) and lower fees.

## State of the project

This project was meant to be plugged on top of the first version of the [Avalanche-Ethereum bridge](https://bridge.avax.network/) that was implemented with ChainBridge.
This first implementation was generating a lot fees and thus it seemed interesting to batch transfers to/from Avalanche. Now that a new low-fee version of the bridge has been deployed, it makes a lot less sense and I stopped developing it.

## TO DO

- [x] Find a way to generate ERC20 token and send them to an address -> `$TAXI` token generated by `cb-sol-cli`
- [x] `registerDeposit()` should accept any ERC20 token
- [x] ChainBridge
- [x] Deploy contracts on 2 chains
- [x] Setup `geth` instead of `ganache-cli`
- [x] Setup ERC20 contracts as mintable/burnable
- [x] Setup `chainsafe/chainbridge` Docker container
- [x] Refactor storage to be able to iterate through keys
- [x] Limit to 1 type of ERC20 token per deposit
- [ ] `registerDeposit()`
- [x] Allow ERC20Handler to withdraw from ChainBridge contract with `approve`
- [x] Send ERC20 tokens through the bridge when shuttle capacity is reached
- [x] Define encoding for dispatch bytes message
- [x] Send dispatch bytes message through the bridge when shuttle capacity is reached
- [x] Embed `dataHash` and `depositNonce` of the ERC20 deposit in dispatch message. `dataHash` computing
- [x] Use a dedicated function to send the dispatch message (to avoid dispatch to happen if the ERC20 deposit has not been executed)
- [ ] `offloadShuttle()`
- [x] Register claimable deposits in state
- [ ] Use destination chain GenericHandler address in `dataHash` computation
- [ ] Check that ERC20 deposit proposal has passed before registering claimable deposits (using `dataHash` and `depositNonce`)
- [ ] Unable to offload a shuttle several times by storing a boolean per `dataHash+depositNonce`
- [x] Test cross-chain message sending/reception
- [ ] Implement a ChainBridge GenericHandler to only allow the shuttle contract to deposit messages
- [ ] Gas optimization
- [ ] Configure realistic gas price
- [ ] Benchmark `require()` + events gas cost
- [ ] Refund the user that payed gas for `sendShuttle()` (ERC20 token?)

## Setup

### Prerequisites

Install `cb-sol-cli`. See their [README.md](https://github.com/ChainSafe/chainbridge-deploy/tree/master/cb-sol-cli).

```sh
git clone https://github.com/ChainSafe/chainbridge-deploy.git
cd chainbridge-deploy/cb-sol-cli
yarn install
make install
```

#### For Avash only

- Install Go and set `$GOPATH` in your env.
- Install and build [avalanchego](https://github.com/ava-labs/avalanchego) and [avash](https://github.com/ava-labs/avash) with sources:
```sh
go get github.com/ava-labs/avash
GO111MODULE=off go get github.com/ava-labs/avash
GO111MODULE=off go get github.com/ava-labs/avalanchego
cd $GOPATH/src/github.com/ava-labs/avalanchego
./scripts/buid.sh
cd $GOPATH/src/github.com/ava-labs/avash
go build
```

### Bootstrap the development environment

Start 2 chains and setup the chainbridge:

```sh
yarn install
yarn develop
```

### Test the code

```sh
yarn test
```

## Collaborate

Commits have to respect [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). They are enforced using [commitlint](https://github.com/conventional-changelog/commitlint) and [husky](https://github.com/typicode/husky).
Use `npx cz` to easily generate commit messages (see [commitizen](https://github.com/commitizen/cz-cli)).

## Useful links

- [Solidity Contracts docs](https://docs.soliditylang.org/en/v0.8.2/contracts.html#)
- [OpenZeppelin Contracts docs](https://docs.openzeppelin.com/contracts/4.x/)
- [Go Ethereum docs](https://geth.ethereum.org/docs/)
- [Chainbridge docs](https://chainbridge.chainsafe.io/)