Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 10 additions & 34 deletions bin/node/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use sc_executor::{Externalities, NativeElseWasmExecutor, RuntimeVersionOf, WasmE
use sp_core::{
storage::well_known_keys,
traits::{CodeExecutor, RuntimeCode},
NativeOrEncoded, NeverNativeValue,
};
use sp_runtime::traits::BlakeTwo256;
use sp_state_machine::TestExternalities as CoreTestExternalities;
Expand Down Expand Up @@ -112,46 +111,24 @@ fn construct_block<E: Externalities>(

// execute the block to get the real header.
executor
.call::<NeverNativeValue, fn() -> _>(
ext,
&runtime_code,
"Core_initialize_block",
&header.encode(),
true,
None,
)
.call(ext, &runtime_code, "Core_initialize_block", &header.encode(), true)
.0
.unwrap();

for i in extrinsics.iter() {
executor
.call::<NeverNativeValue, fn() -> _>(
ext,
&runtime_code,
"BlockBuilder_apply_extrinsic",
&i.encode(),
true,
None,
)
.call(ext, &runtime_code, "BlockBuilder_apply_extrinsic", &i.encode(), true)
.0
.unwrap();
}

let header = match executor
.call::<NeverNativeValue, fn() -> _>(
ext,
&runtime_code,
"BlockBuilder_finalize_block",
&[0u8; 0],
true,
None,
)
.0
.unwrap()
{
NativeOrEncoded::Native(_) => unreachable!(),
NativeOrEncoded::Encoded(h) => Header::decode(&mut &h[..]).unwrap(),
};
let header = Header::decode(
&mut &executor
.call(ext, &runtime_code, "BlockBuilder_finalize_block", &[0u8; 0], true)
.0
.unwrap()[..],
)
.unwrap();

let hash = header.blake2_256();
(Block { header, extrinsics }.encode(), hash.into())
Expand Down Expand Up @@ -218,13 +195,12 @@ fn bench_execute_block(c: &mut Criterion) {
|test_ext| {
for block in blocks.iter() {
executor
.call::<NeverNativeValue, fn() -> _>(
.call(
&mut test_ext.ext(),
&runtime_code,
"Core_execute_block",
&block.0,
use_native,
None,
)
.0
.unwrap();
Expand Down
Loading