Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Prepare UI tests for rust 1.55 #9637

Merged
22 commits merged into from
Sep 24, 2021
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
4 changes: 3 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ variables: &default-vars
CARGO_INCREMENTAL: 0
DOCKER_OS: "debian:stretch"
ARCH: "x86_64"
CI_IMAGE: "paritytech/ci-linux:production"
# FIXME: revert me
# CI_IMAGE: "paritytech/ci-linux:production"
CI_IMAGE: "paritytech/ci-linux:staging-1.54.0"
# FIXME set to release
CARGO_UNLEASH_INSTALL_PARAMS: "--version 1.0.0-alpha.12"
CARGO_UNLEASH_PKG_DEF: "--skip node node-* pallet-template pallet-example pallet-example-* subkey chain-spec-builder"
Expand Down
1 change: 1 addition & 0 deletions client/chain-spec/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
///
Expand Down
1 change: 1 addition & 0 deletions client/db/src/storage_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,7 @@ mod qc {
#[derive(Debug, Clone)]
struct Node {
hash: H256,
#[allow(unused)]
parent: H256,
state: KeyMap,
changes: KeySet,
Expand Down
6 changes: 3 additions & 3 deletions client/executor/runtime-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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()) };

Expand Down
3 changes: 0 additions & 3 deletions client/executor/src/native_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
}
}
Expand Down
8 changes: 4 additions & 4 deletions client/network/src/protocol/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
6 changes: 3 additions & 3 deletions client/service/src/client/call_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
34 changes: 17 additions & 17 deletions client/service/src/client/wasm_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
gui1117 marked this conversation as resolved.
Show resolved Hide resolved
}

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.
Expand All @@ -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()
};
Expand Down Expand Up @@ -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))
Expand All @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ benchmarks! {
);
}
#[cfg(not(feature = "std"))]
return Err("Run this bench with a native runtime in order to see the schedule.".into());
Err("Run this bench with a native runtime in order to see the schedule.")?;
}: {}

// Execute one erc20 transfer using the ink! erc20 example contract.
Expand Down
2 changes: 0 additions & 2 deletions frame/grandpa/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

//! Benchmarks for the GRANDPA pallet.

#![cfg_attr(not(feature = "std"), no_std)]

use super::{Pallet as Grandpa, *};
use frame_benchmarking::benchmarks;
use frame_system::RawOrigin;
Expand Down
2 changes: 0 additions & 2 deletions frame/merkle-mountain-range/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

//! Benchmarks for the MMR pallet.

#![cfg_attr(not(feature = "std"), no_std)]

use crate::*;
use frame_benchmarking::{benchmarks_instance_pallet, impl_benchmark_test_suite};
use frame_support::traits::OnInitialize;
Expand Down
8 changes: 4 additions & 4 deletions frame/support/src/storage/bounded_btree_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use crate::{storage::StorageDecodeLength, traits::Get};
use codec::{Decode, Encode, MaxEncodedLen};
use sp_std::{
borrow::Borrow, collections::btree_map::BTreeMap, convert::TryFrom, fmt, marker::PhantomData,
borrow::Borrow, collections::btree_map::BTreeMap, convert::TryFrom, marker::PhantomData,
ops::Deref,
};

Expand Down Expand Up @@ -173,12 +173,12 @@ where
}

#[cfg(feature = "std")]
impl<K, V, S> fmt::Debug for BoundedBTreeMap<K, V, S>
impl<K, V, S> std::fmt::Debug for BoundedBTreeMap<K, V, S>
where
BTreeMap<K, V>: fmt::Debug,
BTreeMap<K, V>: std::fmt::Debug,
S: Get<u32>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("BoundedBTreeMap").field(&self.0).field(&Self::bound()).finish()
}
}
Expand Down
8 changes: 4 additions & 4 deletions frame/support/src/storage/bounded_btree_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use crate::{storage::StorageDecodeLength, traits::Get};
use codec::{Decode, Encode, MaxEncodedLen};
use sp_std::{
borrow::Borrow, collections::btree_set::BTreeSet, convert::TryFrom, fmt, marker::PhantomData,
borrow::Borrow, collections::btree_set::BTreeSet, convert::TryFrom, marker::PhantomData,
ops::Deref,
};

Expand Down Expand Up @@ -157,12 +157,12 @@ where
}

#[cfg(feature = "std")]
impl<T, S> fmt::Debug for BoundedBTreeSet<T, S>
impl<T, S> std::fmt::Debug for BoundedBTreeSet<T, S>
where
BTreeSet<T>: fmt::Debug,
BTreeSet<T>: std::fmt::Debug,
S: Get<u32>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("BoundedBTreeSet").field(&self.0).field(&Self::bound()).finish()
}
}
Expand Down
8 changes: 4 additions & 4 deletions frame/support/src/storage/bounded_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use core::{
ops::{Deref, Index, IndexMut},
slice::SliceIndex,
};
use sp_std::{convert::TryFrom, fmt, marker::PhantomData, prelude::*};
use sp_std::{convert::TryFrom, marker::PhantomData, prelude::*};

/// A bounded vector.
///
Expand Down Expand Up @@ -201,12 +201,12 @@ impl<T, S> Default for BoundedVec<T, S> {
}

#[cfg(feature = "std")]
impl<T, S> fmt::Debug for BoundedVec<T, S>
impl<T, S> std::fmt::Debug for BoundedVec<T, S>
where
T: fmt::Debug,
T: std::fmt::Debug,
S: Get<u32>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("BoundedVec").field(&self.0).field(&Self::bound()).finish()
}
}
Expand Down
8 changes: 4 additions & 4 deletions frame/support/src/storage/weak_bounded_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use core::{
ops::{Deref, Index, IndexMut},
slice::SliceIndex,
};
use sp_std::{convert::TryFrom, fmt, marker::PhantomData, prelude::*};
use sp_std::{convert::TryFrom, marker::PhantomData, prelude::*};

/// A weakly bounded vector.
///
Expand Down Expand Up @@ -171,12 +171,12 @@ impl<T, S> Default for WeakBoundedVec<T, S> {
}

#[cfg(feature = "std")]
impl<T, S> fmt::Debug for WeakBoundedVec<T, S>
impl<T, S> std::fmt::Debug for WeakBoundedVec<T, S>
where
T: fmt::Debug,
T: std::fmt::Debug,
S: Get<u32>,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("WeakBoundedVec").field(&self.0).field(&Self::bound()).finish()
}
}
Expand Down
4 changes: 2 additions & 2 deletions frame/support/src/traits/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use impl_trait_for_tuples::impl_for_tuples;
use sp_arithmetic::traits::Saturating;
use sp_runtime::traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize};
use sp_runtime::traits::AtLeast32BitUnsigned;

/// The block initialization trait.
///
Expand Down Expand Up @@ -294,7 +294,7 @@ pub trait Hooks<BlockNumber> {
/// A trait to define the build function of a genesis config, T and I are placeholder for pallet
/// trait and pallet instance.
#[cfg(feature = "std")]
pub trait GenesisBuild<T, I = ()>: Default + MaybeSerializeDeserialize {
pub trait GenesisBuild<T, I = ()>: Default + sp_runtime::traits::MaybeSerializeDeserialize {
/// The build function is called within an externalities allowing storage APIs.
/// Thus one can write to storage using regular pallet storages.
fn build(&self);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error: `Pallet` does not have the std feature enabled, this will cause the `test
22 | | }
| |_^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `test_pallet::__substrate_genesis_config_check::is_std_enabled_for_genesis` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: use of undeclared crate or module `system`
--> $DIR/no_std_genesis_config.rs:19:11
Expand All @@ -30,7 +30,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `system`
22 | | }
| |_^ not found in `system`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this enum
|
1 | use frame_system::RawOrigin;
Expand All @@ -48,7 +48,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `system`
22 | | }
| |_^ not found in `system`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
1 | use frame_support_test::Pallet;
Expand All @@ -70,7 +70,7 @@ error[E0412]: cannot find type `GenesisConfig` in crate `test_pallet`
22 | | }
| |_^ not found in `test_pallet`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
|
1 | use frame_system::GenesisConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ error: `Pallet` does not have #[pallet::call] defined, perhaps you should remove
31 | | }
| |_- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `pallet::__substrate_call_check::is_call_part_defined` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: use of undeclared crate or module `system`
--> $DIR/undefined_call_part.rs:28:11
Expand All @@ -33,7 +33,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `system`
31 | | }
| |_^ not found in `system`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this enum
|
1 | use frame_system::RawOrigin;
Expand All @@ -51,7 +51,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `system`
31 | | }
| |_^ not found in `system`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
1 | use crate::pallet::Pallet;
Expand Down
Loading