fix the benchmarking script

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2026-09-02 03:03:39 +03:00
parent e694489f75
commit 20c8b9f1b2
Signed by: st1nky
GPG Key ID: 016064BD97603B40

View File

@ -40,23 +40,23 @@ while getopts 'bfp:v' flag; do
esac
done
if [ "$skip_build" != true ]
then
echo "[+] Compiling Node with 'runtime-benchmarks' features"
cargo build --release --locked --features=runtime-benchmarks
fi
ERR_FILE="benchmarking_errors.txt"
EXECUTABLE=./target/release/ghost
RUNTIME="casper"
rm -f $ERR_FILE
if [ "$skip_build" != true ]
then
echo "[+] Compiling Node with 'runtime-benchmarks' features"
cargo build --release --locked --features=runtime-benchmarks,$RUNTIME-native
fi
# Update the block and extrinsic overhead weights
echo "[+] Benchmarking block and extrinsic overheads..."
OUTPUT=$(
$EXECUTABLE benchmark overhead \
--chain="${RUNTIME}-dev" \
--chain="${RUNTIME}-local" \
--wasm-execution=compiled \
--weight-path="./runtime/${RUNTIME}/constants/src/weights/" \
--header=./file_header.txt \
@ -70,7 +70,7 @@ fi
echo "[+] Benchmarking the machine..."
OUTPUT=$(
$EXECUTABLE benchmark machine --chain=${RUNTIME}-dev 2>&1
$EXECUTABLE benchmark machine --allow-fail --chain=${RUNTIME}-dev 2>&1
)
if [ $? -ne 0 ]; then
# Do not write the error file since it is not a benchmarking error
@ -108,23 +108,18 @@ fi
EXCLUDED_PALLETS=(
# helper pallets
"pallet_election_provider_support_benchmarking"
# pallets without automatic benchmarking
"pallet_babe"
"pallet_grandpa"
"pallet_bags_list"
"frame_system"
"pallet_staking"
"pallet_offences"
"frame_benchmarking"
)
# Load all pallet names in an array
ALL_PALLETS=($(
$EXECUTABLE benchmark pallet --list=pallets --no-csv-header --chain=${RUNTIME}-dev
$EXECUTABLE benchmark pallet --list=pallets --no-csv-header --chain=${RUNTIME}-dev 2>/dev/null | grep -v ':' | grep -v 'baseline'
))
# Filter out the excluded pallets by concatenating the arrays and discarding duplicates
PALLETS=($({ printf '%s\n' "${ALL_PALLETS[@]}" "${EXCLUDED_PALLETS[@]}"; } | sort | uniq -u))
PALLETS=($(
printf '%s\n' "${ALL_PALLETS[@]}" | grep -Fvxf <(printf '%s\n' "${EXCLUDED_PALLETS[@]}")
))
TOTAL_PALLETS=${#PALLETS[@]}
CURRENT=0
@ -142,6 +137,11 @@ for PALLET in "${PALLETS[@]}"; do
unset start_pallet
fi
if [[ -z "$PALLET" || "$PALLET" == "::" || "$PALLET" == "baseline" || "$PALLET" == "pallet" ]]; then
echo "[+] ($CURRENT/$TOTAL_PALLETS) Skipping garbage names: '${PALLET}'"
continue
fi
FOLDER="$(echo "${PALLET#*_}" | tr '_' '-')";
WEIGHT_FILE="./runtime/${RUNTIME}/src/weights/${PALLET}.rs"
echo "[+] Benchmarking $PALLET for $RUNTIME with weight file $WEIGHT_FILE ($CURRENT/$TOTAL_PALLETS)";