• Stars
    star
    303
  • Rank 137,655 (Top 3 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Polkadot Telemetry service

Frontend Backend

Polkadot Telemetry

Overview

This repository contains the backend ingestion server for Substrate Telemetry (which itself is comprised of two binaries; telemetry_shard and telemetry_core) as well as the Frontend you typically see running at telemetry.polkadot.io.

The backend is a Rust project and the frontend is React/Typescript project.

Substrate based nodes can be connected to an arbitrary Telemetry backend using the --telemetry-url (see below for more complete instructions on how to get this up and running).

Messages

Depending on the configured verbosity, substrate nodes will send different types of messages to the Telemetry server. Verbosity level 0 is sufficient to provide the Telemetry server with almost all of the node information needed. Using this verbosity level will lead to the substrate node sending the following message types to Telemetry:

system.connected
system.interval
block.import
notify.finalized

Increasing the verbosity level to 1 will lead to additional "consensus info" messages being sent, one of which has the identifier:

afg.authority_set

Which we use to populate the "validator address" field if applicable.

Increasing the verbosity level beyond 1 is unnecessary, and will not result in any additional messages that Telemetry can handle (but other metric gathering systems might find them useful).

Getting Started

To run the backend, you will need cargo to build the binary. We recommend using rustup.

To run the frontend make sure to grab the latest stable version of node and install dependencies before doing anything:

nvm install stable
(cd frontend && npm install)

Terminal 1 & 2 - Backend

Build the backend binaries by running the following:

cd backend
cargo build --release

And then, in two different terminals, run:

./target/release/telemetry_core

and

./target/release/telemetry_shard

Use --help on either binary to see the available options.

By default, telemetry_core will listen on 127.0.0.1:8000, and telemetry_shard will listen on 127.0.0.1:8001, and expect the telemetry_core to be listening on its default address. To listen on different addresses, use the --listen option on either binary, for example --listen 0.0.0.0:8000. The telemetry_shard also needs to be told where the core is, so if the core is configured with --listen 127.0.0.1:9090, remember to pass --core 127.0.0.1:9090 to the shard, too.

Terminal 3 - Frontend

cd frontend
npm install
npm run start

Once this is running, you'll be able to navigate to http://localhost:3000 to view the UI.

Terminal 4 - Node

Follow up installation instructions from the Polkadot repo

If you started the backend binaries with their default arguments, you can connect a node to the shard by running:

polkadot --dev --telemetry-url 'ws://localhost:8001/submit 0'

Note: The "0" at the end of the URL is a verbosity level, and not part of the URL itself. Verbosity levels range from 0-9, with 0 denoting the lowest verbosity. The URL and this verbosity level are parts of a single argument and must therefore be surrounded in quotes (as seen above) in order to be treated as such by your shell.

Docker

Building images

To build the backend docker image, navigate into the backend folder of this repository and run:

docker build -t parity/substrate-telemetry-backend .

The backend image contains both the telemetry_core and telemetry_shard binaries.

To build the frontend docker image, navigate into the frontend folder and run:

docker build -t parity/substrate-telemetry-frontend .

Run the backend and frontend using docker-compose

The easiest way to run the backend and frontend images is to use docker-compose. To do this, run docker-compose up in the root of this repository to build and run the images. Once running, you can view the UI by navigating a browser to http://localhost:3000.

To connect a substrate node and have it send telemetry to this running instance, you have to tell it where to send telemetry by appending the argument --telemetry-url 'ws://localhost:8001/submit 0' (see "Terminal 4 - Node" above).

Run the backend and frontend using docker

If you'd like to get things running manually using Docker, you can do the following. This assumes that you've built the images as per the above, and have two images named parity/substrate-telemetry-backend and parity/substrate-telemetry-frontend.

  1. Create a new shared network so that the various containers can communicate with eachother:

    docker network create telemetry
    
  2. Start up the backend core process. We expose port 8000 so that a UI running in a host browser can connect to the /feed endpoint.

    docker run --rm -it --network=telemetry \
        --name backend-core \
        -p 8000:8000 \
        --read-only \
        parity/substrate-telemetry-backend \
        telemetry_core -l 0.0.0.0:8000
    
  3. In another terminal, start up the backend shard process. We tell it where it can reach the core to send messages (possible because it has been started on the same network), and we listen on and expose port 8001 so that nodes running in the host can connect and send telemetry to it.

    docker run --rm -it --network=telemetry \
        --name backend-shard \
        -p 8001:8001 \
        --read-only \
        parity/substrate-telemetry-backend \
        telemetry_shard -l 0.0.0.0:8001 -c http://backend-core:8000/shard_submit
    
  4. In another terminal, start up the frontend server. We pass a SUBSTRATE_TELEMETRY_URL env var to tell the UI how to connect to the core process to receive telemetry. This is relative to the host machine, since that is where the browser and UI will be running.

    docker run --rm -it --network=telemetry \
        --name frontend \
        -p 3000:8000 \
        -e SUBSTRATE_TELEMETRY_URL=ws://localhost:8000/feed \
        parity/substrate-telemetry-frontend
    

    NOTE: Here we used SUBSTRATE_TELEMETRY_URL=ws://localhost:8000/feed. This will work if you test with everything running locally on your machine but NOT if your backend runs on a remote server. Keep in mind that the frontend docker image is serving a static site running your browser. The SUBSTRATE_TELEMETRY_URL is the WebSocket url that your browser will use to reach the backend. Say your backend runs on a remote server at foo.example.com, you will need to set the IP/url accordingly in SUBSTRATE_TELEMETRY_URL (in this case, to ws://foo.example.com/feed).

    NOTE: Running the frontend container in read-only mode reduces attack surface that could be used to exploit a container. It requires however a little more effort and mounting additional volumes as shown below:

    docker run --rm -it -p 80:8000 --name frontend \
       -e SUBSTRATE_TELEMETRY_URL=ws://localhost:8000/feed \
       --tmpfs /var/cache/nginx:uid=101,gid=101 \
       --tmpfs /var/run:uid=101,gid=101 \
       --tmpfs /app/tmp:uid=101,gid=101 \
       --read-only \
       parity/substrate-telemetry-frontend
    

With these running, you'll be able to navigate to http://localhost:3000 to view the UI. If you'd like to connect a node and have it send telemetry to your running shard, you can run the following:

docker run --rm -it --network=telemetry \
  --name substrate \
  -p 9944:9944 \
  chevdor/substrate \
  substrate --dev --telemetry-url 'ws://backend-shard:8001/submit 0'

You should now see your node showing up in your local telemetry frontend:

image

Deployment

This section covers the internal deployment of Substrate Telemetry to our staging and live environments.

Deployment to staging

Every time new code is merged to master, a new version of telemetry will be automatically built and deployed to our staging environment, so there is nothing that you need to do. Roughly what will happen is:

Deployment to live

Once we're happy with things in staging, we can do a deployment to live as follows:

  1. Ensure that the PRs you'd like to deploy are merged to master.
  2. Tag the commit on master that you'd like to deploy with the form v1.0-a1b2c3d.
    • The version number (1.0 here) should just be incremented from whatever the latest version found using git tag is. We don't use semantic versioning or anything like that; this is just a dumb "increment version number" approach so that we can see clearly what we've deployed to live and in what order.
    • The suffix is a short git commit hash (which can be generated with git rev-parse --short HEAD), just so that it's really easy to relate the built docker images back to the corresponding code.
  3. Pushing the tag (eg git push origin v1.0-a1b2c3d) will kick off the deployment process, which in this case will also lead to new docker images being built. You can view the progress at https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines.
  4. Once a deployment to staging has been successful, run whatever tests you need against the staging deployment to convince yourself that you're happy with it.
  5. Visit the CI/CD pipelines page again (URl above) and click the "play" button on the "Deploy-production" stage to perform the deployment to live.
  6. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/.

Rolling back to a previous deployment

If something goes wrong running the above, we can roll back the deployment to live as follows.

  1. Decide what image tag you'd like to roll back to. Go to https://hub.docker.com/r/parity/substrate-telemetry-backend/tags?page=1&ordering=last_updated and have a look at the available tags (eg v1.0-a1b2c3d) to select one you'd like. You can cross reference this with the tags available using git tag in the repository to help see which tags correspond to which code changes.
  2. Navigate to https://gitlab.parity.io/parity/substrate-telemetry/-/pipelines/new.
  3. Add a variable called FORCE_DEPLOY with the value true.
  4. Add a variable called FORCE_DOCKER_TAG with a value corresponding to the tag you want to deploy, eg v1.0-a1b2c3d. Images must exist already for this tag.
  5. Hit 'Run Pipeline'. As above, a deployment to staging will be carried out, and if you're happy with that, you can hit the "play" button on the "Deploy-production" stage to perform the deployment to live.
  6. Confirm that things are working once the deployment has finished by visiting https://telemetry.polkadot.io/.

More Repositories

1

substrate

Substrate: The platform for blockchain innovators
Rust
8,212
star
2

polkadot

Polkadot Node Implementation
Rust
6,865
star
3

ink

Parity's ink! to write smart contracts.
Rust
1,316
star
4

wasmi

WebAssembly (Wasm) interpreter.
Rust
1,269
star
5

polkadot-sdk

The Parity Polkadot Blockchain SDK
Rust
979
star
6

jsonrpc

Rust JSON-RPC implementation
Rust
752
star
7

parity-bitcoin

The Parity Bitcoin client
Rust
726
star
8

cumulus

Write Parachains on Substrate
Rust
618
star
9

parity-signer

Air-gapped crypto wallet.
Rust
539
star
10

frontier

Ethereum compatibility layer for Substrate.
Rust
496
star
11

polkadot-launch

Simple CLI tool to launch a local Polkadot test network
TypeScript
458
star
12

jsonrpsee

Rust JSON-RPC library on top of async/await
Rust
457
star
13

parity-wasm

WebAssembly serialization/deserialization in rust
Rust
395
star
14

subxt

Submit extrinsics (transactions) to a substrate node via RPC
Rust
317
star
15

parity-bridge

Rust
317
star
16

smoldot

Alternative client for Substrate-based chains.
Rust
286
star
17

parity-common

Collection of crates used in Parity projects
Rust
284
star
18

parity-bridges-common

Collection of Useful Bridge Building Tools 🏗️
Rust
265
star
19

parity-db

Experimental blockchain database
Rust
263
star
20

banana_split

Shamir's Secret Sharing for people with friends
TypeScript
259
star
21

substrate-api-sidecar

REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
TypeScript
245
star
22

parity-scale-codec

Lightweight, efficient, binary serialization and deserialization codec
Rust
244
star
23

substrate-connect

Run Wasm Light Clients of any Substrate based chain directly in your browser.
TypeScript
230
star
24

cargo-contract

Setup and deployment tool for developing Wasm based smart contracts via ink!
Rust
226
star
25

trie

Base-16 Modified Patricia Merkle Tree (aka Trie)
Rust
201
star
26

substrate-archive

Blockchain Indexing Engine
Rust
197
star
27

shasper

Parity Shasper beacon chain implementation using the Substrate framework.
Rust
196
star
28

parity-zcash

Rust implementation of Zcash protocol
Rust
184
star
29

cachepot

cachepot is `sccache` with extra sec, which in turn is `ccache` with cloud storage
Rust
174
star
30

libsecp256k1

Pure Rust Implementation of secp256k1.
Rust
172
star
31

homebrew-paritytech

Homebrew tap for ethcore
Ruby
160
star
32

zombienet

A cli tool to easily spawn ephemeral Polkadot/Substrate networks and perform tests against them.
TypeScript
158
star
33

polkadot-staking-dashboard

A dashboard for Polkadot staking and nomination pools.
TypeScript
152
star
34

xcm-format

Polkadot Cross Consensus-system Message format.
143
star
35

finality-grandpa

finality gadget for blockchains using common prefix agreement
Rust
139
star
36

substrate-contracts-node

Minimal Substrate node configured for smart contracts via pallet-contracts.
Rust
124
star
37

capi

[WIP] A framework for crafting interactions with Substrate chains
TypeScript
105
star
38

grandpa-bridge-gadget

A Bridge Gadget to Grandpa Finality.
Rust
99
star
39

substrate-debug-kit

A collection of debug tools, scripts and libraries on top of substrate.
Rust
94
star
40

ink-examples

A set of examples for ink! smart contract language. Happy hacking!
Rust
89
star
41

subport

Parity Substrate(-based) chains usage and development support
Rust
84
star
42

wasm-utils

Rust
82
star
43

trappist

Rust
82
star
44

txwrapper-core

Tools for FRAME chain builders to publish chain specific offline transaction generation libraries.
TypeScript
77
star
45

substrate-playground

Start hacking your substrate runtime in a web based VSCode like IDE
TypeScript
74
star
46

scale-info

Info about SCALE encodable Rust types
Rust
73
star
47

parity-tokio-ipc

Parity tokio-ipc
Rust
73
star
48

substrate-light-ui

Minimal, WASM-light-client-bundled Substrate wallet for balance transfers
TypeScript
72
star
49

substrate-ui

Bondy Polkadot UI
JavaScript
72
star
50

statemint

Statemint Node Implementation
Rust
71
star
51

canvas

Node implementation for Canvas ‒ a Substrate parachain for smart contracts.
Rust
69
star
52

substrate-up

Scripts for working with new Substrate projects
Shell
66
star
53

useink

A React hooks library for ink!
TypeScript
62
star
54

stateless-blockchain

Stateless Blockchain on Substrate using RSA Accumulators
Rust
60
star
55

txwrapper

Helper funtions for offline transaction generation.
TypeScript
58
star
56

contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
TypeScript
58
star
57

awesome-ink

A curated list of awesome projects related to Parity's ink!.
56
star
58

srtool

A fork of chevdor's srtool
Shell
56
star
59

cargo-unleash

cargo release automatisation tooling for massiv mono-repos
Rust
55
star
60

ss58-registry

Registry for SS58 account types
Rust
55
star
61

oo7

The Bonds framework along with associated modules.
JavaScript
53
star
62

diener

Diener - dependency diener is a tool for easily changing https://github.com/paritytech/substrate or https://github.com/paritytech/polkadot dependency versions
Rust
52
star
63

lunarity

Lunarity - a Solidity parser in Rust
Rust
50
star
64

nohash-hasher

An implementation of `std :: hash :: Hasher` which does not hash at all.
Rust
49
star
65

arkworks-extensions

Library to integrate arkworks-rs/algebra into Substrate
Rust
47
star
66

wasm-instrument

Instrument and transform wasm modules.
Rust
47
star
67

asset-transfer-api

Typescript API aiming to provide clear, and simple to use tools for transferring assets across common good parachains.
TypeScript
43
star
68

fleetwood

Testbed repo for trying out ideas of what a smart contract API in Rust would look like
Rust
41
star
69

scripts

Collection of Dockerfiles, scripts and related resources
Dockerfile
40
star
70

trappist-extra

Dart
38
star
71

polkadot-introspector

A collection of tools focused on debugging and monitoring the relay chain and parachain progress from a 🐦-view
Rust
38
star
72

parity-extension

Parity Chrome Extension
JavaScript
37
star
73

rhododendron

Asynchronously safe BFT consensus, implementation in Rust
Rust
36
star
74

desub

Decode Substrate with Backwards-Compatible Metadata
Rust
36
star
75

ethkey

Ethereum key generator
Rust
35
star
76

psvm

Polkadot SDK Version Manager
Rust
35
star
77

substrate-open-working-groups

The Susbstrate Open Working Groups (SOWG) are community-based mechanisms to develop standards, specifications, implementations, guidelines or general initiatives in regards to the Substrate framework. It could, but not restricted to, lead to new Polkadot Standards Proposals. SOWG is meant as a place to find and track ongoing efforts and enable everybody with similar interests to join and contribute.
35
star
78

substrate-bip39

Rust
34
star
79

primitives

Rust
34
star
80

parity-config-generator

Parity Config Generator
JavaScript
34
star
81

zombienet-sdk

ZombieNet SDK
Rust
33
star
82

Nomidot

Staking Portal for Polkadot and Kusama
TypeScript
32
star
83

subdb

Experimental domain-specific database for Substrate
Rust
32
star
84

polkadot-api

TypeScript
31
star
85

polkadot-testnet-faucet

TypeScript
30
star
86

polkassembly

Polkassembly now has a new home:
TypeScript
30
star
87

pallet-contracts-waterfall

Collection of simple Substrate smart contract examples written in Rust, AssemblyScript, Solang and the smart contract language ink! to test substrates pallet-contracts module
TypeScript
30
star
88

metadata-portal

Metadata portal for Parity Signer
TypeScript
29
star
89

polkadot-onboard

A wallet integration SDK to facilitate adding different type of wallets (extension, WC, Ledger) to Dapps.
TypeScript
28
star
90

vscode-substrate

Substrate Marketplace VSCode Plugin
TypeScript
28
star
91

oo7-bare

The Bond API.
JavaScript
27
star
92

bigint

Rust
27
star
93

extended-parachain-template

Node template to build parachains with all the required pallets. Slightly opinionated based on what majority of parachain teams are using.
Rust
27
star
94

orchestra

A partial actor pattern with a global orchestrator.
Rust
27
star
95

polkadot-scripts

Collection of random scripts and utilities written for Polkadot
TypeScript
27
star
96

sub-flood

Flooding substrate node with transactions
TypeScript
26
star
97

polkadot-cloud

[BETA] A library and automated platform for developing and publishing assets for Polkadot dapps.
TypeScript
25
star
98

ink-playground

Browser Based Playground for editing, sharing & compiling ink! Smart Contracts
Rust
25
star
99

link

Unstoppable URL shortener built with the ink! smart contract language.
TypeScript
25
star
100

sms-verification

SMS verification for Parity.
JavaScript
25
star