Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominikkq authored Jun 27, 2023
1 parent f429763 commit 21ab20f
Showing 1 changed file with 3 additions and 286 deletions.
289 changes: 3 additions & 286 deletions federator/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Federator

Presents the event and necesary information to validate it on the other network
Presents the event and necesary information to validate it on the other network.
The federator is an off-chain process which performs voting actions to validate transactions between a Mainchain (source) and a Sidechain (target) network. These transactions are obtained from the Bridge contract on the Mainchain using event logs and voted in the Sidechain through a Federation contract. Once all required signers (federators) vote for a transaction the Federation contract starts the process to release the funds on the Sidechain.
The federators will be the owners of the contracts willing to allow to cross their tokens, and by doing so staking they reputation.

## Config

Go to /federator/config copy `config.sample.js` file and rename it to `config.js` set mainchain and sidechain to point to the json files of the networks you are using, for example rsktestnet-kovan.json and kovan.json, `make sure to set the host parameter of those files`. Add a value to the key `FEDERATOR_KEY` in the .env file, and add the private key of the member of the Federation contract, also you can define a general retry attempts number for the failed processes in the application by setting the value of the key `ENV_DEFAULT_ATTEMPTS` to the number of attempts that you desire, you can use 0 for infinite attempts, if no attempt is provided the default value is 3. The members of the federation are controled by the MultiSig contract, same that is owner of the Bridge and AllowedTokens contracts.
You will also need to add an [etherscan api key](https://etherscan.io/myapikey) in this config file.
> Please also note that the private node of RSKj should be running and synced with public one.
## Usage

Run `npm install` to install the dependencies, make sure you followed the previous config step. Then to start the service run `npm start` which will start a single federator that listen to both networks. Check the logs to see that everything is working properly.
Expand All @@ -20,7 +21,7 @@ In order to test with multiple federators, ensure they're added as members of th

## Run a Federator

### config
### Config

To run the federator using Docker, go to the /federator/config folder and rename `config.sample.js` to `config.js`. In that file you will determine the networks the federate must be listening to, for example for the bridge in testnet a federator config.js will look like

Expand Down Expand Up @@ -122,287 +123,3 @@ This endpoint is introduced, in order to better monitor health status on the Fed

### Skip HTTPS check
- As an developer you can set in config.js the property `checkHttps: false` to skip the HTTPS check on the host url config

# Datadog

## Datadog metric tracking

A `DATADOG_API_KEY` environment variable should be available for this to work (**only an error log will let you know if this is not configured - the app will run either way**).
This should be a valid API key associated to the Datadog account in which you're going to be tracking the metrics.
Example for setting it: `export DATADOG_API_KEY=08e436512591258b12bf1781ebe`

## Running a local Datadog agent

If you're interested in the metrics to be tracked in a particular account (might be a personal test account), you can follow the instructions [here](https://docs.datadoghq.com/agent/docker/?tab=standard).
Either way, at the time of writing this (mid-October 2021), running a Docker container as follows should suffice:
```
docker run -d --name dd-agent -v /var/run/docker.sock:/var/run/docker.sock:ro -v /proc/:/host/proc/:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e DD_API_KEY=08e436512591258b12bf1781ebe -e DD_SITE="datadoghq.com" -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC="true" gcr.io/datadoghq/agent:7
```

## Datadog dashboard metadata

The following is a basic dashboard that collects metrics tracked by the Federators - just copying it and pasting it into a new timeboard in Datadog should be enough for it to look like the following:
![image](https://user-images.githubusercontent.com/7085857/137196235-dbdc5877-8072-4390-857a-f937ce0122fd.png)

```json
{
"title": "Federator PoC",
"description": "",
"widgets": [{
"id": 3267013605690894,
"definition": {
"title": "Heartbeat",
"type": "group",
"show_title": true,
"layout_type": "ordered",
"widgets": [{
"id": 3281955858405340,
"definition": {
"title": "Main chain heartbeat",
"title_size": "16",
"title_align": "left",
"type": "query_table",
"requests": [{
"formulas": [{
"alias": "latest block",
"conditional_formats": [],
"limit": {
"count": 500,
"order": "desc"
},
"cell_display_mode": "number",
"formula": "query1"
}],
"response_format": "scalar",
"queries": [{
"query": "min:interoperability.token_bridge.heartbeat.main_chain.emission{*} by {host,address,fed_version,node_info,chain_id}",
"data_source": "metrics",
"name": "query1",
"aggregator": "last"
}]
}],
"has_search_bar": "auto"
}
}, {
"id": 4101321670212740,
"definition": {
"title": "Main chain latest block processed",
"title_size": "16",
"title_align": "left",
"type": "query_value",
"requests": [{
"formulas": [{
"formula": "query1"
}],
"response_format": "scalar",
"queries": [{
"query": "avg:interoperability.token_bridge.heartbeat.main_chain.emission{*}",
"data_source": "metrics",
"name": "query1",
"aggregator": "avg"
}]
}],
"autoscale": false,
"precision": 0
}
}, {
"id": 1917582770012226,
"definition": {
"title": "Side chain heartbeat",
"title_size": "16",
"title_align": "left",
"type": "query_table",
"requests": [{
"formulas": [{
"alias": "latest block",
"conditional_formats": [],
"limit": {
"count": 500,
"order": "desc"
},
"cell_display_mode": "number",
"formula": "query1"
}],
"response_format": "scalar",
"queries": [{
"query": "min:interoperability.token_bridge.heartbeat.side_chain.emission{*} by {host,address,fed_version,node_info,chain_id}",
"data_source": "metrics",
"name": "query1",
"aggregator": "last"
}]
}],
"has_search_bar": "auto"
}
}, {
"id": 577916112954332,
"definition": {
"title": "Side chain latest block processed",
"title_size": "16",
"title_align": "left",
"type": "query_value",
"requests": [{
"formulas": [{
"formula": "query1"
}],
"response_format": "scalar",
"queries": [{
"query": "avg:interoperability.token_bridge.heartbeat.side_chain.emission{*}",
"data_source": "metrics",
"name": "query1",
"aggregator": "avg"
}]
}],
"autoscale": false,
"precision": 0
}
}]
}
}, {
"id": 6945469758716188,
"definition": {
"title": "ERC721",
"type": "group",
"show_title": true,
"layout_type": "ordered",
"widgets": [{
"id": 8265548757769668,
"definition": {
"title": "Votes per address and chain id",
"title_size": "16",
"title_align": "left",
"show_legend": true,
"legend_layout": "auto",
"legend_columns": ["avg", "min", "max", "value", "sum"],
"type": "timeseries",
"requests": [{
"formulas": [{
"formula": "query1"
}],
"response_format": "timeseries",
"on_right_yaxis": false,
"queries": [{
"query": "sum:interoperability.token_bridge.federator.voting{type:erc721} by {address,chain_id,result}.as_count()",
"data_source": "metrics",
"name": "query1"
}],
"style": {
"palette": "dog_classic",
"line_type": "solid",
"line_width": "normal"
},
"display_type": "bars"
}],
"yaxis": {
"include_zero": true,
"scale": "linear",
"label": "",
"min": "auto",
"max": "auto"
},
"markers": []
}
}, {
"id": 878136284410596,
"definition": {
"title": "Votes per address and chain id",
"title_size": "16",
"title_align": "left",
"type": "query_table",
"requests": [{
"formulas": [{
"formula": "query1",
"limit": {
"count": 500,
"order": "desc"
}
}],
"response_format": "scalar",
"queries": [{
"query": "sum:interoperability.token_bridge.federator.voting{type:erc721} by {address,chain_id,result}.as_count()",
"data_source": "metrics",
"name": "query1",
"aggregator": "sum"
}]
}]
}
}]
}
}, {
"id": 3588165781267182,
"definition": {
"title": "ERC20",
"type": "group",
"show_title": true,
"layout_type": "ordered",
"widgets": [{
"id": 3218485023565918,
"definition": {
"title": "Votes per address and chain id",
"title_size": "16",
"title_align": "left",
"show_legend": true,
"legend_layout": "auto",
"legend_columns": ["avg", "min", "max", "value", "sum"],
"type": "timeseries",
"requests": [{
"formulas": [{
"formula": "query1"
}],
"response_format": "timeseries",
"on_right_yaxis": false,
"queries": [{
"query": "sum:interoperability.token_bridge.federator.voting{type:erc20} by {address,chain_id}.as_count()",
"data_source": "metrics",
"name": "query1"
}],
"style": {
"palette": "dog_classic",
"line_type": "solid",
"line_width": "normal"
},
"display_type": "area"
}],
"yaxis": {
"include_zero": true,
"scale": "linear",
"label": "",
"min": "auto",
"max": "auto"
},
"markers": []
}
}, {
"id": 2598946470976434,
"definition": {
"title": "Votes per address and chain id",
"title_size": "16",
"title_align": "left",
"type": "query_table",
"requests": [{
"formulas": [{
"formula": "query1",
"limit": {
"count": 500,
"order": "desc"
}
}],
"response_format": "scalar",
"queries": [{
"query": "sum:interoperability.token_bridge.federator.voting{type:erc20} by {address,chain_id,result}.as_count()",
"data_source": "metrics",
"name": "query1",
"aggregator": "sum"
}]
}]
}
}]
}
}],
"template_variables": [],
"layout_type": "ordered",
"is_read_only": false,
"notify_list": [],
"reflow_type": "auto",
"id": "wsr-524-c9q"
}
```

0 comments on commit 21ab20f

Please sign in to comment.