Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
507014b
Initial planning
elfedy Jun 25, 2025
77f8dfa
no fast runtime
elfedy Jun 25, 2025
44b3e33
use frame-omni-bencher
elfedy Jun 25, 2025
49b14ed
use runtime specific directory structure for scripts
elfedy Jun 25, 2025
6890769
benchmarks config
elfedy Jun 25, 2025
fa797a3
some script fixes
elfedy Jun 26, 2025
cf52d03
Autodetect pallets and do not segment them
elfedy Jun 26, 2025
bbfb7e8
Fix pallet_datahaven_native_transfer benchmarks
elfedy Jun 26, 2025
04b4c97
remove pallet_session from benchmarks
elfedy Jun 26, 2025
f2d5eaf
make claude task folder
elfedy Jun 27, 2025
9b76ec1
fix snowbridge_pallet_system benchmark
elfedy Jun 27, 2025
25b0a41
fix system-v2 benchmark
elfedy Jun 27, 2025
d0981c4
Update ethereum-client fixtures
elfedy Jun 30, 2025
6511873
Set fixture address as EthereumGatewayAddress in benchmarks
elfedy Jul 1, 2025
5782755
fix pallet_inbound_queue benchmark
elfedy Jul 2, 2025
a72f3e7
update plan
elfedy Jul 3, 2025
bb7a690
Comment out failing pallets and leave TODOs
elfedy Jul 3, 2025
1975cca
Add WeightInfo to pallet configs
elfedy Jul 3, 2025
40f9f68
Add some missing pallets (testnet only)
elfedy Jul 4, 2025
816b926
Merge branch 'main' into test/benchmark-init
elfedy Jul 7, 2025
1744012
update pallet system v2 benchmarks
elfedy Jul 7, 2025
f1bb468
Add missing method to snowbridge_pallet_inbound_queue_v2 benchmark
elfedy Jul 7, 2025
8a8ad58
Add outbound_queue_v2 benchmark config for other runtimes
elfedy Jul 7, 2025
8e51937
Use a low existential deposit for benchmarks
elfedy Jul 8, 2025
422b28c
use generated weights in all runtimes
elfedy Jul 8, 2025
1ff9950
cargo fmt
elfedy Jul 8, 2025
e8f4f52
Remove frame_benchmarking weights
elfedy Jul 8, 2025
d92d370
Remove claude task
elfedy Jul 9, 2025
b1b5b28
use correct trait type for frame_system weight
elfedy Jul 9, 2025
bdef2d4
fix native transfer benchmark for real
elfedy Jul 9, 2025
0dcb9e7
Implement custom weight to fee implementation
elfedy Jul 9, 2025
7970f40
add transaction_payment fix to stagenet/mainnet
elfedy Jul 9, 2025
e85cfe9
Add note about runtime-benchmarks existential deposit
elfedy Jul 9, 2025
33580e5
generate papi metadata
elfedy Jul 9, 2025
1091a06
remove unused import
elfedy Jul 9, 2025
2730a59
Merge branch 'main' into test/benchmark-init
elfedy Jul 10, 2025
e4d10ea
Add a comment for system pallets
elfedy Jul 10, 2025
1263431
fix benchmark script
elfedy Jul 10, 2025
7dabde5
Merge branch 'fixing-benchmarks' into test/benchmark-init
elfedy Jul 10, 2025
5238cfc
Add benchmarking section to operator README
elfedy Jul 10, 2025
4005a99
Merge branch 'main' into test/benchmark-init
ahmadkaouk Jul 24, 2025
e5abba1
Merge branch 'main' into test/benchmark-init
TDemeco Jul 25, 2025
669c0ab
update polkadot stable2412 to the lastest
undercover-cactus Jul 31, 2025
32d30fc
update README instruction for benchmark
undercover-cactus Jul 31, 2025
9f64e18
reactivate IAmOnline pallet
undercover-cactus Jul 31, 2025
6ec23f8
try to implement benchmark_helper function
undercover-cactus Aug 4, 2025
db97297
fix: :bug: update `pallet-identity` benchmark helper function
TDemeco Aug 4, 2025
c13142e
use types defined by config
undercover-cactus Aug 5, 2025
679328a
Merge branch 'main' into test/benchmark-init
undercover-cactus Aug 5, 2025
87dab64
new weights generated
undercover-cactus Aug 5, 2025
3759f9c
Missing sp-io lib in stagenet and mainnet runtime
undercover-cactus Aug 5, 2025
94a7465
regenerate metadata again
undercover-cactus Aug 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
413 changes: 208 additions & 205 deletions operator/Cargo.lock

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@

Based on [polkadot-sdk-solochain-template](https://github.com/paritytech/polkadot-sdk-solochain-template)

## Benchmarking

DataHaven uses runtime benchmarking to generate accurate weight calculations for all pallets. The benchmarking process is automated using `frame-omni-bencher`.

### Requirements

Make sure you have the lastest rust version

- `frame-omni-bencher` - Install with: `cargo install frame-omni-bencher --profile=production` (or `cargo install --git https://github.com/paritytech/polkadot-sdk frame-omni-bencher --profile=production --locked`)

### Running Benchmarks

Execute the benchmarking script from the project root:

```bash
# Benchmark all pallets for testnet runtime (default)
./scripts/run-benchmarks.sh

# Benchmark specific runtime
./scripts/run-benchmarks.sh mainnet

# Custom steps and repetitions
./scripts/run-benchmarks.sh testnet 100 50
```

The script will:
1. Automatically discover all available pallets
2. Build the runtime WASM with `runtime-benchmarks` feature
3. Generate weight files in `runtime/{runtime}/src/weights/`
4. Provide a summary of successful and failed benchmarks

### Script Parameters

- `runtime`: Runtime to benchmark (testnet, stagenet, mainnet). Default: testnet
- `steps`: Number of steps for benchmarking. Default: 50
- `repeat`: Number of repetitions. Default: 20

## Zombienet testing

First, install [zombienet](https://github.com/paritytech/zombienet).
Expand Down
78 changes: 78 additions & 0 deletions operator/benchmarking/frame-weight-template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{{header}}

//! Autogenerated weights for `{{pallet}}`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}}
//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: `{{cmd.repeat}}`, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}`
//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}`
//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}`
//! WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}}

// Executed Command:
{{#each args as |arg|}}
// {{arg}}
{{/each}}

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weights for `{{pallet}}`.
pub struct WeightInfo<T>(PhantomData<T>);
{{#if (eq pallet "frame_system_extensions")}}
impl<T: frame_system::Config> frame_system::ExtensionsWeightInfo for WeightInfo<T> {
{{else}}
impl<T: frame_system::Config> {{pallet}}::WeightInfo for WeightInfo<T> {
{{/if}}
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
/// {{comment}}
{{/each}}
{{#each benchmark.component_ranges as |range|}}
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
{{/each}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
// Proof Size summary in bytes:
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds.
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into())))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
{{/each}}
{{#each benchmark.component_calculated_proof_size as |cp|}}
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
{{/each}}
{{#if (and (eq ../pallet "pallet_proxy") (eq benchmark.name "proxy"))}}
// 1 DB read that happen when filtering the proxy call transaction
.saturating_add(T::DbWeight::get().reads(1))
{{/if}}
{{#if (and (eq ../pallet "pallet_precompile_benchmarks") (eq benchmark.name "p256_verify"))}}
// TODO: Remove this multiplication once we are comfortable with the weight estimation
// Double the weight just to mitigate the possibility of having a signature that
// takes longer to verify
.saturating_mul(1u64)
{{/if}}
}
{{/each}}
}
19 changes: 14 additions & 5 deletions operator/pallets/datahaven-native-transfer/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use sp_core::H160;
// Helper function to create a funded account
fn create_funded_account<T: Config>(seed: u32, amount: BalanceOf<T>) -> T::AccountId {
let account: T::AccountId = account("user", seed, seed);
T::Currency::set_balance(&account, amount);
let _ = T::Currency::mint_into(&account, amount);
account
}

Expand All @@ -46,13 +46,19 @@ mod benchmarks {
#[benchmark]
fn transfer_to_ethereum() -> Result<(), BenchmarkError> {
// Setup
let amount: BalanceOf<T> = 1_000_000u128.into();
let fee: BalanceOf<T> = 10_000u128.into();
let total_needed = amount + fee + fee; // Extra fee for existential deposit
let amount: BalanceOf<T> = (10_000 * 1_000_000_000u128).into(); // 10k units
let fee: BalanceOf<T> = (100 * 1_000_000_000u128).into(); // 100 units
let existential_deposit: BalanceOf<T> = T::Currency::minimum_balance();

// Sender needs: amount + fee + existential_deposit;
let total_needed = amount + fee + existential_deposit;

let sender = create_funded_account::<T>(1, total_needed);
let recipient = ethereum_address(42);

// Check the initial balance of the fee recipient
let initial_fee_recipient_balance = T::Currency::balance(&T::FeeRecipient::get());

// Ensure pallet is not paused
Paused::<T>::put(false);

Expand All @@ -64,7 +70,10 @@ mod benchmarks {
T::Currency::balance(&T::EthereumSovereignAccount::get()),
amount
);
assert_eq!(T::Currency::balance(&T::FeeRecipient::get()), fee);
assert_eq!(
T::Currency::balance(&T::FeeRecipient::get()),
initial_fee_recipient_balance + fee
);

Ok(())
}
Expand Down
Loading
Loading