mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
0a5bc82529
* reexport prometheus-super for ease of use of other subsystems * add some prometheus timers for collation generation subsystem * add timing metrics to av-store * add metrics to candidate backing * add timing metric to bitfield signing * add timing metrics to candidate selection * add timing metrics to candidate-validation * add timing metrics to chain-api * add timing metrics to provisioner * add timing metrics to runtime-api * add timing metrics to availability-distribution * add timing metrics to bitfield-distribution * add timing metrics to collator protocol: collator side * add timing metrics to collator protocol: validator side * fix candidate validation test failures * add timing metrics to pov distribution * add timing metrics to statement-distribution * use substrate_prometheus_endpoint prometheus reexport instead of prometheus_super * don't include JOB_DELAY in bitfield-signing metrics * give adder-collator ability to easily export its genesis-state and validation code * wip: adder-collator pushbutton script * don't attempt to register the adder-collator automatically Instead, get these values with ```sh target/release/adder-collator export-genesis-state target/release/adder-collator export-genesis-wasm ``` And then register the parachain on https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer To collect prometheus data, after running the script, create `prometheus.yml` per the instructions at https://www.notion.so/paritytechnologies/Setting-up-Prometheus-locally-835cb3a9df7541a781c381006252b5ff and then run: ```sh docker run -v `pwd`/prometheus.yml:/etc/prometheus/prometheus.yml:z --network host prom/prometheus ``` Demonstrates that data makes it across to prometheus, though it is likely to be useful in the future to tweak the buckets. * Update parachain/test-parachains/adder/collator/src/cli.rs Co-authored-by: Andronik Ordian <write@reusable.software> * use the grandpa-pause parameter * skip metrics in tracing instrumentation * remove unnecessary grandpa_pause cli param Co-authored-by: Andronik Ordian <write@reusable.software>
192 lines
5.1 KiB
Bash
Executable File
192 lines
5.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Run a two node local net with adder-collator.
|
|
|
|
set -e
|
|
|
|
chainspec="rococo-local"
|
|
|
|
# disabled until we can actually successfully register the chain with polkadot-js-api
|
|
# if ! command -v polkadot-js-api > /dev/null; then
|
|
# echo "polkadot-js-api required; try"
|
|
# echo " sudo yarn global add @polkadot/api-cli"
|
|
# exit 1
|
|
# fi
|
|
|
|
PROJECT_ROOT=$(git rev-parse --show-toplevel)
|
|
# shellcheck disable=SC1090
|
|
source "$(dirname "$0")"/common.sh
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
last_modified_rust_file=$(
|
|
find . -path ./target -prune -o -type f -name '*.rs' -printf '%T@ %p\n' |
|
|
sort -nr |
|
|
head -1 |
|
|
cut -d' ' -f2-
|
|
)
|
|
|
|
polkadot="target/release/polkadot"
|
|
adder_collator="target/release/adder-collator"
|
|
|
|
# ensure the polkadot binary exists and is up to date
|
|
if [ ! -x "$polkadot" ] || [ "$polkadot" -ot "$last_modified_rust_file" ]; then
|
|
cargo build --release --features real-overseer
|
|
fi
|
|
# likewise for the adder collator
|
|
if [ ! -x "$adder_collator" ] || [ "$adder_collator" -ot "$last_modified_rust_file" ]; then
|
|
cargo build --release --features real-overseer -p test-parachain-adder-collator
|
|
fi
|
|
|
|
genesis="$(mktemp --directory)"
|
|
genesis_state="$genesis/state"
|
|
validation_code="$genesis/validation_code"
|
|
|
|
"$adder_collator" export-genesis-state > "$genesis_state"
|
|
"$adder_collator" export-genesis-wasm > "$validation_code"
|
|
|
|
|
|
# setup variables
|
|
node_offset=0
|
|
declare -a node_pids
|
|
declare -a node_pipes
|
|
|
|
# create a sed expression which injects the node name and stream type into each line
|
|
function make_sed_expr() {
|
|
name="$1"
|
|
type="$2"
|
|
|
|
printf "s/^/%16s %s: /" "$name" "$type"
|
|
}
|
|
|
|
# turn a string into a flag
|
|
function flagify() {
|
|
printf -- '--%s' "$(tr '[:upper:]' '[:lower:]' <<< "$1")"
|
|
}
|
|
|
|
# start a node and label its output
|
|
#
|
|
# This function takes a single argument, the node name.
|
|
# The name must be one of those which can be passed to the polkadot binary, in un-flagged form,
|
|
# one of:
|
|
# alice, bob, charlie, dave, eve, ferdie, one, two
|
|
function run_node() {
|
|
name="$1"
|
|
# create a named pipe so we can get the node's PID while also sedding its output
|
|
local stdout
|
|
local stderr
|
|
stdout=$(mktemp --dry-run --tmpdir)
|
|
stderr=$(mktemp --dry-run --tmpdir)
|
|
mkfifo "$stdout"
|
|
mkfifo "$stderr"
|
|
node_pipes+=("$stdout")
|
|
node_pipes+=("$stderr")
|
|
|
|
# compute ports from offset
|
|
local port=$((30333+node_offset))
|
|
local rpc_port=$((9933+node_offset))
|
|
local ws_port=$((9944+node_offset))
|
|
local prometheus_port=$((9615+node_offset))
|
|
node_offset=$((node_offset+1))
|
|
|
|
# start the node
|
|
"$polkadot" \
|
|
--chain "$chainspec" \
|
|
--tmp \
|
|
--port "$port" \
|
|
--rpc-port "$rpc_port" \
|
|
--ws-port "$ws_port" \
|
|
--prometheus-port "$prometheus_port" \
|
|
--rpc-cors all \
|
|
"$(flagify "$name")" \
|
|
> "$stdout" \
|
|
2> "$stderr" \
|
|
&
|
|
local pid=$!
|
|
node_pids+=("$pid")
|
|
|
|
# send output from the stdout pipe to stdout, prepending the node name
|
|
sed -e "$(make_sed_expr "$name" "OUT")" "$stdout" >&1 &
|
|
# send output from the stderr pipe to stderr, prepending the node name
|
|
sed -e "$(make_sed_expr "$name" "ERR")" "$stderr" >&2 &
|
|
}
|
|
|
|
# start an adder collator and label its output
|
|
#
|
|
# This function takes a single argument, the node name. This affects only the tagging.
|
|
function run_adder_collator() {
|
|
name="$1"
|
|
# create a named pipe so we can get the node's PID while also sedding its output
|
|
local stdout
|
|
local stderr
|
|
stdout=$(mktemp --dry-run --tmpdir)
|
|
stderr=$(mktemp --dry-run --tmpdir)
|
|
mkfifo "$stdout"
|
|
mkfifo "$stderr"
|
|
node_pipes+=("$stdout")
|
|
node_pipes+=("$stderr")
|
|
|
|
# compute ports from offset
|
|
local port=$((30333+node_offset))
|
|
local rpc_port=$((9933+node_offset))
|
|
local ws_port=$((9944+node_offset))
|
|
local prometheus_port=$((9615+node_offset))
|
|
node_offset=$((node_offset+1))
|
|
|
|
# start the node
|
|
"$adder_collator" \
|
|
--chain "$chainspec" \
|
|
--tmp \
|
|
--port "$port" \
|
|
--rpc-port "$rpc_port" \
|
|
--ws-port "$ws_port" \
|
|
--prometheus-port "$prometheus_port" \
|
|
--rpc-cors all \
|
|
> "$stdout" \
|
|
2> "$stderr" \
|
|
&
|
|
local pid=$!
|
|
node_pids+=("$pid")
|
|
|
|
# send output from the stdout pipe to stdout, prepending the node name
|
|
sed -e "$(make_sed_expr "$name" "OUT")" "$stdout" >&1 &
|
|
# send output from the stderr pipe to stderr, prepending the node name
|
|
sed -e "$(make_sed_expr "$name" "ERR")" "$stderr" >&2 &
|
|
}
|
|
|
|
|
|
# clean up the nodes when this script exits
|
|
function finish {
|
|
for node_pid in "${node_pids[@]}"; do
|
|
kill -9 "$node_pid"
|
|
done
|
|
for node_pipe in "${node_pipes[@]}"; do
|
|
rm "$node_pipe"
|
|
done
|
|
rm -rf "$genesis"
|
|
}
|
|
trap finish EXIT
|
|
|
|
# start the nodes
|
|
run_node Alice
|
|
run_node Bob
|
|
run_adder_collator AdderCollator
|
|
|
|
# register the adder collator
|
|
# doesn't work yet due to https://github.com/polkadot-js/tools/issues/185
|
|
# polkadot-js-api \
|
|
# --ws ws://localhost:9944 \
|
|
# --sudo \
|
|
# --seed "//Alice" \
|
|
# tx.registrar.registerPara \
|
|
# 100 \
|
|
# '{"scheduling":"Always"}' \
|
|
# "@$validation_code" \
|
|
# "@$genesis_state"
|
|
|
|
# now wait; this will exit on its own only if both subprocesses exit
|
|
# the practical implication, as both subprocesses are supposed to run forever, is that
|
|
# this script will also run forever, until killed, at which point the exit trap should kill
|
|
# the subprocesses
|
|
wait
|