-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f2d557
commit daa6dad
Showing
3 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
id: manage-private-keys | ||
title: Manage private keys | ||
description: "How to manage private keys and what types of keys there are." | ||
keywords: | ||
- docs | ||
- polygon | ||
- edge | ||
- private | ||
- key | ||
- keystore | ||
--- | ||
|
||
## Overview | ||
|
||
The Polygon Edge has two types of private keys that it directly manages: | ||
|
||
* **Private key used for the consensus mechanism** | ||
* **Private key used for networking by libp2p** | ||
* **(Optional) BLS Private key used for the consensus mechanism to aggregate validators' signatures** | ||
|
||
Currently, the Polygon Edge doesn't offer support for direct account management. | ||
|
||
Based on the directory structure outlined in the [Backup & Restore guide](/docs/edge/working-with-node/backup-restore), | ||
the Polygon Edge stores these mentioned key files in two distinct directories - **consensus** and **keystore**. | ||
|
||
## Key format | ||
|
||
The private keys are stored in simple **Base64 format**, so they can be human-readable and portable. | ||
|
||
```bash | ||
# Example private key | ||
0802122068a1bdb1c8af5333e58fe586bc0e9fc7aff882da82affb678aef5d9a2b9100c0 | ||
``` | ||
|
||
:::info Key Type | ||
All private key files generated and used inside the Polygon Edge are relying on ECDSA with the curve [secp256k1](https://en.bitcoin.it/wiki/Secp256k1). | ||
|
||
As the curve is non-standard, it cannot be encoded and stored in any standardized PEM format. | ||
Importing keys that don't conform to this key type is not supported. | ||
::: | ||
## Consensus Private Key | ||
|
||
The private key file mentioned as the *consensus private key* is also referred to as the **validator private key**. | ||
This private key is used when the node is acting as a validator in the network and needs to sign new data. | ||
|
||
The private key file is located in `consensus/validator.key`, and adheres to the [key format](/docs/edge/configuration/manage-private-keys#key-format) mentioned. | ||
|
||
:::warning | ||
The validator private key is unique to each validator node. The same key is <b>not</b> to be shared across all validators, as this may compromise the security of your chain. | ||
::: | ||
|
||
## Networking Private Key | ||
|
||
The private key file mentioned for networking is used by libp2p to generate the corresponding PeerID, and allow the node to participate in the network. | ||
|
||
It is located in `keystore/libp2p.key`, and adheres to the [key format](/docs/edge/configuration/manage-private-keys#key-format) mentioned. | ||
|
||
## BLS Secret Key | ||
|
||
The BLS secret key file is used to aggregate committed seals in the consensus layer. The size of aggregated committed seals by BLS is less than the serialized committed ECDSA signatures. | ||
|
||
The BLS feature is optional and, it's possible to choose whether to use BLS or not. Refer [BLS](/docs/edge/consensus/bls) for more details. | ||
|
||
## Import / Export | ||
|
||
As the key files are stored in simple Base64 on disk, they can be easily backed up or imported. | ||
|
||
:::caution Changing the key files | ||
Any kind of change made to the key files on an already set up / running network can lead to serious network/consensus disruption, | ||
since the consensus and peer discovery mechanisms store the data derived from these keys in node-specific storage, and rely on this data to | ||
initiate connections and perform consensus logic | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
id: prometheus-metrics | ||
title: Prometheus metrics | ||
description: "How to enable Prometheus metrics for Polygon Edge." | ||
keywords: | ||
- docs | ||
- polygon | ||
- edge | ||
- metrics | ||
- prometheus | ||
--- | ||
|
||
## Overview | ||
|
||
Polygon Edge can report and serve the Prometheus metrics, which in their turn can be consumed using Prometheus collector(s). | ||
|
||
Prometheus metrics are disabled by default. It can be enabled by specifying the listener address using `--prometheus` flag or `Telemetry.prometheus` field in the config file. | ||
Metrics will be served under `/metrics` on the specified address. | ||
|
||
## Available metrics | ||
|
||
The following metrics are available: | ||
|
||
| **Name** | **Type** | **Description** | | ||
|-----------------------------------------------|---------------|-------------------------------------------------| | ||
| txpool_pending_transactions | Gauge | Number of pending transactions in TxPool | | ||
| consensus_validators | Gauge | Number of Validators | | ||
| consensus_rounds | Gauge | Number of Rounds | | ||
| consensus_num_txs | Gauge | Number of Transactions in the latest block | | ||
| consensus_block_interval | Gauge | Time between this and last block in seconds | | ||
| network_peers | Gauge | Number of Connected peers | | ||
| network_outbound_connections_count | Gauge | Number of outbound connections | | ||
| network_inbound_connections_count | Gauge | Number of inbound connections | | ||
| network_pending_outbound_connections_count | Gauge | Number of pending outbound connections | | ||
| network_pending_inbound_connections_count | Gauge | Number of pending inbound connections | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
--- | ||
id: sample-config | ||
title: Server Config File | ||
description: "Start the Polygon Edge server using a configuration file." | ||
keywords: | ||
- docs | ||
- polygon | ||
- edge | ||
- server | ||
- configuration | ||
- yaml | ||
- jason | ||
|
||
--- | ||
# Server configuration file | ||
Starting the server with various configuration options can be done using a configuration file instead of using just flags. | ||
The command used to start the server with a config file: `polygon-edge server --config <config_file_name>` | ||
|
||
## Export config file with default configuration | ||
The configuration with default settings for the Polygon Edge server can be exported into a config file in either `yaml` or `json` file format. | ||
This file can be used as a template for running the server using a configuration file. | ||
|
||
### YAML | ||
To generate the config file in `yaml` format: | ||
```bash | ||
polygon-edge server export --type yaml | ||
``` | ||
or just | ||
```bash | ||
polygon-edge server export | ||
``` | ||
the config file named `default-config.yaml` will be created in the same directory that this command has been run from. | ||
|
||
File example: | ||
```yaml | ||
chain_config: ./genesis.json | ||
secrets_config: "" | ||
data_dir: "" | ||
block_gas_target: "0x0" | ||
grpc_addr: "" | ||
jsonrpc_addr: "" | ||
telemetry: | ||
prometheus_addr: "" | ||
network: | ||
no_discover: false | ||
libp2p_addr: 127.0.0.1:1478 | ||
nat_addr: "" | ||
dns_addr: "" | ||
max_peers: -1 | ||
max_outbound_peers: -1 | ||
max_inbound_peers: -1 | ||
seal: true | ||
tx_pool: | ||
price_limit: 0 | ||
max_slots: 4096 | ||
log_level: INFO | ||
restore_file: "" | ||
block_time_s: 2 | ||
headers: | ||
access_control_allow_origins: | ||
- '*' | ||
log_to: "" | ||
``` | ||
### JSON | ||
To generate the config file in `json` format: | ||
```bash | ||
polygon-edge server export --type json | ||
``` | ||
the config file named `default-config.json` will be created in the same directory that this command has been run from. | ||
|
||
File example: | ||
|
||
```json | ||
{ | ||
"chain_config": "./genesis.json", | ||
"secrets_config": "", | ||
"data_dir": "", | ||
"block_gas_target": "0x0", | ||
"grpc_addr": "", | ||
"jsonrpc_addr": "", | ||
"telemetry": { | ||
"prometheus_addr": "" | ||
}, | ||
"network": { | ||
"no_discover": false, | ||
"libp2p_addr": "127.0.0.1:1478", | ||
"nat_addr": "", | ||
"dns_addr": "", | ||
"max_peers": -1, | ||
"max_outbound_peers": -1, | ||
"max_inbound_peers": -1 | ||
}, | ||
"seal": true, | ||
"tx_pool": { | ||
"price_limit": 0, | ||
"max_slots": 4096 | ||
}, | ||
"log_level": "INFO", | ||
"restore_file": "", | ||
"block_time_s": 2, | ||
"headers": { | ||
"access_control_allow_origins": [ | ||
"*" | ||
] | ||
}, | ||
"log_to": "" | ||
} | ||
``` | ||
|
||
Checkout [CLI Commands](/docs/edge/get-started/cli-commands) section to get information on how to use these parameters. | ||
|
||
### Typescript schema | ||
|
||
The following is the sample format for the configuration file. It's written in TypeScript to express the properties types (`string`, `number`, `boolean`), from it you could derive your configuration. It's worth mentioning that the `PartialDeep` type from `type-fest` is used to express that all properties are optional. | ||
|
||
```typescript | ||
import { PartialDeep } from 'type-fest'; | ||
type ServerConfig = PartialDeep<{ | ||
chain_config: string; // <genesis_file_path> | ||
secrets_config: string; // <secrets_file_path> | ||
data_dir: string; // <data_directory_path> | ||
block_gas_target: string; // <block_gas_limit> | ||
grpc_addr: string; // <grpc_listener_address> | ||
jsonrpc_addr: string; // <json_rpc_listener_address> | ||
telemetry: { | ||
prometheus_addr: string; // <prometheus_listener_address> | ||
}; | ||
network: { | ||
no_discover: boolean; // <enable/disable_discovery>, | ||
libp2p_addr: string; // <libp2p_server_address>, | ||
nat_addr: string; // <nat_address>, | ||
dns_addr: string; // <dns_address>, | ||
max_peers: number; // <maximum_allowded_peers>, | ||
max_inbound_peers: number; // <maximum_allowded_inbound_peers>, | ||
max_outbound_peers: number; // <maximum_allowded_outbound_peers> | ||
}; | ||
seal: boolean; // <enable/disable_block_sealing> | ||
txpool: { | ||
price_limit: number; // <minimum_gas_price_limit> | ||
max_slots: number; // <maximum_txpool_slots> | ||
}; | ||
log_level: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'DPANIC' | 'PANIC' | 'FATAL'; // <log_level> | ||
restore_file: string; // <restore_file_path> | ||
block_time_s: number; // <block_time_seconds> | ||
headers: Record<string, any>; | ||
log_to: string; // <log_to> | ||
}> | ||
``` | ||
|