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
@@ -21,9 +21,9 @@ use crate::{
trie_backend::TrieBackend, trie_backend_essence::TrieBackendStorage, ChildStorageCollection,
StorageCollection, StorageKey, StorageValue, UsageInfo,
};
use codec::{Decode, Encode};
use codec::Encode;
use hash_db::Hasher;
use sp_core::storage::{well_known_keys, ChildInfo, TrackedStorageKey};
use sp_core::storage::{ChildInfo, TrackedStorageKey};
#[cfg(feature = "std")]
use sp_core::traits::RuntimeCode;
use sp_std::vec::Vec;
@@ -330,7 +330,11 @@ impl<'a, B: Backend<H>, H: Hasher> sp_core::traits::FetchRuntimeCode
for BackendRuntimeCode<'a, B, H>
{
fn fetch_runtime_code<'b>(&'b self) -> Option<std::borrow::Cow<'b, [u8]>> {
self.backend.storage(well_known_keys::CODE).ok().flatten().map(Into::into)
self.backend
.storage(sp_core::storage::well_known_keys::CODE)
.ok()
.flatten()
.map(Into::into)
}
}
@@ -348,17 +352,17 @@ where
pub fn runtime_code(&self) -> Result<RuntimeCode, &'static str> {
let hash = self
.backend
.storage_hash(well_known_keys::CODE)
.storage_hash(sp_core::storage::well_known_keys::CODE)
.ok()
.flatten()
.ok_or("`:code` hash not found")?
.encode();
let heap_pages = self
.backend
.storage(well_known_keys::HEAP_PAGES)
.storage(sp_core::storage::well_known_keys::HEAP_PAGES)
.ok()
.flatten()
.and_then(|d| Decode::decode(&mut &d[..]).ok());
.and_then(|d| codec::Decode::decode(&mut &d[..]).ok());
Ok(RuntimeCode { code_fetcher: self, hash, heap_pages })
}
+11 -13
View File
@@ -17,17 +17,15 @@
//! Concrete externalities implementation.
use crate::{
backend::Backend, overlayed_changes::OverlayedExtensions, IndexOperation, OverlayedChanges,
StorageKey, StorageValue,
};
#[cfg(feature = "std")]
use crate::overlayed_changes::OverlayedExtensions;
use crate::{backend::Backend, IndexOperation, OverlayedChanges, StorageKey, StorageValue};
use codec::{Decode, Encode, EncodeAppend};
use hash_db::Hasher;
use sp_core::{
hexdisplay::HexDisplay,
storage::{well_known_keys::is_child_storage_key, ChildInfo, TrackedStorageKey},
};
use sp_externalities::{Extension, ExtensionStore, Extensions, Externalities};
#[cfg(feature = "std")]
use sp_core::hexdisplay::HexDisplay;
use sp_core::storage::{well_known_keys::is_child_storage_key, ChildInfo, TrackedStorageKey};
use sp_externalities::{Extension, ExtensionStore, Externalities};
use sp_trie::{empty_child_trie_root, trie_types::Layout};
#[cfg(feature = "std")]
@@ -37,7 +35,7 @@ use sp_std::{
any::{Any, TypeId},
boxed::Box,
cmp::Ordering,
fmt, vec,
vec,
vec::Vec,
};
#[cfg(feature = "std")]
@@ -72,8 +70,8 @@ pub enum Error<B, E> {
}
#[cfg(feature = "std")]
impl<B: fmt::Display, E: fmt::Display> fmt::Display for Error<B, E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl<B: std::fmt::Display, E: std::fmt::Display> std::fmt::Display for Error<B, E> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
Error::Backend(ref e) => write!(f, "Storage backend error: {}", e),
Error::Executor(ref e) => write!(f, "Sub-call execution error: {}", e),
@@ -139,7 +137,7 @@ where
storage_transaction_cache: &'a mut StorageTransactionCache<B::Transaction, H, N>,
backend: &'a B,
changes_trie_state: Option<ChangesTrieState<'a, H, N>>,
extensions: Option<&'a mut Extensions>,
extensions: Option<&'a mut sp_externalities::Extensions>,
) -> Self {
Self {
overlay,
+18 -9
View File
@@ -55,11 +55,19 @@ pub use tracing::trace;
#[cfg(not(feature = "std"))]
#[macro_export]
macro_rules! warn {
(target: $target:expr, $($arg:tt)+) => {
()
(target: $target:expr, $message:expr $( , $arg:ident )* $( , )?) => {
{
$(
let _ = &$arg;
)*
}
};
($($arg:tt)+) => {
()
($message:expr, $( $arg:expr, )*) => {
{
$(
let _ = &$arg;
)*
}
};
}
@@ -68,11 +76,12 @@ macro_rules! warn {
#[cfg(not(feature = "std"))]
#[macro_export]
macro_rules! debug {
(target: $target:expr, $($arg:tt)+) => {
()
};
($($arg:tt)+) => {
()
(target: $target:expr, $message:expr $( , $arg:ident )* $( , )?) => {
{
$(
let _ = &$arg;
)*
}
};
}
@@ -21,15 +21,7 @@ mod changeset;
mod offchain;
use self::changeset::OverlayedChangeSet;
use crate::{backend::Backend, stats::StateMachineStats};
pub use offchain::OffchainOverlayedChanges;
use sp_std::{
any::{Any, TypeId},
boxed::Box,
vec::Vec,
};
use crate::{changes_trie::BlockNumber, DefaultError};
use crate::{backend::Backend, changes_trie::BlockNumber, stats::StateMachineStats, DefaultError};
#[cfg(feature = "std")]
use crate::{
changes_trie::{build_changes_trie, State as ChangesTrieState},
@@ -37,16 +29,23 @@ use crate::{
};
use codec::{Decode, Encode};
use hash_db::Hasher;
pub use offchain::OffchainOverlayedChanges;
use sp_core::{
offchain::OffchainOverlayedChange,
storage::{well_known_keys::EXTRINSIC_INDEX, ChildInfo},
};
#[cfg(feature = "std")]
use sp_externalities::{Extension, Extensions};
#[cfg(not(feature = "std"))]
use sp_std::collections::btree_map::{BTreeMap as Map, Entry as MapEntry};
use sp_std::collections::btree_set::BTreeSet;
use sp_std::collections::btree_map::BTreeMap as Map;
use sp_std::{collections::btree_set::BTreeSet, vec::Vec};
#[cfg(feature = "std")]
use std::collections::{hash_map::Entry as MapEntry, HashMap as Map};
#[cfg(feature = "std")]
use std::{
any::{Any, TypeId},
boxed::Box,
};
pub use self::changeset::{AlreadyInRuntime, NoOpenTransaction, NotInRuntime, OverlayedValue};
@@ -581,6 +580,8 @@ impl OverlayedChanges {
self.changes_trie_root(backend, changes_trie_state, parent_hash, false, &mut cache)
.map_err(|_| "Failed to generate changes trie transaction")?;
}
#[cfg(not(feature = "std"))]
let _ = parent_hash;
#[cfg(feature = "std")]
let changes_trie_transaction = cache
@@ -758,6 +759,7 @@ where
/// An overlayed extension is either a mutable reference
/// or an owned extension.
#[cfg(feature = "std")]
pub enum OverlayedExtension<'a> {
MutRef(&'a mut Box<dyn Extension>),
Owned(Box<dyn Extension>),
@@ -770,10 +772,12 @@ pub enum OverlayedExtension<'a> {
/// as owned references. After the execution of a runtime function, we
/// can safely drop this object while not having modified the original
/// list.
#[cfg(feature = "std")]
pub struct OverlayedExtensions<'a> {
extensions: Map<TypeId, OverlayedExtension<'a>>,
}
#[cfg(feature = "std")]
impl<'a> OverlayedExtensions<'a> {
/// Create a new instance of overalyed extensions from the given extensions.
pub fn new(extensions: &'a mut Extensions) -> Self {
@@ -24,7 +24,7 @@ use hash_db::{self, Hasher, Prefix};
#[cfg(feature = "std")]
use parking_lot::RwLock;
use sp_core::storage::ChildInfo;
use sp_std::{boxed::Box, ops::Deref, vec::Vec};
use sp_std::{boxed::Box, vec::Vec};
use sp_trie::{
empty_child_trie_root, read_child_trie_value, read_trie_value,
trie_types::{Layout, TrieDB, TrieError},
@@ -37,8 +37,11 @@ use std::sync::Arc;
#[cfg(not(feature = "std"))]
macro_rules! format {
($($arg:tt)+) => {
crate::DefaultError
( $message:expr, $( $arg:expr )* ) => {
{
$( let _ = &$arg; )*
crate::DefaultError
}
};
}
@@ -488,7 +491,7 @@ impl<H: Hasher> TrieBackendStorage<H> for Arc<dyn Storage<H>> {
type Overlay = PrefixedMemoryDB<H>;
fn get(&self, key: &H::Out, prefix: Prefix) -> Result<Option<DBValue>> {
Storage::<H>::get(self.deref(), key, prefix)
Storage::<H>::get(std::ops::Deref::deref(self), key, prefix)
}
}