From 8f3e95a384638968cf0012249da7205b1a4936c6 Mon Sep 17 00:00:00 2001 From: Salman Pathan Date: Fri, 25 Aug 2023 19:42:58 +0530 Subject: [PATCH] Update readme (#45) * update readme and contributing guidelines * update config path * add mainnet configuration file * update config * update readme * update readme doc --- .github/CODEOWNERS | 1 + .github/CONTRIBUTING.md | 57 +++++++ .github/PULL_REQUEST_TEMPLATE.md | 12 ++ README.md | 154 ++++++++++++++++-- crates/eth2-pallet-init/config.toml | 12 ++ crates/eth2-pallet-init/src/init_pallet.rs | 2 +- eth2substrate-block-relay-rs/config.toml | 17 ++ .../config_for_tests.toml | 12 +- scripts/run-local-light-client.sh | 72 ++++++++ 9 files changed, 314 insertions(+), 25 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 crates/eth2-pallet-init/config.toml create mode 100644 eth2substrate-block-relay-rs/config.toml create mode 100755 scripts/run-local-light-client.sh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..9d93576a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @drewstone @1xstj @salman01zp diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..256b5956 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,57 @@ + + +# Contributing to Webb Protocol Projects + +A big welcome and thank you for considering contributing to Webb Protocol open source projects! It’s people like you that make it a reality for users in our community. + +Reading and following these guidelines will help us make the contribution process easy and effective for everyone involved. It also communicates that you agree to respect the time of the developers managing and developing these open source projects. In return, we will reciprocate that respect by addressing your issue, assessing changes, and helping you finalize your pull requests. + +## Quicklinks + +- [Contributing to Webb Protocol Projects](#contributing-to-webb-protocol-projects) + - [Quicklinks](#quicklinks) + - [Getting Started](#getting-started) + - [Issues](#issues) + - [Pull Requests](#pull-requests) + - [Getting Help](#getting-help) + + +## Getting Started + +Contributions are made to this repo via Issues and Pull Requests (PRs). A few general guidelines that cover both: + +- To report security vulnerabilities, please direct message code maintainers which will promptly be answered. +- Search for existing Issues and PRs before creating your own. +- We work hard to makes sure issues are handled in a timely manner but, depending on the impact, it could take a while to investigate the root cause. A friendly ping in the comment thread to the submitter or a contributor can help draw attention if your issue is blocking. + +### Issues + +Issues should be used to report problems with the implementation, request a new feature, or to discuss potential changes before a PR is created. When you create a new Issue, a template will be loaded that will guide you through collecting and providing the information we need to investigate. + +If you find an Issue that addresses the problem you're having, please add your own reproduction information to the existing issue rather than creating a new one. Adding a [reaction](https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) can also help be indicating to our maintainers that a particular problem is affecting more than just the reporter. + +### Pull Requests + +PRs to our libraries are always welcome and can be a quick way to get your fix or improvement slated for the next release. In general, PRs should: + +- Only fix/add the functionality in question **OR** address wide-spread whitespace/style issues, not both. +- Add unit or integration tests for fixed or changed functionality (if a test suite already exists). +- Address a single concern in the least number of changed lines as possible. +- Include documentation in the repo +- Be accompanied by a complete Pull Request template (loaded automatically when a PR is created). + +For changes that address core functionality or would require breaking changes (e.g. a major release), it's best to open an Issue to discuss your proposal first. This is not required but can save time creating and reviewing changes. + +In general, we follow the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr) + +1. Fork the repository to your own Github account +2. Clone the project to your machine +3. Create a branch locally with a succinct but descriptive name +4. Commit changes to the branch +5. Following any formatting and testing guidelines specific to this repo +6. Push changes to your fork +7. Open a PR in our repository and follow the PR template so that we can efficiently review the changes. + +## Getting Help + +Join us in the [Webb Community](https://discord.gg/cv8EfJu3Tn) and post your question there. \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..56342646 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +## Summary of changes +- + + +### Reference issue to close (if applicable) +- Closes + +----- +### Code Checklist + +- [ ] Tested +- [ ] Documented diff --git a/README.md b/README.md index f940a63b..5e39eed7 100644 --- a/README.md +++ b/README.md @@ -5,29 +5,147 @@ ![Webb Logo](./assets/webb_banner_dark.png#gh-dark-mode-only) -

🪢 🕸️ Eth2 Light Client Relayer 🕸️ 🪢

-

- 🚀 An eth2 -> tangle network relayer for syncing EVM data on Tangle 🚀 -

+

Eth2 Light Client Relayer

-[![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0) -[![Twitter](https://img.shields.io/twitter/follow/webbprotocol.svg?style=flat-square&label=Twitter&color=1DA1F2)](https://twitter.com/webbprotocol) -[![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/webbprotocol) -[![Discord](https://img.shields.io/discord/833784453251596298.svg?style=flat-square&label=Discord&logo=discord)](https://discord.gg/cv8EfJu3Tn) +[![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0)[![Twitter](https://img.shields.io/twitter/follow/webbprotocol.svg?style=flat-square&label=Twitter&color=1DA1F2)](https://twitter.com/webbprotocol)[![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/webbprotocol)[![Discord](https://img.shields.io/discord/833784453251596298.svg?style=flat-square&label=Discord&logo=discord)](https://discord.gg/cv8EfJu3Tn)
-## Running the eth2-subtrate-relay on tangle -1. Compile (via `cargo build -p tangle-standalone --release`) then run the tangle network via `./scripts/run-standalone-local.sh` (branch: `develop`) -2. Run `echo "gown surprise mirror hotel cash alarm raccoon you frog rose midnight enter//webb//0" &> /tmp/empty/secret_key` -4. Checkout the relayer repo (working branch: `thomas/eth_light_client`) -5. Edit the file (as needed) in `./services/light-client-relayer/config_relayer.toml` -6. run `cp ./services/light-client-relayer/config_relayer.toml /tmp/empty/` -7. Set the ETH1_INFURA_API_KEY environment variable (i.e., `export ETH1_INFURA_API_KEY="abc123"`) -8. finally, run the relayer: `cargo r --bin webb-light-client-relayer --features cli -- -c /tmp/empty --tmp -vvvv` +### Getting Started +An eth2 -> tangle network relayer for syncing EVM data on Tangle. -### Goal -In this develop target this version of [**rainbow-bridge**](https://github.com/webb-tools/rainbow-bridge/tree/c0d3986941dbf7f730cc3978c8b27e7e292d41fd). +### Prerequisites + +This repo uses Rust so it is required to have a Rust developer environment set up. First install and configure rustup: + +```bash +# Install +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +# Configure +source ~/.cargo/env +``` + +Configure the Rust toolchain to default to the latest stable version: + +```bash +rustup default stable +rustup update +``` + +Great! Now your Rust environment is ready! + +--- + + +### Tangle Setup +#### 1. Clone Tangle +```bash +git clone https://github.com/webb-tools/tangle.git +cd tangle +cargo build --release -p tangle-standalone +``` +#### 2. Run Tangle Network +```bash +./scripts/run-standalone-local.sh --clean +``` +Note that this will start a clean network state, if you want to continue running on an old state (using old database) +just omit the `--clean` flag. + +#### 3. Insert Key +```bash +echo "gown surprise mirror hotel cash alarm raccoon you frog rose midnight enter//webb//0" &> /tmp/empty/secret_key +``` +--- + +### Light Client Setup + +#### 1. Install Git LFS + +Before getting started, make sure you have [Git LFS installed](../../topics/git/lfs/index.md) in your computer. Open a terminal window and run: + +```shell +git-lfs --version +``` + +If it doesn't recognize this command, you must install it. There are +several [installation methods](https://git-lfs.com/) that you can +choose according to your OS. To install it with Homebrew: + +```shell +brew install git-lfs +``` + +Once installed, **open your local repository in a terminal window** and +install Git LFS in your repository. If you're sure that LFS is already installed, +you can skip this step. If you're unsure, re-installing it does no harm: + +```shell +git lfs install +``` + +#### 2. Configure light client +```bash +# Edit configuration as required +eth2substrate-block-relay-rs/config_for_tests.toml +cp eth2substrate-block-relay-rs/config_for_tests.toml /tmp/empty/ +``` +#### 3. Set Infura API Key +```bash +export ETH1_INFURA_API_KEY="your_infura_key" +``` + +#### 4. Build Light client +```bash +cargo build --release -p node-template +``` + +#### 4. Run light client +```bash +#terminal 1 +./target/release/node-template --tmp --chain local --alice \ + --rpc-cors all --rpc-external --rpc-methods=unsafe \ + --port 30433 \ + --relayer-config-dir=./gadget/config \ + --light-client-init-pallet-config-path=./crates/eth2-pallet-init/config.toml \ + --light-client-relay-config-path=./eth2substrate-block-relay-rs/config.toml + --rpc-port 9444 + +#terminal 2 +./target/release/node-template --tmp --chain local --bob \ + --rpc-cors all --rpc-external --rpc-methods=unsafe \ + --port 30405 \ + --relayer-config-dir=./gadget/config \ + --light-client-init-pallet-config-path=./crates/eth2-pallet-init/config.toml \ + --light-client-relay-config-path=./eth2substrate-block-relay-rs/config.toml + --rpc-port 9445 --bootnodes /ip4/127.0.0.1/tcp/30433/p2p/12D3KooWCzqQx1oEPJ94uDPXPa2VdHqDD5ftpCFmSd5KPHgxMivK + +#terminal 3 +./target/release/node-template --tmp --chain local --charlie \ + --rpc-cors all --rpc-external \ + --rpc-port 9448 \ + --port 30408 \ + --relayer-config-dir=./gadget/config \ + --light-client-init-pallet-config-path=./crates/eth2-pallet-init/config.toml \ + --light-client-relay-config-path=./eth2substrate-block-relay-rs/config.toml + --bootnodes /ip4/127.0.0.1/tcp/30433/p2p/12D3KooWCzqQx1oEPJ94uDPXPa2VdHqDD5ftpCFmSd5KPHgxMivK \ + --unsafe-rpc-external --rpc-methods=unsafe +``` + +--- + +## Contributing + +Interested in contributing to the Webb Relayer Network? Thank you so much for your interest! We are always appreciative for contributions from the open-source community! + +If you have a contribution in mind, please check out our [Contribution Guide](./.github/CONTRIBUTING.md) for information on how to do so. We are excited for your first contribution! + +## License + +Licensed under Apache 2.0 license. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in this crate by you, as defined in the Apache 2.0 license, shall +be licensed as above, without any additional terms or conditions. diff --git a/crates/eth2-pallet-init/config.toml b/crates/eth2-pallet-init/config.toml new file mode 100644 index 00000000..9b875847 --- /dev/null +++ b/crates/eth2-pallet-init/config.toml @@ -0,0 +1,12 @@ +ethereum_network = "Mainnet" +beacon_endpoint = "https://lodestar-mainnet.chainsafe.io" +eth1_endpoint = "https://mainnet.infura.io/v3/ETH1_INFURA_API_KEY" +eth_requests_timeout_seconds = 30 +validate_updates = true +verify_bls_signature = true +hashes_gc_threshold = 51000 +beacon_rpc_version = "V1_5" + +substrate_network_name = "Tangle" +substrate_endpoint = "ws://127.0.0.1:9944" +path_to_signer_secret_key = "/tmp/empty/secret_key" diff --git a/crates/eth2-pallet-init/src/init_pallet.rs b/crates/eth2-pallet-init/src/init_pallet.rs index 9e6cda58..e1d6ce3b 100644 --- a/crates/eth2-pallet-init/src/init_pallet.rs +++ b/crates/eth2-pallet-init/src/init_pallet.rs @@ -59,7 +59,7 @@ pub async fn init_pallet( config: &Config, eth_client_pallet: &mut EthClientPallet, ) -> anyhow::Result<()> { - info!(target: "relay", "=== Contract initialization ==="); + info!(target: "relay", "=== Pallet initialization ==="); println!("config: {:?}", config); if let EthNetwork::Mainnet = config.ethereum_network { assert!( diff --git a/eth2substrate-block-relay-rs/config.toml b/eth2substrate-block-relay-rs/config.toml new file mode 100644 index 00000000..435a230f --- /dev/null +++ b/eth2substrate-block-relay-rs/config.toml @@ -0,0 +1,17 @@ +beacon_endpoint = "https://lodestar-mainnet.chainsafe.io" +eth1_endpoint = "https://mainnet.infura.io/v3/ETH1_INFURA_API_KEY" +network_name = "Mainnet" +headers_batch_size = 33 +substrate_endpoint = "ws://127.0.0.1:9944" +path_to_signer_secret_key = "/tmp/empty/secret_key" +ethereum_network = "Mainnet" +interval_between_light_client_updates_submission_in_epochs = 1 +max_blocks_for_finalization = 5000 +include_next_sync_committee_to_light_client = false +eth_requests_timeout_seconds = 30 +state_requests_timeout_seconds = 1000 +substrate_requests_timeout_seconds = 30 +sleep_time_on_sync_secs = 0 +sleep_time_after_submission_secs = 5 +hashes_gc_threshold = 51000 +beacon_rpc_version = "V1_5" diff --git a/eth2substrate-block-relay-rs/config_for_tests.toml b/eth2substrate-block-relay-rs/config_for_tests.toml index 97c010cb..2c0ce99b 100644 --- a/eth2substrate-block-relay-rs/config_for_tests.toml +++ b/eth2substrate-block-relay-rs/config_for_tests.toml @@ -1,11 +1,11 @@ beacon_endpoint = "https://lodestar-goerli.chainsafe.io" eth1_endpoint = "https://goerli.infura.io/v3/ETH1_INFURA_API_KEY" -path_to_current_sync_committee = "./data/goerli_testdata/next_sync_committee_goerli_period_473.json" -path_to_next_sync_committee = "./data/goerli_testdata/next_sync_committee_goerli_period_474.json" -path_to_execution_blocks_headers = "./data/goerli_testdata/execution_block_headers_goerli_slots_3885697_3886176.json" -path_to_light_client_updates = "./data/goerli_testdata/light_client_updates_goerli_slots_3885697_3886176.json" -path_to_attested_state = "./data/goerli_testdata/beacon_state_goerli_slot_3885731.json" -path_to_finality_state = "./data/goerli_testdata/beacon_state_goerli_slot_3885664.json" +path_to_current_sync_committee = "./eth2substrate-block-relay-rs/data/goerli_testdata/next_sync_committee_goerli_period_473.json" +path_to_next_sync_committee = "./eth2substrate-block-relay-rs/data/goerli_testdata/next_sync_committee_goerli_period_474.json" +path_to_execution_blocks_headers = "./eth2substrate-block-relay-rs/data/goerli_testdata/execution_block_headers_goerli_slots_3885697_3886176.json" +path_to_light_client_updates = "./eth2substrate-block-relay-rs/data/goerli_testdata/light_client_updates_goerli_slots_3885697_3886176.json" +path_to_attested_state = "./eth2substrate-block-relay-rs/data/goerli_testdata/beacon_state_goerli_slot_3885731.json" +path_to_finality_state = "./eth2substrate-block-relay-rs/data/goerli_testdata/beacon_state_goerli_slot_3885664.json" network_name = "Goerli" first_slot = 3885632 slot_without_block = 3885649 diff --git a/scripts/run-local-light-client.sh b/scripts/run-local-light-client.sh new file mode 100755 index 00000000..511f9b62 --- /dev/null +++ b/scripts/run-local-light-client.sh @@ -0,0 +1,72 @@ +#!/bin/bash +set -e +# ensure we kill all child processes when we exit +trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT + +#define default ports +ports=(30433 30405 30408) + +#check to see process is not orphaned or already running +for port in ${ports[@]}; do + if [[ $(lsof -i -P -n | grep LISTEN | grep :$port) ]]; then + echo "Port $port has a running process. Exiting" + exit -1 + fi +done + +CLEAN=${CLEAN:-false} +# Parse arguments for the script + +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -c|--clean) + CLEAN=true + shift # past argument + ;; + *) # unknown option + shift # past argument + ;; + esac +done + +pushd . + +# Check if we should clean the tmp directory +if [ "$CLEAN" = true ]; then + echo "Cleaning tmp directory" + rm -rf ./tmp +fi + +# The following line ensure we run from the project root +PROJECT_ROOT=$(git rev-parse --show-toplevel) +cd "$PROJECT_ROOT" + +echo "*** Start Light client nodes ***" +# Alice +./target/release/node-template --tmp --chain local --alice \ + --rpc-cors all --rpc-external --rpc-methods=unsafe \ + --port 30433 \ + --relayer-config-dir=./gadget/config \ + --light-client-init-pallet-config-path=./crates/eth2-pallet-init/config_for_tests.toml \ + --light-client-relay-config-path=./eth2substrate-block-relay-rs/config_for_tests.toml + --rpc-port 9444 & +# Bob +./target/release/node-template --tmp --chain local --bob \ + --rpc-cors all --rpc-external --rpc-methods=unsafe \ + --port 30405 \ + --relayer-config-dir=./gadget/config \ + --light-client-init-pallet-config-path=./crates/eth2-pallet-init/config_for_tests.toml \ + --light-client-relay-config-path=./eth2substrate-block-relay-rs/config_for_tests.toml + --rpc-port 9445 --bootnodes /ip4/127.0.0.1/tcp/30433/p2p/12D3KooWCzqQx1oEPJ94uDPXPa2VdHqDD5ftpCFmSd5KPHgxMivK & +# Charlie +./target/release/node-template --tmp --chain local --charlie \ + --rpc-cors all --rpc-external \ + --rpc-port 9448 \ + --port 30408 \ + --relayer-config-dir=./gadget/config \ + --light-client-init-pallet-config-path=./crates/eth2-pallet-init/config_for_tests.toml \ + --light-client-relay-config-path=./eth2substrate-block-relay-rs/config_for_tests.toml + --bootnodes /ip4/127.0.0.1/tcp/30433/p2p/12D3KooWCzqQx1oEPJ94uDPXPa2VdHqDD5ftpCFmSd5KPHgxMivK \ + --unsafe-rpc-external --rpc-methods=unsafe +popd