Skip to content

Instantly share code, notes, and snippets.

@k26dr
Last active March 7, 2018 21:39
Show Gist options
  • Save k26dr/6818f13003ddb22ae6637bdbe90eb5d6 to your computer and use it in GitHub Desktop.
Save k26dr/6818f13003ddb22ae6637bdbe90eb5d6 to your computer and use it in GitHub Desktop.
Relaying Transactions from Ethereum to EOS
<script> document.getElementById('ga-logo').innerHTML = `

Everipedia `; document.getElementById('ga-logo').style.display = "flex"; document.getElementById('logo-image').style.width = "50px"; document.getElementById('logo-image').style.margin = "0 5px"; document.getElementById('logo-text').style.fontWeight = "bold"; document.getElementById('logo-text').style.color = "white"; document.getElementById('logo-text').style.fontSize = "30px"; document.getElementById('logo-text').style.paddingTop = "15px"; </script>

Everipedia Logo

Relaying Transactions from Ethereum to EOS

Kedar Iyer
Travis Moore


Inter-blockchain communication

  • Websites can talk to each other using APIs
    • Common protocol: HTTP
  • Each blockchain operates on its own protocol
    • Direct communication is not possible
    • BTC and ETH cannot directly communicate

Why do we need it?

  • Swap tokens trustlessly
    • Must-have for decentralized exchange
  • Transfer ERC20 tokens to a new chain
    • Many non-Ethereum projects use ERC20 tokens for ICO

Enabling inter-blockchain communication

  • Atomic swaps
    • Only enables token swaps
    • Requires support for hashed timelock contract
    • Almost all blockchains support this
  • Transaction Relays
    • General purpose
    • Enables transactions from one blockchain to be run on another chain
    • Only possible on Turing-complete blockchains

Atomic Swaps

  • Hashed timelock contracts
    • Contracts containing tokens, a hash, and an expiration
    • Unlocked by producing a seed that hashes to the hash
  • Strengths
    • Allows two-way swaps
    • Supported by all major blockchains (BTC, LTC, ETH, EOS, etc.)
  • Weakness
    • Requires human input to verify transactions have been included in chain
    • Only enables token transfers

Transaction Relay

  • Runs a light client of one chain on another
  • Uses merkle proofs to verify transactions
  • Strengths
    • General purpose transactions
    • Fully automated
  • Weaknesses
    • One-way swaps
    • Can only relay to Turing-complete chains

Existing Relays

  • BTCRelay
    • One-way BTC to ETH relay
  • PeaceRelay
    • Two-way ETH <-> ETC relay

ETH-EOS relay

  • One-way relay from Ethereum to EOS
  • Syncs ETH block headers in an EOS smart contract
  • Source Code on Github

Challenges


Ethash is a pain

  • Ethash computation must be verified to prove block validity
  • Requires generating a verification cache
    • Memory Intensive: 32MB
    • CPU Intensive: 1.5s
  • Verification cache can be re-used for 30K blocks (~5.5 days)
    • Verifying with pre-generated cache: 10ms

Calculating From Address

  • ETH does not include the from address in transactions
  • Must be calculated from signature
  • CPU Intensive: 15ms

Verifying Transactions

  • Every block contains a merkle root
  • Merkle proof required to prove a transaction was included in a block
  • Ethereum uses custom trie called Merkle Patricia Trie

Other Challenges

  • Ethereum uses a custom encoding scheme: RLP
  • Full block headers consume 1.5MB per day
    • Only store merkle root and header hash (300KB / day)
    • Merklize block headers (< 1KB fixed storage)

Future of Inter-blockchain Communication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment