Connecting to Ethereum

An Ethereum peg zone is the first of its kind that we will be implementing in Cosmos. This is very different from Ethermint, which is the EVM, stripped of Proof-of-Work mining, then layered on top of Tendermint’s consensus and networking protocol stacks. The Ethereum peg zone will enable the movement of ERC20 tokens and Ether between the canonical Ethereum chain and all IBC-connected zones within the Cosmos Network.

The specifications for the peg zone are still being ironed out but you can follow the progress in the peg zone repository, codenamed peggy , linked below.

Cosmos GitHub: (Peggy)

Peggy

In Cosmos, interoperability is easy because we can use the IBC protocol to transfer any crypto-asset. To transfer crypto-assets between Cosmos and Ethereum, however, is very technically complex because IBC packets cannot be efficiently decoded in Ethereum, simply because the EVM isn’t designed to be IBC-compatible. That is, until we implement Peggy.

Peggy had a rough start. The first construction that attempted to connect Cosmos to Ethereum was a hackathon project called ETGate, which turned out to be a gas guzzler. It was designed by Joon, the HackAtom 2 grand prize winner, who we ended up hiring to implement what is now Peggy.

ETGate initially was a direct bridge between the Cosmos Hub and Ethereum which attempted to translate compatibility within the EVM itself. Like so:

[ Ethereum ] <- ETGate -> [ Cosmos Hub ]

This design was highly impractical when confronted with the problem of the different building blocks used in Tendermint and Ethereum. Every primitive used in Tendermint is fundamentally different than that of Ethereum’s. Translating those incompatibilities into compatible, interpretable building blocks inside the EVM, it turns out, is incredibly gas costly.

Here’s the breakdown of those building blocks:

Serialization formats . Tendermint’s encoding method to serialize objects is go-wire. Ethereum serializes objects using RLP (Recursive Length Prefix).

. Tendermint’s encoding method to serialize objects is go-wire. Ethereum serializes objects using RLP (Recursive Length Prefix). Signature schemes . Tendermint uses ed25519 whereas Ethereum uses secp256k1.

. Tendermint uses ed25519 whereas Ethereum uses secp256k1. Data structures. Tendermint stores key-values in IAVL+ trees while Ethereum stores them in Patricia Tries.

ETGate’s design was computationally expensive because it decoded IBC packets within the EVM, of which the contents were Tendermint’s headers, transactions, IAVL+ tree proofs, and ed25519 signatures.

The moment of clarity that led to the evolution of Peggy came from the realization that we could save significant amounts of gas by taking the translation mechanism out of the EVM and onto its own blockchain designed for this specific application.

Peggy’s 5 Components:

Ethereum Smart Contracts: There will be a set of Ethereum smart contracts acting as asset custodians, capable of taking custody of Ethereum native tokens and issuing Cosmos native tokens. Witness: The witness component attests witness to events in Ethereum. It waits for 100 blocks, the finality threshold, and implements this pseudo-finality over the non-finality chain. It runs a fully validating Ethereum node in order to attest to state changes within Ethereum by submitting a WitnessTX to the peg zone. We use a shared security model here by taking the set of Cosmos Hub validators also to be peg zone Witnesses. Peg zone: The peg zone is a translator blockchain, built on Tendermint, that allows users to perform and query transactions. This is how Cosmos communicates with Ethereum. Signer: The signer signs messages using the secp256k1 signature scheme which Ethereum understands to make signatures efficiently verifiable by smart contracts. The signer component generates secp256k1 signatures via the SignTx message and posts it to the peg zone for relaying transactions for validation in the smart contract down the pipeline. Relayer: The relayer component relays a batched list (array) of transactions—signed by the Signer component—and posts them to the Ethereum smart contract.

Tying it All Together

Real World Example: Moving a Cosmos native token→Ethereum

Let’s say, for example, you want to move some quantity of Photons out of Cosmos and convert them to Ether of equal value on Ethereum. How would this work using Peggy? For simplicity’s sake, we’ll gloss over the low-level technical details and just describe the high-level flow.