datahaven/operator/scripts/run-benchmarks.sh

168 lines
4.8 KiB
Bash
Raw Permalink Normal View History

test: init benchmark infra (#110) * Add `run_benchmarks.sh` script to run runtime benchmarks * Sets up benchmark configs and directory structure to store weights (`operator/runtime/<RUNTIME>/weights`) * (naive) fixes to some benchmarks: * `pallet_datahaven_native_transfer`: * use a mock for `NativeTokenId` * look at the balance difference of the treasury instead of the total (this makes the benchmark agnostic to genesis setup) * `snowbridge_pallet_system` / `snowbridge_pallet_system_v2` use native token xcm location vs relay chain one. Add missing benchmark methods and update fixture with valid data. * `snowbridge_pallet_ethereum_client`: update fixtures with valid data * `snowbrige_pallet_inbound_queue_v2`: set EthereumGatewayAddress when initializing storage on benchmark and use a mock message processor ( as fixture has `CreateAsset` payload which is not supported in the `EigenLayerMessageProcessor`) * `snowbridge_pallet_outbound_queue_v2`: add missing `submit_delivery_receipt` benchmark which required a dedicated fixture (all copied from the upstream pallet) * `pallet_treasury`: Use an `ExistentialDeposit` of `1` on benchmark, else payout fails. * `pallet_transaction_payment`: Use a custom `WeightToFee` that makes the Fee small, else account in benchmark cannot pay for fees (It is funded a multiplier of `ExistentialDeposit` and is expected for that to be enough, but it's not in our particular setup). * comment out `pallet_identity` and `pallet_im_online` due to incompatibilities (to be addressed later) * Basic benchmark run to set `WeightInfo` from `weights` in configs (real run should be done later using target hardware) --------- Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Tobi Demeco <50408393+TDemeco@users.noreply.github.com> Co-authored-by: undercover-cactus <lola@moonsonglabs.com> Co-authored-by: TDemeco <tdemeco@itba.edu.ar>
2025-08-06 11:44:42 +00:00
#!/bin/bash
# DataHaven Benchmarking Script using frame-omni-bencher
# Automatically discovers and benchmarks all pallets in the runtime
set -e
# Configuration
RUNTIME=${1:-testnet}
STEPS=${2:-50}
REPEAT=${3:-20}
FEATURES="runtime-benchmarks"
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Display usage if help is requested
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 [runtime] [steps] [repeat]"
echo ""
echo "Arguments:"
echo " runtime - Runtime to benchmark (testnet, stagenet, mainnet). Default: testnet"
echo " steps - Number of steps for benchmarking. Default: 50"
echo " repeat - Number of repetitions. Default: 20"
echo ""
echo "Examples:"
echo " $0 # Benchmark all pallets for testnet"
echo " $0 mainnet # Benchmark all pallets for mainnet"
echo " $0 testnet 100 50 # Custom steps and repeat"
exit 0
fi
echo -e "${GREEN}DataHaven Benchmarking Script${NC}"
echo "Runtime: $RUNTIME"
echo "Steps: $STEPS"
echo "Repeat: $REPEAT"
echo ""
# Ensure frame-omni-bencher is installed
if ! command -v frame-omni-bencher &> /dev/null; then
echo -e "${YELLOW}Installing frame-omni-bencher...${NC}"
cargo install frame-omni-bencher
fi
# Ensure weight template exists
TEMPLATE_PATH="benchmarking/frame-weight-template.hbs"
if [ ! -f "$TEMPLATE_PATH" ]; then
echo -e "${RED}Error: Weight template file not found at $TEMPLATE_PATH${NC}"
echo "Please ensure the template exists in the benchmarking directory"
exit 1
fi
# Build the runtime WASM
fix: update weight configurations for the three runtimes (#249) # Update Runtime Weights and WeightInfo Implementations ## Summary Updated runtime weights across all three runtimes (mainnet, stagenet, testnet) and configured WeightInfo implementations to use the new benchmarked weights. ## Changes - All weight files have been updated with new benchmark data from Substrate Benchmark CLI v51.0.0 - Updated some WeightInfo configurations to use custom weights instead of the default `()`, such as `pallet_im_online`. ## Weights comparison against Moonbeam Some weights are much higher than it's counterpart in Moonbeam, as we can observe in the following table. We need to investigate if this is expected. EDIT: ### Weights using the `production` profile comparing stagenet vs moonbase | **Pallet** | **Function** | **DataHaven Weight** | **Moonbase Weight** | **Difference** | **Notes** | |------------|--------------|----------------------|---------------------|----------------|-----------| | **pallet_balances** | transfer_allow_death | 68,497,000 | 43,117,000 | **+59%** | DataHaven higher | | | transfer_keep_alive | 55,245,000 | 41,490,000 | **+33%** | DataHaven higher | | | force_set_balance_creating | 22,034,000 | 21,537,000 | **+2%** | Similar | | | force_set_balance_killing | 31,246,000 | 23,467,000 | **+33%** | DataHaven higher | | | force_transfer | 72,181,000 | 45,384,000 | **+59%** | DataHaven higher | | | transfer_all | 67,765,000 | 51,403,000 | **+32%** | DataHaven higher | | | force_unreserve | 25,876,000 | 19,490,000 | **+33%** | DataHaven higher | | | upgrade_accounts (base) | 23,200,000 | 17,599,000 | **+32%** | DataHaven higher | | | force_adjust_total_issuance | 8,780,000 | 6,780,000 | **+29%** | DataHaven higher | | | burn_allow_death | 43,258,000 | 25,822,000 | **+68%** | DataHaven higher | | | burn_keep_alive | 30,368,000 | 22,961,000 | **+32%** | DataHaven higher | | **pallet_evm** | withdraw | 3,174,000 | 2,104,000 | **+51%** | DataHaven higher | | **frame_system** | remark (base) | 33,694,157 | 38,668,753 | **-13%** | Moonbase higher | | | remark_with_event (base) | 8,210,000 | 5,745,000 | **+43%** | DataHaven higher | | | set_heap_pages | 5,204,000 | 3,734,000 | **+39%** | DataHaven higher | | | set_code | 139,034,247,000 | 102,532,308,000 | **+36%** | DataHaven higher | | | set_storage (base) | 3,248,000 | 2,094,000 | **+55%** | DataHaven higher | | | kill_storage (base) | 3,344,000 | 2,120,000 | **+58%** | DataHaven higher | | | kill_prefix (base) | 6,028,000 | 4,258,000 | **+42%** | DataHaven higher | | | authorize_upgrade | 12,866,000 | 8,966,000 | **+44%** | DataHaven higher | | | apply_authorized_upgrade | 142,435,318,000 | 106,561,461,000 | **+34%** | DataHaven higher | | **pallet_multisig** | as_multi_threshold_1 (base) | 30,107,366 | 17,588,619 | **+71%** | DataHaven higher | | | as_multi_create (base) | 45,353,453 | 32,782,725 | **+38%** | DataHaven higher | | | as_multi_approve (base) | 22,928,808 | 18,299,865 | **+25%** | DataHaven higher | | | as_multi_complete (base) | 57,510,735 | 41,555,387 | **+38%** | DataHaven higher | | | approve_as_multi_create (base) | 42,860,897 | 32,390,857 | **+32%** | DataHaven higher | | | approve_as_multi_approve (base) | 21,640,639 | 16,839,439 | **+29%** | DataHaven higher | | | cancel_as_multi (base) | 44,014,197 | 32,643,060 | **+35%** | DataHaven higher | | **pallet_treasury** | spend_local | 15,605,000 | 12,992,000 | **+20%** | DataHaven higher | | | remove_approval | 8,641,000 | 7,766,000 | **+11%** | DataHaven higher | | | on_initialize_proposals (base) | 19,249,676 | 16,973,066 | **+13%** | DataHaven higher | | | spend | 14,082,000 | 26,612,000 | **-47%** | Moonbase higher | | | payout | 74,847,000 | 247,397,000 | **-70%** | Moonbase significantly higher | | | check_status | 16,325,000 | 16,223,000 | **+1%** | Similar | | | void_spend | 15,059,000 | 15,167,000 | **-1%** | Similar | | **pallet_scheduler** | service_agendas_base | 4,583,000 | 6,215,000 | **-26%** | Moonbase higher | | | service_agenda_base (base) | 8,728,153 | 6,640,549 | **+31%** | DataHaven higher | | | service_task_base | 4,875,000 | 3,455,000 | **+41%** | DataHaven higher | | | service_task_fetched (base) | 24,253,000 | 18,898,000 | **+28%** | DataHaven higher | | | service_task_named | 7,176,000 | 5,027,000 | **+43%** | DataHaven higher | | | service_task_periodic | 4,842,000 | 3,415,000 | **+42%** | DataHaven higher | | | execute_dispatch_signed | 10,378,000 | 4,837,000 | **+115%** | DataHaven significantly higher | | | execute_dispatch_unsigned | 3,511,000 | 2,451,000 | **+43%** | DataHaven higher | | | schedule (base) | 17,795,637 | 13,165,173 | **+35%** | DataHaven higher | | | cancel (base) | 20,509,326 | 15,513,197 | **+32%** | DataHaven higher | --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-10-29 15:14:21 +00:00
echo -e "${YELLOW}Building runtime $RUNTIME (production profile) with features: $FEATURES${NC}"
cargo build --profile production --features "$FEATURES" -p datahaven-$RUNTIME-runtime
test: init benchmark infra (#110) * Add `run_benchmarks.sh` script to run runtime benchmarks * Sets up benchmark configs and directory structure to store weights (`operator/runtime/<RUNTIME>/weights`) * (naive) fixes to some benchmarks: * `pallet_datahaven_native_transfer`: * use a mock for `NativeTokenId` * look at the balance difference of the treasury instead of the total (this makes the benchmark agnostic to genesis setup) * `snowbridge_pallet_system` / `snowbridge_pallet_system_v2` use native token xcm location vs relay chain one. Add missing benchmark methods and update fixture with valid data. * `snowbridge_pallet_ethereum_client`: update fixtures with valid data * `snowbrige_pallet_inbound_queue_v2`: set EthereumGatewayAddress when initializing storage on benchmark and use a mock message processor ( as fixture has `CreateAsset` payload which is not supported in the `EigenLayerMessageProcessor`) * `snowbridge_pallet_outbound_queue_v2`: add missing `submit_delivery_receipt` benchmark which required a dedicated fixture (all copied from the upstream pallet) * `pallet_treasury`: Use an `ExistentialDeposit` of `1` on benchmark, else payout fails. * `pallet_transaction_payment`: Use a custom `WeightToFee` that makes the Fee small, else account in benchmark cannot pay for fees (It is funded a multiplier of `ExistentialDeposit` and is expected for that to be enough, but it's not in our particular setup). * comment out `pallet_identity` and `pallet_im_online` due to incompatibilities (to be addressed later) * Basic benchmark run to set `WeightInfo` from `weights` in configs (real run should be done later using target hardware) --------- Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Tobi Demeco <50408393+TDemeco@users.noreply.github.com> Co-authored-by: undercover-cactus <lola@moonsonglabs.com> Co-authored-by: TDemeco <tdemeco@itba.edu.ar>
2025-08-06 11:44:42 +00:00
# Get the WASM path
fix: update weight configurations for the three runtimes (#249) # Update Runtime Weights and WeightInfo Implementations ## Summary Updated runtime weights across all three runtimes (mainnet, stagenet, testnet) and configured WeightInfo implementations to use the new benchmarked weights. ## Changes - All weight files have been updated with new benchmark data from Substrate Benchmark CLI v51.0.0 - Updated some WeightInfo configurations to use custom weights instead of the default `()`, such as `pallet_im_online`. ## Weights comparison against Moonbeam Some weights are much higher than it's counterpart in Moonbeam, as we can observe in the following table. We need to investigate if this is expected. EDIT: ### Weights using the `production` profile comparing stagenet vs moonbase | **Pallet** | **Function** | **DataHaven Weight** | **Moonbase Weight** | **Difference** | **Notes** | |------------|--------------|----------------------|---------------------|----------------|-----------| | **pallet_balances** | transfer_allow_death | 68,497,000 | 43,117,000 | **+59%** | DataHaven higher | | | transfer_keep_alive | 55,245,000 | 41,490,000 | **+33%** | DataHaven higher | | | force_set_balance_creating | 22,034,000 | 21,537,000 | **+2%** | Similar | | | force_set_balance_killing | 31,246,000 | 23,467,000 | **+33%** | DataHaven higher | | | force_transfer | 72,181,000 | 45,384,000 | **+59%** | DataHaven higher | | | transfer_all | 67,765,000 | 51,403,000 | **+32%** | DataHaven higher | | | force_unreserve | 25,876,000 | 19,490,000 | **+33%** | DataHaven higher | | | upgrade_accounts (base) | 23,200,000 | 17,599,000 | **+32%** | DataHaven higher | | | force_adjust_total_issuance | 8,780,000 | 6,780,000 | **+29%** | DataHaven higher | | | burn_allow_death | 43,258,000 | 25,822,000 | **+68%** | DataHaven higher | | | burn_keep_alive | 30,368,000 | 22,961,000 | **+32%** | DataHaven higher | | **pallet_evm** | withdraw | 3,174,000 | 2,104,000 | **+51%** | DataHaven higher | | **frame_system** | remark (base) | 33,694,157 | 38,668,753 | **-13%** | Moonbase higher | | | remark_with_event (base) | 8,210,000 | 5,745,000 | **+43%** | DataHaven higher | | | set_heap_pages | 5,204,000 | 3,734,000 | **+39%** | DataHaven higher | | | set_code | 139,034,247,000 | 102,532,308,000 | **+36%** | DataHaven higher | | | set_storage (base) | 3,248,000 | 2,094,000 | **+55%** | DataHaven higher | | | kill_storage (base) | 3,344,000 | 2,120,000 | **+58%** | DataHaven higher | | | kill_prefix (base) | 6,028,000 | 4,258,000 | **+42%** | DataHaven higher | | | authorize_upgrade | 12,866,000 | 8,966,000 | **+44%** | DataHaven higher | | | apply_authorized_upgrade | 142,435,318,000 | 106,561,461,000 | **+34%** | DataHaven higher | | **pallet_multisig** | as_multi_threshold_1 (base) | 30,107,366 | 17,588,619 | **+71%** | DataHaven higher | | | as_multi_create (base) | 45,353,453 | 32,782,725 | **+38%** | DataHaven higher | | | as_multi_approve (base) | 22,928,808 | 18,299,865 | **+25%** | DataHaven higher | | | as_multi_complete (base) | 57,510,735 | 41,555,387 | **+38%** | DataHaven higher | | | approve_as_multi_create (base) | 42,860,897 | 32,390,857 | **+32%** | DataHaven higher | | | approve_as_multi_approve (base) | 21,640,639 | 16,839,439 | **+29%** | DataHaven higher | | | cancel_as_multi (base) | 44,014,197 | 32,643,060 | **+35%** | DataHaven higher | | **pallet_treasury** | spend_local | 15,605,000 | 12,992,000 | **+20%** | DataHaven higher | | | remove_approval | 8,641,000 | 7,766,000 | **+11%** | DataHaven higher | | | on_initialize_proposals (base) | 19,249,676 | 16,973,066 | **+13%** | DataHaven higher | | | spend | 14,082,000 | 26,612,000 | **-47%** | Moonbase higher | | | payout | 74,847,000 | 247,397,000 | **-70%** | Moonbase significantly higher | | | check_status | 16,325,000 | 16,223,000 | **+1%** | Similar | | | void_spend | 15,059,000 | 15,167,000 | **-1%** | Similar | | **pallet_scheduler** | service_agendas_base | 4,583,000 | 6,215,000 | **-26%** | Moonbase higher | | | service_agenda_base (base) | 8,728,153 | 6,640,549 | **+31%** | DataHaven higher | | | service_task_base | 4,875,000 | 3,455,000 | **+41%** | DataHaven higher | | | service_task_fetched (base) | 24,253,000 | 18,898,000 | **+28%** | DataHaven higher | | | service_task_named | 7,176,000 | 5,027,000 | **+43%** | DataHaven higher | | | service_task_periodic | 4,842,000 | 3,415,000 | **+42%** | DataHaven higher | | | execute_dispatch_signed | 10,378,000 | 4,837,000 | **+115%** | DataHaven significantly higher | | | execute_dispatch_unsigned | 3,511,000 | 2,451,000 | **+43%** | DataHaven higher | | | schedule (base) | 17,795,637 | 13,165,173 | **+35%** | DataHaven higher | | | cancel (base) | 20,509,326 | 15,513,197 | **+32%** | DataHaven higher | --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com> Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-10-29 15:14:21 +00:00
WASM_PATH="target/production/wbuild/datahaven-$RUNTIME-runtime/datahaven_${RUNTIME}_runtime.compact.compressed.wasm"
test: init benchmark infra (#110) * Add `run_benchmarks.sh` script to run runtime benchmarks * Sets up benchmark configs and directory structure to store weights (`operator/runtime/<RUNTIME>/weights`) * (naive) fixes to some benchmarks: * `pallet_datahaven_native_transfer`: * use a mock for `NativeTokenId` * look at the balance difference of the treasury instead of the total (this makes the benchmark agnostic to genesis setup) * `snowbridge_pallet_system` / `snowbridge_pallet_system_v2` use native token xcm location vs relay chain one. Add missing benchmark methods and update fixture with valid data. * `snowbridge_pallet_ethereum_client`: update fixtures with valid data * `snowbrige_pallet_inbound_queue_v2`: set EthereumGatewayAddress when initializing storage on benchmark and use a mock message processor ( as fixture has `CreateAsset` payload which is not supported in the `EigenLayerMessageProcessor`) * `snowbridge_pallet_outbound_queue_v2`: add missing `submit_delivery_receipt` benchmark which required a dedicated fixture (all copied from the upstream pallet) * `pallet_treasury`: Use an `ExistentialDeposit` of `1` on benchmark, else payout fails. * `pallet_transaction_payment`: Use a custom `WeightToFee` that makes the Fee small, else account in benchmark cannot pay for fees (It is funded a multiplier of `ExistentialDeposit` and is expected for that to be enough, but it's not in our particular setup). * comment out `pallet_identity` and `pallet_im_online` due to incompatibilities (to be addressed later) * Basic benchmark run to set `WeightInfo` from `weights` in configs (real run should be done later using target hardware) --------- Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Tobi Demeco <50408393+TDemeco@users.noreply.github.com> Co-authored-by: undercover-cactus <lola@moonsonglabs.com> Co-authored-by: TDemeco <tdemeco@itba.edu.ar>
2025-08-06 11:44:42 +00:00
if [ ! -f "$WASM_PATH" ]; then
echo -e "${RED}Error: WASM runtime not found at $WASM_PATH${NC}"
exit 1
fi
# Discover pallets automatically using frame-omni-bencher
echo -e "${YELLOW}Discovering available pallets...${NC}"
PALLETS=($(
frame-omni-bencher v1 benchmark pallet \
--runtime "$WASM_PATH" \
--list 2>/dev/null | \
tail -n+2 | \
cut -d',' -f1 | \
sort | \
uniq
))
if [ ${#PALLETS[@]} -eq 0 ]; then
echo -e "${RED}Error: No pallets found to benchmark${NC}"
exit 1
fi
echo -e "${GREEN}Found ${#PALLETS[@]} pallets to benchmark:${NC}"
for pallet in "${PALLETS[@]}"; do
echo " - $pallet"
done
echo ""
# Track success/failure
feat: ✨ Implement Moonbeam-style OpenGov governance (#131) ## 🎯 Overview This PR implements a comprehensive Moonbeam-inspired OpenGov (Gov2) governance system across all DataHaven runtime environments (Stagenet, Testnet, and Mainnet). The implementation provides multi-track referenda, conviction voting, collective decision-making through dual councils, and complete benchmarking support. ## ✨ Key Features ### 🗳️ Multi-Track Referendum System Implements **6 distinct governance tracks** with different thresholds and parameters: | Track | Purpose | |-------|---------| | **Root (0)** | Critical runtime upgrades | | **Whitelisted Caller (1)** | Fast-tracked technical proposals | | **General Admin (2)** | General governance proposals | | **Referendum Canceller (3)** | Cancel dangerous referenda | | **Referendum Killer (4)** | Emergency removal of malicious referenda | | **Fast General Admin (5)** | Expedited administrative decisions | ### 🏛️ Dual Council Structure - **Technical Committee**: Manages technical proposals with fast-track powers - **Treasury Council**: Oversees treasury spending with shorter motion duration ### 🔐 Custom Origins System 5 specialized permission levels for granular governance control: - `GeneralAdmin` - `ReferendumCanceller` - `ReferendumKiller` - `WhitelistedCaller` - `FastGeneralAdmin` ### ⚖️ Conviction Voting - Vote multipliers from 0.1x to 6x based on lock duration - Delegation support for proxy voting - Maximum 20 concurrent votes per account 🤖 Implementation assisted by [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
2025-09-02 20:46:35 +00:00
declare -a RESULTS
test: init benchmark infra (#110) * Add `run_benchmarks.sh` script to run runtime benchmarks * Sets up benchmark configs and directory structure to store weights (`operator/runtime/<RUNTIME>/weights`) * (naive) fixes to some benchmarks: * `pallet_datahaven_native_transfer`: * use a mock for `NativeTokenId` * look at the balance difference of the treasury instead of the total (this makes the benchmark agnostic to genesis setup) * `snowbridge_pallet_system` / `snowbridge_pallet_system_v2` use native token xcm location vs relay chain one. Add missing benchmark methods and update fixture with valid data. * `snowbridge_pallet_ethereum_client`: update fixtures with valid data * `snowbrige_pallet_inbound_queue_v2`: set EthereumGatewayAddress when initializing storage on benchmark and use a mock message processor ( as fixture has `CreateAsset` payload which is not supported in the `EigenLayerMessageProcessor`) * `snowbridge_pallet_outbound_queue_v2`: add missing `submit_delivery_receipt` benchmark which required a dedicated fixture (all copied from the upstream pallet) * `pallet_treasury`: Use an `ExistentialDeposit` of `1` on benchmark, else payout fails. * `pallet_transaction_payment`: Use a custom `WeightToFee` that makes the Fee small, else account in benchmark cannot pay for fees (It is funded a multiplier of `ExistentialDeposit` and is expected for that to be enough, but it's not in our particular setup). * comment out `pallet_identity` and `pallet_im_online` due to incompatibilities (to be addressed later) * Basic benchmark run to set `WeightInfo` from `weights` in configs (real run should be done later using target hardware) --------- Co-authored-by: Ahmad Kaouk <ahmadkaouk.93@gmail.com> Co-authored-by: Tobi Demeco <50408393+TDemeco@users.noreply.github.com> Co-authored-by: undercover-cactus <lola@moonsonglabs.com> Co-authored-by: TDemeco <tdemeco@itba.edu.ar>
2025-08-06 11:44:42 +00:00
# Create runtime weights directory if it doesn't exist
WEIGHTS_DIR="runtime/$RUNTIME/src/weights"
mkdir -p "$WEIGHTS_DIR"
# Run benchmarks for each pallet using frame-omni-bencher
echo -e "${GREEN}Starting benchmarks...${NC}\n"
# Function to run benchmark for a pallet
benchmark_pallet() {
local PALLET=$1
local OUTPUT_FILE=$2
echo -e "${YELLOW}Benchmarking $PALLET...${NC}"
# Run the benchmark with tee to show output and save to log, using PIPESTATUS to get exit code
frame-omni-bencher v1 benchmark pallet \
--runtime "$WASM_PATH" \
--pallet "$PALLET" \
--extrinsic "" \
--template "$TEMPLATE_PATH" \
--output "$WEIGHTS_DIR/$OUTPUT_FILE.rs" \
--steps "$STEPS" \
--repeat "$REPEAT" 2>&1 | tee "benchmark_${PALLET}.log"
# Check the exit code from the benchmark command (first command in the pipeline)
local exit_code=${PIPESTATUS[0]}
if [ $exit_code -eq 0 ]; then
echo -e "${GREEN}$PALLET benchmarked successfully${NC}"
return 0
else
echo -e "${RED}✗ Error benchmarking $PALLET${NC}"
return 1
fi
}
# Benchmark all discovered pallets
for PALLET in "${PALLETS[@]}"; do
# Use the pallet name directly as the output file name
OUTPUT_FILE="$PALLET"
if benchmark_pallet "$PALLET" "$OUTPUT_FILE"; then
RESULTS[$PALLET]="SUCCESS"
else
RESULTS[$PALLET]="FAILED"
fi
echo ""
done
# Summary
echo -e "\n${GREEN}Benchmarking Summary:${NC}"
echo "========================"
SUCCESS_COUNT=0
FAILED_COUNT=0
for PALLET in "${!RESULTS[@]}"; do
if [ "${RESULTS[$PALLET]}" == "SUCCESS" ]; then
echo -e "${GREEN}${NC} $PALLET"
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
else
echo -e "${RED}${NC} $PALLET"
FAILED_COUNT=$((FAILED_COUNT + 1))
fi
done
echo ""
echo "Total: ${#PALLETS[@]} pallets"
echo "Success: $SUCCESS_COUNT"
echo "Failed: $FAILED_COUNT"
if [ $FAILED_COUNT -eq 0 ]; then
echo -e "\n${GREEN}All benchmarks completed successfully!${NC}"
exit 0
else
echo -e "\n${YELLOW}$FAILED_COUNT benchmark(s) failed. Check the logs for details.${NC}"
exit 1
fi