Skip to content

Latest commit

 

History

History
177 lines (131 loc) · 5.25 KB

README.md

File metadata and controls

177 lines (131 loc) · 5.25 KB

Polkadot Ethereum Parachain

Check Coverage Status

A Polkadot parachain for bridging arbitrary data from and to Ethereum.

Documentation

See our Rustdocs for an overview of the crates, APIs, and types that make up our parachain.

Development

Follow these steps to prepare your local environment for Substrate development.

Requirements

The project is currently being developed and is working with the following version of Rust:

stable-x86_64-unknown-linux-gnu (default)
rustc 1.45.0 (5c1f21c3b 2020-07-13)

Simple Method

Install all the required dependencies with a single command (be patient, this can take up to 30 minutes).

curl https://getsubstrate.io -sSf | bash -s -- --fast

Manual Method

Find manual setup instructions at the Substrate Developer Hub.

Dependencies

Before building the parachain, ensure our smart contracts are deployed on your local truffle chain.

Follow the Setup guide to do this.

Configuration

For a fully operational chain, further configuration may be required.

Ethereum Contract Addresses

Each application module (ETH, ERC20) within the parachain must be configured with the contract address for its peer application on the Ethereum side. These addresses are included in Genesis storage via the chain spec.

For development and testing, it is not necessary to configure these. The builtin chain-spec already includes addresses that work out of the box with contracts deployed via ganache-cli.

To change the config to use your own addresses, follow these steps:

Generate a development chain-spec:

target/debug/artemis-node build-spec --dev > spec.json

Edit the generated spec file and replace the following addresses:

      "ethApp": {
        "address": "0xfc97a6197dc90bef6bbefd672742ed75e9768553"
      },
      "erc20App": {
        "address": "0xeda338e4dc46038493b885327842fd3e301cab39"
      }

Relayer Key

It is not required to change anything here for local development and testing.

The parachain depends on a external relayer service to forward messages to and from Ethereum. The relayer service is trusted by the parachain. Its identity should be injected into the GenesisConfig for the Verifier pallet.

The node's baked-in chain spec uses //Relay as the relayer's account seed. For reference, see chain_spec.rs.

Build

Once the development environment is set up, build the node template. This command will build the Wasm and native code:

cargo build --release

Run

Purge any existing dev chain state:

target/release/artemis-node purge-chain --dev

Start a dev chain:

target/release/artemis-node --tmp --dev

Or, start a dev chain with a custom chain spec:

target/release/artemis-node --tmp --spec spec.json

Interacting with the chain

You can interact with a development chain using our webapp. Its an instance of the Polkadot-JS webapp with the necessary configuration to interact with our development chain.

Custom Types

For interacting with our chain using the Polkadot-JS API, you'll need to supply these custom types:

{
  "Address": "AccountId",
  "LookupSource": "AccountId",
  "AppId": "[u8; 20]",
  "Message": {
    "payload": "Vec<u8>",
    "verification": "VerificationInput"
  },
  "VerificationInput": {
    "_enum": {
      "Basic": "VerificationBasic",
      "None": null
    }
  },
  "VerificationBasic": {
    "blockNumber": "u64",
    "eventIndex": "u32"
  },
  "TokenId": "H160",
  "BridgedAssetId": "H160",
  "AssetAccountData": {
    "free": "U256"
  },
  "EthereumHeader": {
    "parentHash": "H256",
    "timestamp": "u64",
    "number": "u64",
    "author": "H160",
    "transactionsRoot": "H256",
    "ommersHash": "H256",
    "extraData": "Vec<u8>",
    "stateRoot": "H256",
    "receiptsRoot": "H256",
    "logBloom": "Bloom",
    "gasUsed": "U256",
    "gasLimit": "U256",
    "difficulty": "U256",
    "seal": "Vec<Vec<u8>>"
  },
  "Bloom": {
    "_": "[u8; 256]"
  }
}