# Bridge: Web3 Foundation Grant Application (Public) ## Grant Description (will turn into MD file for PR) # General purpose Bridge - Substrate <-> Ethereum Centrifuge would like to build a general-purpose bridge to pass arbitrary messages between the Centrifuge (Substrate) Chain and Ethereum or any other target network. There is an increasing need of a general purpose bridge by the community to solve the growing need of arbitrary chain communication challenges. Centrifuge requires multiple types of message to be passed between the Centrifuge Chain and Ethereum, hence a general purpose message passing bridge is the desired solution. The initial version of the bridge will rely on a trusted/semi-decentralized setup with the option to extend the bridge over time to be more trustless/decentralized. This design allows proving out arbitrary message passing between the different networks in the first step foregoing the added complexity of a completely trusted bridge. The development effort will cover: - Moving arbitrary data from substrate chain to Ethereum - Moving NFTs being minted on substrate chain to Ethereum ERC721 - Developer documentation - How-to-run own bridge documentation ## Team Members Centrifuge * Philip Stehlik (Project lead) * Miguel Hervas Lazaro (Substrate, Go, Ethereum) * Philip Stanislaus (Substrate, Go) * Manuel Polzhofer (Ethereum) ChainSafe * Gregory Markou (Project Lead, Go, Rust) * Other ChainSafe developers ## Team Website Centrifuge https://centrifuge.io/ ChainSafe https://chainsafe.io/ ## Legal Structure Centrifuge is the main applicant for the grant. The development effort is stemming from Centrifuge's requirements. Centrifuge works with ChainSafe as a contractor to supplement the development capacities. The grant will be executed with Centrifuge's German GmbH. ## Team's Experience The Centrifuge team has built a decentralized platform for the financial supply chain (invoices, purchase orders, warehouse receipts) comprising of a P2P network and Ethereum smart contracts over the last 1.5 years. [The platform](https://medium.com/centrifuge/the-centrifuge-protocol-the-inner-workings-4fcbc9f7aa2f) allows [tokenization of any digital assets](https://medium.com/centrifuge/user-mintable-privacy-enabled-nft-via-ethereum-erc-721-662ba7e4425). A strong team in the [DeFi movement](https://medium.com/centrifuge/tinlake-bringing-individual-non-fungible-assets-to-defi-f5ff0c77cadd), they are now building a Centrifuge-specific chain with Substrate, integrated their existing Go application with the Substrate chain. The Centrifuge team also developed the Go Substrate RPC client supported by a [Web3 Foundation grant](https://medium.com/web3foundation/web3-foundation-grants-wave-3-recipients-6426e77f1230!). The Centrifuge team has deep knowledge in distributed/decentralized applications, libp2p, Golang, Solidity and Ethereum overall, zkSNARKs, and tokenization of assets with NFTs and has been developing with Substrate since Summer 2019. Following previous exchanges/collaboration on integrating the Centrifuge Go Applications with Substrate RPC, the Centrifuge team is excited to work directly and continuously with the ChainSafe team on this bridge project. ChainSafe Systems is a Toronto based blockchain R&D firm. Our focus is on building the future of Web3. Our current work consists of several open source initiatives that we undertake internally as well as various projects which are commissioned by clients. We are proud to be working towards the release of ETH2.0. As part of phase 0, we are working on an implementation of the beacon chain in TypeScript, as well as the accompanying libraries such as ssz-js, gossipsub-js & bls-js. We have also received funding for light client research and development and are excited to be moving full speed ahead on this front as well. ChainSafe is also working towards the release of Gossamer, a Golang implementation of the Polkadot Runtime Environment. ChainSafe is working on Ethermint and converting it into a Cosmos-SDK module. We are also working closely within the Ethereum Classic ecosystem. Our work involves maintaining the Geth Classic Client and of updating the client to meet the Atlantis and Aghartha hard forks. In conjunction with the Geth Classic Client, we are currently adding ETC support to Hyperledger Besu. Finally, ChainSafe has begun working with Aragon One to create Aragon Chain, a custom implementation of the Aragon ecosystem built as a Cosmos SDK module based on Ethermint. ## Team Code Repos * https://github.com/centrifuge/centrifuge-chain * https://github.com/centrifuge/go-substrate-rpc-client * https://github.com/centrifuge/go-centrifuge * https://github.com/centrifuge/protocol * https://github.com/centrifuge/centrifuge-ethereum-contracts * https://github.com/centrifuge/tinlake * https://github.com/centrifuge/precise-proofs * https://github.com/ChainSafe/ChainBridge * https://github.com/ChainSafe/gossamer ## Intended Language of Development Go (Bridge) Rust (SRML) Solidity (Ethereum contracts) ## Development Roadmap ### Components #### Substrate ##### Substrate: Main Bridge Module The bridge srml modules lock and hold messages (stored as hashes) until the required amount of signatures has been reached. *Estimated cost: ~$5,000* ##### Substrate: Non-fungible Asset Locking Module SRML modules to be deployed to the Substrate Chain to lock non-fungible assets to be sent to the Ethereum mainnet. Required to locking/releasing assets on on the Centrifuge Chain, effectively acting as a bridge safe. *Estimated cost: ~$5,000* #### Ethereum Smart Contracts ##### Main Bridge Smart Contracts This will be the bridge contract on Ethereum that contains the relevant features to ensure security and functionality like registering supported keys for the bridge and alike. The bridge ethereum contracts lock and hold messages (stored as hashes) until the required amount of signatures has been reached. EVM based smart contracts allow for the passing of arbitrary data (a collection of bytes), that can either be handled directly by associated bridge contracts (through the contract receiver model, explained later), or by the end user. If a specific type parameter is supplied in the call to the main bridge smart contracts, the messaged will be carried to the respective receiver. In the example of an ERC20, there would be an ERC20Receiver contract that allows for the distribution of any ERC20 asset. This model can replicated however the bridge operators see fit. The smart contract will be built out such that you can add modules, extending the functionality of the bridge in the future, a design similar to that of the bridge core module. *Estimated cost: ~$6,000* ##### Ethereum: Non-fungible Asset Bridge Contract Solidity contract to (un)lock non-fungible assets. Effectively acting as a bridge safe on Ethereum. *Estimated cost: ~$4,000* #### Core Bridge Application The bridge consists of two major components, the bridge validator & bridge adapters. Bridge adapters are in-charge of both reading and writing to a blockchain, and must be built custom to the specific blockchain. The bridge validator controls the adapters, it listens for events coming from the listening adapter, and relays the necessary information to the specified blockchain writer. Overview: ![](https://storage.googleapis.com/centrifuge-hackmd/upload_3f3d5f24368c47a7858ee8f73ca7086c.jpg) Specific flow: ![](https://storage.googleapis.com/centrifuge-hackmd/upload_566e897b223ec5f1a1644d592f63be87.png) The bridge validator also ensures there are no duplicates messages. *Estimated cost: ~$10,000* ### Timeline and Milestones Final Completion Date: *March 2020* #### PoC-1 (v0.0.1) The goal is to enable the transfer of an arbitrary length byte array from the Centrifuge Chain over a trusted bridge setup to Ethereum. PoC 1 will not have strong security guarantees, the bridge contracts will not contain multi-signatures (an admin will be used), and the bridge will not perform additional due-diligence to ensure an asset has not already been bridged, or missed. PoC 1 is strictly meant to facilitate early testing of the interactions moving an NFT from Centrifuge Chain to Ethereum. The NFT transfer will have the foundations of the generic token transferring built in to the Ethereum smart contracts. Verifiable by: - CI build and test status, documentation. In addition, running tests against local centchain + bridge + ethereum-client (dev mode). Will provide How-To documentation + docker images for individual components. Timeline (Duration): *25 days* Cost: *$10,000* #### PoC-2 (v0.0.2) The goal for the Ethereum smart contracts and SRML modules is to add: - multi-signature support - per-chain nonce (a count denoting how many transactions have occurred from a specified chain) - remove the admin functionality (remains optional). The core bridge will perform checks to ensure no duplicate processing of messages. Verifiable by: - CI build and test status, documentation. In addition, running tests against local centchain + bridge + ethereum-client (dev mode). Will provide How-To documentation + docker images for individual components. Timeline (Duration): *30 days* Cost: *$15,000* #### MvP (v0.1.0) MVP adds support for Centrifuge ERC20 to be converted into the native asset on the Centrifuge Chain. It also includes the pervious features: - Generic message passing - Generic ERC handling - Centrifuge NFT transfers Verifiable by: - CI build and test status, documentation. In addition, running tests against local centchain + bridge + ethereum-client (dev mode). Will provide How-To documentation + docker images for individual components. Timeline (Duration): *15 days* Cost: *$5,000* ## Funds Required Overall Development cost for: * Basic bridge + (non)-fungible asset: *~$30,000* ## Outlook The team is planning to integrate the Centrifuge Chain with their existing Go-based application https://github.com/centrifuge/go-centrifuge. With that, the Arbitrary Message Bridge described in this document will find actual usage from day one and the team will maintain and support the client going forward and collaborate with other community members on new feature additions and changes. Even though the initial bridge application will be operated by Centrifuge, it will transition to a trustless setup in the future. In addition to: - Support other blockchains - Research incremental decentralization: - Consensus mechanism over bridge validators - Verification via blockchain headers - ... ## Additional Information * Centrifuge is currently implementing a Substrate-based chain. The initial public PoS testnet is live. The bridge is a crucial part of interacting with the Ethereum DeFi ecosystem. * ChainSafe has already previously built a modular multi-directional bridge that will be used as a reference point to build a new core bridge completely independent of the source and target chains around it. * ChainSafe has already a Polkadot runtime built in Go (Gossamer), with extensive experience building SRML components. * Centrifuge and ChainSafe have extensive experience integrating their Go applications with Ethereum