Companion for #13302 (#2357)

* primitives/core: Derive scale_info::TypeInfo for runtime APIs

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* parachains: Derive scale_info::TypeInfo for FungiblesAccessError

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* parachains: Fix `TypeInfo` import path

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* update lockfile for {"polkadot", "substrate"}

* Adjust testing for the new API

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Adjust deprecated methods

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: parity-processbot <>
This commit is contained in:
Alexandru Vasile
2023-04-11 17:23:39 +03:00
committed by GitHub
parent fd2f200265
commit d4989b1c3c
9 changed files with 331 additions and 289 deletions
+273 -258
View File
File diff suppressed because it is too large Load Diff
+16 -7
View File
@@ -22,7 +22,9 @@ use cumulus_relay_chain_interface::RelayChainInterface;
// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_consensus::ImportQueue;
use sc_executor::NativeElseWasmExecutor;
use sc_executor::{
HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
};
use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
@@ -81,12 +83,19 @@ pub fn new_partial(
})
.transpose()?;
let executor = ParachainExecutor::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
config.runtime_cache_size,
);
let heap_pages = config
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
let wasm = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.build();
let executor = ParachainExecutor::new_with_wasm_executor(wasm);
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
@@ -7,6 +7,7 @@ description = "Assets common utilities"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
log = { version = "0.4.17", default-features = false }
# Substrate
@@ -21,7 +21,7 @@ use sp_std::vec::Vec;
use xcm::latest::MultiAsset;
/// The possible errors that can happen querying the storage of assets.
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)]
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
pub enum FungiblesAccessError {
/// `MultiLocation` to `AssetId`/`ClassId` conversion failed.
AssetIdConversionFailed,
+12 -8
View File
@@ -42,7 +42,7 @@ use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT},
BlockImportParams, ImportQueue,
};
use sc_executor::WasmExecutor;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
@@ -257,13 +257,17 @@ where
})
.transpose()?;
let executor = sc_executor::WasmExecutor::<HostFunctions>::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
None,
config.runtime_cache_size,
);
let heap_pages = config
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
let executor = sc_executor::WasmExecutor::<HostFunctions>::builder()
.with_execution_method(config.wasm_method)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.build();
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
+2
View File
@@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
# Substrate
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -23,6 +24,7 @@ xcm = { git = "https://github.com/paritytech/polkadot", default-features = false
default = [ "std" ]
std = [
"codec/std",
"scale-info/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
+2 -1
View File
@@ -20,6 +20,7 @@
use codec::{Decode, Encode};
use polkadot_parachain::primitives::HeadData;
use scale_info::TypeInfo;
use sp_runtime::{traits::Block as BlockT, RuntimeDebug};
use sp_std::prelude::*;
@@ -229,7 +230,7 @@ impl CollationInfoV1 {
}
/// Information about a collation.
#[derive(Clone, Debug, codec::Decode, codec::Encode, PartialEq)]
#[derive(Clone, Debug, codec::Decode, codec::Encode, PartialEq, TypeInfo)]
pub struct CollationInfo {
/// Messages destined to be interpreted by the Relay chain itself.
pub upward_messages: Vec<UpwardMessage>,
+9 -8
View File
@@ -22,7 +22,7 @@ use runtime::{
Balance, Block, BlockHashCount, GenesisConfig, Runtime, RuntimeCall, Signature, SignedExtra,
SignedPayload, UncheckedExtrinsic, VERSION,
};
use sc_executor::{WasmExecutionMethod, WasmExecutor};
use sc_executor::{HeapAllocStrategy, WasmExecutionMethod, WasmExecutor};
use sc_executor_common::runtime_blob::RuntimeBlob;
use sc_service::client;
use sp_blockchain::HeaderBackend;
@@ -181,13 +181,14 @@ pub fn validate_block(
let mut ext = TestExternalities::default();
let mut ext_ext = ext.ext();
let executor = WasmExecutor::<sp_io::SubstrateHostFunctions>::new(
WasmExecutionMethod::Interpreted,
Some(1024),
1,
None,
2,
);
let heap_pages = HeapAllocStrategy::Static { extra_pages: 1024 };
let executor = WasmExecutor::<sp_io::SubstrateHostFunctions>::builder()
.with_execution_method(WasmExecutionMethod::Interpreted)
.with_max_runtime_instances(1)
.with_runtime_cache_size(2)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.build();
executor
.uncached_call(
+15 -6
View File
@@ -21,6 +21,7 @@
pub mod chain_spec;
mod genesis;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use std::{
future::Future,
net::{IpAddr, Ipv4Addr, SocketAddr},
@@ -184,12 +185,20 @@ pub fn new_partial(
>,
sc_service::Error,
> {
let executor = sc_executor::NativeElseWasmExecutor::<RuntimeExecutor>::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
config.runtime_cache_size,
);
let heap_pages = config
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
let wasm = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.build();
let executor =
sc_executor::NativeElseWasmExecutor::<RuntimeExecutor>::new_with_wasm_executor(wasm);
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(config, None, executor)?;