Peggy dev update #1:

75% of the cost of your transfer across the bridge is a simple state update in an ERC20 contract. We manage to fit all the hashing and verifications for 125 signatures into 25% of the cost!

Peggy dev update #1:

At the moment of writing Ethereum gas is at a record 300gwei, which requires a staggering sum of $2.40 to send a base Ethereum transaction.

ERC20 transactions cost around $4.50 at 300gwei.

At the heart of Althea's design for a  Cosmos <-> Ethereum bridge is an ultra efficient Ethereum contract. Built for the dual challenge of high fees and the large validator set of the Cosmos hub.

The Althea Peggy Ethereum contract can validate a weighted powers vote from the complete set of 125 validators on the Cosmos hub for a cost of $1.20 per Cosmos -> Ethereum ERC20 transfer @ 300gwei. For a total cost of $5.70 per ERC20 transfer.

Consider for a moment how efficient this is. 75% of the cost of your transfer across the bridge is a simple state update in an ERC20 contract. We manage to fit all the hashing and verifications for 125 signatures into 25% of the cost!

We have another two big performance improvements to go! Potentially reducing the bridge to less than 12% of the total ERC20 cost.


The Optimizations

So how did we do it?

Our team is uniquely suited for this.

I worked as a performance engineer on Red Hat’s performance and scale team for two years before leaving to found Althea.

Jehan Tremback, my co-founder and advisor has been closely involved with Ethereum since it's inception, with a speciality in payment channels.

Putting our heads together we decided that rather than trying to avoid the problem of weighted powers votes on the chain we should optimize a multisig wallet for large voting sets and frequent updates.

  1. The validators list is stored as a hash: Instead of storing the validator, set the contract simply hashes it and stores the hash. Emitting an event on any change, the caller must find the event and present it to the contract. This is a 100X improvement over using a storage object for each validator.
  2. Validator votes are verified in order of descending power: Once 66% of the votes are accounted for, signature verifications stop and the action passes. On average this is a 75% reduction in sig operations.
  3. Transactions are batched: By sending a batch of 12 - 100 transactions, the cost of verifying the validator votes can be amortized.

Once deployed this will be the most efficient and, to my current knowledge, the largest scale multisig wallet on Ethereum.

But don't take my word for it, you can run the tests yourself.

#!/bin/bash
git clone https://github.com/cosmos/peggy/
cd peggy && git checkout althea-peggy && cd solidity
HUSKY_SKIP_INSTALL=1 npm install
npm run typechain
npm run evm &
npm run tests

As you can see here, this test is run against the Cosmos hub validator set as of 7/14/2020. The operation containing the ERC20 transfers is 'submitBatch' which is submitting 100 Cosmos -> Ethereum ERC20 transactions as a single operation.

Those of you checking my math may note that that my estimate is coming in too high. I ran my numbers using an even 5 million gas for the 100 transaction batch. On the assumption that that the EVM will require more operations to call many ERC20 contracts than the one ERC20 contract it calls for all 100 transactions in this test batch.

The Peggy Relayer

At this point, active development has moved on from the Ethereum contract.

In the current state it's possible to manually progress the Peggy Cosmos module state machine and send the resulting validator set updates to the Ethereum contract.

Current progress is focused on the Peggy Cosmos module and the tooling required to operate it automatically and most importantly robustly.

When designing Althea's payment system we ran into a lot of reliability problems with Ethereum and Ethereum full nodes [see development updates #61, #70, #71 or #73].

Trying to use Ethereum sometimes and using Ethereum all the time are very different problems.

We're bringing this experience and our battle tested tooling to the Althea Peggy relayer.

Time line

  • End of August: Working relayer tooling, this means working 'valset' updates where the relayer observes the Cosmos chain, produces signatures over the validator set and ferries those to the Ethereum contract.
  • End of September: Working transaction batches, the relayer will be both updating the voting set and ferrying transactions to the test chain
  • End of October: Transaction batch fee market, automated testing of edgecases around bridge failure.
  • End of November: Public testnet
  • December-January 2021: Althea mainnet deployed with Peggy
  • 2021: Peggy for the hub as part of Atom 2021

If you would like to contribute, or just keep track of Peggy development join the Peggy channel on the Cosmos Discord server!