forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runtime benchmarks: start (paritytech#136)
* runtime benchmarks: start * merge tests + benchmarks infrastructure * fix compilation * Fix compilation issues with runtime-benchmark feature flag Mainly involved pulling in correct dependencies and adding some functions which were called but didn't yet exist. * Fix broken compilation for tests * Move header signing methods into trait * Move signing related test helpers to own module * Remove comment about feature flag * Add constants to tests * Add top level comment for testing utilities Co-authored-by: Hernando Castano <castano.ha@gmail.com>
- Loading branch information
Showing
20 changed files
with
950 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2019-2020 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity Bridges Common. | ||
|
||
// Parity Bridges Common is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity Bridges Common is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use super::*; | ||
|
||
use crate::test_utils::{build_custom_header, build_genesis_header, validator_utils::*}; | ||
|
||
use frame_benchmarking::benchmarks; | ||
use frame_system::RawOrigin; | ||
use primitives::U256; | ||
|
||
benchmarks! { | ||
_ { } | ||
|
||
// Benchmark `import_unsigned_header` extrinsic with the best possible conditions: | ||
// * Parent header is finalized. | ||
// * New header doesn't require receipts. | ||
// * Nothing is finalized by new header. | ||
// * Nothing is pruned by new header. | ||
import_unsigned_header_best_case { | ||
let n in 1..1000; | ||
|
||
// initialize storage with some initial header | ||
let initial_header = build_genesis_header(&validator(0)); | ||
let initial_header_hash = initial_header.compute_hash(); | ||
let initial_difficulty = initial_header.difficulty; | ||
initialize_storage::<T>( | ||
&initial_header, | ||
initial_difficulty, | ||
&validators_addresses(2), | ||
); | ||
|
||
// prepare header to be inserted | ||
let header = build_custom_header( | ||
&validator(1), | ||
&initial_header, | ||
|mut header| { | ||
header.gas_limit = header.gas_limit + U256::from(n); | ||
header | ||
}, | ||
); | ||
|
||
}: import_unsigned_header(RawOrigin::None, header, None) | ||
verify { | ||
assert_eq!(BridgeStorage::<T>::new().best_block().0.number, 1); | ||
} | ||
} |
Oops, something went wrong.