Into_Aurora_02: Rainbow Bridge Overview

Near Protocol Nigeria (NPK Guild)
5 min readSep 23, 2022

author: cenwadike.near || twitter: @iam_combi16

Intro

Rainbow Bridge, connecting NEAR Protocol and Ethereum is of the most underrated blockchain bridge.

Rainbow bridge stands out in terms of security and scalability. To understand, you need to know the architecture of a regular blockchain bridges first.

Regular bridges

Bridging is simply sending an asset to an escrow account on a “source chain”, and minting the corresponding asset from so-called “Minter contract” on the “target chain”.

In the case of a regular bridge, some kind of entity (might be one entity, multi-sig, or validators) has to monitor the balances of the escrow and minter accounts, as well as track information about senders, amounts, and receivers as assets move through the bridge.

The obvious risk of this architecture lies in its centralization. As entities could act maliciously if they have sufficient economic incentive.

For many regular blockchain bridges, users merely trust a single entity in transferring millions of assets.

Rainbow bridge

With the Rainbow bridge, you don’t need to trust the bridge itself. Rainbow bridge uses the lowest possible trust level one can have for an interoperability solution — you only need to trust NEAR protocol and Ethereum.

In other words, you don’t need to worry about a centralized entity to be in charge of your transfer — we call it “trustless”.

The core idea behind rainbow bridge is :

1. An Ethereum light client implemented on NEAR.

2. A NEAR light client implemented on Ethereum.

3. A mechanism to relay block headers between both blockchain

4. Asset connectors

What is a light client then?

A light client is a protocol specification that tracks the state of the blockchain without running heavy computation. A light client can independently verify the state that it tracks in a “trustless” way.

Rainbow bridge implements light clients for NEAR and Ethereum as smart contracts on each chain.

Put simply, this smart contract on the NEAR has the ability to validate an Ethereum hash. In contrast, smart contracts on Ethereum have the ability to validate NEAR’s consensus on a block as well.

This means there is no need for a middle party to validate unlike a regular bridge.

Rainbow bridge also implemented relay services for Ethereum to NEAR relay and NEAR to Ethereum relay.

The Ethereum to NEAR relay service, among other features, validates the hash of Ethereum state(block) and submits the block header information to the Ethereum light client on NEAR.

NEAR to Ethereum relay service contrasts the functionality of Ethereum to NEAR relay service. It validates NEAR block header and submits the block header information to NEAR light client on Ethereum.

Rainbow bridge also implements “watchdogs” service which can be run by anyone. The “watchdog” service monitors the relayed block headers, conducts validation of block signatures, and can automatically challenge the validity of blocks.

If a challenge is successful, i.e. the relayed block is “fake”, the relayer of the fake block is slashed, and the “watchdog” gets rewarded.

Asset connectors

Rainbow bridge asset connectors extend the core bridge functions, and implement logic of how specific assets are bridged from the source chain to the target chain.

ERC-20/NEP-141-connector which connects fungible tokens between Ethereum and NEAR, is composed of smart contracts on NEAR and Ethereum

Ethereum contracts can lock the user’s fund, verify proof for withdrawal of ERC-20 token from NEAR and unlock the user’s fund.

NEAR contracts can verify proof for deposit from Ethereum, mint wrapped-ERC-20 token, and burn wrapped-ERC-20 token.

Security assumptions

Unlike Ethereum, NEAR uses Ed25519 to sign messages of the validators who approve the blocks. And unfortunately, Ethereum runtime is incapable of decoding Ed25519 itself as of the time of writing, meaning that it has to be done by the third party.

On this note, Rainbow bridge implemented Ed25519 in a smart contract on Ethereum. However, high computational power is required to verify these signatures on the smart contract — which means prohibitively high gas fees to run on the smart contract on Ethereum.

Rainbow bridge guarantees trustless relayer service on Ethereum using “watchdogs” .

As such, the NEAR light client on Ethereum acts in an “optimistic” way with the “watchdogs”; while the Ethereum light client on NEAR is “realistic” — NEAR is able to validate Ethereum hash at a small cost.

Every time a NEAR block is submitted, it is stored in a so-called untrusted state.

Only after some period of time(4 hours atm), in the case a challenge was not issued, then the block is treated as finalized. Here, the watchdog is the one who is challenging the light client.

The light client on the Ethereum verifies everything in the NEAR header except the signatures. “Watchdogs” conduct validation of signatures off-chain and if any fraud is detected, they submit a challenge by running an Ed25519 verification off-chain and submitting a proof on-chain.

Conclusion

Rainbow bridge is a robust blockchain bridge that has withstood 2 unsuccessful attacks. It uses a realistic Ethereum light client on NEAR and an optimistic NEAR light client on Ethereum. Trustless NEAR to Ethereum relay is enforced by “watchdogs”. And specific assets are connected on both chains using connectors.

“watchdogs” service is said to be soon replaced by zero knowledge proof, to provide better guarantee for a trustless experience from Rainbow bridge.

Reference:

Rainbow Bridge: https://near.org/blog/eth-near-rainbow-bridge/

Rainbow bridge is underrated: https://twitter.com/0xnarumi/status/1568687342155886592?t=CrVINUk6_vpC7BdkL4H92A&s=08

Rainbow bridge repository: https://github.com/aurora-is-near/rainbow-bridge

Rainbow token connector: https://github.com/aurora-is-near/rainbow-token-connector

“watchdogs won’t be needed”: https://twitter.com/mnaeraxr/status/1521043400367259650?s=20

FOR MORE INFORMATION FOLLOW US AT

Twitter :https://twitter.com/nearprotocolng?s=21

Telegram: https://t.me/NPKGUILD

website: https://nearnigeria.org/

--

--

Near Protocol Nigeria (NPK Guild)

NPK Guild is a Near Protocol Community based in Nigeria, aimed at educating and incentivising young Nigerians onBlockchain technology and the NEAR ECOSYSTEM