Prepare UI tests for rust 1.55 (#9637)

* Prepare UI tests for rust 1.54

* Delete wrong_page.stderr

* CI: run with a staging CI image

* Revert "CI: run with a staging CI image"

This reverts commit 66f5b00d14b50fd9d8fbf773f7e884f380697591.

* CI: debug, again

* LOG_TARGET is only used in std

* Remove unnecessary unsafe

* Fixes

* Use correct rustc locally

* FMT

* Compile with benchmarking

* Review feedback

* Some ui tests

* I know...

* Fix wasm tests

Co-authored-by: Denis P <denis.pisarev@parity.io>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Bastian Köcher
2021-09-24 13:42:08 +03:00
committed by GitHub
parent 1879a2d04f
commit 62187b5916
60 changed files with 431 additions and 335 deletions
@@ -163,6 +163,7 @@ struct ClientSpec<E> {
// Never used, left only for backward compatibility.
consensus_engine: (),
#[serde(skip_serializing)]
#[allow(unused)]
genesis: serde::de::IgnoredAny,
/// Mapping from `block_hash` to `wasm_code`.
///
+1
View File
@@ -1418,6 +1418,7 @@ mod qc {
#[derive(Debug, Clone)]
struct Node {
hash: H256,
#[allow(unused)]
parent: H256,
state: KeyMap,
changes: KeySet,
@@ -91,7 +91,7 @@ sp_core::wasm_export_functions! {
// This function dirties the **host** pages. I.e. we dirty 4KiB at a time and it will take
// 16 writes to process a single wasm page.
let mut heap_ptr = heap_base as usize;
let heap_ptr = heap_base as usize;
// Find the next wasm page boundary.
let heap_ptr = round_up_to(heap_ptr, 65536);
@@ -234,7 +234,7 @@ sp_core::wasm_export_functions! {
match instance.get_global_val("test_global") {
Some(sp_sandbox::Value::I64(val)) => val,
None => 30,
val => 40,
_ => 40,
}
}
@@ -362,7 +362,7 @@ sp_core::wasm_export_functions! {
// It is expected that the given pointer is not allocated.
fn check_and_set_in_heap(heap_base: u32, offset: u32) {
let test_message = b"Hello invalid heap memory";
let ptr = unsafe { (heap_base + offset) as *mut u8 };
let ptr = (heap_base + offset) as *mut u8;
let message_slice = unsafe { sp_std::slice::from_raw_parts_mut(ptr, test_message.len()) };
@@ -101,8 +101,6 @@ pub struct WasmExecutor {
host_functions: Arc<Vec<&'static dyn Function>>,
/// WASM runtime cache.
cache: Arc<RuntimeCache>,
/// The size of the instances cache.
max_runtime_instances: usize,
/// The path to a directory which the executor can leverage for a file cache, e.g. put there
/// compiled artifacts.
cache_path: Option<PathBuf>,
@@ -138,7 +136,6 @@ impl WasmExecutor {
default_heap_pages: default_heap_pages.unwrap_or(DEFAULT_HEAP_PAGES),
host_functions: Arc::new(host_functions),
cache: Arc::new(RuntimeCache::new(max_runtime_instances, cache_path.clone())),
max_runtime_instances,
cache_path,
}
}
@@ -143,10 +143,10 @@ pub struct RemoteReadResponse {
/// Announcement summary used for debug logging.
#[derive(Debug)]
pub struct AnnouncementSummary<H: HeaderT> {
block_hash: H::Hash,
number: H::Number,
parent_hash: H::Hash,
state: Option<BlockState>,
pub block_hash: H::Hash,
pub number: H::Number,
pub parent_hash: H::Hash,
pub state: Option<BlockState>,
}
impl<H: HeaderT> generic::BlockAnnounce<H> {
@@ -41,7 +41,7 @@ use std::{cell::RefCell, panic::UnwindSafe, result, sync::Arc};
pub struct LocalCallExecutor<Block: BlockT, B, E> {
backend: Arc<B>,
executor: E,
wasm_override: Option<WasmOverride<E>>,
wasm_override: Option<WasmOverride>,
wasm_substitutes: WasmSubstitutes<Block, E, B>,
spawn_handle: Box<dyn SpawnNamed>,
client_config: ClientConfig<Block>,
@@ -62,7 +62,7 @@ where
let wasm_override = client_config
.wasm_runtime_overrides
.as_ref()
.map(|p| WasmOverride::new(p.clone(), executor.clone()))
.map(|p| WasmOverride::new(p.clone(), &executor))
.transpose()?;
let wasm_substitutes = WasmSubstitutes::new(
@@ -371,7 +371,7 @@ mod tests {
1,
);
let overrides = crate::client::wasm_override::dummy_overrides(&executor);
let overrides = crate::client::wasm_override::dummy_overrides();
let onchain_code = WrappedRuntimeCode(substrate_test_runtime::wasm_binary_unwrap().into());
let onchain_code = RuntimeCode {
code_fetcher: &onchain_code,
@@ -104,22 +104,19 @@ impl From<WasmOverrideError> for sp_blockchain::Error {
/// Scrapes WASM from a folder and returns WASM from that folder
/// if the runtime spec version matches.
#[derive(Clone, Debug)]
pub struct WasmOverride<E> {
pub struct WasmOverride {
// Map of runtime spec version -> Wasm Blob
overrides: HashMap<u32, WasmBlob>,
executor: E,
}
impl<E> WasmOverride<E>
where
E: RuntimeVersionOf + Clone + 'static,
{
pub fn new<P>(path: P, executor: E) -> Result<Self>
impl WasmOverride {
pub fn new<P, E>(path: P, executor: &E) -> Result<Self>
where
P: AsRef<Path>,
E: RuntimeVersionOf,
{
let overrides = Self::scrape_overrides(path.as_ref(), &executor)?;
Ok(Self { overrides, executor })
let overrides = Self::scrape_overrides(path.as_ref(), executor)?;
Ok(Self { overrides })
}
/// Gets an override by it's runtime spec version.
@@ -131,7 +128,10 @@ where
/// Scrapes a folder for WASM runtimes.
/// Returns a hashmap of the runtime version and wasm runtime code.
fn scrape_overrides(dir: &Path, executor: &E) -> Result<HashMap<u32, WasmBlob>> {
fn scrape_overrides<E>(dir: &Path, executor: &E) -> Result<HashMap<u32, WasmBlob>>
where
E: RuntimeVersionOf,
{
let handle_err = |e: std::io::Error| -> sp_blockchain::Error {
WasmOverrideError::Io(dir.to_owned(), e).into()
};
@@ -176,11 +176,14 @@ where
Ok(overrides)
}
fn runtime_version(
fn runtime_version<E>(
executor: &E,
code: &WasmBlob,
heap_pages: Option<u64>,
) -> Result<RuntimeVersion> {
) -> Result<RuntimeVersion>
where
E: RuntimeVersionOf,
{
let mut ext = BasicExternalities::default();
executor
.runtime_version(&mut ext, &code.runtime_code(heap_pages))
@@ -190,15 +193,12 @@ where
/// Returns a WasmOverride struct filled with dummy data for testing.
#[cfg(test)]
pub fn dummy_overrides<E>(executor: &E) -> WasmOverride<E>
where
E: RuntimeVersionOf + Clone + 'static,
{
pub fn dummy_overrides() -> WasmOverride {
let mut overrides = HashMap::new();
overrides.insert(0, WasmBlob::new(vec![0, 0, 0, 0, 0, 0, 0, 0]));
overrides.insert(1, WasmBlob::new(vec![1, 1, 1, 1, 1, 1, 1, 1]));
overrides.insert(2, WasmBlob::new(vec![2, 2, 2, 2, 2, 2, 2, 2]));
WasmOverride { overrides, executor: executor.clone() }
WasmOverride { overrides }
}
#[cfg(test)]