Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Relayer Docs #81

Merged
merged 13 commits into from
Mar 17, 2023
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const { withSentryConfig } = require("@sentry/nextjs");
const withNextra = require("nextra")({
theme: "nextra-theme-docs",
themeConfig: "./theme.config.js",
unstable_flexsearch: true,
unstable_staticImage: true,
flexsearch: true,
staticImage: true,
});

const sentryWebpackPluginOptions = {
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
"author": "Webb Team",
"license": "MPL-2.0",
"dependencies": {
"@headlessui/react": "^1.7.7",
"@headlessui/react": "^1.7.13",
"@heroicons/react": "1.0.6",
"@mdx-js/react": "^2.2.1",
"@react-aria/ssr": "3.4.0",
"@sentry/nextjs": "^7.27.0",
"@vercel/analytics": "^0.1.6",
"@mdx-js/react": "^2.3.0",
"@react-aria/ssr": "3.5.0",
"@sentry/nextjs": "^7.43.0",
"@vercel/analytics": "^0.1.11",
"axios": "0.27.2",
"classnames": "2.3.2",
"copy-to-clipboard": "3.3.3",
"framer-motion": "^7.10.2",
"js-cookie": "3.0.1",
"ms": "^2.1.3",
"next": "^13.0.0",
"next": "^13.2.4",
"next-themes": "^0.2.0",
"nextra": "^2.0.1",
"nextra-theme-docs": "^2.0.1",
"nextra": "^2.2.19",
"nextra-theme-docs": "^2.2.19",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "2.4.0",
Expand All @@ -41,21 +41,21 @@
"swr": "1.3.0"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@babel/core": "7.21.0",
"@types/node": "^16.11.12",
"@types/react": "18.0.26",
"autoprefixer": "10.4.13",
"@types/react": "18.0.28",
"autoprefixer": "10.4.14",
"broken-link-checker": "^0.7.8",
"csstype": "3.1.1",
"eslint": "8.29.0",
"eslint": "8.36.0",
"eslint-config-next": "12.3.1",
"eslint-config-prettier": "8.5.0",
"eslint-config-prettier": "8.7.0",
"gray-matter": "^4.0.3",
"postcss": "8.4.20",
"prettier": "^2.6.2",
"postcss": "8.4.21",
"prettier": "^2.8.4",
"rss": "^1.2.2",
"tailwindcss": "3.2.4",
"typescript": "4.9.4"
"tailwindcss": "3.2.7",
"typescript": "4.9.5"
},
"prettier": {
"embeddedLanguageFormatting": "off",
Expand Down
2 changes: 1 addition & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MyDocument extends Document {
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="true"
crossOrigin="anonymous"
/>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;800&display=optional"
Expand Down
1 change: 1 addition & 0 deletions pages/docs/relayer/running-relayer/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"quick-start": "Quick Start",
"running-docker": "Running with Docker",
"cloud-setup": "Running with Systemd",
"config-options": "Configuration Options",
Expand Down
192 changes: 192 additions & 0 deletions pages/docs/relayer/running-relayer/quick-start.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
---
title: Quick Start
description: Get up to speed for running the relayer.
---

import Callout from "../../../../components/Callout";
import { Tabs, Tab } from "../../../../components/Tabs";

# Quick Start

You can spin up the Relayer in a few simple commands. This guide will walk you through the steps to get started.

By the end of this guide, you will have a running relayer that is publicly accessible via HTTPS endpoint behind a reverse proxy.

## Prerequisites

- A Unix-based operating system (Linux, macOS, WSL, etc.)
- curl

## Installation

In your terminal, run the following command to download the latest version of the relayer:

```bash
curl -fsSL https://git.io/get-webb-relayer.sh | sh
```

To install a specific version of the relayer, run the following command:

```bash
curl -fsSL https://git.io/get-webb-relayer.sh | sh -s <version>
```

This will download the relayer binary (or update it if it already exists) and place it in your `$HOME/.webb` directory. The script
will also suggest adding the directory to your `PATH` environment variable.

### Verify Installation

To verify that the relayer was installed successfully, run the following command:

```bash
~/.webb/webb-relayer --version
```

## Configuration

Before running the relayer, you will need to configure it. The relayer could be configured by using TOML or JSON files along with environment variables.
The Relayer will look for configuration files in the default locations, but you can also specify the path to the configuration file using the `--config` flag.

- Default locations for configuration files:

- `$HOME/.config/webb-relayer/` (Linux)
- `$HOME/Library/Application Support/tools.webb.webb-relayer/` (macOS)

For simplicity, we will use the TOML configuration file format in this guide and we will place the configuration file in the default locations.

### Download the Example Configuration File

To download the example configuration file, run the following command:

<Tabs items={["Linux/WSL", "macOS"]} storageKey="selected-binary">
<Tab>

```bash
curl -fsSL https://raw.githubusercontent.com/webb-tools/webb-relayer/master/config/example/config.toml -o ~/.config/webb-relayer/config.toml
```

</Tab>
<Tab>

```bash
curl -fsSL https://raw.githubusercontent.com/webb-tools/webb-relayer/master/config/example/config.toml -o ~/Library/Application\ Support/tools.webb.webb-relayer/config.toml
```

</Tab>
</Tabs>

### Configure the Relayer

Open the configuration file in your favorite text editor and take a look at the configuration options. The configuration file is well-documented and should be self-explanatory.
shekohex marked this conversation as resolved.
Show resolved Hide resolved

### Environment Variables

The relayer can also be configured using environment variables. The environment variables will override the values in the configuration file.
For example, if you want to override the `port` value in the configuration file, you can set the `WEBB_PORT` environment variable.
shekohex marked this conversation as resolved.
Show resolved Hide resolved

For our example configuration file, the following environment variables are required:

- `PRIVATE_KEY` - The private key of the relayer. This can be a hex-encoded private key or a mnemonic phrase.

create a new file called `.env` in the same directory as your current directory and add the following line:

```bash
# Hex-encoded private for the relayer, or the mnemonic phrase
PRIVATE_KEY="0x..."
```

save the file and exit the editor.

shekohex marked this conversation as resolved.
Show resolved Hide resolved
## Running the Relayer

To run the relayer, run the following command:

```bash
~/.webb/webb-relayer -vvv --tmp
```

<Callout type="idea">
The `--tmp` flag will start the relayer with a temporary database. This is useful for testing, but you should not use this flag in production.
</Callout>

You should see the following output:

```rust
2023-03-14T14:13:08.315804Z DEBUG webb_relayer_config::cli: Getting default dirs for webb relayer
at crates/relayer-config/src/cli.rs:61

2023-03-14T14:13:08.316568Z DEBUG webb_relayer_config::cli: Using temp dir for store
at crates/relayer-config/src/cli.rs:131

2023-03-14T14:13:08.352455Z INFO webb_relayer::service: Starting the server on 0.0.0.0:9955
at services/webb-relayer/src/service.rs:141

2023-03-14T14:13:08.355367Z DEBUG webb_relayer::service: Starting Background Services for (goerli) chain.
at services/webb-relayer/src/service.rs:172

2023-03-14T14:13:08.880637Z WARN webb_relayer::service: Tx Queue disabled for (5)
at services/webb-relayer/src/service.rs:1053

2023-03-14T14:13:08.880641Z DEBUG webb_relayer::service: VAnchor events watcher for (0x9678…5077) Started.
at services/webb-relayer/src/service.rs:648

2023-03-14T14:13:08.880660Z DEBUG webb_probe: kind: lifecycle, started: true
at services/webb-relayer/src/main.rs:80

2023-03-14T14:13:08.880666Z WARN webb_relayer::service: Governance relaying is not enabled for relayer
at services/webb-relayer/src/service.rs:1197

2023-03-14T14:13:16.286918Z INFO webb_event_watcher_traits::evm::event_watcher: 🔄 #8650987 of #8654131 (99.9637%)
at crates/event-watcher-traits/src/evm/event_watcher.rs:218
in webb_event_watcher_traits::evm::event_watcher::run with chain_id: Ok(5), address: 0x9678…5077, tag: VAnchor Contract Watcher

2023-03-14T14:13:23.496016Z INFO webb_event_watcher_traits::evm::event_watcher: 🔄 #8653887 of #8654131 (99.9972%)
at crates/event-watcher-traits/src/evm/event_watcher.rs:218
in webb_event_watcher_traits::evm::event_watcher::run with chain_id: Ok(5), address: 0x9678…5077, tag: VAnchor Contract Watcher

2023-03-14T14:13:39.302727Z INFO webb_event_watcher_traits::evm::event_watcher: 🔄 #8654129 of #8654131 (100.0000%)
at crates/event-watcher-traits/src/evm/event_watcher.rs:218
in webb_event_watcher_traits::evm::event_watcher::run with chain_id: Ok(5), address: 0x9678…5077, tag: VAnchor Contract Watcher

```

### Verifying the Relayer is Running

To verify that the relayer is running, you can use the `/api/v1/ip` endpoint:

<Tabs items={["Running Locally", "on a server"]} storageKey="selected-binary">
<Tab>

```bash
curl http://localhost:9955/api/v1/ip
```

</Tab>
<Tab>

```bash
curl http://<your-server-ip>:9955/api/v1/ip
```

</Tab>
</Tabs>

You should see the following output:

```json
{"ip":"<your-public-ip>"}
```

**Congratulations**! You have successfully started the relayer.

## What's Next?

Now that you have the relayer running, you need to run it behind a reverse proxy. You can use [Caddy](https://caddyserver.com/) or [Nginx](https://www.nginx.com/) for this.

Once you have the relayer running behind a reverse proxy, you should be able to access it from your domain name. For example, if you are running the relayer on `relayer.example.com`, you should be able to access the relayer at `https://relayer.example.com/api/v1/ip`.
shekohex marked this conversation as resolved.
Show resolved Hide resolved

After that you may like to configure the relayer by supporting more chains. You can find more information about that in our [Relayer Configuration examples](https://github.com/webb-tools/relayer/tree/main/config).

## Dapp Integration

After completing the above steps, submit a PR with changes for your https endpoint in the [Webb Dapp](https://github.com/webb-tools/webb-dapp) repo.
17 changes: 10 additions & 7 deletions theme.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@ const theme = {
titleTemplate: `%s – Webb`,
};
},
unstable_flexsearch: true,
unstable_staticImage: true,
toc: {
float: true,
},
font: false,
feedback: {
link: "Question? Give us feedback →",
useLink: () => "Question? Give us feedback →",
},
logo: HeaderLogo,
logoLink: false,
Expand All @@ -43,7 +40,7 @@ const theme = {
router.asPath === "/" ? SITE_ROOT : `${SITE_ROOT}${router.asPath}`;

const asPath = router.asPath;

return (
<>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand Down Expand Up @@ -81,8 +78,14 @@ const theme = {
<meta property="og:type" content="website" />
<meta property="og:url" content={fullUrl} />
<link rel="canonical" href={fullUrl} />
<meta property="twitter:image" content="https://webb-assets.s3.amazonaws.com/WebbLogo.svg" />
<meta property="og:image" content="https://webb-assets.s3.amazonaws.com/WebbLogo.svg" />
<meta
property="twitter:image"
content="https://webb-assets.s3.amazonaws.com/WebbLogo.svg"
/>
<meta
property="og:image"
content="https://webb-assets.s3.amazonaws.com/WebbLogo.svg"
/>
<meta property="og:locale" content="en_IE" />
<meta property="og:site_name" content="Webb" />
<link rel="prefetch" href="/" as="document" />
Expand Down
Loading