mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
Don't include :code by default in storage proofs (#5060)
* Adds test to verify that the runtime currently is always contained in the proof * Start passing the runtime wasm code from the outside * Fix compilation * More build fixes * Make the test work as expected now :) * Last fixes * Fixes benchmarks * Review feedback * Apply suggestions from code review Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * Review feedback * Fix compilation Co-authored-by: Sergei Pepyakin <s.pepyakin@gmail.com>
This commit is contained in:
committed by
GitHub
parent
67837c6233
commit
6ee39261c8
@@ -25,8 +25,8 @@ use node_runtime::constants::currency::*;
|
||||
use node_testing::keyring::*;
|
||||
use sp_core::{Blake2Hasher, NativeOrEncoded, NeverNativeValue};
|
||||
use sp_core::storage::well_known_keys;
|
||||
use sp_core::traits::CodeExecutor;
|
||||
use frame_support::Hashable;
|
||||
use sp_core::traits::{CodeExecutor, RuntimeCode};
|
||||
use frame_support::Hashable;
|
||||
use sp_state_machine::TestExternalities as CoreTestExternalities;
|
||||
use sc_executor::{NativeExecutor, RuntimeInfo, WasmExecutionMethod, Externalities};
|
||||
|
||||
@@ -89,9 +89,12 @@ fn construct_block<E: Externalities>(
|
||||
digest: Default::default(),
|
||||
};
|
||||
|
||||
let runtime_code = RuntimeCode::from_externalities(ext).expect("`ext` provides `:code`");
|
||||
|
||||
// execute the block to get the real header.
|
||||
executor.call::<_, NeverNativeValue, fn() -> _>(
|
||||
ext,
|
||||
&runtime_code,
|
||||
"Core_initialize_block",
|
||||
&header.encode(),
|
||||
true,
|
||||
@@ -101,6 +104,7 @@ fn construct_block<E: Externalities>(
|
||||
for i in extrinsics.iter() {
|
||||
executor.call::<_, NeverNativeValue, fn() -> _>(
|
||||
ext,
|
||||
&runtime_code,
|
||||
"BlockBuilder_apply_extrinsic",
|
||||
&i.encode(),
|
||||
true,
|
||||
@@ -110,6 +114,7 @@ fn construct_block<E: Externalities>(
|
||||
|
||||
let header = match executor.call::<_, NeverNativeValue, fn() -> _>(
|
||||
ext,
|
||||
&runtime_code,
|
||||
"BlockBuilder_finalize_block",
|
||||
&[0u8;0],
|
||||
true,
|
||||
@@ -165,7 +170,9 @@ fn bench_execute_block(c: &mut Criterion) {
|
||||
// Get the runtime version to initialize the runtimes cache.
|
||||
{
|
||||
let mut test_ext = new_test_ext(&genesis_config);
|
||||
executor.runtime_version(&mut test_ext.ext());
|
||||
let runtime_code = RuntimeCode::from_externalities(&test_ext.ext())
|
||||
.expect("`test_ext` provides `:code`");
|
||||
executor.runtime_version(&mut test_ext.ext(), &runtime_code).unwrap();
|
||||
}
|
||||
|
||||
let blocks = test_blocks(&genesis_config, &executor);
|
||||
@@ -173,9 +180,12 @@ fn bench_execute_block(c: &mut Criterion) {
|
||||
b.iter_batched_ref(
|
||||
|| new_test_ext(&genesis_config),
|
||||
|test_ext| {
|
||||
let runtime_code = RuntimeCode::from_externalities(&test_ext.ext())
|
||||
.expect("`test_ext` provides `:code`");
|
||||
for block in blocks.iter() {
|
||||
executor.call::<_, NeverNativeValue, fn() -> _>(
|
||||
&mut test_ext.ext(),
|
||||
&runtime_code,
|
||||
"Core_execute_block",
|
||||
&block.0,
|
||||
use_native,
|
||||
|
||||
Reference in New Issue
Block a user