-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
326 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,78 @@ | ||
// This file is part of Astar. | ||
|
||
// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
// Astar 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. | ||
|
||
// Astar 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 Astar. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use super::*; | ||
|
||
use frame_benchmarking::v2::*; | ||
use parity_scale_codec::Encode; | ||
use sp_core::H160; | ||
|
||
#[benchmarks] | ||
mod benchmarks { | ||
use super::*; | ||
|
||
#[benchmark] | ||
fn evm_call_without_execution() { | ||
let context = Context { | ||
source_vm_id: VmId::Wasm, | ||
weight_limit: Weight::from_parts(1_000_000, 1_000_000), | ||
}; | ||
let vm_id = VmId::Evm; | ||
let source = whitelisted_caller(); | ||
let target = H160::repeat_byte(1).encode(); | ||
let input = vec![1, 2, 3]; | ||
|
||
#[block] | ||
{ | ||
Pallet::<T>::call_without_execution(context, vm_id, source, target, input).unwrap(); | ||
} | ||
} | ||
|
||
#[benchmark] | ||
fn wasm_call_without_execution() { | ||
let context = Context { | ||
source_vm_id: VmId::Evm, | ||
weight_limit: Weight::from_parts(1_000_000, 1_000_000), | ||
}; | ||
let vm_id = VmId::Wasm; | ||
let source = whitelisted_caller(); | ||
let target = whitelisted_caller::<T::AccountId>().encode(); | ||
let input = vec![1, 2, 3]; | ||
|
||
#[block] | ||
{ | ||
Pallet::<T>::call_without_execution(context, vm_id, source, target, input).unwrap(); | ||
} | ||
} | ||
|
||
impl_benchmark_test_suite!( | ||
Pallet, | ||
crate::benchmarking::tests::new_test_ext(), | ||
crate::mock::TestRuntime, | ||
); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::mock; | ||
use sp_io::TestExternalities; | ||
|
||
pub fn new_test_ext() -> TestExternalities { | ||
mock::ExtBuilder::default().build() | ||
} | ||
} |
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
Oops, something went wrong.