Skip to content

🚌 A shuttle to batch cross-chain transfers and lower fees

License

Notifications You must be signed in to change notification settings

Nuttymoon/chain-shuttle

Repository files navigation

Chain Shuttle

🚌 A shuttle to batch cross-chain transfers using 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 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

  • Find a way to generate ERC20 token and send them to an address -> $TAXI token generated by cb-sol-cli
  • registerDeposit() should accept any ERC20 token
  • ChainBridge
    • Deploy contracts on 2 chains
    • Setup geth instead of ganache-cli
    • Setup ERC20 contracts as mintable/burnable
    • Setup chainsafe/chainbridge Docker container
  • Refactor storage to be able to iterate through keys
  • Limit to 1 type of ERC20 token per deposit
  • registerDeposit()
    • Allow ERC20Handler to withdraw from ChainBridge contract with approve
    • Send ERC20 tokens through the bridge when shuttle capacity is reached
    • Define encoding for dispatch bytes message
    • Send dispatch bytes message through the bridge when shuttle capacity is reached
    • Embed dataHash and depositNonce of the ERC20 deposit in dispatch message. dataHash computing
  • Use a dedicated function to send the dispatch message (to avoid dispatch to happen if the ERC20 deposit has not been executed)
  • offloadShuttle()
    • 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
  • 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.

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 and avash with sources:
    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:

yarn install
yarn develop

Test the code

yarn test

Collaborate

Commits have to respect Conventional Commits. They are enforced using commitlint and husky.
Use npx cz to easily generate commit messages (see commitizen).

Useful links

About

🚌 A shuttle to batch cross-chain transfers and lower fees

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published