Gear Bridge is an implementation of a trustless ZK-based cross-chain bridge facilitating the transfer of assets between Ethereum and Gear-based blockchains, such as the Vara network.
Ethernal team have performed partial audit of the code, which covered the following scope for the commit d42251c:
- prover
plonky2circuits for crypto primitivesethereumsmart-contracts
Warning
One of the conclusions of this audit was that malicious node which relayer is connected to can cause the proof generation process to be halt. So all deployed relayers MUST use their own dedicated gear node which is known to be non-malicious.
They've also performed another audit which covered the following scope for the commit 8b1018bd:
gearprogramsethereumsmart-contracts
The Gear <-> Eth transfer protocol allows relaying messages from Gear-based blockchains to Ethereum and back. These messages contain generic data defined by protocols built on top of the bridge. The protocol doesn't guarantee the order in which messages are relayed.
This repository contains the implementation of a token bridging protocol built on top of a more generic messaging protocol.
- Pallet-Gear-Eth-Bridge Built-in Actor: a Built-in Actor - the entry point into the generic bridging protocol. Receives messages from any actor on the Gear network and relays them to
pallet-gear-eth-bridge. - Pallet-Gear-Eth-Bridge: Receives messages from the
pallet-gear-eth-bridgebuilt-in actor and stores them in the binary Merkle trie. This Merkle trie gets slashed at the end of eachERA. Also stores and updates hashedGRANDPAauthority set. - Relayer(proxy)1: Accepts proofs of Merkle trie root inclusion and, if they're valid, stores Merkle trie roots in memory. Deployed behind ERC-1967 Proxy.
- Verifier: A contract capable of verifying
plonkproofs created by gnark. The submitted proofs are plonky2 proofs wrapped bygnark. - MessageQueue(proxy)1: Used to recover messages from Merkle tries. A user can request a message to be relayed further onto Ethereum by providing proof of inclusion of a message actually included in the Merkle trie, given that this Merkle root was already relayed by
gear->eth protocol relayer(or another party). This is also the exit point of the generic Gear -> Eth bridging protocol. - Checkpoint-Light-Client: Lazy ethereum light client that maintains
sync committeevalidator list and is capable of verifying block headers using it. - Ethereum-Event-Client: Program on Gear that's capable of verifying that some event was included into some block. To check validity of the block it requests data from
checkpoint-light-client. - Historical-Proxy: Program on Gear that maintains historical
eth-events-*program addresses and redirects requests to aeth-events-*responsible of processing requested transaction. Serves as an exit point from core Ethereum -> Gear protocol. - Gear -> Eth Protocol Relayer: Reads Gear state, generates ZK-proofs, and submits them to Ethereum. Capable of creating two types of ZK-proofs: proof of authority set changes and proof of inclusion of Merkle trie root into the storage of
pallet-gear-eth-bridge. Proofs of authority set changes are intermediate and stored in on-chainproof storagewhile proofs of Merkle trie root inclusion are submitted to Ethereum. - Eth -> Gear Protocol Relayer: Relayer that monitors
sync committeechanges and blocks signed by it on Ethereum and updates state ofcheckpoint-light-clientusing it.
- VFT: A program capable of transferring, burning, and minting
vfttokens. It repeats the implementation of theERC20standard on the Gear network, the standard implementationvftcan be found here. - VFT-Manager: Receives
vfttokens from users, burns/locks them, and emits a message to thepallet-gear-eth-bridgebuilt-in actor. This message contains information about which token is being bridged, how much of it, and the recipient of funds on the Ethereum network. Also managesEth -> Geartoken transfers by verifying ethereum events usinghistorical-proxyprogram and minting/unlocking corresponding tokens. It can work with both Ethereum and Gear supplied tokens. When token supply is based on Ethereum it will perform burns and mints of correspondingVFTtokens. When token supply is based on Gear it will perform locks and unlocks of correspondingVFTtokens. - ERC20Manager(proxy)1: Mirroring behaviour of
vft-managerbut on Ethereum side and without sending request to apallet-gear-eth-bridge. - Bridging Payment: Program on Gear and smart-contract on Ethereum that have the same functions. When bridging request is sent to them, they collect fees and relay this request to the corresponding smart-contract/program responsible of executing this request. Then some
token relayercan observe events signaling that request have been processed and fee is paid and process this request on the other chain, using its own funds as tx fees.bridging paymentservices are fully in control of relayer that've deployed them, so to perform bridging using them one should trust the owner. - Gear -> Eth Token Relayer and Eth -> Gear Token Relayer: These relayers hook to the events produced by
bridging paymentservices and perform cross-chain actions to guarantee message delivery. For example,gear -> eth token relayercollects bridging fees from user on Gear. When merkle root that contain this message will be relayed to Ethereum, this relayer will send transaction to theMessageQueuethat will trigger transfer fromERC20Managerto the user.
Workflow of Gear -> Ethereum Token2 Transfer
- The user submits his bridging request to
frontend frontendsubmitsapprovecall to thevftprogram. Approve should allowvft-managerto spend amount of tokens that user have requested to bridge.frontendsubmits user request to thebridging-payment.bridging-paymenttakes fee and submits a message to thevft-managerto initiate bridging.- The
vft-managerburns/locksvfttokens and emits a message to thepallet-gear-eth-bridgebuilt-in actor. - The
pallet-gear-eth-bridgebuilt-in actor relays the message topallet-gear-eth-bridge. - The
pallet-gear-eth-bridgestores the message in a Merkle trie. - Eventually, the
gear->eth protocol relayer(or another party) relays the message to theRelayercontract, and it gets stored there. gear->eth token relayersees that user message was relayed and submits a Merkle proof of inclusion to theMessageQueuecontract.- The
MessageQueuecontract reads the Merkle root from theRelayercontract, checks the Merkle proof, and relays the message to theERC20Manager. - The
ERC20Managerreleases funds to the user's account on Ethereum.
Workflow of Ethereum -> Gear Token2 Transfer
- The user submits his bridging request to
frontend frontendsubmitsapprovecall to the correspondingERC20contract. Approve should allowBridgingPaymentto spend amount of tokens that user have requested to bridge.frontendsubmits user request to theBridgingPayment.- The
ERC20Managerlocks/burnsERC20tokens and emits an event. - Eventually, the
eth->gear protocol relayer(or another party) sumbits tocheckpoint-light-clientethereum block which has block number bigger than one where event have been emitted. - Eventually, the
eth->gear token relayer(or another party) submits this event tohistorical-proxy historical-proxyverifies this event by sending a message to the correspondingeth-events-*.eth-events-*verifies that block where event is present is a valid finalized block on ethereum by callingcheckpoint-light-client.historical-proxyroutes user bridging request tovft-managervft-managersends message to avftprogram that corresponds to aERC20token that've been locked/burned in step 4. This message is eithertransfer(in the case when token supply is on Gear) ormint(in the case when token supply is on Ethereum).vftprogram mints/transfers tokens to a user address.
Install rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shInstall golang: golang installation
Install forge:
curl -L https://foundry.paradigm.xyz | bash
foundryupNote
To build ring crate follow BUILDING.md.
Build workspace:
cargo build --release -p relayerAnd then run
./target/release/relayer --helpto see required parameters to start different kinds of relayers.



