All Projects → pantos-io → ethrelay

pantos-io / ethrelay

Licence: MIT license
Ethereum smart contracts that enable the verification of transactions of a "target" blockchain on a different "verifying" blockchain in a trustless and decentralized way

Programming Languages

javascript
184084 projects - #8 most used programming language
solidity
1140 projects

Projects that are alternatives of or similar to ethrelay

syscoin
Syscoin is a crypto currency that is universally merge-mineable and offers a unique variety of services including decentralized identities, asset token issuance platform capabilities directly on the blockchain and trustless 0-counterparty interoptibility with the Ethereum blockchain
Stars: ✭ 152 (+347.06%)
Mutual labels:  interoperability, blockchain-technology
nis-python-client
Python client for NEM NIS API (https://nemproject.github.io). XEM\NEM\Crypto
Stars: ✭ 16 (-52.94%)
Mutual labels:  blockchain-technology
berlinblockchainweek
Website for Berlin Blockchain Week 2018
Stars: ✭ 15 (-55.88%)
Mutual labels:  blockchain-technology
rivine
Blockchain technology for creating custom chains.
Stars: ✭ 23 (-32.35%)
Mutual labels:  blockchain-technology
spacefold
🌓 A demo of instant cross-chain communication using Connext!
Stars: ✭ 57 (+67.65%)
Mutual labels:  cross-chain-communication
MadMax
Ethereum Static Vulnerability Detector for Gas-Focussed Vulnerabilities
Stars: ✭ 96 (+182.35%)
Mutual labels:  blockchain-technology
react-native-defi-app
React Native Defi Decentralized Applications(dApps)
Stars: ✭ 31 (-8.82%)
Mutual labels:  blockchain-technology
blockchain-carbon-accounting
This project implements blockchain applications for climate action and accounting, including emissions calculations, carbon trading, and validation of climate claims. It is part of the Linux Foundation's Hyperledger Climate Action and Accounting SIG.
Stars: ✭ 123 (+261.76%)
Mutual labels:  blockchain-technology
fingernft
FingerNFT是一款开源NFT市场,兼容Opensea、Rarible。
Stars: ✭ 1,827 (+5273.53%)
Mutual labels:  blockchain-technology
Aquarium
A minimalistic blockchain implementation
Stars: ✭ 27 (-20.59%)
Mutual labels:  blockchain-technology
blockgeeks-build-blockchain-advanced
Code that shows how to build your own Bitcoin-like blockchain with JavaScript.
Stars: ✭ 24 (-29.41%)
Mutual labels:  blockchain-technology
deep ethereum
电子书:以太坊技术与实现
Stars: ✭ 304 (+794.12%)
Mutual labels:  blockchain-technology
Simple-Game-ERC-721-Token-Template
🔮 Very Simple ERC-721 Smart Contract Template to create your own ERC-721 Tokens on the Ethereum Blockchain, with many customizable Options 🔮
Stars: ✭ 83 (+144.12%)
Mutual labels:  blockchain-technology
HealthLedger
Application for tracking Organs donations in hospitals and minimizing the scope of Organ trafficking using Blockchain (Hyperledger) technology.
Stars: ✭ 29 (-14.71%)
Mutual labels:  blockchain-technology
hashport-validator
Official repository containing the source code of the Hashport validators
Stars: ✭ 19 (-44.12%)
Mutual labels:  interoperability
readme
The Blockchain Bible,a collections for blockchain tech,bitcoin,ethereum,crypto currencies,cryptography,decentralized solutions,business scenarios,hyperledger tech,meetups,区块链,数字货币,加密货币,比特币,以太坊,密码学,去中心化,超级账本
Stars: ✭ 46 (+35.29%)
Mutual labels:  blockchain-technology
datasacks
Tools to make Unity3D UI connections better.
Stars: ✭ 24 (-29.41%)
Mutual labels:  interoperability
rippled-php
A PHP library for rippled (XRP Ledger) communication.
Stars: ✭ 33 (-2.94%)
Mutual labels:  blockchain-technology
chainDB
A noSQL database based on blockchain technology
Stars: ✭ 13 (-61.76%)
Mutual labels:  blockchain-technology
libra-go
Go Client for interacting with Libra Blockchain
Stars: ✭ 50 (+47.06%)
Mutual labels:  blockchain-technology

ETH Relay

This project contains Ethereum smart contracts that enable the verification of transactions of a "target" blockchain on a different "verifying" blockchain in a trustless and decentralized way.

This means a user can send a request to the verifying chain asking whether or not a certain transaction has been included in the target chain and is verified. The verifying chain then provides a reliable and truthful answer without relying on any third party trust.

The ability to verify transactions "across" different blockchains is vital to enable applications such as cross-blockchain token transfers.

Important: ETH Relay is a research prototype. It represents ongoing work conducted within the TAST research project. Use with care.

Get Started

ETH Relay is best enjoyed through the accompanying go-ethrelay CLI tool that can be found here.
However, if you want to deploy the contracts manually, follow the steps below.

Installation

The following guide will walk you through the deployment of ETH Relay with a local blockchain (Ganache) as the verifying chain and the main Ethereum blockchain as the target blockchain. This means blocks from the main Ethereum blockchain (source) are forwarded to the ETH Relay contract on the local blockchain (destination).

Direct installation

In this section, we describe how to install ETH Relay directly based on Node.js and Truffle. You can find an alternative installation guide based on Docker below.

Direct installation: prerequisites

You need to have the following tools installed:

For simply running the tests, it is not necessarily required to use Ganache as Truffle provides an integrated blockchain that is used for automatic testing.

Direct installation: deployment

  1. Clone the repository: git clone [email protected]:pantos-io/ethrelay.git
  2. Change into the project directory: cd ethrelay/
  3. Install all dependencies: npm install
  4. Deploy contracts: truffle migrate --reset

Direct installation: testing

Run the tests with truffle test.

Docker installation

As an alternative to the direct installation method described above, you can install ETH Relay with Docker.

Docker installation: prerequisites

You need to have

installed.

Docker installation: deployment

There are two different ways how to deploy ETH Relay with Docker. First alternative:

  1. Run Ganache: docker run --network=host trufflesuite/ganache-cli -p 7545 (alternatively, you can also run the GUI variant of Ganache without Docker)
  2. Deploy contracts: docker run --network=host pantosio/ethrelay migrate --reset

Second alternative:

  1. Clone the repository: git clone [email protected]:pantos-io/ethrelay.git
  2. Change into the project directory: cd ethrelay/
  3. Run Ganache and deploy contracts: docker-compose up

Docker installation: testing

Run the tests with docker run --network=host pantosio/ethrelay test.

Export contract

For the export script to work correctly, you should set the GOETHRELAY environment variable to the project root of go-ethrelay on your machine, e.g., export GOETHRELAY=~/code/.../go-ethrelay/. By default, it exports to ${GOPATH}/src/github.com/pantos-io/go-ethrelay.

To generate the Go contract files and export them to the go-ethrelay project run ./export.sh

How it works

Users can query the ETH Relay contract living on the verifying blockchain by sending requests like "Is transaction tx in block b part of the target blockchain?" For the contract to answer the request it has to verify two things.

  1. Verify that block b is part of the target blockchain.
  2. Verify that transaction tx is part of block b.

The way this is achieved is the following:

1. Verifying Blocks

To verify that a block b is part of the target blockchain, the ETH Relay contract on the verifying chain needs to know about the state of the target blockchain.

For that, clients continuously submit block headers of the target chain to the ETH Relay contract. For each block header that the contract receives, it performs a kind of light validation:

  1. Verify that the block's parent already exists within the contract.
  2. Verify that the block's number is exactly one higher than its parent.
  3. Verify that the block's timestamp is correct.
  4. Verify that the block's gas limit is correct.

If these checks are successful, the contract accepts the block and stores it internally.

The contract does not verify the Proof of Work (PoW) for each block it receives, as validating the PoW for every block becomes very expensive. Instead, the contract assigns a dispute period to newly added blocks. Within this period, clients have the possibility to dispute any block they think is illegal.

In case of a dispute, the full PoW verification is carried out. If the verification fails, the block and all its successors are removed from the contract.

This way, the target chain is replicated within the ETH Relay contract on the verifying chain, so that the contract can reliably provide an answer to the question whether or not a block b is part of the target blockchain.

2. Verifying Transactions

So now the contract knows whether or not a block b is part of the target blockchain. It now needs to verify that the transaction tx is part of block b.

Whenever a client sends a transaction verification request to the contract, it needs to generate a Merkle Proof first. The Merkle Proof is sent with the request and is then verified by the contract. If the proof validation is successful, transaction tx is part of block b. If the validation fails, tx is not part of b.

A more detailed explanation of the inner workings can be found here.

Troubleshooting

Wrong Compiler Version

Error: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Linux.g++) - note that nightly builds are considered to be strictly less than the released version
 --> contracts/Ethrelay.sol:2:1:
  |
2 | pragma solidity >=0.7.0 <0.9.0;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Make sure the recommended Solidity compiler version (0.9 > version >= 0.7) is used with solc --version.

Legacy Access Request Rate Exceeded Error

When running the tests you might run into the following error: Returned error: legacy access request rate exceeded or Returned error: project ID is required.

To fix this error, create an account with Infura and create a new Infura project. Then in file ./constants.js change the constant INFURA_ENDPOINT to the mainnet URL from your Infura project (e.g. https://mainnet.infura.io/v3/ab050ca78686478a9e9b06dfc4b2f069).

Wrong Truffle Version

When running the tests you might run into the following error: TypeError: param.substring is not a function.

To fix this error, make sure the recommended Truffle version is used, i.e. v5.1.29.

How to contribute

ETH Relay is a research prototype. We welcome anyone to contribute. File a bug report or submit feature requests through the issue tracker. If you want to contribute feel free to submit a pull request.

Acknowledgements

  • The development of this prototype was funded by Pantos within the TAST research project.
  • The original code for the Ethash contract that is partly used in this project comes from the smartpool project.
  • The code for the RLPReader contract that is partly used in this project comes from Hamdi Allam with parts of it taken from Andreas Olofsson.

Licence

This project is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].