Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

seal: Add automated weights for contract API calls #7017

Merged
34 commits merged into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
407920b
seal: Add capability to put uninstrumented code (for benchmarks)
athei Jul 31, 2020
343f0fb
seal: Cap the the data length for deposited events
athei Aug 19, 2020
1235f26
seal: Fix error reporting in the case out of bound sandbox access
athei Aug 27, 2020
ec69d05
seal: Refactor existing benchmarks
athei Aug 3, 2020
b1a1133
seal: Convert benchmark file to tabs
athei Aug 5, 2020
dfa6076
seal: Add benchmarks for functions called by contracts
athei Aug 10, 2020
2cbe472
seal: Create a default schedule from benchmark generated WeightInfo
athei Aug 31, 2020
1e065cf
seal: Make use of WeightInfo in extrinsic weight annotations
athei Sep 1, 2020
c680745
seal: Replace the old schedule by the benchmark generated one
athei Sep 1, 2020
0132ede
Merge branch 'master' into at-seal-api-benchmarks
athei Sep 23, 2020
ca7742d
Review: Fix copy paste typo in schedule construction
athei Sep 23, 2020
cdec9ae
Review: Fix stale docs
athei Sep 23, 2020
0a2bd2a
Fix whitespace errors
athei Sep 23, 2020
771bf8a
Review: Use checked_div in order to be more defensive
athei Sep 23, 2020
a326fac
Merge branch 'master' into at-seal-api-benchmarks
athei Sep 24, 2020
d76bcde
Review: Rename no_charge to already_charged
athei Sep 24, 2020
b3aa6ac
Review: Whitelist caller of extrinsics
athei Sep 24, 2020
678f155
Review: Remove trailing whitespace
athei Sep 24, 2020
190144e
Review: Remove confusing "self::" syntax
athei Sep 24, 2020
dd2edeb
Review: Add docs for the benchmark prepration submodule
athei Sep 24, 2020
4e65609
Review: Move code generation functions to own module
athei Sep 24, 2020
687c2a5
Review: Refactor and document benchmark helper functions
athei Sep 24, 2020
b42e400
Remove additional empty line
athei Sep 24, 2020
56b8d31
Added missing comment on caller_funding
athei Sep 24, 2020
a7d3da1
Update frame/contracts/src/benchmarking/code.rs
athei Sep 24, 2020
09766bb
Fix missing sp_std::prelude import in code.rs
athei Sep 25, 2020
c54fa98
Merge branch 'master' into at-seal-api-benchmarks
athei Sep 25, 2020
9d1c66b
Merge remote-tracking branch 'origin/master' into at-seal-api-benchmarks
shawntabrizi Oct 6, 2020
e565433
cargo run --release --features runtime-benchmarks --manifest-path bin…
shawntabrizi Oct 6, 2020
036a8ba
Use weights from the benchmark machine for the substrate node
athei Oct 6, 2020
2c154dd
Remove prefixes from Schedule members
athei Oct 7, 2020
6f2f333
Data lengths in the WeightInfo Trait are specified in kilobytes
athei Oct 7, 2020
51a8c38
Rename ApiWeights to HostFunctionWeights
athei Oct 8, 2020
94a08b5
Merge branch 'master' into at-seal-api-benchmarks
athei Oct 8, 2020
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
15 changes: 11 additions & 4 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ impl pallet_contracts::Trait for Runtime {
type MaxDepth = pallet_contracts::DefaultMaxDepth;
type MaxValueSize = pallet_contracts::DefaultMaxValueSize;
type WeightPrice = pallet_transaction_payment::Module<Self>;
type WeightInfo = weights::pallet_contracts::WeightInfo<Self>;
}

impl pallet_sudo::Trait for Runtime {
Expand Down Expand Up @@ -926,7 +927,7 @@ construct_runtime!(
FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config<T>, Storage, Event<T>},
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
Expand Down
1 change: 1 addition & 0 deletions bin/node/runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
pub mod frame_system;
pub mod pallet_balances;
pub mod pallet_collective;
pub mod pallet_contracts;
pub mod pallet_democracy;
pub mod pallet_elections_phragmen;
pub mod pallet_identity;
Expand Down
294 changes: 294 additions & 0 deletions bin/node/runtime/src/weights/pallet_contracts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
// This file is part of Substrate.

// Copyright (C) 2020 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.

//! Weights for pallet_contracts
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
//! DATE: 2020-10-06, STEPS: [50], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []

#![allow(unused_parens)]
#![allow(unused_imports)]

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

pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Trait> pallet_contracts::WeightInfo for WeightInfo<T> {
fn update_schedule() -> Weight {
(33_207_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn put_code(n: u32, ) -> Weight {
(0 as Weight)
.saturating_add((144_833_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn instantiate(n: u32, ) -> Weight {
(223_974_000 as Weight)
.saturating_add((1_007_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn call() -> Weight {
(210_638_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn claim_surcharge() -> Weight {
(508_079_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn seal_caller(r: u32, ) -> Weight {
(143_336_000 as Weight)
.saturating_add((397_788_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_address(r: u32, ) -> Weight {
(147_296_000 as Weight)
.saturating_add((396_962_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_gas_left(r: u32, ) -> Weight {
(141_677_000 as Weight)
.saturating_add((393_308_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_balance(r: u32, ) -> Weight {
(157_556_000 as Weight)
.saturating_add((879_861_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
}
fn seal_value_transferred(r: u32, ) -> Weight {
(148_867_000 as Weight)
.saturating_add((391_678_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_minimum_balance(r: u32, ) -> Weight {
(147_252_000 as Weight)
.saturating_add((393_977_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_tombstone_deposit(r: u32, ) -> Weight {
(144_208_000 as Weight)
.saturating_add((394_625_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_rent_allowance(r: u32, ) -> Weight {
(135_320_000 as Weight)
.saturating_add((925_541_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_block_number(r: u32, ) -> Weight {
(145_849_000 as Weight)
.saturating_add((390_065_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_now(r: u32, ) -> Weight {
(146_363_000 as Weight)
.saturating_add((391_772_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_weight_to_fee(r: u32, ) -> Weight {
(129_872_000 as Weight)
.saturating_add((670_744_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
}
fn seal_gas(r: u32, ) -> Weight {
(130_985_000 as Weight)
.saturating_add((198_427_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_input(r: u32, ) -> Weight {
(138_647_000 as Weight)
.saturating_add((8_363_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_input_per_kb(n: u32, ) -> Weight {
(149_418_000 as Weight)
.saturating_add((272_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_return(r: u32, ) -> Weight {
(129_116_000 as Weight)
.saturating_add((5_745_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_return_per_kb(n: u32, ) -> Weight {
(139_601_000 as Weight)
.saturating_add((680_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_terminate(r: u32, ) -> Weight {
(138_548_000 as Weight)
.saturating_add((355_473_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(r as Weight)))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(r as Weight)))
}
fn seal_restore_to(r: u32, ) -> Weight {
(239_880_000 as Weight)
.saturating_add((138_305_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(r as Weight)))
.saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(r as Weight)))
}
fn seal_restore_to_per_delta(d: u32, ) -> Weight {
(40_572_000 as Weight)
.saturating_add((3_748_632_000 as Weight).saturating_mul(d as Weight))
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(d as Weight)))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
.saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(d as Weight)))
}
fn seal_random(r: u32, ) -> Weight {
(148_156_000 as Weight)
.saturating_add((1_036_452_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
}
fn seal_deposit_event(r: u32, ) -> Weight {
(176_039_000 as Weight)
.saturating_add((1_497_705_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight {
(1_923_547_000 as Weight)
.saturating_add((783_354_000 as Weight).saturating_mul(t as Weight))
.saturating_add((240_600_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(t as Weight)))
.saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(t as Weight)))
}
fn seal_set_rent_allowance(r: u32, ) -> Weight {
(151_095_000 as Weight)
.saturating_add((1_104_696_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn seal_set_storage(r: u32, ) -> Weight {
(0 as Weight)
.saturating_add((14_975_467_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
}
fn seal_set_storage_per_kb(n: u32, ) -> Weight {
(2_465_724_000 as Weight)
.saturating_add((203_125_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn seal_clear_storage(r: u32, ) -> Weight {
(0 as Weight)
.saturating_add((5_254_595_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
}
fn seal_get_storage(r: u32, ) -> Weight {
(60_303_000 as Weight)
.saturating_add((1_135_486_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
}
fn seal_get_storage_per_kb(n: u32, ) -> Weight {
(931_900_000 as Weight)
.saturating_add((144_572_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
}
fn seal_transfer(r: u32, ) -> Weight {
(50_722_000 as Weight)
.saturating_add((6_701_164_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((100 as Weight).saturating_mul(r as Weight)))
}
fn seal_call(r: u32, ) -> Weight {
(0 as Weight)
.saturating_add((10_589_747_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().reads((100 as Weight).saturating_mul(r as Weight)))
}
fn seal_call_per_transfer_input_output_kb(t: u32, i: u32, o: u32, ) -> Weight {
(11_223_388_000 as Weight)
.saturating_add((4_965_182_000 as Weight).saturating_mul(t as Weight))
.saturating_add((50_603_000 as Weight).saturating_mul(i as Weight))
.saturating_add((72_972_000 as Weight).saturating_mul(o as Weight))
.saturating_add(T::DbWeight::get().reads(105 as Weight))
.saturating_add(T::DbWeight::get().reads((101 as Weight).saturating_mul(t as Weight)))
.saturating_add(T::DbWeight::get().writes((101 as Weight).saturating_mul(t as Weight)))
}
fn seal_instantiate(r: u32, ) -> Weight {
(0 as Weight)
.saturating_add((22_933_938_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().reads((300 as Weight).saturating_mul(r as Weight)))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes((200 as Weight).saturating_mul(r as Weight)))
}
fn seal_instantiate_per_input_output_kb(i: u32, o: u32, ) -> Weight {
(20_986_307_000 as Weight)
.saturating_add((152_611_000 as Weight).saturating_mul(i as Weight))
.saturating_add((73_457_000 as Weight).saturating_mul(o as Weight))
.saturating_add(T::DbWeight::get().reads(207 as Weight))
.saturating_add(T::DbWeight::get().writes(202 as Weight))
}
fn seal_hash_sha2_256(r: u32, ) -> Weight {
(145_988_000 as Weight)
.saturating_add((343_540_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight {
(719_758_000 as Weight)
.saturating_add((420_306_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_hash_keccak_256(r: u32, ) -> Weight {
(116_261_000 as Weight)
.saturating_add((360_601_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight {
(583_726_000 as Weight)
.saturating_add((333_091_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_hash_blake2_256(r: u32, ) -> Weight {
(144_609_000 as Weight)
.saturating_add((332_388_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight {
(612_987_000 as Weight)
.saturating_add((150_030_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_hash_blake2_128(r: u32, ) -> Weight {
(142_085_000 as Weight)
.saturating_add((329_426_000 as Weight).saturating_mul(r as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight {
(632_517_000 as Weight)
.saturating_add((149_974_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
}
}
Loading