- before getting to know Peace Relay, you should first learn about how BTC Relay works
- formal introduction of Peace Relay and more detail by Loi Luu on medium!
Peace Relay is a system of smart contracts that aim to allow for cross-EVM-chain communication using relay contracts.
These contracts will be able to verifiy merkle-patricia proofs about state, transactions, or receipts within specific blocks.
This, along with the wonderful Ethash verification work done by SmartPool, allows for trustless cross chain transfers of all tokens on any EVM chain. This implementation uses the merkle-patricia proofs implemented by Zac Mitton.
-
Some important notes:
- In order to do cross-chain verification, we need valid block header informations stored in
PeaceRelay
contract so then other proofs like transaction proof or account state proof can be verified based on merkle roots in block header. Right now in the early stage of Peace Relay we assume the block header submitted is the correct header from counter chain. In the future, these headers will be verified based on PoW within and chain re-organization will be taken care of. - In the demo, when user in one chain(say ETH) wants to transfer his funds to other chain(say ETC), he will lock his ethers in ETH and gets some tokens on ETC in return. Then he can use these tokens for his business on ETC chain. If someone wish to trade ethers between chains, they can use Peace Relay the way others use BTC Relay - by verifying a transaction and it's value.
- In order to do cross-chain verification, we need valid block header informations stored in
-
How it works step by step:
- Here we assume a scenario where a user wish to lock his ethers in ETH and gets some tokens in ETC in return. There are
PeaceRelay
contracts deployed on both ETH and ETC,ETCLocking
contract deployed on ETH andETCToken
contract deployed on ETC.PeaceRelay
contract stores block headers.ETCLocking
contract locks/unlocks the ethers in ETH.ETCToken
contract mints/burns tokens in ETC.
- deploy
PeaceRelay
contract on both ETH and ETC and submits headers into the contract- block header of ETH is submitted into
PeaceRelay
contract on ETC and vice versa
- block header of ETH is submitted into
- deploy
ETCLocking
on ETH andETCToken
on ETC - send transaction to execute
ETCLocking.lock
function along with amount of ethers to lock- note that in
ETCLocking.lock
function, there's no way this function will abort(throw) unless no enough gas is provided for execution, so in order to make sure that ethers did get locked in we require that transaction sender must provide with enough amount of gas
- note that in
- generate the proof of the transaction in step 4 off-chain
- send transaction to execute
ETCToken.mint
function provided with proof from step 5- then user can spend those tokens at will until someday they wish to convert them back to ethers in ETH
- to convert tokens to ethers, send transaction to execute
ETCToken.burn
to burn the tokens - generate the proof of the transaction in step 6 off-chain
- proof in this step contains transaction and corresponding transaction receipt
- send transaction to execute
ETCLocking.unlock
function provided with proof from step 7 to unlcok ethers
- Here we assume a scenario where a user wish to lock his ethers in ETH and gets some tokens in ETC in return. There are