Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmarks to transaction extensions #2726

Merged
merged 57 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0c1aeeb
WIP tx ext benches
georgepisaltu Nov 27, 2023
b9ee241
Make benches work for basic extensions
georgepisaltu Nov 28, 2023
699e94c
Add sudo extension benchmark
georgepisaltu Nov 28, 2023
087b0bb
Add prevalidate attests benchmark
georgepisaltu Nov 29, 2023
0b39b1e
Add benches for `ChargeAssetTxPayment`
georgepisaltu Nov 30, 2023
a1140e3
Add bench for transaction payment extension
georgepisaltu Nov 30, 2023
809b2e2
Add benches for refund relayer extension
georgepisaltu Dec 12, 2023
d0f9e64
Add weights to system extensions
georgepisaltu Dec 13, 2023
ab060e7
Fix lints
georgepisaltu Dec 13, 2023
6b3ddd5
Fix runtime benchmarks in runtimes
georgepisaltu Dec 13, 2023
f3d50a3
Add license to weights file
georgepisaltu Dec 14, 2023
227a970
Format toml files
georgepisaltu Dec 14, 2023
1819ebd
Add weights to sudo extension
georgepisaltu Dec 14, 2023
ee1a81c
Add weights for prevalidate attests extension
georgepisaltu Dec 15, 2023
8a64936
Add weights for transaction payment extension
georgepisaltu Dec 15, 2023
b3b1260
Fix bridges compilation issue
georgepisaltu Dec 15, 2023
8ef2b28
Add weights for asset conversion tx payment ext
georgepisaltu Dec 19, 2023
8f4d0a0
Add weights for asset tx payment ext
georgepisaltu Dec 20, 2023
2c8a093
Revert "Add benches for refund relayer extension"
georgepisaltu Dec 20, 2023
50b4d81
Use minimum balance in tx payment bench
georgepisaltu Dec 20, 2023
3122fd6
Simplify frame system extension benches
georgepisaltu Dec 20, 2023
3a132be
Update substrate benchmark template
georgepisaltu Dec 20, 2023
e278be0
Update regular bench template
georgepisaltu Dec 20, 2023
c067812
Test run system extensions weights
georgepisaltu Dec 20, 2023
217b900
Add system extension weights for cumulus runtime
georgepisaltu Dec 21, 2023
465df79
Fix contracts tx payment extensions weight
georgepisaltu Dec 21, 2023
f02a2c7
Add weight for sudo extension
georgepisaltu Dec 21, 2023
6f25283
Add weights for claims extension
georgepisaltu Dec 21, 2023
eb7d407
Fix tx payment benches and add weights
georgepisaltu Dec 21, 2023
579d586
Fix transaction payment ext bench balance
georgepisaltu Jan 3, 2024
51851d3
Asset conversion tx payment ext weights
georgepisaltu Jan 3, 2024
7a4855a
Asset tx payment ext weights
georgepisaltu Jan 4, 2024
54024aa
Transaction payment ext weights
georgepisaltu Jan 4, 2024
a4f07ce
Remove whitelisted caller from system ext benches
georgepisaltu Jan 4, 2024
eb02eee
Merge remote-tracking branch 'upstream/gav-tx-ext' into second-new-be…
georgepisaltu Jan 4, 2024
9f75110
Add event assertion to tx payment ext benches
georgepisaltu Jan 5, 2024
8d5cf18
Fix bridges system extensions weight config
georgepisaltu Jan 5, 2024
fd72c1e
Fix omitted merge conflict
georgepisaltu Jan 5, 2024
dfb8f40
Add ext weights to people runtime
georgepisaltu Jan 5, 2024
2ceccd7
Add tx ext weights for coretime
georgepisaltu Jan 5, 2024
4721b21
Add tx ext weights for people westend
georgepisaltu Jan 5, 2024
f208719
Fix beacon brigde config
georgepisaltu Jan 5, 2024
8f47af4
Remove useless trait bounds on extensions
georgepisaltu Jan 5, 2024
d991a32
Add doc comment to system ext weight type
georgepisaltu Jan 5, 2024
1c51611
Rename ext weight info type in config
georgepisaltu Jan 5, 2024
7159b1c
Minor refactor in system ext weights
georgepisaltu Jan 5, 2024
4f7d9a4
Rename `ExtConfig`s to `BenchmarkingConfig`
georgepisaltu Jan 5, 2024
3a53eb5
Simplify `claims::BenchmarkingConfig`
georgepisaltu Jan 5, 2024
215295a
Remove redundant `compute_fee` in tx payment ext
georgepisaltu Jan 5, 2024
f9d4149
Fix clippy
georgepisaltu Jan 5, 2024
eb3065a
Move to benchmark helper trait
georgepisaltu Jan 9, 2024
b6aee22
Fix leftover `BenchmarkingConfig` impls
georgepisaltu Jan 10, 2024
7452f50
Merge remote-tracking branch 'upstream/gav-tx-ext' into new-benches
georgepisaltu Jan 10, 2024
8314db5
Fix omitted errors
georgepisaltu Jan 10, 2024
fa74a1a
Fix clippy
georgepisaltu Jan 10, 2024
2cec153
Run zepter
georgepisaltu Jan 10, 2024
86ea914
Fix toml formatting
georgepisaltu Jan 10, 2024
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
44 changes: 23 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bridges/bin/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ runtime-benchmarks = [
"pallet-bridge-messages/runtime-benchmarks",
"pallet-bridge-parachains/runtime-benchmarks",
"pallet-bridge-relayers/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
Expand Down
1 change: 1 addition & 0 deletions bridges/bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl pallet_transaction_payment::Config for TestRuntime {
MaximumMultiplier,
>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
}

impl pallet_bridge_grandpa::Config for TestRuntime {
Expand Down
11 changes: 7 additions & 4 deletions bridges/bin/runtime-common/src/priority_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,23 @@ mod integrity_tests {
// nodes to the proof (x0.5 because we expect some nodes to be reused)
let estimated_message_size = 512;
// let's say all our messages have the same dispatch weight
let estimated_message_dispatch_weight =
Runtime::WeightInfo::message_dispatch_weight(estimated_message_size);
let estimated_message_dispatch_weight = <Runtime as pallet_bridge_messages::Config<
MessagesInstance,
>>::WeightInfo::message_dispatch_weight(
estimated_message_size
);
// messages proof argument size is (for every message) messages size + some additional
// trie nodes. Some of them are reused by different messages, so let's take 2/3 of default
// "overhead" constant
let messages_proof_size = Runtime::WeightInfo::expected_extra_storage_proof_size()
let messages_proof_size = <Runtime as pallet_bridge_messages::Config<MessagesInstance>>::WeightInfo::expected_extra_storage_proof_size()
.saturating_mul(2)
.saturating_div(3)
.saturating_add(estimated_message_size)
.saturating_mul(messages as _);

// finally we are able to estimate transaction size and weight
let transaction_size = base_tx_size.saturating_add(messages_proof_size);
let transaction_weight = Runtime::WeightInfo::receive_messages_proof_weight(
let transaction_weight = <Runtime as pallet_bridge_messages::Config<MessagesInstance>>::WeightInfo::receive_messages_proof_weight(
&PreComputedSize(transaction_size as _),
messages as _,
estimated_message_dispatch_weight.saturating_mul(messages),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub mod minimal {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SystemExtensionsWeightInfo = ();
type SS58Prefix = SS58Prefix;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type Nonce = u64;
Expand Down Expand Up @@ -223,6 +224,7 @@ pub mod mainnet {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SystemExtensionsWeightInfo = ();
type SS58Prefix = SS58Prefix;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type Nonce = u64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SystemExtensionsWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SystemExtensionsWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
Expand Down
1 change: 1 addition & 0 deletions bridges/snowbridge/parachain/pallets/system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl frame_system::Config for Test {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SystemExtensionsWeightInfo = ();
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
Expand Down
1 change: 1 addition & 0 deletions cumulus/parachain-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ runtime-benchmarks = [
"pallet-parachain-template/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
Expand Down
4 changes: 4 additions & 0 deletions cumulus/parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ impl pallet_transaction_payment::Config for Runtime {
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightInfo = ();
}

impl pallet_sudo::Config for Runtime {
Expand Down Expand Up @@ -529,6 +530,7 @@ construct_runtime!(
mod benches {
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[frame_system_extensions, SystemExtensionsBench::<Runtime>]
[pallet_balances, Balances]
[pallet_session, SessionBench::<Runtime>]
[pallet_timestamp, Timestamp]
Expand Down Expand Up @@ -712,6 +714,7 @@ impl_runtime_apis! {
use frame_benchmarking::{Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use frame_system_benchmarking::Pallet as SystemBench;
use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
use cumulus_pallet_session_benchmarking::Pallet as SessionBench;

let mut list = Vec::<BenchmarkList>::new();
Expand All @@ -727,6 +730,7 @@ impl_runtime_apis! {
use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch};

use frame_system_benchmarking::Pallet as SystemBench;
use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
impl frame_system_benchmarking::Config for Runtime {
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-asset-conversion-tx-payment/runtime-benchmarks",
"pallet-asset-conversion/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
Expand All @@ -131,6 +132,7 @@ runtime-benchmarks = [
"pallet-proxy/runtime-benchmarks",
"pallet-state-trie-migration/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-xcm-benchmarks/runtime-benchmarks",
Expand Down
Loading
Loading