Skip to content

Commit

Permalink
Merge branch 'main' into ron/polkadot-assets-on-ethereum
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Apr 5, 2024
2 parents fdf15aa + 24b9d31 commit 1e6dac0
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 4 deletions.
4 changes: 2 additions & 2 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ contract Gateway is IGateway, IInitializable {
using Address for address;
using SafeNativeTransfer for address payable;

address internal immutable AGENT_EXECUTOR;
address public immutable AGENT_EXECUTOR;

// Verification state
address internal immutable BEEFY_CLIENT;
address public immutable BEEFY_CLIENT;

// BridgeHub
ParaID internal immutable BRIDGE_HUB_PARA_ID;
Expand Down
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@
* [Initial Deployment of Gateway Contracts](runbooks/initial-deployment-of-gateway-contracts.md)
* [Halt Bridge in Case of Emergency](runbooks/halt-bridge-in-case-of-emergency.md)
* [Contract Upgrades](runbooks/contract-upgrades.md)
* [Run Relayers](runbooks/run-relayers.md)
5 changes: 3 additions & 2 deletions docs/runbooks/initial-deployment-of-gateway-contracts.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
description: >-
How to upgrade the Ethereum gateway controlling the bridge on the Ethereum
side.
How to set the Ethereum gateway controlling the bridge on the Ethereum side.
This guide is specifically for setting the gateway address when deployed
initially, not when the contracts are upgraded.
---

# Initial Deployment of Gateway Contracts
Expand Down
133 changes: 133 additions & 0 deletions docs/runbooks/run-relayers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
description: How to run relayers that are rewarded for relaying bridge messages
---

# Run Relayers

## Snowbridge Infra Suite Repository

This guide references Github repository [Snowfork/snowbridge-infra-suite](https://github.com/Snowfork/snowbridge-infra-suite) for example scripts and config files. 

Clone this repository on your server.

```
git clone https://github.com/Snowfork/snowbridge-infra-suite.git
```

## Relayer Binary

### Build Relayer

To build the relayer from source, follow these steps.

1. [Install Mage](https://github.com/magefile/mage?tab=readme-ov-file#installation)
2. Clone Snowbridge repository and build the relayer

```
git clone https://github.com/Snowfork/snowbridge.git
cd snowbridge/relayer
mage build
```

The relayer binary will be built at `build/snowbridge-relay`. Copy the binary over to the snowbridge-infra-suite directory

```
cp build/snowbridge ../../snowbridge-infra-suite
```

### Docker

TODO update docker release

```
docker pull ghcr.io/snowfork/snowbridge-relay:169e308
```

## Private Keys

You will need the follow private keys for the relayers:

1. Ethereum private keys for 
1. the BEEFY relayer
2. the Parachain relayer (x2 keys - one for the primary governance channel and one for the secondary governance channel)
2. Polkadot private keys for
1. the Beacon relayer
2. the Execution relayer

Add the private key files in directory `keys` in `snowbridge-infra-suite`. Create the following key files:

* beefy-relayer.key
* parachain-0-relayer.key (primary governance)
* parachain-1-relayer.key (secondary governance)
* beacon-relayer.key
* execution-relayer.key

These keys are used by the scripts.

## BEEFY Relayer

The BEEFY relayer relays BEEFY commitments to track consensus on Polkadot.

To run the BEEFY relayer, run script `/scripts/start-beefy-relayer.sh` in `snowbridge-infra-suite`.

It expects:

* A config file at `./config/beefy-relayer.json` Set the following values in the config file:
* `BeefyClient`: The contract address where the BeefyClient is deployed.
* `beefy-activation-block`: The beefy block to start syncing from.
* `endpoint`: Both the Polkadot and Ethereum nodes to connect to.
* `gas-limit`: The Ethereum gaslimit to limit the gas used per transaction.
* An Ethereum private key file at `./keys/beefy-relayer.key`

## Parachain Relayer

The Parachain relayer relays messages from Polkadot to Ethereum for a certain channel. You need to run a relayer per channel that you would like to support.

To run the Parachain relayer, run script `/scripts/start-parachain-relayer.sh 0` in `snowbridge-infra-suite`.

It expects:

* A config file at `./config/parachain-0-relayer.json` Set the following values in the config file:
* `BeefyClient`: The contract address where the BeefyClient is deployed.
* `Gateway`: The contract address where the Gateway contract is deployed.
* `beefy-activation-block`: The beefy block to start syncing from.
* `endpoint`: All the endpoints for the respective chains.
* `channel-id:` The channel of the messages that will be relayed.
* `gas-limit`: The Ethereum gaslimit to limit the gas used per transaction.
* An Ethereum private key file at `./keys/parachain-0-relayer.key`

## Beacon Relayer

The Beacon relayer relays consensus updates on Ethereum to Polkadot. 

To run the Beacon relayer, run script `/scripts/start-beacon-relayer.sh` in `snowbridge-infra-suite`.

It expects:

* A config file at `./config/parachain-0-relayer.json` Set the following values in the config file:
* `endpoint`: Both the Polkadot and Ethereum nodes to connect to.
* A Polkadot private key file at `./keys/beacon-relayer.key`

## Execution Relayer

The Execution relayer relays messages from Ethereum to Polkadot for a certain channel. You need to run a relayer per channel that you would like to support.

To run the Beacon relayer, run script `/scripts/start-execution-relayer.sh` in `snowbridge-infra-suite`.

It expects:

* A config file at `./config/parachain-0-relayer.json` Set the following values in the config file:
* `Gateway`: The contract address where the Gateway contract is deployed.
* `endpoint`: Both the Polkadot and Ethereum nodes to connect to.
* `channel-id:` The channel of the messages that will be relayed.
* A Polkadot private key file at `./keys/beacon-relayer.key`

## Service Files

To register the relayers as systemd services, use each service file under `snowbridge-infra-suite/services`. Each service can be registered with these steps:

```
sudo systemctl enable services/beacon-relay.service
sudo systemctl start beacon-relay.service
sudo systemctl status beacon-relay.service
```
3 changes: 3 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go 1.20

use ./relayer
39 changes: 39 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA=
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

0 comments on commit 1e6dac0

Please sign in to comment.