relayer

command module
v0.0.0-...-b4f0473 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: LGPL-3.0 Imports: 3 Imported by: 0

README

Relayer

Relayer service that streams transactions from blockchain networks, packages data into messages, and sends the packages to the correlated bridge component.

Development

Run mage to see a list of available tasks (building, testing, linting, etc).

To enable revive for linting in VS-code, add the following to your config:

{
    "go.lintTool": "revive",
    "go.lintFlags": [
        "-config=${workspaceFolder}/revive.toml"
    ],
}

Contract Bindings

The relayer relies on dynamically generated bindings for our Ethereum contracts. They need to be updated whenever the contracts change.

Compile the contracts in the contracts directory:

forge build

Generate contract bindings:

go generate ./...

SSZ Encodings

To generate the SSZ encodings:

go install github.com/ferranbt/fastssz/sszgen
sszgen --path relays/beacon/state/beacon.go --objs BeaconStateCapellaMainnet,BlockRootsContainerMainnet,TransactionsRootContainer,BeaconBlockCapellaMainnet,WithdrawalsRootContainerMainnet

Configuration

Note: For local development and testing, we use our E2E test stack described here. It automatically generates suitable relayer configurations for testing.

For an example configuration, please consult the setup script for our local development stack. Specifically the start_relayer bash function.

Tests

To run both unit and integration tests, start a local E2E test stack and run the following command:

mage test

Running

Run message relayer with multiple instances

Configuration required for different relayers to coordinate. Take execution-relay which relayes message from Ethereum to AssetHub for example, assuming there are 3 instances deployed:

execution-relay-asset-hub-0.json


{
  ...
  "schedule": {
    "id": 0,
    "totalRelayerCount": 3,
    "sleepInterval": 20
  }
}

execution-relay-asset-hub-1.json


{
  ...
  "schedule": {
    "id": 1,
    "totalRelayerCount": 3,
    "sleepInterval": 20
  }
}

execution-relay-asset-hub-2.json


{
  ...
  "schedule": {
    "id": 2,
    "totalRelayerCount": 3,
    "sleepInterval": 20
  }
}

  • id: ID of current relayer(start from 0)
  • totalRelayerCount: Number of total count of all relayers
  • sleepInterval: Sleep interval(in seconds) to check if message(nonce) has already been relayed

The configuration above applies also to multiple instances of parachain-relay which relayes message from AssetHub to Ethereum.

Cost Analysis
Running Ethereum message relayer

For Ethereum message relayer take extrinsic for example:

As we can see it will cost 0.041163771 DOT as transaction fee and the reward is 0.053783 DOT, so it's about 0.012 DOT as incentive for each message.

Running Parachain message relayer

For Parachain message relayer take transaction for example:

As we can see it will cost 0.000628 ETH as transaction fee and the reward is 0.000942 ETH, so it's about 0.0003 ETH as incentive for each message.

Documentation

Overview

Copyright © 2020 Snowfork <denali@snowfork.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis
cmd
run
Package crypto is used to provide functionality to several keypair types.
Package crypto is used to provide functionality to several keypair types.
beacon/state
Code generated by fastssz.
Code generated by fastssz.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL