mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 01:27:56 +00:00
5cf682cece
* client/authority-discovery: Limit number of connections to authorities Instead of connecting to all sentry nodes of all authorities, with this patch the authority discovery module does the following: - Choose one sentry node per authority at random. - Choose MAX_NUM_AUTHORITY_CONN out of the above at random. The module uses randomness to prevent hot spots, e.g. all nodes trying to connect to a single node. If the authority discovery module would choose the nodes to connect to at random on each new address that it learns of, the node would go through a lot of connection churn. Instead it creates a random seed at start up and uses this seed for its RNG on each update cycle. * client/authority-discovery: Extract address cache into own module * client/authority-discovery/src/addr_cache: Add basic unit tests * client/authority-discovery: Replace unwrap with expect on [u8] cmp * .maintain/sentry-node/docker-compose.yml: Prefix endpoint flags * client/authority-discovery/src/addr_cache: Use sort_unstable and cmp * client/authority-discovery: Use BTreeMap in addr_cache for sorted iter To reduce connection churn it is preferrable to have `get_subset` of the `addr_cache` to return the same result on repeated calls. `get_subset` iterates a map. To make the process of iteration deterministic, use a `BTreeMap` instead of a `HashMap`.
137 lines
3.7 KiB
YAML
137 lines
3.7 KiB
YAML
# Docker compose file to simulate a sentry node setup.
|
|
#
|
|
#
|
|
# Setup:
|
|
#
|
|
# Validator A is not supposed to be connected to the public internet. Instead it
|
|
# connects to a sentry node (sentry-a) which connects to the public internet.
|
|
# Validator B can reach validator A via sentry node A and vice versa.
|
|
#
|
|
#
|
|
# Usage:
|
|
#
|
|
# 1. Build `target/release/substrate` binary: `cargo build --release`
|
|
#
|
|
# 2. Start networks and containers: `sudo docker-compose -f .maintain/sentry-node/docker-compose.yml up`
|
|
#
|
|
# 3. Reach:
|
|
# - polkadot/apps on localhost:3000
|
|
# - validator-a: localhost:9944
|
|
# - validator-b: localhost:9945
|
|
# - sentry-a: localhost:9946
|
|
|
|
version: "3.7"
|
|
services:
|
|
|
|
validator-a:
|
|
ports:
|
|
- "9944:9944"
|
|
volumes:
|
|
- ../../target/release/substrate:/usr/local/bin/substrate
|
|
image: parity/substrate
|
|
networks:
|
|
- network-a
|
|
command:
|
|
# Local node id: QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR
|
|
- "--node-key"
|
|
- "0000000000000000000000000000000000000000000000000000000000000001"
|
|
- "--base-path"
|
|
- "/tmp/alice"
|
|
- "--chain=local"
|
|
- "--port"
|
|
- "30333"
|
|
- "--validator"
|
|
- "--alice"
|
|
- "--sentry-nodes"
|
|
- "/dns4/sentry-a/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi"
|
|
- "--reserved-nodes"
|
|
- "/dns4/sentry-a/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi"
|
|
# Not only bind to localhost.
|
|
- "--unsafe-ws-external"
|
|
- "--unsafe-rpc-external"
|
|
# - "--log"
|
|
# - "sub-libp2p=trace"
|
|
# - "--log"
|
|
# - "afg=trace"
|
|
- "--log"
|
|
- "sub-authority-discovery=trace"
|
|
- "--no-telemetry"
|
|
- "--rpc-cors"
|
|
- "all"
|
|
|
|
sentry-a:
|
|
image: parity/substrate
|
|
ports:
|
|
- "9946:9944"
|
|
volumes:
|
|
- ../../target/release/substrate:/usr/local/bin/substrate
|
|
networks:
|
|
- network-a
|
|
- internet
|
|
command:
|
|
# Local node id: QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi
|
|
- "--node-key"
|
|
- "0000000000000000000000000000000000000000000000000000000000000003"
|
|
- "--base-path"
|
|
- "/tmp/sentry"
|
|
- "--chain=local"
|
|
- "--port"
|
|
- "30333"
|
|
- "--charlie"
|
|
- "--bootnodes"
|
|
- "/dns4/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR"
|
|
- "--bootnodes"
|
|
- "/dns4/validator-b/tcp/30333/p2p/QmSVnNf9HwVMT1Y4cK1P6aoJcEZjmoTXpjKBmAABLMnZEk"
|
|
- "--reserved-nodes"
|
|
- "/dns4/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR"
|
|
- "--no-telemetry"
|
|
- "--rpc-cors"
|
|
- "all"
|
|
# Not only bind to localhost.
|
|
- "--unsafe-ws-external"
|
|
- "--unsafe-rpc-external"
|
|
- "--log"
|
|
- "sub-authority-discovery=trace"
|
|
- "--sentry"
|
|
|
|
validator-b:
|
|
image: parity/substrate
|
|
ports:
|
|
- "9945:9944"
|
|
volumes:
|
|
- ../../target/release/substrate:/usr/local/bin/substrate
|
|
networks:
|
|
- internet
|
|
command:
|
|
# Local node id: QmSVnNf9HwVMT1Y4cK1P6aoJcEZjmoTXpjKBmAABLMnZEk
|
|
- "--node-key"
|
|
- "0000000000000000000000000000000000000000000000000000000000000002"
|
|
- "--base-path"
|
|
- "/tmp/bob"
|
|
- "--chain=local"
|
|
- "--port"
|
|
- "30333"
|
|
- "--validator"
|
|
- "--bob"
|
|
- "--bootnodes"
|
|
- "/dns4/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR"
|
|
- "--bootnodes"
|
|
- "/dns4/sentry-a/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi"
|
|
- "--no-telemetry"
|
|
- "--rpc-cors"
|
|
- "all"
|
|
# Not only bind to localhost.
|
|
- "--unsafe-ws-external"
|
|
- "--unsafe-rpc-external"
|
|
- "--log"
|
|
- "sub-authority-discovery=trace"
|
|
|
|
ui:
|
|
image: polkadot-js/apps
|
|
ports:
|
|
- "3000:80"
|
|
|
|
networks:
|
|
network-a:
|
|
internet:
|