mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 04:07:57 +00:00
5eb816d7a6
* Start * More work! * Moar * More changes * More fixes * More worrk * More fixes * More fixes to make it compile * Adds `NoOffchainStorage` * Pass the extensions * Small basti making small progress * Fix merge errors and remove `ExecutionContext` * Move registration of `ReadRuntimeVersionExt` to `ExecutionExtension` Instead of registering `ReadRuntimeVersionExt` in `sp-state-machine` it is moved to `ExecutionExtension` which provides the default extensions. * Fix compilation * Register the global extensions inside runtime api instance * Fixes * Fix `generate_initial_session_keys` by passing the keystore extension * Fix the grandpa tests * Fix more tests * Fix more tests * Don't set any heap pages if there isn't an override * Fix small fallout * FMT * Fix tests * More tests * Offchain worker custom extensions * More fixes * Make offchain tx pool creation reusable Introduces an `OffchainTransactionPoolFactory` for creating offchain transactions pools that can be registered in the runtime externalities context. This factory will be required for a later pr to make the creation of offchain transaction pools easier. * Fixes * Fixes * Set offchain transaction pool in BABE before using it in the runtime * Add the `offchain_tx_pool` to Grandpa as well * Fix the nodes * Print some error when using the old warnings * Fix merge issues * Fix compilation * Rename `babe_link` * Rename to `offchain_tx_pool_factory` * Cleanup * FMT * Fix benchmark name * Fix `try-runtime` * Remove `--execution` CLI args * Make clippy happy * Forward bls functions * Fix docs * Update UI tests * Update client/api/src/execution_extensions.rs Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Koute <koute@users.noreply.github.com> * Update client/cli/src/params/import_params.rs Co-authored-by: Koute <koute@users.noreply.github.com> * Update client/api/src/execution_extensions.rs Co-authored-by: Koute <koute@users.noreply.github.com> * Pass the offchain storage to the MMR RPC * Update client/api/src/execution_extensions.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * Review comments * Fixes --------- Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Koute <koute@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
167 lines
4.5 KiB
Bash
Executable File
167 lines
4.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This file is part of Substrate.
|
|
# Copyright (C) Parity Technologies (UK) Ltd.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# This script has three parts which all use the Substrate runtime:
|
|
# - Pallet benchmarking to update the pallet weights
|
|
# - Overhead benchmarking for the Extrinsic and Block weights
|
|
# - Machine benchmarking
|
|
#
|
|
# Should be run on a reference machine to gain accurate benchmarks
|
|
# current reference machine: https://github.com/paritytech/substrate/pull/5848
|
|
|
|
while getopts 'bfp:v' flag; do
|
|
case "${flag}" in
|
|
b)
|
|
# Skip build.
|
|
skip_build='true'
|
|
;;
|
|
f)
|
|
# Fail if any sub-command in a pipe fails, not just the last one.
|
|
set -o pipefail
|
|
# Fail on undeclared variables.
|
|
set -u
|
|
# Fail if any sub-command fails.
|
|
set -e
|
|
# Fail on traps.
|
|
set -E
|
|
;;
|
|
p)
|
|
# Start at pallet
|
|
start_pallet="${OPTARG}"
|
|
;;
|
|
v)
|
|
# Echo all executed commands.
|
|
set -x
|
|
;;
|
|
*)
|
|
# Exit early.
|
|
echo "Bad options. Check Script."
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
if [ "$skip_build" != true ]
|
|
then
|
|
echo "[+] Compiling Substrate benchmarks..."
|
|
cargo build --profile=production --locked --features=runtime-benchmarks --bin substrate
|
|
fi
|
|
|
|
# The executable to use.
|
|
SUBSTRATE=./target/production/substrate
|
|
|
|
# Manually exclude some pallets.
|
|
EXCLUDED_PALLETS=(
|
|
# Helper pallets
|
|
"pallet_election_provider_support_benchmarking"
|
|
# Pallets without automatic benchmarking
|
|
"pallet_babe"
|
|
"pallet_grandpa"
|
|
"pallet_mmr"
|
|
"pallet_offences"
|
|
# Only used for testing, does not need real weights.
|
|
"frame_benchmarking_pallet_pov"
|
|
)
|
|
|
|
# Load all pallet names in an array.
|
|
ALL_PALLETS=($(
|
|
$SUBSTRATE benchmark pallet --list --chain=dev |\
|
|
tail -n+2 |\
|
|
cut -d',' -f1 |\
|
|
sort |\
|
|
uniq
|
|
))
|
|
|
|
# Filter out the excluded pallets by concatenating the arrays and discarding duplicates.
|
|
PALLETS=($({ printf '%s\n' "${ALL_PALLETS[@]}" "${EXCLUDED_PALLETS[@]}"; } | sort | uniq -u))
|
|
|
|
echo "[+] Benchmarking ${#PALLETS[@]} Substrate pallets by excluding ${#EXCLUDED_PALLETS[@]} from ${#ALL_PALLETS[@]}."
|
|
|
|
# Define the error file.
|
|
ERR_FILE="benchmarking_errors.txt"
|
|
# Delete the error file before each run.
|
|
rm -f $ERR_FILE
|
|
|
|
# Benchmark each pallet.
|
|
for PALLET in "${PALLETS[@]}"; do
|
|
# If `-p` is used, skip benchmarks until the start pallet.
|
|
if [ ! -z "$start_pallet" ] && [ "$start_pallet" != "$PALLET" ]
|
|
then
|
|
echo "[+] Skipping ${PALLET}..."
|
|
continue
|
|
else
|
|
unset start_pallet
|
|
fi
|
|
|
|
FOLDER="$(echo "${PALLET#*_}" | tr '_' '-')";
|
|
WEIGHT_FILE="./frame/${FOLDER}/src/weights.rs"
|
|
echo "[+] Benchmarking $PALLET with weight file $WEIGHT_FILE";
|
|
|
|
OUTPUT=$(
|
|
$SUBSTRATE benchmark pallet \
|
|
--chain=dev \
|
|
--steps=50 \
|
|
--repeat=20 \
|
|
--pallet="$PALLET" \
|
|
--extrinsic="*" \
|
|
--wasm-execution=compiled \
|
|
--heap-pages=4096 \
|
|
--output="$WEIGHT_FILE" \
|
|
--header="./HEADER-APACHE2" \
|
|
--template=./.maintain/frame-weight-template.hbs 2>&1
|
|
)
|
|
if [ $? -ne 0 ]; then
|
|
echo "$OUTPUT" >> "$ERR_FILE"
|
|
echo "[-] Failed to benchmark $PALLET. Error written to $ERR_FILE; continuing..."
|
|
fi
|
|
done
|
|
|
|
# Update the block and extrinsic overhead weights.
|
|
echo "[+] Benchmarking block and extrinsic overheads..."
|
|
OUTPUT=$(
|
|
$SUBSTRATE benchmark overhead \
|
|
--chain=dev \
|
|
--wasm-execution=compiled \
|
|
--weight-path="./frame/support/src/weights/" \
|
|
--header="./HEADER-APACHE2" \
|
|
--warmup=10 \
|
|
--repeat=100 2>&1
|
|
)
|
|
if [ $? -ne 0 ]; then
|
|
echo "$OUTPUT" >> "$ERR_FILE"
|
|
echo "[-] Failed to benchmark the block and extrinsic overheads. Error written to $ERR_FILE; continuing..."
|
|
fi
|
|
|
|
echo "[+] Benchmarking the machine..."
|
|
OUTPUT=$(
|
|
$SUBSTRATE benchmark machine --chain=dev 2>&1
|
|
)
|
|
if [ $? -ne 0 ]; then
|
|
# Do not write the error to the error file since it is not a benchmarking error.
|
|
echo "[-] Failed the machine benchmark:\n$OUTPUT"
|
|
fi
|
|
|
|
# Check if the error file exists.
|
|
if [ -f "$ERR_FILE" ]; then
|
|
echo "[-] Some benchmarks failed. See: $ERR_FILE"
|
|
exit 1
|
|
else
|
|
echo "[+] All benchmarks passed."
|
|
exit 0
|
|
fi
|