mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 08:47:57 +00:00
Don't include :code by default in storage proofs (#5179)
* 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> * Fix compilation and change the way `RuntimeCode` works * Fix tests * Switch to `Cow` Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org> Co-authored-by: Sergei Pepyakin <s.pepyakin@gmail.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
use codec::{Encode, Decode};
|
||||
use frame_support::Hashable;
|
||||
use sp_state_machine::TestExternalities as CoreTestExternalities;
|
||||
use sp_core::{NeverNativeValue, NativeOrEncoded, traits::CodeExecutor};
|
||||
use sp_core::{NeverNativeValue, NativeOrEncoded, traits::{CodeExecutor, RuntimeCode}};
|
||||
use sp_runtime::{ApplyExtrinsicResult, traits::{Header as HeaderT, BlakeTwo256}};
|
||||
use sc_executor::{NativeExecutor, WasmExecutionMethod};
|
||||
use sc_executor::error::Result;
|
||||
@@ -29,6 +29,7 @@ use node_runtime::{
|
||||
};
|
||||
use node_primitives::{Hash, BlockNumber};
|
||||
use node_testing::keyring::*;
|
||||
use sp_externalities::Externalities;
|
||||
|
||||
/// The wasm runtime code.
|
||||
///
|
||||
@@ -71,8 +72,18 @@ pub fn executor_call<
|
||||
native_call: Option<NC>,
|
||||
) -> (Result<NativeOrEncoded<R>>, bool) {
|
||||
let mut t = t.ext();
|
||||
|
||||
let code = t.storage(sp_core::storage::well_known_keys::CODE).unwrap();
|
||||
let heap_pages = t.storage(sp_core::storage::well_known_keys::HEAP_PAGES);
|
||||
let runtime_code = RuntimeCode {
|
||||
code_fetcher: &sp_core::traits::WrappedRuntimeCode(code.as_slice().into()),
|
||||
hash: sp_core::blake2_256(&code).to_vec(),
|
||||
heap_pages: heap_pages.and_then(|hp| Decode::decode(&mut &hp[..]).ok()),
|
||||
};
|
||||
|
||||
executor().call::<R, NC>(
|
||||
&mut t,
|
||||
&runtime_code,
|
||||
method,
|
||||
data,
|
||||
use_native,
|
||||
|
||||
Reference in New Issue
Block a user